KT-13378 Provide ability to configure highlighting for !! in expressions and ? in types
This commit is contained in:
committed by
Dmitry Jemerov
parent
ab619c5655
commit
270b41dc66
@@ -64,6 +64,8 @@ options.kotlin.attribute.descriptor.builtin.annotation=Modifier
|
||||
options.kotlin.attribute.descriptor.string.escape=String//Escape in string and template braces
|
||||
options.kotlin.attribute.descriptor.closure.braces=Braces and Operators//Lambda expression braces and arrow
|
||||
options.kotlin.attribute.descriptor.safe.access=Braces and Operators//Safe access dot
|
||||
options.kotlin.attribute.descriptor.quest=Braces and Operators//Question after the type
|
||||
options.kotlin.attribute.descriptor.exclexcl=Braces and Operators//Non-null assertion
|
||||
options.kotlin.attribute.descriptor.arrow=Braces and Operators//Arrow
|
||||
options.kotlin.attribute.descriptor.colon=Braces and Operators//Colon
|
||||
options.kotlin.attribute.descriptor.double.colon=Braces and Operators//Double colon
|
||||
|
||||
+1
@@ -47,6 +47,7 @@ internal class BeforeResolveHighlightingVisitor(holder: AnnotationHolder) : High
|
||||
}
|
||||
}
|
||||
elementType == KtTokens.SAFE_ACCESS -> KotlinHighlightingColors.SAFE_ACCESS
|
||||
elementType == KtTokens.EXCLEXCL -> KotlinHighlightingColors.EXCLEXCL
|
||||
else -> return
|
||||
}
|
||||
|
||||
|
||||
@@ -72,6 +72,7 @@ public class KotlinHighlighter extends SyntaxHighlighterBase {
|
||||
keys1.put(KtTokens.SEMICOLON, KotlinHighlightingColors.SEMICOLON);
|
||||
keys1.put(KtTokens.COLON, KotlinHighlightingColors.COLON);
|
||||
keys1.put(KtTokens.COLONCOLON, KotlinHighlightingColors.DOUBLE_COLON);
|
||||
keys1.put(KtTokens.QUEST, KotlinHighlightingColors.QUEST);
|
||||
keys1.put(KtTokens.DOT, KotlinHighlightingColors.DOT);
|
||||
keys1.put(KtTokens.ARROW, KotlinHighlightingColors.ARROW);
|
||||
|
||||
|
||||
+2
@@ -42,6 +42,8 @@ public class KotlinHighlightingColors {
|
||||
public static final TextAttributesKey DOUBLE_COLON = createTextAttributesKey("KOTLIN_DOUBLE_COLON");
|
||||
public static final TextAttributesKey DOT = createTextAttributesKey("KOTLIN_DOT", DefaultLanguageHighlighterColors.DOT);
|
||||
public static final TextAttributesKey SAFE_ACCESS = createTextAttributesKey("KOTLIN_SAFE_ACCESS", DefaultLanguageHighlighterColors.DOT);
|
||||
public static final TextAttributesKey QUEST = createTextAttributesKey("KOTLIN_QUEST");
|
||||
public static final TextAttributesKey EXCLEXCL = createTextAttributesKey("KOTLIN_EXCLEXCL");
|
||||
public static final TextAttributesKey ARROW = createTextAttributesKey("KOTLIN_ARROW", PARENTHESIS);
|
||||
public static final TextAttributesKey LINE_COMMENT = createTextAttributesKey("KOTLIN_LINE_COMMENT", DefaultLanguageHighlighterColors.LINE_COMMENT);
|
||||
public static final TextAttributesKey BLOCK_COMMENT = createTextAttributesKey("KOTLIN_BLOCK_COMMENT", DefaultLanguageHighlighterColors.BLOCK_COMMENT);
|
||||
|
||||
@@ -45,8 +45,9 @@ class KotlinColorSettingsPage : ColorSettingsPage, RainbowColorSettingsPage {
|
||||
*/
|
||||
<ANNOTATION>@Deprecated</ANNOTATION>("Deprecated class")
|
||||
<BUILTIN_ANNOTATION>private</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 <PARAMETER><MUTABLE_VARIABLE><INSTANCE_PROPERTY>prop1</INSTANCE_PROPERTY></MUTABLE_VARIABLE></PARAMETER> : Int) {
|
||||
fun <FUNCTION_DECLARATION>foo</FUNCTION_DECLARATION>(<PARAMETER>nullable</PARAMETER> : String?, <PARAMETER>r</PARAMETER> : <TRAIT>Runnable</TRAIT>, <PARAMETER>f</PARAMETER> : () -> Int, <PARAMETER>fl</PARAMETER> : <TRAIT>FunctionLike</TRAIT>, dyn: <KEYWORD>dynamic</KEYWORD>) {
|
||||
fun <FUNCTION_DECLARATION>foo</FUNCTION_DECLARATION>(<PARAMETER>nullable</PARAMETER> : String<QUEST>?</QUEST>, <PARAMETER>r</PARAMETER> : <TRAIT>Runnable</TRAIT>, <PARAMETER>f</PARAMETER> : () -> Int, <PARAMETER>fl</PARAMETER> : <TRAIT>FunctionLike</TRAIT>, dyn: <KEYWORD>dynamic</KEYWORD>) {
|
||||
<PACKAGE_FUNCTION_CALL>println</PACKAGE_FUNCTION_CALL>("length\nis ${"$"}{<PARAMETER>nullable</PARAMETER><SAFE_ACCESS>?.</SAFE_ACCESS><INSTANCE_PROPERTY>length</INSTANCE_PROPERTY>} <STRING_ESCAPE><INVALID_STRING_ESCAPE>\e</INVALID_STRING_ESCAPE></STRING_ESCAPE>")
|
||||
<PACKAGE_FUNCTION_CALL>println</PACKAGE_FUNCTION_CALL>(<PARAMETER>nullable</PARAMETER><EXCLEXCL>!!</EXCLEXCL>.<INSTANCE_PROPERTY>length</INSTANCE_PROPERTY>)
|
||||
val <LOCAL_VARIABLE>ints</LOCAL_VARIABLE> = java.util.<CONSTRUCTOR_CALL>ArrayList</CONSTRUCTOR_CALL><Int?>(2)
|
||||
<LOCAL_VARIABLE>ints</LOCAL_VARIABLE>[0] = 102 + <PARAMETER><VARIABLE_AS_FUNCTION_CALL>f</VARIABLE_AS_FUNCTION_CALL></PARAMETER>() + <PARAMETER><VARIABLE_AS_FUNCTION_LIKE_CALL>fl</VARIABLE_AS_FUNCTION_LIKE_CALL></PARAMETER>()
|
||||
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>;
|
||||
@@ -128,6 +129,8 @@ var <PACKAGE_PROPERTY><MUTABLE_VARIABLE>globalCounter</MUTABLE_VARIABLE></PACKAG
|
||||
KotlinBundle.message("options.kotlin.attribute.descriptor.double.colon") to KotlinHighlightingColors.DOUBLE_COLON,
|
||||
OptionsBundle.message("options.java.attribute.descriptor.dot") to KotlinHighlightingColors.DOT,
|
||||
KotlinBundle.message("options.kotlin.attribute.descriptor.safe.access") to KotlinHighlightingColors.SAFE_ACCESS,
|
||||
KotlinBundle.message("options.kotlin.attribute.descriptor.quest") to KotlinHighlightingColors.QUEST,
|
||||
KotlinBundle.message("options.kotlin.attribute.descriptor.exclexcl") to KotlinHighlightingColors.EXCLEXCL,
|
||||
OptionsBundle.message("options.java.attribute.descriptor.line.comment") to KotlinHighlightingColors.LINE_COMMENT,
|
||||
OptionsBundle.message("options.java.attribute.descriptor.block.comment") to KotlinHighlightingColors.BLOCK_COMMENT,
|
||||
KotlinBundle.message("options.kotlin.attribute.descriptor.kdoc.comment") to KotlinHighlightingColors.DOC_COMMENT,
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
fun <info descr="null" textAttributesKey="KOTLIN_FUNCTION_DECLARATION">test</info>(<info descr="null" textAttributesKey="KOTLIN_PARAMETER">s</info>: <info descr="null" textAttributesKey="KOTLIN_CLASS">String</info>?) {
|
||||
<info descr="null" textAttributesKey="KOTLIN_PARAMETER">s</info><info descr="null" textAttributesKey="KOTLIN_EXCLEXCL">!!</info>.<info descr="null" textAttributesKey="KOTLIN_INSTANCE_PROPERTY">length</info>
|
||||
}
|
||||
@@ -102,6 +102,12 @@ public class HighlightingTestGenerated extends AbstractHighlightingTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("NonNullAssertion.kt")
|
||||
public void testNonNullAssertion() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/highlighter/NonNullAssertion.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("Object.kt")
|
||||
public void testObject() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/highlighter/Object.kt");
|
||||
|
||||
Reference in New Issue
Block a user