From ee24554e287f54826b425f49693878d4d69f67d2 Mon Sep 17 00:00:00 2001 From: Evgeny Gerashchenko Date: Sun, 8 Apr 2012 22:58:50 +0400 Subject: [PATCH] Fixed highlighting of builtin annotations (they were highlighted like keywords). --- .../highlighter/SoftKeywordsHighlightingVisitor.java | 11 +++++++++-- idea/testData/highlighter/Functions.kt | 4 ++-- idea/testData/highlighter/TypesAndAnnotations.kt | 6 +++--- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/idea/src/org/jetbrains/jet/plugin/highlighter/SoftKeywordsHighlightingVisitor.java b/idea/src/org/jetbrains/jet/plugin/highlighter/SoftKeywordsHighlightingVisitor.java index 4dacbfc30cf..337ceb1c863 100644 --- a/idea/src/org/jetbrains/jet/plugin/highlighter/SoftKeywordsHighlightingVisitor.java +++ b/idea/src/org/jetbrains/jet/plugin/highlighter/SoftKeywordsHighlightingVisitor.java @@ -22,8 +22,10 @@ package org.jetbrains.jet.plugin.highlighter; import com.intellij.lang.ASTNode; import com.intellij.lang.annotation.AnnotationHolder; import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.editor.colors.TextAttributesKey; import com.intellij.psi.PsiElement; import com.intellij.psi.impl.source.tree.LeafPsiElement; +import com.intellij.psi.tree.IElementType; import org.jetbrains.jet.lang.psi.*; import org.jetbrains.jet.lexer.JetTokens; @@ -35,8 +37,13 @@ class SoftKeywordsHighlightingVisitor extends HighlightingVisitor { @Override public void visitElement(PsiElement element) { if (element instanceof LeafPsiElement) { - if (JetTokens.SOFT_KEYWORDS.contains(((LeafPsiElement) element).getElementType())) { - holder.createInfoAnnotation(element, null).setTextAttributes(JetHighlightingColors.KEYWORD); + IElementType elementType = ((LeafPsiElement)element).getElementType(); + if (JetTokens.SOFT_KEYWORDS.contains(elementType)) { + TextAttributesKey attributes = JetHighlightingColors.KEYWORD; + if (JetTokens.MODIFIER_KEYWORDS.contains(elementType)) { + attributes = JetHighlightingColors.BUILTIN_ANNOTATION; + } + holder.createInfoAnnotation(element, null).setTextAttributes(attributes); } } } diff --git a/idea/testData/highlighter/Functions.kt b/idea/testData/highlighter/Functions.kt index 7bc28c1f028..51b9c1f0d31 100644 --- a/idea/testData/highlighter/Functions.kt +++ b/idea/testData/highlighter/Functions.kt @@ -8,8 +8,8 @@ fun global() { fun Int.ext() { } -open class Container { - open fun member() { +open class Container { + open fun member() { global() 5.ext() member() diff --git a/idea/testData/highlighter/TypesAndAnnotations.kt b/idea/testData/highlighter/TypesAndAnnotations.kt index d40cd837716..4f988fcf4c8 100644 --- a/idea/testData/highlighter/TypesAndAnnotations.kt +++ b/idea/testData/highlighter/TypesAndAnnotations.kt @@ -4,9 +4,9 @@ trait TheTrait { class TheClass : TheTrait { } -annotation class magnificent -annotation class deprecated +annotation class magnificent +annotation class deprecated [deprecated] -magnificent abstract class AbstractClass<T> { +magnificent abstract class AbstractClass<T> { }