diff --git a/idea/src/org/jetbrains/jet/plugin/highlighter/JetColorSettingsPage.java b/idea/src/org/jetbrains/jet/plugin/highlighter/JetColorSettingsPage.java index 11ed1ca98e0..3e7ac7a0088 100644 --- a/idea/src/org/jetbrains/jet/plugin/highlighter/JetColorSettingsPage.java +++ b/idea/src/org/jetbrains/jet/plugin/highlighter/JetColorSettingsPage.java @@ -105,6 +105,17 @@ public class JetColorSettingsPage implements ColorSettingsPage { new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.valid.escape.in.string"), JetHighlightingColors.VALID_STRING_ESCAPE), new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.invalid.escape.in.string"), JetHighlightingColors.INVALID_STRING_ESCAPE), + new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.operator.sign"), JetHighlightingColors.OPERATOR_SIGN), + new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.parentheses"), JetHighlightingColors.PARENTHESIS), + new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.braces"), JetHighlightingColors.BRACES), + new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.brackets"), JetHighlightingColors.BRACKETS), + new AttributesDescriptor("Function literal braces", JetHighlightingColors.FUNCTION_LITERAL_BRACES), + new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.comma"), JetHighlightingColors.COMMA), + new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.semicolon"), JetHighlightingColors.SEMICOLON), + new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.dot"), JetHighlightingColors.DOT), + new AttributesDescriptor("Safe access dot", JetHighlightingColors.SAFE_ACCESS), + new AttributesDescriptor("Arrow", JetHighlightingColors.ARROW), + new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.line.comment"), JetHighlightingColors.LINE_COMMENT), new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.block.comment"), JetHighlightingColors.BLOCK_COMMENT), new AttributesDescriptor("KDoc comment", JetHighlightingColors.DOC_COMMENT), @@ -115,7 +126,6 @@ public class JetColorSettingsPage implements ColorSettingsPage { new AttributesDescriptor("Instance property backing field access", JetHighlightingColors.INSTANCE_BACKING_FIELD_ACCESS), new AttributesDescriptor("Function literal default parameter", JetHighlightingColors.FUNCTION_LITERAL_DEFAULT_PARAMETER), - new AttributesDescriptor("Function literal bracket", JetHighlightingColors.FUNCTION_LITERAL_BRACKET), new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.bad.character"), JetHighlightingColors.BAD_CHARACTER), diff --git a/idea/src/org/jetbrains/jet/plugin/highlighter/JetHighlighter.java b/idea/src/org/jetbrains/jet/plugin/highlighter/JetHighlighter.java index 7164b512b90..cfdfa989d44 100644 --- a/idea/src/org/jetbrains/jet/plugin/highlighter/JetHighlighter.java +++ b/idea/src/org/jetbrains/jet/plugin/highlighter/JetHighlighter.java @@ -24,6 +24,7 @@ import com.intellij.openapi.editor.colors.TextAttributesKey; import com.intellij.openapi.fileTypes.SyntaxHighlighterBase; import com.intellij.psi.TokenType; import com.intellij.psi.tree.IElementType; +import com.intellij.psi.tree.TokenSet; import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.lexer.JetLexer; import org.jetbrains.jet.lexer.JetTokens; @@ -59,6 +60,21 @@ public class JetHighlighter extends SyntaxHighlighterBase { keys1.put(JetTokens.INTEGER_LITERAL, JetHighlightingColors.NUMBER); keys1.put(JetTokens.FLOAT_LITERAL, JetHighlightingColors.NUMBER); + fillMap(keys1, JetTokens.OPERATIONS.minus( + TokenSet.create(JetTokens.IDENTIFIER, JetTokens.LABEL_IDENTIFIER)).minus( + JetTokens.KEYWORDS), JetHighlightingColors.OPERATOR_SIGN); + keys1.put(JetTokens.LPAR, JetHighlightingColors.PARENTHESIS); + keys1.put(JetTokens.RPAR, JetHighlightingColors.PARENTHESIS); + keys1.put(JetTokens.LBRACE, JetHighlightingColors.BRACES); + keys1.put(JetTokens.RBRACE, JetHighlightingColors.BRACES); + keys1.put(JetTokens.LBRACKET, JetHighlightingColors.BRACKETS); + keys1.put(JetTokens.RBRACKET, JetHighlightingColors.BRACKETS); + keys1.put(JetTokens.COMMA, JetHighlightingColors.COMMA); + keys1.put(JetTokens.SEMICOLON, JetHighlightingColors.SEMICOLON); + keys1.put(JetTokens.DOT, JetHighlightingColors.DOT); + keys1.put(JetTokens.SAFE_ACCESS, JetHighlightingColors.SAFE_ACCESS); + keys1.put(JetTokens.ARROW, JetHighlightingColors.ARROW); + keys1.put(JetTokens.OPEN_QUOTE, JetHighlightingColors.STRING); keys1.put(JetTokens.CLOSING_QUOTE, JetHighlightingColors.STRING); keys1.put(JetTokens.REGULAR_STRING_PART, JetHighlightingColors.STRING); diff --git a/idea/src/org/jetbrains/jet/plugin/highlighter/JetHighlightingColors.java b/idea/src/org/jetbrains/jet/plugin/highlighter/JetHighlightingColors.java index 96f3fd62730..34030dad8cd 100644 --- a/idea/src/org/jetbrains/jet/plugin/highlighter/JetHighlightingColors.java +++ b/idea/src/org/jetbrains/jet/plugin/highlighter/JetHighlightingColors.java @@ -56,6 +56,56 @@ public class JetHighlightingColors { SyntaxHighlighterColors.INVALID_STRING_ESCAPE.getDefaultAttributes() ); + public static final TextAttributesKey OPERATOR_SIGN = TextAttributesKey.createTextAttributesKey( + "KOTLIN_OPERATION_SIGN", + SyntaxHighlighterColors.OPERATION_SIGN.getDefaultAttributes() + ); + + public static final TextAttributesKey PARENTHESIS = TextAttributesKey.createTextAttributesKey( + "KOTLIN_PARENTHESIS", + SyntaxHighlighterColors.PARENTHS.getDefaultAttributes() + ); + + public static final TextAttributesKey BRACES = TextAttributesKey.createTextAttributesKey( + "KOTLIN_BRACES", + SyntaxHighlighterColors.BRACES.getDefaultAttributes() + ); + + public static final TextAttributesKey BRACKETS = TextAttributesKey.createTextAttributesKey( + "KOTLIN_BRACKETS", + SyntaxHighlighterColors.BRACKETS.getDefaultAttributes() + ); + + public static final TextAttributesKey FUNCTION_LITERAL_BRACES = TextAttributesKey.createTextAttributesKey( + "KOTLIN_FUNCTION_LITERAL_BRACES", + new TextAttributes(null, null, null, null, Font.BOLD) + ); + + public static final TextAttributesKey COMMA = TextAttributesKey.createTextAttributesKey( + "KOTLIN_COMMA", + SyntaxHighlighterColors.COMMA.getDefaultAttributes() + ); + + public static final TextAttributesKey SEMICOLON = TextAttributesKey.createTextAttributesKey( + "KOTLIN_SEMICOLON", + SyntaxHighlighterColors.JAVA_SEMICOLON.getDefaultAttributes() + ); + + public static final TextAttributesKey DOT = TextAttributesKey.createTextAttributesKey( + "KOTLIN_DOT", + SyntaxHighlighterColors.DOT.getDefaultAttributes() + ); + + public static final TextAttributesKey SAFE_ACCESS = TextAttributesKey.createTextAttributesKey( + "KOTLIN_SAFE_ACCESS", + SyntaxHighlighterColors.DOT.getDefaultAttributes() + ); + + public static final TextAttributesKey ARROW = TextAttributesKey.createTextAttributesKey( + "KOTLIN_ARROW", + SyntaxHighlighterColors.PARENTHS.getDefaultAttributes() + ); + public static final TextAttributesKey LINE_COMMENT = TextAttributesKey.createTextAttributesKey( "KOTLIN_LINE_COMMENT", SyntaxHighlighterColors.LINE_COMMENT.getDefaultAttributes() @@ -92,11 +142,6 @@ public class JetHighlightingColors { new TextAttributes(null, null, null, null, Font.BOLD) ); - public static final TextAttributesKey FUNCTION_LITERAL_BRACKET = TextAttributesKey.createTextAttributesKey( - "KOTLIN_FUNCTION_LITERAL_BRACKET", - new TextAttributes(null, null, null, null, Font.BOLD) - ); - public static final TextAttributesKey BAD_CHARACTER = TextAttributesKey.createTextAttributesKey( "KOTLIN_BAD_CHARACTER", HighlighterColors.BAD_CHARACTER.getDefaultAttributes() diff --git a/idea/src/org/jetbrains/jet/plugin/highlighter/SoftKeywordsHighlightingVisitor.java b/idea/src/org/jetbrains/jet/plugin/highlighter/SoftKeywordsHighlightingVisitor.java index 0aa1ea36870..27f90d405c9 100644 --- a/idea/src/org/jetbrains/jet/plugin/highlighter/SoftKeywordsHighlightingVisitor.java +++ b/idea/src/org/jetbrains/jet/plugin/highlighter/SoftKeywordsHighlightingVisitor.java @@ -55,14 +55,14 @@ class SoftKeywordsHighlightingVisitor extends HighlightingVisitor { public void visitFunctionLiteralExpression(JetFunctionLiteralExpression expression) { if (ApplicationManager.getApplication().isUnitTestMode()) return; JetFunctionLiteral functionLiteral = expression.getFunctionLiteral(); - holder.createInfoAnnotation(functionLiteral.getOpenBraceNode(), null).setTextAttributes(JetHighlightingColors.FUNCTION_LITERAL_BRACKET); + holder.createInfoAnnotation(functionLiteral.getOpenBraceNode(), null).setTextAttributes(JetHighlightingColors.FUNCTION_LITERAL_BRACES); ASTNode closingBraceNode = functionLiteral.getClosingBraceNode(); if (closingBraceNode != null) { - holder.createInfoAnnotation(closingBraceNode, null).setTextAttributes(JetHighlightingColors.FUNCTION_LITERAL_BRACKET); + holder.createInfoAnnotation(closingBraceNode, null).setTextAttributes(JetHighlightingColors.FUNCTION_LITERAL_BRACES); } ASTNode arrowNode = functionLiteral.getArrowNode(); if (arrowNode != null) { - holder.createInfoAnnotation(arrowNode, null).setTextAttributes(JetHighlightingColors.FUNCTION_LITERAL_BRACKET); + holder.createInfoAnnotation(arrowNode, null).setTextAttributes(JetHighlightingColors.FUNCTION_LITERAL_BRACES); } }