diff options
author | Nick Sandonato | 2014-02-14 00:11:46 +0000 |
---|---|---|
committer | Nick Sandonato | 2014-02-18 23:33:11 +0000 |
commit | 7a11958b25aeed796673bcd5ae0f296c071cb7d9 (patch) | |
tree | 4b15efd0bec024796d7c79ec9616646a1ce047ef | |
parent | 854826a0bbc0e9b82a9710b598bab0899c4408f6 (diff) | |
download | webtools.sourceediting-7a11958b25aeed796673bcd5ae0f296c071cb7d9.tar.gz webtools.sourceediting-7a11958b25aeed796673bcd5ae0f296c071cb7d9.tar.xz webtools.sourceediting-7a11958b25aeed796673bcd5ae0f296c071cb7d9.zip |
[428374] [formatting] unknown regions remove inline css textv201402182334
5 files changed, 37 insertions, 3 deletions
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 9032a04139..0e3d4eb70f 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 @@ Manifest-Version: 1.0 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 02f34fabad..5f158168d0 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 @@ public abstract class AbstractCSSSourceFormatter implements CSSSourceGenerator { */ 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 @@ public abstract class AbstractCSSSourceFormatter implements CSSSourceGenerator { 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 2e98604c79..3c9292c3a5 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 9909ef65a1..3048bb9d97 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 @@ description=\ 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 3b9d8d7384..e4a2f63bea 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> |