Converted LabelsAnnotator to extra visitor invoked from JetPsiChecker.
This commit is contained in:
@@ -124,7 +124,6 @@
|
||||
<liveTemplateMacro implementation="org.jetbrains.jet.plugin.liveTemplates.macro.JetIterableVariableMacro"/>
|
||||
<liveTemplateMacro implementation="org.jetbrains.jet.plugin.liveTemplates.macro.JetSuggestVariableNameMacro"/>
|
||||
|
||||
<annotator language="jet" implementationClass="org.jetbrains.jet.plugin.highlighter.LabelsAnnotator"/>
|
||||
<annotator language="jet" implementationClass="org.jetbrains.jet.plugin.highlighter.JetPsiChecker"/>
|
||||
<annotator language="jet" implementationClass="org.jetbrains.jet.plugin.highlighter.DebugInfoAnnotator"/>
|
||||
|
||||
|
||||
@@ -58,7 +58,8 @@ public class JetPsiChecker implements Annotator {
|
||||
@Override
|
||||
public void annotate(@NotNull PsiElement element, @NotNull final AnnotationHolder holder) {
|
||||
element.accept(new SoftKeywordsHighlightingVisitor(holder));
|
||||
|
||||
element.accept(new LabelsHighlightingVisitor(holder));
|
||||
|
||||
if (element instanceof JetFile) {
|
||||
JetFile file = (JetFile)element;
|
||||
|
||||
|
||||
+17
-19
@@ -29,26 +29,24 @@ import org.jetbrains.jet.lang.psi.JetSimpleNameExpression;
|
||||
import org.jetbrains.jet.lang.psi.JetVisitorVoid;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
|
||||
public class LabelsAnnotator implements Annotator {
|
||||
public void annotate(@NotNull PsiElement element, @NotNull final AnnotationHolder holder) {
|
||||
// if (ApplicationManager.getApplication().isUnitTestMode()) return;
|
||||
element.accept(new JetVisitorVoid() {
|
||||
@Override
|
||||
public void visitPrefixExpression(JetPrefixExpression expression) {
|
||||
JetSimpleNameExpression operationSign = expression.getOperationReference();
|
||||
if (JetTokens.LABELS.contains(operationSign.getReferencedNameElementType())) {
|
||||
holder.createInfoAnnotation(operationSign, null).setTextAttributes(JetHighlightingColors.LABEL);
|
||||
}
|
||||
}
|
||||
class LabelsHighlightingVisitor extends HighlightingVisitor {
|
||||
LabelsHighlightingVisitor(AnnotationHolder holder) {
|
||||
super(holder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitLabelQualifiedExpression(JetLabelQualifiedExpression expression) {
|
||||
JetSimpleNameExpression targetLabel = expression.getTargetLabel();
|
||||
if (targetLabel != null) {
|
||||
holder.createInfoAnnotation(targetLabel, null).setTextAttributes(JetHighlightingColors.LABEL);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void visitPrefixExpression(JetPrefixExpression expression) {
|
||||
JetSimpleNameExpression operationSign = expression.getOperationReference();
|
||||
if (JetTokens.LABELS.contains(operationSign.getReferencedNameElementType())) {
|
||||
holder.createInfoAnnotation(operationSign, null).setTextAttributes(JetHighlightingColors.LABEL);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
@Override
|
||||
public void visitLabelQualifiedExpression(JetLabelQualifiedExpression expression) {
|
||||
JetSimpleNameExpression targetLabel = expression.getTargetLabel();
|
||||
if (targetLabel != null) {
|
||||
holder.createInfoAnnotation(targetLabel, null).setTextAttributes(JetHighlightingColors.LABEL);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user