Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 179746 Details for
Bug 326420
[validation] Text after HTML style comment in JavaScript region marked as validation error
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Fix Patch
326420_text_with_html_comment.txt (text/plain), 5.24 KB, created by
Ian Tewksbury
on 2010-09-28 10:27:05 EDT
(
hide
)
Description:
Fix Patch
Filename:
MIME Type:
Creator:
Ian Tewksbury
Created:
2010-09-28 10:27:05 EDT
Size:
5.24 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.wst.jsdt.web.core >Index: src/org/eclipse/wst/jsdt/web/core/javascript/JsTranslator.java >=================================================================== >RCS file: /cvsroot/webtools/sourceediting/plugins/org.eclipse.wst.jsdt.web.core/src/org/eclipse/wst/jsdt/web/core/javascript/JsTranslator.java,v >retrieving revision 1.16.2.2 >diff -u -r1.16.2.2 JsTranslator.java >--- src/org/eclipse/wst/jsdt/web/core/javascript/JsTranslator.java 1 Sep 2010 15:24:45 -0000 1.16.2.2 >+++ src/org/eclipse/wst/jsdt/web/core/javascript/JsTranslator.java 28 Sep 2010 14:23:49 -0000 >@@ -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(); > } > } >#P org.eclipse.wst.jsdt.web.ui >Index: src/org/eclipse/wst/jsdt/web/ui/internal/format/FormattingStrategyJSDT.java >=================================================================== >RCS file: /cvsroot/webtools/sourceediting/plugins/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/format/FormattingStrategyJSDT.java,v >retrieving revision 1.13.4.1 >diff -u -r1.13.4.1 FormattingStrategyJSDT.java >--- src/org/eclipse/wst/jsdt/web/ui/internal/format/FormattingStrategyJSDT.java 1 Sep 2010 15:24:48 -0000 1.13.4.1 >+++ src/org/eclipse/wst/jsdt/web/ui/internal/format/FormattingStrategyJSDT.java 28 Sep 2010 14:23:50 -0000 >@@ -56,14 +56,8 @@ > * (repeatedly) as the API evolves. > */ > public class FormattingStrategyJSDT extends ContextBasedFormattingStrategy { >- private static final String XML_COMMENT_START = "<!--"; //$NON-NLS-1$ >- private static final String XML_COMMENT_END = "//-->"; //$NON-NLS-1$ >- >- /** matches on <!-- at beginning of script region */ >- private static final Pattern START_PATTERN = Pattern.compile("(\\A(\\s*<!--))"); >- >- /** matches on //--> or --> at end of script region */ >- private static final Pattern END_PATTERN = Pattern.compile("(((//\\s*)?-->\\s*)\\z)"); >+ /** matches on //--> at end of script region */ >+ private static final Pattern END_PATTERN = Pattern.compile("((//.*-->\\s*)\\z)"); > > private static final int regionStartIndentLevel = 1; > /** Documents to be formatted by this strategy */ >@@ -114,17 +108,18 @@ > String postText = lineDelim; > > //find start comment tag >- Matcher matcher = START_PATTERN.matcher(jsTextNotTranslated); >+ Pattern startPattern = Pattern.compile("(\\A(\\s*<!--.*(" + lineDelim + ")?))"); >+ Matcher matcher = startPattern.matcher(jsTextNotTranslated); > if(matcher.find()) { >- jsTextNotTranslated = matcher.replaceAll(""); >- preText = lineDelim + XML_COMMENT_START; >+ jsTextNotTranslated = matcher.replaceFirst(""); >+ preText = lineDelim + matcher.group().trim(); > } > > //find end tag > matcher = END_PATTERN.matcher(jsTextNotTranslated); > if(matcher.find()) { >- jsTextNotTranslated = matcher.replaceAll(""); >- postText = lineDelim + XML_COMMENT_END + lineDelim; >+ jsTextNotTranslated = matcher.replaceFirst(""); >+ postText = lineDelim + matcher.group().trim() + lineDelim; > } > > //replace the text in the document with the none-translated JS text but without HTML leading and trailing comments
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 326420
: 179746