Debug highlighting for error types
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package org.jetbrains.jet.lang.types;
|
package org.jetbrains.jet.lang.types;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.jet.lang.descriptors.*;
|
import org.jetbrains.jet.lang.descriptors.*;
|
||||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||||
@@ -196,10 +197,22 @@ public class ErrorUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isErrorType(@NotNull JetType type) {
|
public static boolean isErrorType(@NotNull JetType type) {
|
||||||
return type != TypeUtils.NO_EXPECTED_TYPE &&(
|
return type != TypeUtils.NO_EXPECTED_TYPE && !(type instanceof NamespaceType) &&
|
||||||
(type instanceof DeferredType && ((DeferredType) type).getActualType() == null) ||
|
(
|
||||||
type instanceof ErrorTypeImpl ||
|
(type instanceof DeferredType && ((DeferredType) type).getActualType() == null) ||
|
||||||
isError(type.getConstructor()));
|
type instanceof ErrorTypeImpl ||
|
||||||
|
isError(type.getConstructor())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean containsErrorType(@Nullable JetType type) {
|
||||||
|
if (type == null) return false;
|
||||||
|
if (type instanceof NamespaceType) return false;
|
||||||
|
if (isErrorType(type)) return true;
|
||||||
|
for (TypeProjection projection : type.getArguments()) {
|
||||||
|
if (containsErrorType(projection.getType())) return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isError(@NotNull DeclarationDescriptor candidate) {
|
public static boolean isError(@NotNull DeclarationDescriptor candidate) {
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import org.jetbrains.jet.lang.psi.*;
|
|||||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||||
import org.jetbrains.jet.lang.resolve.calls.ResolvedCallImpl;
|
import org.jetbrains.jet.lang.resolve.calls.ResolvedCallImpl;
|
||||||
import org.jetbrains.jet.lang.types.ErrorUtils;
|
import org.jetbrains.jet.lang.types.ErrorUtils;
|
||||||
|
import org.jetbrains.jet.lang.types.JetType;
|
||||||
import org.jetbrains.jet.lexer.JetTokens;
|
import org.jetbrains.jet.lexer.JetTokens;
|
||||||
import org.jetbrains.jet.plugin.JetHighlighter;
|
import org.jetbrains.jet.plugin.JetHighlighter;
|
||||||
import org.jetbrains.jet.plugin.compiler.WholeProjectAnalyzerFacade;
|
import org.jetbrains.jet.plugin.compiler.WholeProjectAnalyzerFacade;
|
||||||
@@ -102,7 +103,8 @@ public class DebugInfoAnnotator implements Annotator {
|
|||||||
}
|
}
|
||||||
boolean resolved = target != null;
|
boolean resolved = target != null;
|
||||||
boolean unresolved = unresolvedReferences.contains(expression);
|
boolean unresolved = unresolvedReferences.contains(expression);
|
||||||
if (declarationDescriptor != null && !ApplicationManager.getApplication().isUnitTestMode() && ErrorUtils.isError(declarationDescriptor)) {
|
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(JetHighlighter.JET_RESOLVED_TO_ERROR);
|
holder.createErrorAnnotation(expression, "[DEBUG] Resolved to error element").setTextAttributes(JetHighlighter.JET_RESOLVED_TO_ERROR);
|
||||||
}
|
}
|
||||||
if (resolved && unresolved) {
|
if (resolved && unresolved) {
|
||||||
|
|||||||
Reference in New Issue
Block a user