"field": highlighting fix, including color schemes and example
This commit is contained in:
@@ -133,6 +133,7 @@ options.kotlin.attribute.descriptor.instance.property=Instance property
|
|||||||
options.kotlin.attribute.descriptor.package.property=Package-level property
|
options.kotlin.attribute.descriptor.package.property=Package-level property
|
||||||
options.kotlin.attribute.descriptor.property.with.backing=Property with backing field
|
options.kotlin.attribute.descriptor.property.with.backing=Property with backing field
|
||||||
options.kotlin.attribute.descriptor.backing.field.access=Backing field access
|
options.kotlin.attribute.descriptor.backing.field.access=Backing field access
|
||||||
|
options.kotlin.attribute.descriptor.field=Backing field variable
|
||||||
options.kotlin.attribute.descriptor.extension.property=Extension property
|
options.kotlin.attribute.descriptor.extension.property=Extension property
|
||||||
options.kotlin.attribute.descriptor.dynamic.property=Dynamic property
|
options.kotlin.attribute.descriptor.dynamic.property=Dynamic property
|
||||||
options.kotlin.attribute.descriptor.it=Function literal default parameter
|
options.kotlin.attribute.descriptor.it=Function literal default parameter
|
||||||
|
|||||||
+1
@@ -66,6 +66,7 @@ public class JetHighlightingColors {
|
|||||||
public static final TextAttributesKey PACKAGE_PROPERTY = createTextAttributesKey("KOTLIN_PACKAGE_PROPERTY", CodeInsightColors.STATIC_FIELD_ATTRIBUTES);
|
public static final TextAttributesKey PACKAGE_PROPERTY = createTextAttributesKey("KOTLIN_PACKAGE_PROPERTY", CodeInsightColors.STATIC_FIELD_ATTRIBUTES);
|
||||||
public static final TextAttributesKey PROPERTY_WITH_BACKING_FIELD = createTextAttributesKey("KOTLIN_PROPERTY_WITH_BACKING_FIELD");
|
public static final TextAttributesKey PROPERTY_WITH_BACKING_FIELD = createTextAttributesKey("KOTLIN_PROPERTY_WITH_BACKING_FIELD");
|
||||||
public static final TextAttributesKey BACKING_FIELD_ACCESS = createTextAttributesKey("KOTLIN_BACKING_FIELD_ACCESS");
|
public static final TextAttributesKey BACKING_FIELD_ACCESS = createTextAttributesKey("KOTLIN_BACKING_FIELD_ACCESS");
|
||||||
|
public static final TextAttributesKey BACKING_FIELD_VARIABLE = createTextAttributesKey("KOTLIN_BACKING_FIELD_VARIABLE");
|
||||||
public static final TextAttributesKey EXTENSION_PROPERTY = createTextAttributesKey("KOTLIN_EXTENSION_PROPERTY");
|
public static final TextAttributesKey EXTENSION_PROPERTY = createTextAttributesKey("KOTLIN_EXTENSION_PROPERTY");
|
||||||
public static final TextAttributesKey DYNAMIC_PROPERTY_CALL = createTextAttributesKey("KOTLIN_DYNAMIC_PROPERTY_CALL");
|
public static final TextAttributesKey DYNAMIC_PROPERTY_CALL = createTextAttributesKey("KOTLIN_DYNAMIC_PROPERTY_CALL");
|
||||||
|
|
||||||
|
|||||||
+5
@@ -22,6 +22,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor;
|
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor;
|
||||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor;
|
import org.jetbrains.kotlin.descriptors.PropertyDescriptor;
|
||||||
import org.jetbrains.kotlin.descriptors.VariableDescriptor;
|
import org.jetbrains.kotlin.descriptors.VariableDescriptor;
|
||||||
|
import org.jetbrains.kotlin.descriptors.impl.SyntheticFieldDescriptor;
|
||||||
import org.jetbrains.kotlin.lexer.JetTokens;
|
import org.jetbrains.kotlin.lexer.JetTokens;
|
||||||
import org.jetbrains.kotlin.psi.JetParameter;
|
import org.jetbrains.kotlin.psi.JetParameter;
|
||||||
import org.jetbrains.kotlin.psi.JetProperty;
|
import org.jetbrains.kotlin.psi.JetProperty;
|
||||||
@@ -42,6 +43,10 @@ class PropertiesHighlightingVisitor extends AfterAnalysisHighlightingVisitor {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
DeclarationDescriptor target = bindingContext.get(BindingContext.REFERENCE_TARGET, expression);
|
DeclarationDescriptor target = bindingContext.get(BindingContext.REFERENCE_TARGET, expression);
|
||||||
|
if (target instanceof SyntheticFieldDescriptor) {
|
||||||
|
JetPsiChecker.highlightName(holder, expression, JetHighlightingColors.BACKING_FIELD_VARIABLE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!(target instanceof PropertyDescriptor)) {
|
if (!(target instanceof PropertyDescriptor)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,11 @@
|
|||||||
<option name="FONT_TYPE" value="1" />
|
<option name="FONT_TYPE" value="1" />
|
||||||
</value>
|
</value>
|
||||||
</option>
|
</option>
|
||||||
|
<option name="KOTLIN_BACKING_FIELD_VARIABLE">
|
||||||
|
<value>
|
||||||
|
<option name="FONT_TYPE" value="1" />
|
||||||
|
</value>
|
||||||
|
</option>
|
||||||
<option name="KOTLIN_SMART_CAST_VALUE">
|
<option name="KOTLIN_SMART_CAST_VALUE">
|
||||||
<value>
|
<value>
|
||||||
<option name="BACKGROUND" value="223c23" />
|
<option name="BACKGROUND" value="223c23" />
|
||||||
|
|||||||
@@ -20,6 +20,11 @@
|
|||||||
<option name="FONT_TYPE" value="1" />
|
<option name="FONT_TYPE" value="1" />
|
||||||
</value>
|
</value>
|
||||||
</option>
|
</option>
|
||||||
|
<option name="KOTLIN_BACKING_FIELD_VARIABLE">
|
||||||
|
<value>
|
||||||
|
<option name="FONT_TYPE" value="1" />
|
||||||
|
</value>
|
||||||
|
</option>
|
||||||
<option name="KOTLIN_SMART_CAST_VALUE">
|
<option name="KOTLIN_SMART_CAST_VALUE">
|
||||||
<value>
|
<value>
|
||||||
<option name="BACKGROUND" value="dbffdb" />
|
<option name="BACKGROUND" value="dbffdb" />
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ public class KotlinColorSettingsPage : ColorSettingsPage {
|
|||||||
|
|
||||||
var <PROPERTY_WITH_BACKING_FIELD><PACKAGE_PROPERTY><MUTABLE_VARIABLE>globalCounter</MUTABLE_VARIABLE></PACKAGE_PROPERTY></PROPERTY_WITH_BACKING_FIELD> : Int = 5
|
var <PROPERTY_WITH_BACKING_FIELD><PACKAGE_PROPERTY><MUTABLE_VARIABLE>globalCounter</MUTABLE_VARIABLE></PACKAGE_PROPERTY></PROPERTY_WITH_BACKING_FIELD> : Int = 5
|
||||||
<KEYWORD>get</KEYWORD>() {
|
<KEYWORD>get</KEYWORD>() {
|
||||||
return <BACKING_FIELD_ACCESS><PACKAGE_PROPERTY><MUTABLE_VARIABLE>${"$"}globalCounter</MUTABLE_VARIABLE></PACKAGE_PROPERTY></BACKING_FIELD_ACCESS>
|
return <BACKING_FIELD_VARIABLE><LOCAL_VARIABLE><MUTABLE_VARIABLE>field</MUTABLE_VARIABLE></LOCAL_VARIABLE></BACKING_FIELD_VARIABLE>
|
||||||
}
|
}
|
||||||
|
|
||||||
<KEYWORD>public</KEYWORD> <KEYWORD>abstract</KEYWORD> class <ABSTRACT_CLASS>Abstract</ABSTRACT_CLASS> {
|
<KEYWORD>public</KEYWORD> <KEYWORD>abstract</KEYWORD> class <ABSTRACT_CLASS>Abstract</ABSTRACT_CLASS> {
|
||||||
@@ -133,6 +133,7 @@ var <PROPERTY_WITH_BACKING_FIELD><PACKAGE_PROPERTY><MUTABLE_VARIABLE>globalCount
|
|||||||
JetBundle.message("options.kotlin.attribute.descriptor.package.property") to JetHighlightingColors.PACKAGE_PROPERTY,
|
JetBundle.message("options.kotlin.attribute.descriptor.package.property") to JetHighlightingColors.PACKAGE_PROPERTY,
|
||||||
JetBundle.message("options.kotlin.attribute.descriptor.property.with.backing") to JetHighlightingColors.PROPERTY_WITH_BACKING_FIELD,
|
JetBundle.message("options.kotlin.attribute.descriptor.property.with.backing") to JetHighlightingColors.PROPERTY_WITH_BACKING_FIELD,
|
||||||
JetBundle.message("options.kotlin.attribute.descriptor.backing.field.access") to JetHighlightingColors.BACKING_FIELD_ACCESS,
|
JetBundle.message("options.kotlin.attribute.descriptor.backing.field.access") to JetHighlightingColors.BACKING_FIELD_ACCESS,
|
||||||
|
JetBundle.message("options.kotlin.attribute.descriptor.field") to JetHighlightingColors.BACKING_FIELD_VARIABLE,
|
||||||
JetBundle.message("options.kotlin.attribute.descriptor.extension.property") to JetHighlightingColors.EXTENSION_PROPERTY,
|
JetBundle.message("options.kotlin.attribute.descriptor.extension.property") to JetHighlightingColors.EXTENSION_PROPERTY,
|
||||||
JetBundle.message("options.kotlin.attribute.descriptor.dynamic.property") to JetHighlightingColors.DYNAMIC_PROPERTY_CALL,
|
JetBundle.message("options.kotlin.attribute.descriptor.dynamic.property") to JetHighlightingColors.DYNAMIC_PROPERTY_CALL,
|
||||||
JetBundle.message("options.kotlin.attribute.descriptor.it") to JetHighlightingColors.FUNCTION_LITERAL_DEFAULT_PARAMETER,
|
JetBundle.message("options.kotlin.attribute.descriptor.it") to JetHighlightingColors.FUNCTION_LITERAL_DEFAULT_PARAMETER,
|
||||||
|
|||||||
Vendored
+10
@@ -0,0 +1,10 @@
|
|||||||
|
var <info textAttributesKey="KOTLIN_PACKAGE_PROPERTY"><info textAttributesKey="KOTLIN_MUTABLE_VARIABLE"><info descr="This property has a backing field" textAttributesKey="KOTLIN_PROPERTY_WITH_BACKING_FIELD">my</info></info></info> = 0
|
||||||
|
<info textAttributesKey="KOTLIN_KEYWORD">get</info>() = <info textAttributesKey="KOTLIN_BACKING_FIELD_VARIABLE"><info textAttributesKey="KOTLIN_MUTABLE_VARIABLE"><info textAttributesKey="KOTLIN_LOCAL_VARIABLE">field</info></info></info>
|
||||||
|
<info textAttributesKey="KOTLIN_KEYWORD">set</info>(<info textAttributesKey="KOTLIN_PARAMETER">arg</info>) {
|
||||||
|
<info textAttributesKey="KOTLIN_BACKING_FIELD_VARIABLE"><info textAttributesKey="KOTLIN_MUTABLE_VARIABLE"><info textAttributesKey="KOTLIN_LOCAL_VARIABLE">field</info></info></info> = <info textAttributesKey="KOTLIN_PARAMETER">arg</info> + 1
|
||||||
|
}
|
||||||
|
|
||||||
|
fun <info textAttributesKey="KOTLIN_FUNCTION_DECLARATION">foo</info>(): <info textAttributesKey="KOTLIN_CLASS">Int</info> {
|
||||||
|
val <info textAttributesKey="KOTLIN_LOCAL_VARIABLE">field</info> = <info textAttributesKey="KOTLIN_PACKAGE_PROPERTY"><info textAttributesKey="KOTLIN_MUTABLE_VARIABLE">my</info></info>
|
||||||
|
return <info textAttributesKey="KOTLIN_LOCAL_VARIABLE">field</info>
|
||||||
|
}
|
||||||
@@ -53,6 +53,12 @@ public class HighlightingTestGenerated extends AbstractHighlightingTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("Field.kt")
|
||||||
|
public void testField() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/highlighter/Field.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("Functions.kt")
|
@TestMetadata("Functions.kt")
|
||||||
public void testFunctions() throws Exception {
|
public void testFunctions() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/highlighter/Functions.kt");
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/highlighter/Functions.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user