JS editing/commenting/highlighting for JSPX

This commit is contained in:
Maxim Mossienko
2005-01-17 23:11:29 +03:00
parent c061437593
commit d6f1b5db3a
2 changed files with 13 additions and 16 deletions

View File

@@ -188,7 +188,7 @@ public class CommentByBlockCommentHandler implements CodeInsightActionHandler, B
private BlockCommenter javaCommenter = new JavaBlockCommenter();
private boolean isJavaCommentInsideXml(PsiElement element) {
boolean javaComment = !(element instanceof XmlToken);
boolean javaComment = false;
final XmlTag tag = PsiTreeUtil.getParentOfType(element, XmlTag.class, false);
@@ -423,4 +423,4 @@ public class CommentByBlockCommentHandler implements CodeInsightActionHandler, B
myDocument.deleteString(delOffset3, delOffset4);
}
}
}
}

View File

@@ -559,14 +559,7 @@ public class CommentByLineCommentHandler implements CodeInsightActionHandler, Li
public void doComment(int offset, int line, LineCommenter.LineCommenterContext context) {
final Document myDocument = context.getDocument();
if (!initialized) {
PsiDocumentManager.getInstance(context.getProject()).commitAllDocuments();
initialize(context);
initialized = true;
}
initialize(context);
if (myJavaComment) {
myDocument.insertString(offset, "//");
@@ -577,6 +570,8 @@ public class CommentByLineCommentHandler implements CodeInsightActionHandler, Li
}
private void initialize(final LineCommenterContext context) {
if (initialized) return;
PsiDocumentManager.getInstance(context.getProject()).commitAllDocuments();
Document myDocument = context.getDocument();
myJavaComment = false;
@@ -589,12 +584,14 @@ public class CommentByLineCommentHandler implements CodeInsightActionHandler, Li
myJavaComment = true;
}
}
initialized = true;
}
public void doUncomment(int offset1, int offset2, LineCommenterContext context) {
final Document myDocument = context.getDocument();
initialize(context);
if (CharArrayUtil.regionMatches(myDocument.getCharsSequence(), offset1, "//")) {
if (myJavaComment && CharArrayUtil.regionMatches(myDocument.getCharsSequence(), offset1, "//")) {
myDocument.deleteString(offset1, offset1 + "//".length());
}
else {
@@ -605,8 +602,9 @@ public class CommentByLineCommentHandler implements CodeInsightActionHandler, Li
public int getCommentStart(int offset, LineCommenterContext context) {
final Document myDocument = context.getDocument();
if (offset > myDocument.getTextLength() - "//".length()) return -1;
initialize(context);
if (CharArrayUtil.regionMatches(myDocument.getCharsSequence(), offset, "//")) {
if (myJavaComment && CharArrayUtil.regionMatches(myDocument.getCharsSequence(), offset, "//")) {
PsiDocumentManager.getInstance(context.getProject()).commitDocument(myDocument);
PsiElement element = context.getFile().findElementAt(offset);
if (element instanceof PsiComment && element.getTextRange().getStartOffset() == offset) {
@@ -622,11 +620,10 @@ public class CommentByLineCommentHandler implements CodeInsightActionHandler, Li
public int getCommentEnd(int offset, LineCommenterContext context) {
if (offset < 0) return -1;
if (!initialized) {
initialize(context);
}
initialize(context);
if (myJavaComment) return offset;
return super.getCommentEnd(offset, context);
}
}
}
}