diff --git a/src/com/goide/highlighting/GoColorsAndFontsPage.java b/src/com/goide/highlighting/GoColorsAndFontsPage.java index 15cc8214c1..2fbaa48871 100644 --- a/src/com/goide/highlighting/GoColorsAndFontsPage.java +++ b/src/com/goide/highlighting/GoColorsAndFontsPage.java @@ -50,6 +50,7 @@ public class GoColorsAndFontsPage implements ColorSettingsPage { new AttributesDescriptor("Type specification", TYPE_SPECIFICATION), new AttributesDescriptor("Type reference", TYPE_REFERENCE), new AttributesDescriptor("Builtin type", BUILTIN_TYPE_REFERENCE), + new AttributesDescriptor("Builtin function", BUILTIN_FUNCTION), new AttributesDescriptor("Exported function", EXPORTED_FUNCTION), new AttributesDescriptor("Local function", LOCAL_FUNCTION), new AttributesDescriptor("Package exported interface", PACKAGE_EXPORTED_INTERFACE), @@ -74,6 +75,7 @@ public class GoColorsAndFontsPage implements ColorSettingsPage { ATTRIBUTES_KEY_MAP.put("tr", TYPE_REFERENCE); ATTRIBUTES_KEY_MAP.put("ts", TYPE_SPECIFICATION); ATTRIBUTES_KEY_MAP.put("bt", BUILTIN_TYPE_REFERENCE); + ATTRIBUTES_KEY_MAP.put("bf", BUILTIN_FUNCTION); ATTRIBUTES_KEY_MAP.put("kw", KEYWORD); ATTRIBUTES_KEY_MAP.put("ef", EXPORTED_FUNCTION); ATTRIBUTES_KEY_MAP.put("lf", LOCAL_FUNCTION); @@ -225,6 +227,7 @@ public String getDemoText() { " _ = variableFunc(1)\n" + " _ = demo1\n" + " _ = demo2\n" + + " println(\"builtin function\")" + "\n" + "}\n" + "\n" + diff --git a/src/com/goide/highlighting/GoHighlightingAnnotator.java b/src/com/goide/highlighting/GoHighlightingAnnotator.java index 12a4de5dfe..e46efafdfd 100644 --- a/src/com/goide/highlighting/GoHighlightingAnnotator.java +++ b/src/com/goide/highlighting/GoHighlightingAnnotator.java @@ -92,6 +92,7 @@ private static TextAttributesKey getColor(GoVarDefinition o) { } private static TextAttributesKey getColor(GoNamedSignatureOwner o) { + if (GoPsiImplUtil.builtin(o)) return BUILTIN_FUNCTION; return o.isPublic() ? EXPORTED_FUNCTION : LOCAL_FUNCTION; } diff --git a/src/com/goide/highlighting/GoSyntaxHighlightingColors.java b/src/com/goide/highlighting/GoSyntaxHighlightingColors.java index b7b2264a7e..2212734d96 100644 --- a/src/com/goide/highlighting/GoSyntaxHighlightingColors.java +++ b/src/com/goide/highlighting/GoSyntaxHighlightingColors.java @@ -41,6 +41,7 @@ public class GoSyntaxHighlightingColors { public static final TextAttributesKey TYPE_SPECIFICATION = createTextAttributesKey("GO_TYPE_SPECIFICATION", DefaultLanguageHighlighterColors.CLASS_NAME); public static final TextAttributesKey TYPE_REFERENCE = createTextAttributesKey("GO_TYPE_REFERENCE", DefaultLanguageHighlighterColors.CLASS_REFERENCE); public static final TextAttributesKey BUILTIN_TYPE_REFERENCE = createTextAttributesKey("GO_BUILTIN_TYPE_REFERENCE", DefaultLanguageHighlighterColors.CLASS_REFERENCE); + public static final TextAttributesKey BUILTIN_FUNCTION = createTextAttributesKey("GO_BUILTIN_FUNCTION", DefaultLanguageHighlighterColors.FUNCTION_DECLARATION); public static final TextAttributesKey EXPORTED_FUNCTION = createTextAttributesKey("GO_EXPORTED_FUNCTION", DefaultLanguageHighlighterColors.FUNCTION_DECLARATION); public static final TextAttributesKey LOCAL_FUNCTION = createTextAttributesKey("GO_LOCAL_FUNCTION", DefaultLanguageHighlighterColors.FUNCTION_DECLARATION); public static final TextAttributesKey PACKAGE_EXPORTED_INTERFACE = createTextAttributesKey("GO_PACKAGE_EXPORTED_INTERFACE", DefaultLanguageHighlighterColors.INTERFACE_NAME); diff --git a/testData/colorHighlighting/builtinFunctions.go b/testData/colorHighlighting/builtinFunctions.go new file mode 100644 index 0000000000..465496c687 --- /dev/null +++ b/testData/colorHighlighting/builtinFunctions.go @@ -0,0 +1,5 @@ +package main + +func main() { + println("demo") +} diff --git a/testData/colorHighlighting/funcAndMethod.go b/testData/colorHighlighting/funcAndMethod.go index 0863b8d53e..dc09b9e04c 100644 --- a/testData/colorHighlighting/funcAndMethod.go +++ b/testData/colorHighlighting/funcAndMethod.go @@ -1,7 +1,7 @@ package main type inner interface { - Inner() string + Inner() string } type ( @@ -13,7 +13,7 @@ type ( ) func (a dem) Demo() inner { - return error("demo") + return error("demo") } func main() { diff --git a/testData/colorHighlighting/label.go b/testData/colorHighlighting/label.go index 07ce42b30f..dc86b28920 100644 --- a/testData/colorHighlighting/label.go +++ b/testData/colorHighlighting/label.go @@ -1,6 +1,6 @@ package main -func test() int { +func test() int { foo: for { continue foo diff --git a/testData/colorHighlighting/octAndHex.go b/testData/colorHighlighting/octAndHex.go index 059a4ce9e7..e1bdcce148 100644 --- a/testData/colorHighlighting/octAndHex.go +++ b/testData/colorHighlighting/octAndHex.go @@ -1,5 +1,5 @@ package main -var a int = 0112 -var b int = 0x112 -var c int = 0Xabf112 \ No newline at end of file +var a int = 0112 +var b int = 0x112 +var c int = 0Xabf112 \ No newline at end of file diff --git a/testData/colorHighlighting/simple.go b/testData/colorHighlighting/simple.go index c7b623530b..21c16901cd 100644 --- a/testData/colorHighlighting/simple.go +++ b/testData/colorHighlighting/simple.go @@ -3,5 +3,5 @@ package main import `fmt` func main() { - fmt.Println("Hello") + fmt.Println("Hello") } \ No newline at end of file diff --git a/testData/colorHighlighting/types.go b/testData/colorHighlighting/types.go index e71084d008..0ee2f1f451 100644 --- a/testData/colorHighlighting/types.go +++ b/testData/colorHighlighting/types.go @@ -2,25 +2,25 @@ package main type ( PublicInterface interface { - PublicFunc() int - privateFunc() int + PublicFunc() int + privateFunc() int } private interface { - PublicFunc() int - privateFunc() int + PublicFunc() int + privateFunc() int } PublicStruct struct { - PublicField int - privateField int + PublicField int + privateField int } privateStruct struct { - PublicField int - privateField int + PublicField int + privateField int } - demoInt int + demoInt int ) \ No newline at end of file diff --git a/tests/com/goide/editor/GoHighlightingAnnotatorTest.java b/tests/com/goide/editor/GoHighlightingAnnotatorTest.java index 087051a933..5d3b82634e 100644 --- a/tests/com/goide/editor/GoHighlightingAnnotatorTest.java +++ b/tests/com/goide/editor/GoHighlightingAnnotatorTest.java @@ -17,12 +17,19 @@ package com.goide.editor; import com.goide.GoCodeInsightFixtureTestCase; +import com.intellij.testFramework.LightProjectDescriptor; import com.intellij.testFramework.TestDataPath; import org.jetbrains.annotations.NotNull; @TestDataPath("$PROJECT_ROOT/testData/colorHighlighting") public class GoHighlightingAnnotatorTest extends GoCodeInsightFixtureTestCase { - + + @Override + protected void setUp() throws Exception { + super.setUp(); + setUpProjectSdk(); + } + public void testSimple() { doTest(); } @@ -47,6 +54,10 @@ public void testTypes() { doTest(); } + public void testBuiltinFunctions() { + doTest(); + } + @Override protected boolean isWriteActionRequired() { return false; @@ -61,5 +72,10 @@ private void doTest() { protected String getBasePath() { return "colorHighlighting"; } + + @Override + protected LightProjectDescriptor getProjectDescriptor() { + return createMockProjectDescriptor(); + } }