diff --git a/compiler/frontend/src/org/jetbrains/jet/checkers/CheckerTestUtil.java b/compiler/frontend/src/org/jetbrains/jet/checkers/CheckerTestUtil.java index c817f0e4db9..0a3a55ae8ad 100644 --- a/compiler/frontend/src/org/jetbrains/jet/checkers/CheckerTestUtil.java +++ b/compiler/frontend/src/org/jetbrains/jet/checkers/CheckerTestUtil.java @@ -30,6 +30,7 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.diagnostics.AbstractDiagnosticFactory; import org.jetbrains.jet.lang.diagnostics.Diagnostic; import org.jetbrains.jet.lang.diagnostics.Severity; +import org.jetbrains.jet.lang.psi.JetReferenceExpression; import org.jetbrains.jet.lang.resolve.AnalyzingUtils; import org.jetbrains.jet.lang.resolve.BindingContext; @@ -75,9 +76,36 @@ public class CheckerTestUtil { for (PsiErrorElement errorElement : AnalyzingUtils.getSyntaxErrorRanges(root)) { diagnostics.add(new SyntaxErrorDiagnostic(errorElement)); } + final List debugAnnotations = getDebugInfoDiagnostics(root, bindingContext); + diagnostics.addAll(debugAnnotations); return diagnostics; } + public static List getDebugInfoDiagnostics(@NotNull PsiElement root, @NotNull BindingContext bindingContext) { + final List debugAnnotations = Lists.newArrayList(); + DebugInfoUtil.markDebugAnnotations(root, bindingContext, new DebugInfoUtil.DebugInfoReporter() { + @Override + public void reportErrorElement(@NotNull JetReferenceExpression expression) { + newDiagnostic(expression, DebugInfoDiagnosticFactory.ERROR_ELEMENT); + } + + @Override + public void reportMissingUnresolved(@NotNull JetReferenceExpression expression) { + newDiagnostic(expression, DebugInfoDiagnosticFactory.MISSING_UNRESOLVED); + } + + @Override + public void reportUnresolvedWithTarget(@NotNull JetReferenceExpression expression, @NotNull String target) { + newDiagnostic(expression, DebugInfoDiagnosticFactory.UNRESOLVED_WITH_TARGET); + } + + private void newDiagnostic(JetReferenceExpression expression, DebugInfoDiagnosticFactory factory) { + debugAnnotations.add(new DebugInfoDiagnostic(expression, factory)); + } + }); + return debugAnnotations; + } + public interface DiagnosticDiffCallbacks { @NotNull PsiFile getFile(); void missingDiagnostic(String type, int expectedStart, int expectedEnd); @@ -287,27 +315,19 @@ public class CheckerTestUtil { result.append(""); } - private static class SyntaxErrorDiagnosticFactory extends AbstractDiagnosticFactory { - private static final SyntaxErrorDiagnosticFactory instance = new SyntaxErrorDiagnosticFactory(); + public static class AbstractDiagnosticForTests implements Diagnostic { + private final PsiElement element; + private final AbstractDiagnosticFactory factory; - @NotNull - @Override - public String getName() { - return "SYNTAX"; - } - } - - public static class SyntaxErrorDiagnostic implements Diagnostic { - private final PsiErrorElement errorElement; - - public SyntaxErrorDiagnostic(@NotNull PsiErrorElement errorElement) { - this.errorElement = errorElement; + public AbstractDiagnosticForTests(@NotNull PsiElement element, @NotNull AbstractDiagnosticFactory factory) { + this.element = element; + this.factory = factory; } @NotNull @Override public AbstractDiagnosticFactory getFactory() { - return SyntaxErrorDiagnosticFactory.instance; + return factory; } @NotNull @@ -318,20 +338,20 @@ public class CheckerTestUtil { @NotNull @Override - public PsiErrorElement getPsiElement() { - return errorElement; + public PsiElement getPsiElement() { + return element; } @NotNull @Override public List getTextRanges() { - return Collections.singletonList(errorElement.getTextRange()); + return Collections.singletonList(element.getTextRange()); } @NotNull @Override public PsiFile getPsiFile() { - return errorElement.getContainingFile(); + return element.getContainingFile(); } @Override @@ -339,7 +359,48 @@ public class CheckerTestUtil { return true; } } - + + private static class SyntaxErrorDiagnosticFactory extends AbstractDiagnosticFactory { + public static final SyntaxErrorDiagnosticFactory INSTANCE = new SyntaxErrorDiagnosticFactory(); + + private SyntaxErrorDiagnosticFactory() {} + + @NotNull + @Override + public String getName() { + return "SYNTAX"; + } + } + + public static class SyntaxErrorDiagnostic extends AbstractDiagnosticForTests { + public SyntaxErrorDiagnostic(@NotNull PsiErrorElement errorElement) { + super(errorElement, SyntaxErrorDiagnosticFactory.INSTANCE); + } + } + + public static class DebugInfoDiagnosticFactory extends AbstractDiagnosticFactory { + public static final DebugInfoDiagnosticFactory ERROR_ELEMENT = new DebugInfoDiagnosticFactory("ERROR_ELEMENT"); + public static final DebugInfoDiagnosticFactory UNRESOLVED_WITH_TARGET = new DebugInfoDiagnosticFactory("UNRESOLVED_WITH_TARGET"); + public static final DebugInfoDiagnosticFactory MISSING_UNRESOLVED = new DebugInfoDiagnosticFactory("MISSING_UNRESOLVED"); + + private final String name; + private DebugInfoDiagnosticFactory(String name) { + this.name = name; + } + + @NotNull + @Override + public String getName() { + return "DEBUG_INFO_" + name; + } + } + + public static class DebugInfoDiagnostic extends AbstractDiagnosticForTests { + public DebugInfoDiagnostic(@NotNull JetReferenceExpression reference, @NotNull DebugInfoDiagnosticFactory factory) { + super(reference, factory); + } + } + private static List getSortedDiagnosticDescriptors(Collection diagnostics) { List list = Lists.newArrayList(diagnostics); Collections.sort(list, DIAGNOSTIC_COMPARATOR); diff --git a/compiler/frontend/src/org/jetbrains/jet/checkers/DebugInfoUtil.java b/compiler/frontend/src/org/jetbrains/jet/checkers/DebugInfoUtil.java new file mode 100644 index 00000000000..83668551a69 --- /dev/null +++ b/compiler/frontend/src/org/jetbrains/jet/checkers/DebugInfoUtil.java @@ -0,0 +1,143 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.checkers; + +import com.google.common.collect.Maps; +import com.google.common.collect.Sets; +import com.intellij.openapi.application.ApplicationManager; +import com.intellij.psi.PsiElement; +import com.intellij.psi.tree.IElementType; +import com.intellij.psi.tree.TokenSet; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.JetNodeTypes; +import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor; +import org.jetbrains.jet.lang.diagnostics.AbstractDiagnosticFactory; +import org.jetbrains.jet.lang.diagnostics.Diagnostic; +import org.jetbrains.jet.lang.diagnostics.Errors; +import org.jetbrains.jet.lang.diagnostics.UnresolvedReferenceDiagnosticFactory; +import org.jetbrains.jet.lang.psi.*; +import org.jetbrains.jet.lang.resolve.BindingContext; +import org.jetbrains.jet.lang.types.ErrorUtils; +import org.jetbrains.jet.lang.types.JetType; +import org.jetbrains.jet.lexer.JetTokens; + +import java.util.Collection; +import java.util.Map; +import java.util.Set; + +import static org.jetbrains.jet.lang.resolve.BindingContext.*; +import static org.jetbrains.jet.lexer.JetTokens.*; +import static org.jetbrains.jet.lexer.JetTokens.ELVIS; +import static org.jetbrains.jet.lexer.JetTokens.EXCLEXCL; + +public class DebugInfoUtil { + private static final TokenSet EXCLUDED = TokenSet.create( + COLON, AS_KEYWORD, AS_SAFE, IS_KEYWORD, NOT_IS, OROR, ANDAND, EQ, EQEQEQ, EXCLEQEQEQ, ELVIS, EXCLEXCL, IN_KEYWORD, NOT_IN); + + public interface DebugInfoReporter { + + void reportErrorElement(@NotNull JetReferenceExpression expression); + + void reportMissingUnresolved(@NotNull JetReferenceExpression expression); + + void reportUnresolvedWithTarget(@NotNull JetReferenceExpression expression, @NotNull String target); + } + + public static void markDebugAnnotations( + @NotNull PsiElement root, + @NotNull final BindingContext bindingContext, + @NotNull final DebugInfoReporter debugInfoReporter + ) { + final Map markedWithErrorElements = Maps.newHashMap(); + for (Diagnostic diagnostic : bindingContext.getDiagnostics()) { + AbstractDiagnosticFactory factory = diagnostic.getFactory(); + if (factory instanceof UnresolvedReferenceDiagnosticFactory) { + markedWithErrorElements.put((JetReferenceExpression) diagnostic.getPsiElement(), factory); + } + else if (factory == Errors.SUPER_IS_NOT_AN_EXPRESSION + || factory == Errors.SUPER_NOT_AVAILABLE) { + JetSuperExpression superExpression = (JetSuperExpression) diagnostic.getPsiElement(); + markedWithErrorElements.put(superExpression.getInstanceReference(), factory); + } + } + + root.acceptChildren(new JetTreeVisitorVoid() { + + @Override + public void visitReferenceExpression(JetReferenceExpression expression) { + if (expression instanceof JetSimpleNameExpression) { + JetSimpleNameExpression nameExpression = (JetSimpleNameExpression) expression; + IElementType elementType = expression.getNode().getElementType(); + if (elementType == JetNodeTypes.OPERATION_REFERENCE) { + IElementType referencedNameElementType = nameExpression.getReferencedNameElementType(); + if (EXCLUDED.contains(referencedNameElementType)) { + return; + } + if (JetTokens.LABELS.contains(referencedNameElementType)) return; + } + else if (nameExpression.getReferencedNameElementType() == JetTokens.THIS_KEYWORD) { + return; + } + } + + String target = null; + DeclarationDescriptor declarationDescriptor = bindingContext.get(REFERENCE_TARGET, expression); + if (declarationDescriptor != null) { + target = declarationDescriptor.toString(); + } + if (target == null) { + PsiElement labelTarget = bindingContext.get(LABEL_TARGET, expression); + if (labelTarget != null) { + target = labelTarget.getText(); + } + } + if (target == null) { + Collection declarationDescriptors = + bindingContext.get(AMBIGUOUS_REFERENCE_TARGET, expression); + if (declarationDescriptors != null) { + target = "[" + declarationDescriptors.size() + " descriptors]"; + } + } + if (target == null) { + Collection labelTargets = bindingContext.get(AMBIGUOUS_LABEL_TARGET, expression); + if (labelTargets != null) { + target = "[" + labelTargets.size() + " elements]"; + } + } + + boolean resolved = target != null; + boolean markedWithError = markedWithErrorElements.containsKey(expression); + JetType expressionType = bindingContext.get(EXPRESSION_TYPE, expression); + if (declarationDescriptor != null && + !ApplicationManager.getApplication().isUnitTestMode() && + (ErrorUtils.isError(declarationDescriptor) || ErrorUtils.containsErrorType(expressionType))) { + debugInfoReporter.reportErrorElement(expression); + } + if (resolved && markedWithError) { + AbstractDiagnosticFactory factory = markedWithErrorElements.get(expression); + if (factory instanceof UnresolvedReferenceDiagnosticFactory) { + debugInfoReporter.reportUnresolvedWithTarget(expression, target); + } + } + else if (!resolved && !markedWithError) { + debugInfoReporter.reportMissingUnresolved(expression); + } + } + }); + } + +} diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BindingContextUtils.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BindingContextUtils.java index c0676aae2a8..d4ecc31a924 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BindingContextUtils.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BindingContextUtils.java @@ -261,9 +261,8 @@ public class BindingContextUtils { Collection targets = Lists.newArrayList(); for (DeclarationDescriptor descriptor : declarationsByLabel) { PsiElement element = descriptorToDeclaration(trace.getBindingContext(), descriptor); - if (element != null) { - targets.add(element); - } + assert element != null : "Label can only point to something in the same lexical scope"; + targets.add(element); } if (!targets.isEmpty()) { trace.record(AMBIGUOUS_LABEL_TARGET, targetLabel, targets); diff --git a/compiler/testData/diagnostics/tests/NamespaceQualified.kt b/compiler/testData/diagnostics/tests/NamespaceQualified.kt index aa962dbcc59..15165141c9b 100644 --- a/compiler/testData/diagnostics/tests/NamespaceQualified.kt +++ b/compiler/testData/diagnostics/tests/NamespaceQualified.kt @@ -19,7 +19,7 @@ package foobar.a import java.util.* val b : List? = a - val b1 : util.List? = a + val b1 : util.List? = a // FILE: b.kt package foobar diff --git a/compiler/testData/diagnostics/tests/ResolveToJava.kt b/compiler/testData/diagnostics/tests/ResolveToJava.kt index e4cfd9367a1..d797ccd5395 100644 --- a/compiler/testData/diagnostics/tests/ResolveToJava.kt +++ b/compiler/testData/diagnostics/tests/ResolveToJava.kt @@ -14,7 +14,7 @@ fun test(l : java.util val y : java.util.List val b : java.lang.Object val a : util.List - val z : java.utils.List + val z : java.utils.List val f : java.io.File? = null diff --git a/compiler/testData/diagnostics/tests/ShiftFunctionTypes.kt b/compiler/testData/diagnostics/tests/ShiftFunctionTypes.kt index 0337823529e..cfc6fb59656 100644 --- a/compiler/testData/diagnostics/tests/ShiftFunctionTypes.kt +++ b/compiler/testData/diagnostics/tests/ShiftFunctionTypes.kt @@ -8,7 +8,6 @@ package n // FILE: f.kt abstract class XXX() { abstract val a : Int - abstract val a1 : package.Int abstract val a2 : n.B abstract val a3 : (A) abstract val a31 : (n.B) diff --git a/compiler/testData/diagnostics/tests/incompleteCode/incompleteAssignment.kt b/compiler/testData/diagnostics/tests/incompleteCode/incompleteAssignment.kt index 0f5df3b436b..ae97c706035 100644 --- a/compiler/testData/diagnostics/tests/incompleteCode/incompleteAssignment.kt +++ b/compiler/testData/diagnostics/tests/incompleteCode/incompleteAssignment.kt @@ -5,7 +5,7 @@ fun sum(a : IntArray) : Int { // Write your solution here res = 0 for (e in a) - res += + res += } fun main(args : Array) { test(0) diff --git a/compiler/testData/diagnostics/tests/scopes/Imports.kt b/compiler/testData/diagnostics/tests/scopes/Imports.kt index 5ef08d7bb8f..6d2919ccaf3 100644 --- a/compiler/testData/diagnostics/tests/scopes/Imports.kt +++ b/compiler/testData/diagnostics/tests/scopes/Imports.kt @@ -7,13 +7,13 @@ import b.ext //extension function import b.value //property import b.C.bar //function from class object import b.C.cValue //property from class object -import b.constant.fff //function from val -import b.constant.dValue //property from val +import b.constant.fff //function from val +import b.constant.dValue //property from val import b.constant import b.E.f //val from class object -import smth.illegal -import b.C.smth.illegal -import b.bar.smth +import smth.illegal +import b.C.smth.illegal +import b.bar.smth import b.bar.* fun test(arg: B) { diff --git a/compiler/testData/diagnostics/tests/scopes/kt1080.kt b/compiler/testData/diagnostics/tests/scopes/kt1080.kt index 92a3c3f0866..23d40f8fbe7 100644 --- a/compiler/testData/diagnostics/tests/scopes/kt1080.kt +++ b/compiler/testData/diagnostics/tests/scopes/kt1080.kt @@ -3,7 +3,7 @@ package kt1080 -import reflect.Constructor +import reflect.Constructor import b.* import d @@ -12,4 +12,4 @@ import b.d //FILE:b.kt -package b.d +package b.d \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/scopes/kt900-2.kt b/compiler/testData/diagnostics/tests/scopes/kt900-2.kt index ae879a33cc0..7bf46e7d022 100644 --- a/compiler/testData/diagnostics/tests/scopes/kt900-2.kt +++ b/compiler/testData/diagnostics/tests/scopes/kt900-2.kt @@ -3,10 +3,10 @@ package d //import from objects before properties resolve import d.A.* -import d.M.R -import d.M.R.bar -import d.M.T -import d.M.Y +import d.M.R +import d.M.R.bar +import d.M.T +import d.M.Y var r: T = T() val y: T = Y diff --git a/compiler/testData/diagnostics/tests/scopes/kt900.kt b/compiler/testData/diagnostics/tests/scopes/kt900.kt index 79f5364bc5e..8ddfdb2f2f2 100644 --- a/compiler/testData/diagnostics/tests/scopes/kt900.kt +++ b/compiler/testData/diagnostics/tests/scopes/kt900.kt @@ -35,7 +35,7 @@ object N { //FILE:b.kt package b -import b.N.M +import b.N.M import b.A.P import b.A.B diff --git a/compiler/testData/diagnostics/tests/thisAndSuper/Super.kt b/compiler/testData/diagnostics/tests/thisAndSuper/Super.kt index 4e5dd94da97..8c584a2cc48 100644 --- a/compiler/testData/diagnostics/tests/thisAndSuper/Super.kt +++ b/compiler/testData/diagnostics/tests/thisAndSuper/Super.kt @@ -11,7 +11,7 @@ class A() : C(), T { fun test() { super - super + super<T> super.foo() super.foo() super.bar() @@ -23,8 +23,8 @@ class A() : C(), T { super<>.foo() super<() -> Unit>.foo() super<Unit>.foo() - super@B.foo() - super@B.bar() + super<T>@B.foo() + super<C>@B.bar() } class B : T { @@ -37,7 +37,7 @@ class A() : C(), T { super<C>@B.foo() super.foo() super - super + super<T> } } } diff --git a/compiler/testData/diagnostics/tests/thisAndSuper/superInToplevelFunction.kt b/compiler/testData/diagnostics/tests/thisAndSuper/superInToplevelFunction.kt index e494e1d88ab..050bde1f598 100644 --- a/compiler/testData/diagnostics/tests/thisAndSuper/superInToplevelFunction.kt +++ b/compiler/testData/diagnostics/tests/thisAndSuper/superInToplevelFunction.kt @@ -1,5 +1,5 @@ fun foo() { super super.foo() - super.foo() + super<Nothing>.foo() } \ No newline at end of file diff --git a/idea/src/org/jetbrains/jet/plugin/highlighter/DebugInfoAnnotator.java b/idea/src/org/jetbrains/jet/plugin/highlighter/DebugInfoAnnotator.java index 0421c720cc7..30eefaa8290 100644 --- a/idea/src/org/jetbrains/jet/plugin/highlighter/DebugInfoAnnotator.java +++ b/idea/src/org/jetbrains/jet/plugin/highlighter/DebugInfoAnnotator.java @@ -16,33 +16,19 @@ package org.jetbrains.jet.plugin.highlighter; -import com.google.common.collect.Sets; import com.intellij.lang.annotation.AnnotationHolder; import com.intellij.lang.annotation.Annotator; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.progress.ProcessCanceledException; import com.intellij.openapi.roots.ProjectFileIndex; import com.intellij.psi.PsiElement; -import com.intellij.psi.tree.IElementType; -import com.intellij.psi.tree.TokenSet; import org.jetbrains.annotations.NotNull; -import org.jetbrains.jet.JetNodeTypes; -import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor; -import org.jetbrains.jet.lang.diagnostics.Diagnostic; -import org.jetbrains.jet.lang.diagnostics.UnresolvedReferenceDiagnosticFactory; -import org.jetbrains.jet.lang.psi.*; +import org.jetbrains.jet.checkers.DebugInfoUtil; +import org.jetbrains.jet.lang.psi.JetFile; +import org.jetbrains.jet.lang.psi.JetReferenceExpression; import org.jetbrains.jet.lang.resolve.BindingContext; -import org.jetbrains.jet.lang.types.ErrorUtils; -import org.jetbrains.jet.lang.types.JetType; -import org.jetbrains.jet.lexer.JetTokens; import org.jetbrains.jet.plugin.project.WholeProjectAnalyzerFacade; -import java.util.Collection; -import java.util.Set; - -import static org.jetbrains.jet.lang.resolve.BindingContext.*; -import static org.jetbrains.jet.lexer.JetTokens.*; - /** * Quick showing possible problems with jet internals in IDEA with a tooltips * @@ -50,8 +36,6 @@ import static org.jetbrains.jet.lexer.JetTokens.*; */ public class DebugInfoAnnotator implements Annotator { - public static final TokenSet EXCLUDED = TokenSet.create(COLON, AS_KEYWORD, AS_SAFE, IS_KEYWORD, NOT_IS, OROR, ANDAND, EQ, EQEQEQ, EXCLEQEQEQ, ELVIS, EXCLEXCL); - public static boolean isDebugInfoEnabled() { return ApplicationManager.getApplication().isInternal(); } @@ -69,67 +53,24 @@ public class DebugInfoAnnotator implements Annotator { JetFile file = (JetFile) element; try { final BindingContext bindingContext = WholeProjectAnalyzerFacade.analyzeProjectWithCacheOnAFile(file).getBindingContext(); - - final Set unresolvedReferences = Sets.newHashSet(); - for (Diagnostic diagnostic : bindingContext.getDiagnostics()) { - if (diagnostic.getFactory() instanceof UnresolvedReferenceDiagnosticFactory) { - unresolvedReferences.add((JetReferenceExpression)diagnostic.getPsiElement()); - } - } - - file.acceptChildren(new JetVisitorVoid() { - + DebugInfoUtil.markDebugAnnotations(file, bindingContext, new DebugInfoUtil.DebugInfoReporter() { @Override - public void visitReferenceExpression(JetReferenceExpression expression) { - if (expression instanceof JetSimpleNameExpression) { - JetSimpleNameExpression nameExpression = (JetSimpleNameExpression) expression; - IElementType elementType = expression.getNode().getElementType(); - if (elementType == JetNodeTypes.OPERATION_REFERENCE) { - IElementType referencedNameElementType = nameExpression.getReferencedNameElementType(); - if (EXCLUDED.contains(referencedNameElementType)) { - return; - } - if (JetTokens.LABELS.contains(referencedNameElementType)) return; - } - else if (nameExpression.getReferencedNameElementType() == JetTokens.THIS_KEYWORD) { - return; - } - } - - String target = null; - DeclarationDescriptor declarationDescriptor = bindingContext.get(REFERENCE_TARGET, expression); - if (declarationDescriptor != null) { - target = declarationDescriptor.toString(); - } - else { - PsiElement labelTarget = bindingContext.get(LABEL_TARGET, expression); - if (labelTarget != null) { - target = labelTarget.getText(); - } - else { - Collection declarationDescriptors = bindingContext.get(AMBIGUOUS_REFERENCE_TARGET, expression); - if (declarationDescriptors != null) { - target = "[" + declarationDescriptors.size() + " descriptors]"; - } - } - } - boolean resolved = target != null; - boolean unresolved = unresolvedReferences.contains(expression); - JetType expressionType = bindingContext.get(EXPRESSION_TYPE, expression); - if (declarationDescriptor != null && !ApplicationManager.getApplication().isUnitTestMode() && (ErrorUtils.isError(declarationDescriptor) || ErrorUtils.containsErrorType(expressionType))) { - holder.createErrorAnnotation(expression, "[DEBUG] Resolved to error element").setTextAttributes(JetHighlightingColors.RESOLVED_TO_ERROR); - } - if (resolved && unresolved) { - holder.createErrorAnnotation(expression, "[DEBUG] Reference marked as unresolved is actually resolved to " + target).setTextAttributes(JetHighlightingColors.DEBUG_INFO); - } - else if (!resolved && !unresolved) { - holder.createErrorAnnotation(expression, "[DEBUG] Reference is not resolved to anything, but is not marked unresolved").setTextAttributes(JetHighlightingColors.DEBUG_INFO); - } + public void reportErrorElement(@NotNull JetReferenceExpression expression) { + holder.createErrorAnnotation(expression, "[DEBUG] Resolved to error element") + .setTextAttributes(JetHighlightingColors.RESOLVED_TO_ERROR); } @Override - public void visitJetElement(JetElement element) { - element.acceptChildren(this); + public void reportMissingUnresolved(@NotNull JetReferenceExpression expression) { + holder.createErrorAnnotation(expression, + "[DEBUG] Reference is not resolved to anything, but is not marked unresolved") + .setTextAttributes(JetHighlightingColors.DEBUG_INFO); + } + + @Override + public void reportUnresolvedWithTarget(@NotNull JetReferenceExpression expression, @NotNull String target) { + holder.createErrorAnnotation(expression, "[DEBUG] Reference marked as unresolved is actually resolved to " + target) + .setTextAttributes(JetHighlightingColors.DEBUG_INFO); } }); } @@ -144,4 +85,5 @@ public class DebugInfoAnnotator implements Annotator { } } + }