|
Lines 48-56
Link Here
|
| 48 |
import org.eclipse.jface.text.IDocumentExtension4; |
48 |
import org.eclipse.jface.text.IDocumentExtension4; |
| 49 |
import org.eclipse.jface.text.IDocumentListener; |
49 |
import org.eclipse.jface.text.IDocumentListener; |
| 50 |
import org.eclipse.jface.text.IDocumentRewriteSessionListener; |
50 |
import org.eclipse.jface.text.IDocumentRewriteSessionListener; |
|
|
51 |
import org.eclipse.jface.text.IRegion; |
| 51 |
import org.eclipse.jface.text.Position; |
52 |
import org.eclipse.jface.text.Position; |
| 52 |
import org.eclipse.jface.text.Region; |
53 |
import org.eclipse.jface.text.Region; |
| 53 |
import org.eclipse.wst.jsdt.core.IBuffer; |
54 |
import org.eclipse.wst.jsdt.core.IBuffer; |
|
|
55 |
import org.eclipse.wst.jsdt.web.core.internal.Logger; |
| 54 |
import org.eclipse.wst.sse.core.StructuredModelManager; |
56 |
import org.eclipse.wst.sse.core.StructuredModelManager; |
| 55 |
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument; |
57 |
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument; |
| 56 |
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; |
58 |
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; |
|
Lines 513-519
Link Here
|
| 513 |
// skip over XML/HTML comment starts |
515 |
// skip over XML/HTML comment starts |
| 514 |
if (regionText.indexOf(XML_COMMENT_START) >= 0) { |
516 |
if (regionText.indexOf(XML_COMMENT_START) >= 0) { |
| 515 |
int index = regionText.indexOf(XML_COMMENT_START); |
517 |
int index = regionText.indexOf(XML_COMMENT_START); |
| 516 |
int leadingTrimPlusCommentStart = index + XML_COMMENT_START.length(); |
518 |
|
| 517 |
boolean replaceCommentStart = true; |
519 |
boolean replaceCommentStart = true; |
| 518 |
for (int i = 0; i < index; i++) { |
520 |
for (int i = 0; i < index; i++) { |
| 519 |
/* |
521 |
/* |
|
Lines 522-532
Link Here
|
| 522 |
*/ |
524 |
*/ |
| 523 |
replaceCommentStart = replaceCommentStart && Character.isWhitespace(regionText.charAt(i)); |
525 |
replaceCommentStart = replaceCommentStart && Character.isWhitespace(regionText.charAt(i)); |
| 524 |
} |
526 |
} |
|
|
527 |
|
| 525 |
if (replaceCommentStart) { |
528 |
if (replaceCommentStart) { |
|
|
529 |
IRegion line; |
| 530 |
int end; |
| 531 |
int length; |
| 532 |
try { |
| 533 |
line = container.getParentDocument().getLineInformationOfOffset(index + scriptStart); |
| 534 |
end = line.getOffset() + line.getLength() - scriptStart; |
| 535 |
if(end > regionText.length()) { |
| 536 |
end = regionText.length()-1; |
| 537 |
} |
| 538 |
length = end - index; |
| 539 |
} catch (BadLocationException e) { |
| 540 |
Logger.logException("Could not get HTML style comment line information", e); //$NON-NLS-1$ |
| 541 |
|
| 542 |
end = index + XML_COMMENT_START.length(); |
| 543 |
length = XML_COMMENT_START.length(); |
| 544 |
} |
| 545 |
|
| 526 |
StringBuffer newRegionText = new StringBuffer(regionText.substring(0, index)); |
546 |
StringBuffer newRegionText = new StringBuffer(regionText.substring(0, index)); |
| 527 |
spaces = Util.getPad(XML_COMMENT_START.length()); |
547 |
spaces = Util.getPad(length); |
| 528 |
newRegionText.append(spaces); |
548 |
newRegionText.append(spaces); |
| 529 |
newRegionText.append(regionText.substring(leadingTrimPlusCommentStart)); |
549 |
newRegionText.append(regionText.substring(end)); |
| 530 |
regionText = newRegionText.toString(); |
550 |
regionText = newRegionText.toString(); |
| 531 |
} |
551 |
} |
| 532 |
} |
552 |
} |