diff --git a/idea/src/META-INF/plugin.xml b/idea/src/META-INF/plugin.xml index 7cf9a1a8c01..f7c6e2835f6 100644 --- a/idea/src/META-INF/plugin.xml +++ b/idea/src/META-INF/plugin.xml @@ -77,6 +77,8 @@ + + diff --git a/idea/src/org/jetbrains/jet/plugin/highlighter/JetColorSettingsPage.java b/idea/src/org/jetbrains/jet/plugin/highlighter/JetColorSettingsPage.java new file mode 100644 index 00000000000..22ccb3bf900 --- /dev/null +++ b/idea/src/org/jetbrains/jet/plugin/highlighter/JetColorSettingsPage.java @@ -0,0 +1,113 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.plugin.highlighter; + +import com.intellij.openapi.editor.colors.TextAttributesKey; +import com.intellij.openapi.fileTypes.SyntaxHighlighter; +import com.intellij.openapi.options.colors.AttributesDescriptor; +import com.intellij.openapi.options.colors.ColorDescriptor; +import com.intellij.openapi.options.colors.ColorSettingsPage; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.plugin.JetIconProvider; + +import javax.swing.*; +import java.util.Collections; +import java.util.Map; + +public class JetColorSettingsPage implements ColorSettingsPage { + @Override + public Icon getIcon() { + return JetIconProvider.KOTLIN_ICON; + } + + @NotNull + @Override + public SyntaxHighlighter getHighlighter() { + return new JetHighlighter(); + } + + @NotNull + @Override + public String getDemoText() { + return "/* Block comment */\n" + + "import kotlin.util.*\n" + + " Bad characters: \\n #\n" + + "val globalConst = 0\n" + + "/**\n" + + " * Doc comment here for `SomeClass`\n" + + " * @see Iterator#next()\n" + + " */\n" + + "[Annotation]\n" + + "public class SomeClass(param : ATrait, reassignedParam : Array, val paramProperty: String?) { // some comment\n" + + " private field : T {\n" + + " return null\n" + + " }\n" + + " private open unusedField : Double = 12345.67890\n" + + " private anotherString : UnknownType = \"$field Another\\nStrin\\g\";\n" + + "\n" + + " {\n" + + " paramProperty.?length ?: 33\n" + + " val localVal : Int = \"IntelliJ\" // Error, incompatible types\n" + + " println(anotherString + field + localVar + globalConst)\n" + + " val time = Date.parse(\"1.2.3\") // Method is deprecated\n" + + " var reassignedValue = \"\" as Int\n" + + " reassignedValue++\n" + + " object : Runnable {\n" + + " override fun() {\n" + + " val a = localVar\n" + + " }\n" + + " }\n" + + " reassignedParam = Array(2)\n" + + " reassignedParam[0] = 1\n" + + " reassignedParam.foreach @lit {\n" + + " if (it == 0) return@lit\n" + + " println(it + localVar)\n" + + " }\n" + + " }\n" + + "}\n" + + "trait ATrait {\n" + + " fun memberFun(param : (Int) -> Int)\n" + + "}\n" + + "abstract class SomeAbstractClass {\n" + + "}"; + } + + @Override + public Map getAdditionalHighlightingTagToDescriptorMap() { + return Collections.emptyMap(); + } + + @NotNull + @Override + public AttributesDescriptor[] getAttributeDescriptors() { + return new AttributesDescriptor[]{ + new AttributesDescriptor("Keyword", JetHighlighter.JET_KEYWORD) + }; + } + + @NotNull + @Override + public ColorDescriptor[] getColorDescriptors() { + return ColorDescriptor.EMPTY_ARRAY; + } + + @NotNull + @Override + public String getDisplayName() { + return "Kotlin"; + } +} diff --git a/idea/src/org/jetbrains/jet/plugin/highlighter/JetHighlighter.java b/idea/src/org/jetbrains/jet/plugin/highlighter/JetHighlighter.java index d7a0e406080..777618e064b 100644 --- a/idea/src/org/jetbrains/jet/plugin/highlighter/JetHighlighter.java +++ b/idea/src/org/jetbrains/jet/plugin/highlighter/JetHighlighter.java @@ -41,7 +41,7 @@ public class JetHighlighter extends SyntaxHighlighterBase { private static final Map keys1; private static final Map keys2; - private static final TextAttributesKey JET_KEYWORD = TextAttributesKey.createTextAttributesKey( + static final TextAttributesKey JET_KEYWORD = TextAttributesKey.createTextAttributesKey( "JET.KEYWORD", SyntaxHighlighterColors.KEYWORD.getDefaultAttributes() );