Fixed highlighting for safe access dot.

This commit is contained in:
Evgeny Gerashchenko
2012-04-10 19:43:38 +04:00
parent 217483d9d2
commit 6b2e90126d
4 changed files with 20 additions and 18 deletions
@@ -58,7 +58,7 @@ public class JetColorSettingsPage implements ColorSettingsPage {
"[<ANNOTATION>Deprecated</ANNOTATION>]\n" +
"<BUILTIN_ANNOTATION>public</BUILTIN_ANNOTATION> class <CLASS>MyClass</CLASS><<BUILTIN_ANNOTATION>out</BUILTIN_ANNOTATION> <TYPE_PARAMETER>T</TYPE_PARAMETER> : <TRAIT>Iterable</TRAIT><<TYPE_PARAMETER>T</TYPE_PARAMETER>>>(var <INSTANCE_PROPERTY><MUTABLE_VARIABLE>prop1</MUTABLE_VARIABLE></INSTANCE_PROPERTY> : Int) {\n" +
" fun <FUNCTION_DECLARATION>foo</FUNCTION_DECLARATION>(<PARAMETER>nullable</PARAMETER> : String?, <PARAMETER>r</PARAMETER> : <TRAIT>Runnable</TRAIT>, <PARAMETER>f</PARAMETER> : () -> Int) {\n" +
" <NAMESPACE_FUNCTION_CALL>println</NAMESPACE_FUNCTION_CALL>(\"length is ${<PARAMETER>nullable</PARAMETER>?.<INSTANCE_PROPERTY>length</INSTANCE_PROPERTY>} <INVALID_STRING_ESCAPE>\\e</INVALID_STRING_ESCAPE>\")\n" +
" <NAMESPACE_FUNCTION_CALL>println</NAMESPACE_FUNCTION_CALL>(\"length is ${<PARAMETER>nullable</PARAMETER><SAFE_ACCESS>?.</SAFE_ACCESS><INSTANCE_PROPERTY>length</INSTANCE_PROPERTY>} <INVALID_STRING_ESCAPE>\\e</INVALID_STRING_ESCAPE>\")\n" +
" val <LOCAL_VARIABLE>ints</LOCAL_VARIABLE> = java.util.<CONSTRUCTOR_CALL>ArrayList</CONSTRUCTOR_CALL><Int?>(2)\n" +
" <LOCAL_VARIABLE>ints</LOCAL_VARIABLE>[0] = 102 + <PARAMETER>f</PARAMETER>()\n" +
" val <LOCAL_VARIABLE>myFun</LOCAL_VARIABLE> = <FUNCTION_LITERAL_BRACES_AND_ARROW>{</FUNCTION_LITERAL_BRACES_AND_ARROW> <FUNCTION_LITERAL_BRACES_AND_ARROW>-></FUNCTION_LITERAL_BRACES_AND_ARROW> \"\" <FUNCTION_LITERAL_BRACES_AND_ARROW>}</FUNCTION_LITERAL_BRACES_AND_ARROW>\n" +
@@ -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);
@@ -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);
}
}
}
+16 -16
View File
@@ -7,20 +7,20 @@ class B() : A() {
}
fun f9(a : A?) {
a?.foo()
a?.<error descr="Unresolved reference: bar">bar</error>()
a<info>?.</info>foo()
a<info>?.</info><error descr="Unresolved reference: bar">bar</error>()
if (a is B) {
<info descr="Automatically cast to B">a</info>.bar()
<info descr="Automatically cast to B">a</info>.foo()
}
a?.foo()
a?.<error descr="Unresolved reference: bar">bar</error>()
a<info>?.</info>foo()
a<info>?.</info><error descr="Unresolved reference: bar">bar</error>()
if (!(a is B)) {
a?.<error descr="Unresolved reference: bar">bar</error>()
a?.foo()
a<info>?.</info><error descr="Unresolved reference: bar">bar</error>()
a<info>?.</info>foo()
}
if (!(a is B) || <info descr="Automatically cast to B">a</info>.bar() == #()) {
a?.<error descr="Unresolved reference: bar">bar</error>()
a<info>?.</info><error descr="Unresolved reference: bar">bar</error>()
}
if (!(a is B)) {
return;
@@ -56,7 +56,7 @@ fun f11(a : A?) {
is A -> <info descr="Automatically cast to A">a</info>.foo()
is Any -> <info descr="Automatically cast to A">a</info>.foo()
is Any? -> a.<error descr="Unresolved reference: bar">bar</error>()
else -> a?.foo()
else -> a<info>?.</info>foo()
}
}
@@ -69,12 +69,12 @@ fun f12(a : A?) {
is val c : <error descr="[TYPE_MISMATCH_IN_BINDING_PATTERN] B must be a supertype of A?. Use is to match against B">B</error> -> c.foo()
is val c is C -> <info descr="Automatically cast to C">c</info>.bar()
is val c is C -> <info descr="Automatically cast to C">a</info>.bar()
else -> a?.foo()
else -> a<info>?.</info>foo()
}
if (a is val b) {
a?.<error descr="Unresolved reference: bar">bar</error>()
b?.foo()
a<info>?.</info><error descr="Unresolved reference: bar">bar</error>()
b<info>?.</info>foo()
}
if (a is val b is B) {
<info descr="Automatically cast to B">b</info>.foo()
@@ -89,13 +89,13 @@ fun f13(a : A?) {
<info descr="Automatically cast to B">c</info>.bar()
}
else {
a?.foo()
a<info>?.</info>foo()
<error descr="Unresolved reference: c">c</error>.bar()
}
a?.foo()
a<info>?.</info>foo()
if (!(a is val c is B)) {
a?.foo()
a<info>?.</info>foo()
<error descr="Unresolved reference: c">c</error>.bar()
}
else {
@@ -103,13 +103,13 @@ fun f13(a : A?) {
<error descr="Unresolved reference: c">c</error>.bar()
}
a?.foo()
a<info>?.</info>foo()
if (a is val c is B && <info descr="Automatically cast to B">a</info>.foo() == #() && <info descr="Automatically cast to B">c</info>.bar() == #()) {
<info descr="Automatically cast to B">c</info>.foo()
<info descr="Automatically cast to B">c</info>.bar()
}
else {
a?.foo()
a<info>?.</info>foo()
<error descr="Unresolved reference: c">c</error>.bar()
}