[326818] [validation] Text after HTML style comment in JavaScript region marked as validation error
diff --git a/bundles/org.eclipse.wst.jsdt.web.core/META-INF/MANIFEST.MF b/bundles/org.eclipse.wst.jsdt.web.core/META-INF/MANIFEST.MF index 48bb144..2618de7 100644 --- a/bundles/org.eclipse.wst.jsdt.web.core/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.wst.jsdt.web.core/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: %Bundle-Name.0 Bundle-SymbolicName: org.eclipse.wst.jsdt.web.core;singleton:=true -Bundle-Version: 1.0.302.qualifier +Bundle-Version: 1.0.303.qualifier Bundle-Activator: org.eclipse.wst.jsdt.web.core.internal.JsCorePlugin Bundle-Vendor: %Bundle-Vendor.0 Bundle-Localization: plugin
diff --git a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/JsTranslator.java b/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/JsTranslator.java index 50abda8..24672dd 100644 --- a/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/JsTranslator.java +++ b/bundles/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/JsTranslator.java
@@ -48,9 +48,11 @@ import org.eclipse.jface.text.IDocumentExtension4; import org.eclipse.jface.text.IDocumentListener; import org.eclipse.jface.text.IDocumentRewriteSessionListener; +import org.eclipse.jface.text.IRegion; import org.eclipse.jface.text.Position; import org.eclipse.jface.text.Region; import org.eclipse.wst.jsdt.core.IBuffer; +import org.eclipse.wst.jsdt.web.core.internal.Logger; import org.eclipse.wst.sse.core.StructuredModelManager; import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument; import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; @@ -513,7 +515,7 @@ // skip over XML/HTML comment starts if (regionText.indexOf(XML_COMMENT_START) >= 0) { int index = regionText.indexOf(XML_COMMENT_START); - int leadingTrimPlusCommentStart = index + XML_COMMENT_START.length(); + boolean replaceCommentStart = true; for (int i = 0; i < index; i++) { /* @@ -522,11 +524,29 @@ */ replaceCommentStart = replaceCommentStart && Character.isWhitespace(regionText.charAt(i)); } + if (replaceCommentStart) { + IRegion line; + int end; + int length; + try { + line = container.getParentDocument().getLineInformationOfOffset(index + scriptStart); + end = line.getOffset() + line.getLength() - scriptStart; + if(end > regionText.length()) { + end = regionText.length()-1; + } + length = end - index; + } catch (BadLocationException e) { + Logger.logException("Could not get HTML style comment line information", e); //$NON-NLS-1$ + + end = index + XML_COMMENT_START.length(); + length = XML_COMMENT_START.length(); + } + StringBuffer newRegionText = new StringBuffer(regionText.substring(0, index)); - spaces = Util.getPad(XML_COMMENT_START.length()); + spaces = Util.getPad(length); newRegionText.append(spaces); - newRegionText.append(regionText.substring(leadingTrimPlusCommentStart)); + newRegionText.append(regionText.substring(end)); regionText = newRegionText.toString(); } }