From 33a242584fc627a67f5e46f582efe234806eb1fe Mon Sep 17 00:00:00 2001 From: Evgeny Gerashchenko Date: Tue, 10 Apr 2012 18:29:05 +0400 Subject: [PATCH] Fixed highlighting of closure arrow in color settings, renamed corresponding property and expanded sample. --- .../src/org/jetbrains/jet/plugin/JetBundle.properties | 2 +- .../jet/plugin/highlighter/JetColorSettingsPage.java | 11 ++++++----- .../jet/plugin/highlighter/JetHighlightingColors.java | 4 ++-- .../highlighter/SoftKeywordsHighlightingVisitor.java | 6 +++--- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/idea/src/org/jetbrains/jet/plugin/JetBundle.properties b/idea/src/org/jetbrains/jet/plugin/JetBundle.properties index db441d6bf92..50fc52c1247 100644 --- a/idea/src/org/jetbrains/jet/plugin/JetBundle.properties +++ b/idea/src/org/jetbrains/jet/plugin/JetBundle.properties @@ -52,7 +52,7 @@ macro.fun.anonymousSuper=anonymousSuper() change.visibility.modifier=Change visibility modifier options.jet.attribute.descriptor.builtin.annotation=Built-in annotation -options.jet.attribute.descriptor.closure.braces=Function literal braces +options.jet.attribute.descriptor.closure.braces=Function literal braces and arrow options.jet.attribute.descriptor.safe.access=Safe access dot options.jet.attribute.descriptor.arrow=Arrow options.jet.attribute.descriptor.kdoc.comment=KDoc comment diff --git a/idea/src/org/jetbrains/jet/plugin/highlighter/JetColorSettingsPage.java b/idea/src/org/jetbrains/jet/plugin/highlighter/JetColorSettingsPage.java index 8e80f0f4016..e20ca17824f 100644 --- a/idea/src/org/jetbrains/jet/plugin/highlighter/JetColorSettingsPage.java +++ b/idea/src/org/jetbrains/jet/plugin/highlighter/JetColorSettingsPage.java @@ -61,12 +61,13 @@ public class JetColorSettingsPage implements ColorSettingsPage { " println(\"length is ${nullable?.length} \\e\")\n" + " val ints = java.util.ArrayList(2)\n" + " ints[0] = 102 + f()\n" + + " val myFun = { -> \"\" }\n" + " var ref = ints.size()\n" + - " if (!ints.empty) {\n" + - " ints.forEach @lit {\n" + + " if (!ints.empty) {\n" + + " ints.forEach @lit {\n" + " if (it == null) return @lit\n" + " println(it + ref)\n" + - " }\n" + + " }\n" + " }\n" + " }\n" + "}\n" + @@ -111,13 +112,13 @@ public class JetColorSettingsPage implements ColorSettingsPage { 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(JetBundle.message("options.jet.attribute.descriptor.closure.braces"), JetHighlightingColors.FUNCTION_LITERAL_BRACES_AND_ARROW), + new AttributesDescriptor(JetBundle.message("options.jet.attribute.descriptor.arrow"), JetHighlightingColors.ARROW), new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.brackets"), JetHighlightingColors.BRACKETS), - new AttributesDescriptor(JetBundle.message("options.jet.attribute.descriptor.closure.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(JetBundle.message("options.jet.attribute.descriptor.safe.access"), JetHighlightingColors.SAFE_ACCESS), - new AttributesDescriptor(JetBundle.message("options.jet.attribute.descriptor.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), diff --git a/idea/src/org/jetbrains/jet/plugin/highlighter/JetHighlightingColors.java b/idea/src/org/jetbrains/jet/plugin/highlighter/JetHighlightingColors.java index b3ca1bda1c9..2d6b968c18c 100644 --- a/idea/src/org/jetbrains/jet/plugin/highlighter/JetHighlightingColors.java +++ b/idea/src/org/jetbrains/jet/plugin/highlighter/JetHighlightingColors.java @@ -76,8 +76,8 @@ public class JetHighlightingColors { SyntaxHighlighterColors.BRACKETS.getDefaultAttributes() ); - public static final TextAttributesKey FUNCTION_LITERAL_BRACES = TextAttributesKey.createTextAttributesKey( - "KOTLIN_FUNCTION_LITERAL_BRACES", + public static final TextAttributesKey FUNCTION_LITERAL_BRACES_AND_ARROW = TextAttributesKey.createTextAttributesKey( + "KOTLIN_FUNCTION_LITERAL_BRACES_AND_ARROW", new TextAttributes(null, null, null, null, Font.BOLD) ); diff --git a/idea/src/org/jetbrains/jet/plugin/highlighter/SoftKeywordsHighlightingVisitor.java b/idea/src/org/jetbrains/jet/plugin/highlighter/SoftKeywordsHighlightingVisitor.java index 337ceb1c863..e02eee1e1c4 100644 --- a/idea/src/org/jetbrains/jet/plugin/highlighter/SoftKeywordsHighlightingVisitor.java +++ b/idea/src/org/jetbrains/jet/plugin/highlighter/SoftKeywordsHighlightingVisitor.java @@ -52,14 +52,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_BRACES); + holder.createInfoAnnotation(functionLiteral.getOpenBraceNode(), null).setTextAttributes(JetHighlightingColors.FUNCTION_LITERAL_BRACES_AND_ARROW); ASTNode closingBraceNode = functionLiteral.getClosingBraceNode(); if (closingBraceNode != null) { - holder.createInfoAnnotation(closingBraceNode, null).setTextAttributes(JetHighlightingColors.FUNCTION_LITERAL_BRACES); + holder.createInfoAnnotation(closingBraceNode, null).setTextAttributes(JetHighlightingColors.FUNCTION_LITERAL_BRACES_AND_ARROW); } ASTNode arrowNode = functionLiteral.getArrowNode(); if (arrowNode != null) { - holder.createInfoAnnotation(arrowNode, null).setTextAttributes(JetHighlightingColors.FUNCTION_LITERAL_BRACES); + holder.createInfoAnnotation(arrowNode, null).setTextAttributes(JetHighlightingColors.FUNCTION_LITERAL_BRACES_AND_ARROW); } } }