[428374] [formatting] unknown regions remove inline css text
diff --git a/bundles/org.eclipse.wst.css.core/META-INF/MANIFEST.MF b/bundles/org.eclipse.wst.css.core/META-INF/MANIFEST.MF index 9032a04..0e3d4eb 100644 --- a/bundles/org.eclipse.wst.css.core/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.wst.css.core/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.wst.css.core; singleton:=true -Bundle-Version: 1.1.602.qualifier +Bundle-Version: 1.1.603.qualifier Bundle-Activator: org.eclipse.wst.css.core.internal.CSSCorePlugin Bundle-Vendor: %providerName Bundle-Localization: plugin
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/AbstractCSSSourceFormatter.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/AbstractCSSSourceFormatter.java index 02f34fa..5f15816 100644 --- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/AbstractCSSSourceFormatter.java +++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/AbstractCSSSourceFormatter.java
@@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2012 IBM Corporation and others. + * Copyright (c) 2004, 2014 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -493,6 +493,7 @@ */ protected final void formatChildren(ICSSNode node, StringBuffer source) { ICSSNode child = node.getFirstChild(); + ICSSNode last = null; boolean first = true; while (child != null) { // append child @@ -505,10 +506,34 @@ formatBefore(node, child, new String(childSource), source, null); } source.append(childSource); + last = child; // append between children child = child.getNextSibling(); first = false; } + // This handles the case where the last child doesn't align with the end of the parent node, likely malformed content + if (node instanceof IndexedRegion && last instanceof IndexedRegion && (node.getOwnerDocument().getNodeType() == ICSSNode.STYLEDECLARATION_NODE)) { + IndexedRegion parent = (IndexedRegion) node; + IndexedRegion lastChild = (IndexedRegion) last; + if (lastChild.getEndOffset() < parent.getEndOffset()) { + // Find the region at the end offset of the last child + IStructuredDocumentRegion region = node.getOwnerDocument().getModel().getStructuredDocument().getRegionAtCharacterOffset(lastChild.getEndOffset()); + ITextRegionList regions = region != null ? region.getRegions() : null; + if (regions != null) { + Iterator it = regions.iterator(); + while (it.hasNext()) { + ITextRegion token = (ITextRegion) it.next(); + if (token.getType() == CSSRegionContexts.CSS_UNKNOWN) { + // Found something that won't be consumed. Append the regions that remain in the node to the source + do { + source.append(region.getFullText()); + } while ((region = region.getNext()) != null && region.getEndOffset() <= parent.getEndOffset()); + break; + } + } + } + } + } } /**
diff --git a/features/org.eclipse.wst.web_core.feature.patch/buildnotes_org.eclipse.wst.web_core.feature.patch.html b/features/org.eclipse.wst.web_core.feature.patch/buildnotes_org.eclipse.wst.web_core.feature.patch.html index 2e98604..3c9292c 100644 --- a/features/org.eclipse.wst.web_core.feature.patch/buildnotes_org.eclipse.wst.web_core.feature.patch.html +++ b/features/org.eclipse.wst.web_core.feature.patch/buildnotes_org.eclipse.wst.web_core.feature.patch.html
@@ -14,5 +14,6 @@ <h2>org.eclipse.wst.web_core.feature</h2> <h3>org.eclipse.wst.html.core</h3> <p>Bug <a href="https://bugs.eclipse.org/414162">414162</a>. Model changes during validation trigger errors</p> +<p>Bug <a href="https://bugs.eclipse.org/414162">428374</a>. [formatting] unknown regions remove inline css text</p> </body> -</html> \ No newline at end of file +</html>
diff --git a/features/org.eclipse.wst.web_core.feature.patch/feature.properties b/features/org.eclipse.wst.web_core.feature.patch/feature.properties index 9909ef6..3048bb9 100644 --- a/features/org.eclipse.wst.web_core.feature.patch/feature.properties +++ b/features/org.eclipse.wst.web_core.feature.patch/feature.properties
@@ -28,6 +28,7 @@ The bugs and fixes are described in the following bugzilla entries:\n\ \n\ Bug https://bugs.eclipse.org/414162 Model changes during validation trigger errors\n\ +Bug https://bugs.eclipse.org/428374 [formatting] unknown regions remove inline css text\n\ \n\ # "copyright" property - text of the "Feature Update Copyright" copyright=\
diff --git a/features/org.eclipse.wst.web_core.feature.patch/feature.xml b/features/org.eclipse.wst.web_core.feature.patch/feature.xml index 3b9d8d7..e4a2f63 100644 --- a/features/org.eclipse.wst.web_core.feature.patch/feature.xml +++ b/features/org.eclipse.wst.web_core.feature.patch/feature.xml
@@ -28,4 +28,11 @@ version="0.0.0" unpack="false"/> + <plugin + id="org.eclipse.wst.css.core" + download-size="0" + install-size="0" + version="0.0.0" + unpack="false"/> + </feature>