Disabled names highlighting in tests.
This commit is contained in:
@@ -41,8 +41,7 @@ public class FunctionsHighlightingVisitor extends AfterAnalysisHighlightingVisit
|
||||
public void visitNamedFunction(JetNamedFunction function) {
|
||||
PsiElement nameIdentifier = function.getNameIdentifier();
|
||||
if (nameIdentifier != null) {
|
||||
holder.createInfoAnnotation(nameIdentifier, null).setTextAttributes(
|
||||
JetHighlightingColors.FUNCTION_DECLARATION);
|
||||
JetPsiChecker.highlightName(holder, nameIdentifier, JetHighlightingColors.FUNCTION_DECLARATION);
|
||||
}
|
||||
|
||||
super.visitNamedFunction(function);
|
||||
@@ -57,8 +56,7 @@ public class FunctionsHighlightingVisitor extends AfterAnalysisHighlightingVisit
|
||||
if (typeElement instanceof JetUserType) {
|
||||
JetSimpleNameExpression nameExpression = ((JetUserType)typeElement).getReferenceExpression();
|
||||
if (nameExpression != null) {
|
||||
holder.createInfoAnnotation(nameExpression, null).setTextAttributes(
|
||||
JetHighlightingColors.CONSTRUCTOR_CALL);
|
||||
JetPsiChecker.highlightName(holder, nameExpression, JetHighlightingColors.CONSTRUCTOR_CALL);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -72,20 +70,18 @@ public class FunctionsHighlightingVisitor extends AfterAnalysisHighlightingVisit
|
||||
DeclarationDescriptor calleeDescriptor = bindingContext.get(BindingContext.REFERENCE_TARGET, (JetReferenceExpression)callee);
|
||||
if (calleeDescriptor != null) {
|
||||
if (calleeDescriptor instanceof ConstructorDescriptor) {
|
||||
holder.createInfoAnnotation(callee, null).setTextAttributes(
|
||||
JetHighlightingColors.CONSTRUCTOR_CALL);
|
||||
JetPsiChecker.highlightName(holder, callee, JetHighlightingColors.CONSTRUCTOR_CALL);
|
||||
}
|
||||
else if (calleeDescriptor instanceof FunctionDescriptor && !(calleeDescriptor instanceof VariableAsFunctionDescriptor)) {
|
||||
FunctionDescriptor fun = (FunctionDescriptor)calleeDescriptor;
|
||||
if (fun.getReceiverParameter() != ReceiverDescriptor.NO_RECEIVER) {
|
||||
holder.createInfoAnnotation(callee, null).setTextAttributes(
|
||||
JetHighlightingColors.EXTENSION_FUNCTION_CALL);
|
||||
JetPsiChecker.highlightName(holder, callee, JetHighlightingColors.EXTENSION_FUNCTION_CALL);
|
||||
}
|
||||
else if (fun.getContainingDeclaration() instanceof NamespaceDescriptor) {
|
||||
holder.createInfoAnnotation(callee, null).setTextAttributes(JetHighlightingColors.NAMESPACE_FUNCTION_CALL);
|
||||
JetPsiChecker.highlightName(holder, callee, JetHighlightingColors.NAMESPACE_FUNCTION_CALL);
|
||||
}
|
||||
else {
|
||||
holder.createInfoAnnotation(callee, null).setTextAttributes(JetHighlightingColors.FUNCTION_CALL);
|
||||
JetPsiChecker.highlightName(holder, callee, JetHighlightingColors.FUNCTION_CALL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.intellij.lang.annotation.Annotation;
|
||||
import com.intellij.lang.annotation.AnnotationHolder;
|
||||
import com.intellij.lang.annotation.Annotator;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.editor.colors.TextAttributesKey;
|
||||
import com.intellij.openapi.progress.ProcessCanceledException;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.MultiRangeReference;
|
||||
@@ -55,6 +56,18 @@ public class JetPsiChecker implements Annotator {
|
||||
return errorReportingEnabled;
|
||||
}
|
||||
|
||||
static boolean isNamesHighlightingEnabled() {
|
||||
return !ApplicationManager.getApplication().isUnitTestMode();
|
||||
}
|
||||
|
||||
static void highlightName(@NotNull AnnotationHolder holder,
|
||||
@NotNull PsiElement psiElement,
|
||||
@NotNull TextAttributesKey attributesKey) {
|
||||
if (isNamesHighlightingEnabled()) {
|
||||
holder.createInfoAnnotation(psiElement, null).setTextAttributes(attributesKey);
|
||||
}
|
||||
}
|
||||
|
||||
private static HighlightingVisitor[] getBeforeAnalysisVisitors(AnnotationHolder holder) {
|
||||
return new HighlightingVisitor[]{
|
||||
new SoftKeywordsHighlightingVisitor(holder),
|
||||
|
||||
@@ -20,13 +20,9 @@
|
||||
package org.jetbrains.jet.plugin.highlighter;
|
||||
|
||||
import com.intellij.lang.annotation.AnnotationHolder;
|
||||
import com.intellij.lang.annotation.Annotator;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.psi.JetLabelQualifiedExpression;
|
||||
import org.jetbrains.jet.lang.psi.JetPrefixExpression;
|
||||
import org.jetbrains.jet.lang.psi.JetSimpleNameExpression;
|
||||
import org.jetbrains.jet.lang.psi.JetVisitorVoid;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
|
||||
class LabelsHighlightingVisitor extends HighlightingVisitor {
|
||||
@@ -38,7 +34,7 @@ class LabelsHighlightingVisitor extends HighlightingVisitor {
|
||||
public void visitPrefixExpression(JetPrefixExpression expression) {
|
||||
JetSimpleNameExpression operationSign = expression.getOperationReference();
|
||||
if (JetTokens.LABELS.contains(operationSign.getReferencedNameElementType())) {
|
||||
holder.createInfoAnnotation(operationSign, null).setTextAttributes(JetHighlightingColors.LABEL);
|
||||
JetPsiChecker.highlightName(holder, operationSign, JetHighlightingColors.LABEL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +42,7 @@ class LabelsHighlightingVisitor extends HighlightingVisitor {
|
||||
public void visitLabelQualifiedExpression(JetLabelQualifiedExpression expression) {
|
||||
JetSimpleNameExpression targetLabel = expression.getTargetLabel();
|
||||
if (targetLabel != null) {
|
||||
holder.createInfoAnnotation(targetLabel, null).setTextAttributes(JetHighlightingColors.LABEL);
|
||||
JetPsiChecker.highlightName(holder, targetLabel, JetHighlightingColors.LABEL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,14 +41,13 @@ class PropertiesHighlightingVisitor extends AfterAnalysisHighlightingVisitor {
|
||||
}
|
||||
|
||||
if (((PropertyDescriptor)target).getReceiverParameter() != ReceiverDescriptor.NO_RECEIVER) {
|
||||
holder.createInfoAnnotation(expression, null).setTextAttributes(
|
||||
JetHighlightingColors.EXTENSION_PROPERTY);
|
||||
JetPsiChecker.highlightName(holder, expression, JetHighlightingColors.EXTENSION_PROPERTY);
|
||||
}
|
||||
|
||||
boolean namespace = target.getContainingDeclaration() instanceof NamespaceDescriptor;
|
||||
putPropertyAnnotation(expression, namespace, false);
|
||||
if (expression.getReferencedNameElementType() == JetTokens.FIELD_IDENTIFIER) {
|
||||
holder.createInfoAnnotation(expression, null).setTextAttributes(JetHighlightingColors.BACKING_FIELD_ACCESS);
|
||||
JetPsiChecker.highlightName(holder, expression, JetHighlightingColors.BACKING_FIELD_ACCESS);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,10 +82,8 @@ class PropertiesHighlightingVisitor extends AfterAnalysisHighlightingVisitor {
|
||||
}
|
||||
|
||||
private void putPropertyAnnotation(@NotNull PsiElement elementToHighlight, boolean namespace, boolean withBackingField) {
|
||||
holder.createInfoAnnotation(elementToHighlight, null).setTextAttributes(
|
||||
namespace
|
||||
? JetHighlightingColors.NAMESPACE_PROPERTY
|
||||
: JetHighlightingColors.INSTANCE_PROPERTY
|
||||
JetPsiChecker.highlightName(holder, elementToHighlight,
|
||||
namespace ? JetHighlightingColors.NAMESPACE_PROPERTY : JetHighlightingColors.INSTANCE_PROPERTY
|
||||
);
|
||||
if (withBackingField) {
|
||||
holder.createInfoAnnotation(
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.jetbrains.jet.plugin.highlighter;
|
||||
|
||||
import com.intellij.lang.annotation.Annotation;
|
||||
import com.intellij.lang.annotation.AnnotationHolder;
|
||||
import com.intellij.openapi.editor.colors.TextAttributesKey;
|
||||
import com.intellij.psi.PsiElement;
|
||||
@@ -51,11 +50,13 @@ class TypeKindHighlightingVisitor extends HighlightingVisitor {
|
||||
private void visitNameExpression(JetExpression expression) {
|
||||
PsiReference ref = expression.getReference();
|
||||
if (ref == null) return;
|
||||
PsiElement target = ref.resolve();
|
||||
if (target instanceof JetClass) {
|
||||
highlightClassByKind((JetClass)target, expression);
|
||||
} else if (target instanceof JetTypeParameter) {
|
||||
holder.createInfoAnnotation(expression, null).setTextAttributes(JetHighlightingColors.TYPE_PARAMETER);
|
||||
if (JetPsiChecker.isNamesHighlightingEnabled()) {
|
||||
PsiElement target = ref.resolve();
|
||||
if (target instanceof JetClass) {
|
||||
highlightClassByKind((JetClass)target, expression);
|
||||
} else if (target instanceof JetTypeParameter) {
|
||||
JetPsiChecker.highlightName(holder, expression, JetHighlightingColors.TYPE_PARAMETER);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +74,7 @@ class TypeKindHighlightingVisitor extends HighlightingVisitor {
|
||||
public void visitTypeParameter(JetTypeParameter parameter) {
|
||||
PsiElement identifier = parameter.getNameIdentifier();
|
||||
if (identifier != null) {
|
||||
holder.createInfoAnnotation(identifier, null).setTextAttributes(JetHighlightingColors.TYPE_PARAMETER);
|
||||
JetPsiChecker.highlightName(holder, identifier, JetHighlightingColors.TYPE_PARAMETER);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,7 +100,6 @@ class TypeKindHighlightingVisitor extends HighlightingVisitor {
|
||||
}
|
||||
}
|
||||
}
|
||||
Annotation annotation = holder.createInfoAnnotation(whatToHighlight, null);
|
||||
annotation.setTextAttributes(textAttributes);
|
||||
JetPsiChecker.highlightName(holder, whatToHighlight, textAttributes);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ class VariablesHighlightingVisitor extends AfterAnalysisHighlightingVisitor {
|
||||
if (descriptor instanceof VariableDescriptor) {
|
||||
VariableDescriptor variableDescriptor = (VariableDescriptor) descriptor;
|
||||
if (variableDescriptor.isVar()) {
|
||||
holder.createInfoAnnotation(elementToHighlight, null).setTextAttributes(JetHighlightingColors.MUTABLE_VARIABLE);
|
||||
JetPsiChecker.highlightName(holder, elementToHighlight, JetHighlightingColors.MUTABLE_VARIABLE);
|
||||
}
|
||||
|
||||
if (Boolean.TRUE.equals(bindingContext.get(MUST_BE_WRAPPED_IN_A_REF, variableDescriptor))) {
|
||||
@@ -103,11 +103,11 @@ class VariablesHighlightingVisitor extends AfterAnalysisHighlightingVisitor {
|
||||
}
|
||||
|
||||
if (descriptor instanceof LocalVariableDescriptor) {
|
||||
holder.createInfoAnnotation(elementToHighlight, null).setTextAttributes(JetHighlightingColors.LOCAL_VARIABLE);
|
||||
JetPsiChecker.highlightName(holder, elementToHighlight, JetHighlightingColors.LOCAL_VARIABLE);
|
||||
}
|
||||
|
||||
if (descriptor instanceof ValueParameterDescriptor) {
|
||||
holder.createInfoAnnotation(elementToHighlight, null).setTextAttributes(JetHighlightingColors.PARAMETER);
|
||||
JetPsiChecker.highlightName(holder, elementToHighlight, JetHighlightingColors.PARAMETER);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user