From 6b2e90126d71570a35a0b76b8b4d3568bd6a2180 Mon Sep 17 00:00:00 2001 From: Evgeny Gerashchenko Date: Tue, 10 Apr 2012 19:43:38 +0400 Subject: [PATCH] Fixed highlighting for safe access dot. --- .../highlighter/JetColorSettingsPage.java | 2 +- .../plugin/highlighter/JetHighlighter.java | 1 - .../SoftKeywordsHighlightingVisitor.java | 3 ++ idea/testData/checker/infos/Autocasts.jet | 32 +++++++++---------- 4 files changed, 20 insertions(+), 18 deletions(-) diff --git a/idea/src/org/jetbrains/jet/plugin/highlighter/JetColorSettingsPage.java b/idea/src/org/jetbrains/jet/plugin/highlighter/JetColorSettingsPage.java index 366c166646a..23e7685d7a8 100644 --- a/idea/src/org/jetbrains/jet/plugin/highlighter/JetColorSettingsPage.java +++ b/idea/src/org/jetbrains/jet/plugin/highlighter/JetColorSettingsPage.java @@ -58,7 +58,7 @@ public class JetColorSettingsPage implements ColorSettingsPage { "[Deprecated]\n" + "public class MyClass<out T : Iterable<T>>(var prop1 : Int) {\n" + " fun foo(nullable : String?, r : Runnable, f : () -> Int) {\n" + - " println(\"length is ${nullable?.length} \\e\")\n" + + " println(\"length is ${nullable?.length} \\e\")\n" + " val ints = java.util.ArrayList(2)\n" + " ints[0] = 102 + f()\n" + " val myFun = { -> \"\" }\n" + diff --git a/idea/src/org/jetbrains/jet/plugin/highlighter/JetHighlighter.java b/idea/src/org/jetbrains/jet/plugin/highlighter/JetHighlighter.java index 6f99c1f92ae..77f52f5ff7c 100644 --- a/idea/src/org/jetbrains/jet/plugin/highlighter/JetHighlighter.java +++ b/idea/src/org/jetbrains/jet/plugin/highlighter/JetHighlighter.java @@ -68,7 +68,6 @@ public class JetHighlighter extends SyntaxHighlighterBase { keys.put(JetTokens.COMMA, JetHighlightingColors.COMMA); keys.put(JetTokens.SEMICOLON, JetHighlightingColors.SEMICOLON); keys.put(JetTokens.DOT, JetHighlightingColors.DOT); - keys.put(JetTokens.SAFE_ACCESS, JetHighlightingColors.SAFE_ACCESS); keys.put(JetTokens.ARROW, JetHighlightingColors.ARROW); keys.put(JetTokens.OPEN_QUOTE, JetHighlightingColors.STRING); diff --git a/idea/src/org/jetbrains/jet/plugin/highlighter/SoftKeywordsHighlightingVisitor.java b/idea/src/org/jetbrains/jet/plugin/highlighter/SoftKeywordsHighlightingVisitor.java index e02eee1e1c4..6acbca66e2c 100644 --- a/idea/src/org/jetbrains/jet/plugin/highlighter/SoftKeywordsHighlightingVisitor.java +++ b/idea/src/org/jetbrains/jet/plugin/highlighter/SoftKeywordsHighlightingVisitor.java @@ -45,6 +45,9 @@ class SoftKeywordsHighlightingVisitor extends HighlightingVisitor { } holder.createInfoAnnotation(element, null).setTextAttributes(attributes); } + if (JetTokens.SAFE_ACCESS.equals(elementType)) { + holder.createInfoAnnotation(element, null).setTextAttributes(JetHighlightingColors.SAFE_ACCESS); + } } } diff --git a/idea/testData/checker/infos/Autocasts.jet b/idea/testData/checker/infos/Autocasts.jet index 87be56bbfcb..9bd17ee710a 100644 --- a/idea/testData/checker/infos/Autocasts.jet +++ b/idea/testData/checker/infos/Autocasts.jet @@ -7,20 +7,20 @@ class B() : A() { } fun f9(a : A?) { - a?.foo() - a?.bar() + a?.foo() + a?.bar() if (a is B) { a.bar() a.foo() } - a?.foo() - a?.bar() + a?.foo() + a?.bar() if (!(a is B)) { - a?.bar() - a?.foo() + a?.bar() + a?.foo() } if (!(a is B) || a.bar() == #()) { - a?.bar() + a?.bar() } if (!(a is B)) { return; @@ -56,7 +56,7 @@ fun f11(a : A?) { is A -> a.foo() is Any -> a.foo() is Any? -> a.bar() - else -> a?.foo() + else -> a?.foo() } } @@ -69,12 +69,12 @@ fun f12(a : A?) { is val c : B -> c.foo() is val c is C -> c.bar() is val c is C -> a.bar() - else -> a?.foo() + else -> a?.foo() } if (a is val b) { - a?.bar() - b?.foo() + a?.bar() + b?.foo() } if (a is val b is B) { b.foo() @@ -89,13 +89,13 @@ fun f13(a : A?) { c.bar() } else { - a?.foo() + a?.foo() c.bar() } - a?.foo() + a?.foo() if (!(a is val c is B)) { - a?.foo() + a?.foo() c.bar() } else { @@ -103,13 +103,13 @@ fun f13(a : A?) { c.bar() } - a?.foo() + a?.foo() if (a is val c is B && a.foo() == #() && c.bar() == #()) { c.foo() c.bar() } else { - a?.foo() + a?.foo() c.bar() }