diff --git a/idea/src/org/jetbrains/jet/plugin/highlighter/JetPsiChecker.java b/idea/src/org/jetbrains/jet/plugin/highlighter/JetPsiChecker.java
index 27fab5d3a42..24f14ae7c85 100644
--- a/idea/src/org/jetbrains/jet/plugin/highlighter/JetPsiChecker.java
+++ b/idea/src/org/jetbrains/jet/plugin/highlighter/JetPsiChecker.java
@@ -31,6 +31,7 @@ import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiReference;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import org.jetbrains.annotations.TestOnly;
import org.jetbrains.jet.lang.diagnostics.*;
import org.jetbrains.jet.lang.psi.JetFile;
import org.jetbrains.jet.lang.psi.JetReferenceExpression;
@@ -48,6 +49,7 @@ import java.util.Set;
*/
public class JetPsiChecker implements Annotator {
private static volatile boolean errorReportingEnabled = true;
+ private static boolean namesHighlightingTest;
public static void setErrorReportingEnabled(boolean value) {
errorReportingEnabled = value;
@@ -57,8 +59,13 @@ public class JetPsiChecker implements Annotator {
return errorReportingEnabled;
}
+ @TestOnly
+ public static void setNamesHighlightingTest(boolean namesHighlightingTest) {
+ JetPsiChecker.namesHighlightingTest = namesHighlightingTest;
+ }
+
static boolean isNamesHighlightingEnabled() {
- return !ApplicationManager.getApplication().isUnitTestMode();
+ return !ApplicationManager.getApplication().isUnitTestMode() || namesHighlightingTest;
}
static void highlightName(@NotNull AnnotationHolder holder,
diff --git a/idea/testData/highlighter/Functions.kt b/idea/testData/highlighter/Functions.kt
new file mode 100644
index 00000000000..7bc28c1f028
--- /dev/null
+++ b/idea/testData/highlighter/Functions.kt
@@ -0,0 +1,17 @@
+fun global() {
+ fun inner() {
+
+ }
+ inner()
+}
+
+fun Int.ext() {
+}
+
+open class Container {
+ open fun member() {
+ global()
+ 5.ext()
+ member()
+ }
+}
diff --git a/idea/testData/highlighter/TypesAndAnnotations.kt b/idea/testData/highlighter/TypesAndAnnotations.kt
new file mode 100644
index 00000000000..d40cd837716
--- /dev/null
+++ b/idea/testData/highlighter/TypesAndAnnotations.kt
@@ -0,0 +1,12 @@
+trait TheTrait {
+}
+
+class TheClass : TheTrait {
+}
+
+annotation class magnificent
+annotation class deprecated
+
+[deprecated]
+magnificent abstract class AbstractClass<T> {
+}
diff --git a/idea/testData/highlighter/Variables.kt b/idea/testData/highlighter/Variables.kt
new file mode 100644
index 00000000000..2c19abed3bb
--- /dev/null
+++ b/idea/testData/highlighter/Variables.kt
@@ -0,0 +1,25 @@
+var x = 5
+
+val Int.sq : Int
+get() {
+ return this * this
+}
+
+val y : Int = 1
+get() {
+ return 5.sq + $y + x
+}
+
+class Foo(val a : Int, b : String) {
+ {
+ b
+ }
+
+ var v : Int
+ get() {
+ return 1;
+ }
+ set(value) {
+ value
+ }
+}
\ No newline at end of file
diff --git a/idea/testData/highlighter/VariablesAsFunctions.kt b/idea/testData/highlighter/VariablesAsFunctions.kt
new file mode 100644
index 00000000000..e2905b06e3d
--- /dev/null
+++ b/idea/testData/highlighter/VariablesAsFunctions.kt
@@ -0,0 +1,13 @@
+var global : () -> Unit = {}
+
+val Int.ext : () -> Unit
+get() {
+ return {}
+}
+
+fun foo(a : () -> Unit) {
+ a()
+ global()
+ // TODO uncomment next line and replace "[" with "<" when KT-1728 is fixed
+ // 1.[info textAttributesKey="KOTLIN_EXTENSION_PROPERTY">ext()
+}
\ No newline at end of file
diff --git a/idea/tests/org/jetbrains/jet/plugin/JetNamesHighlightingTest.java b/idea/tests/org/jetbrains/jet/plugin/JetNamesHighlightingTest.java
new file mode 100644
index 00000000000..2895ba37716
--- /dev/null
+++ b/idea/tests/org/jetbrains/jet/plugin/JetNamesHighlightingTest.java
@@ -0,0 +1,52 @@
+/*
+ * 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;
+
+import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase;
+import org.jetbrains.jet.plugin.highlighter.JetPsiChecker;
+
+/**
+ * @author Evgeny Gerashchenko
+ * @since 4/4/12
+ */
+public class JetNamesHighlightingTest extends LightDaemonAnalyzerTestCase {
+ public void testTypesAndAnnotations() throws Exception {
+ doTest();
+ }
+
+ public void testVariables() throws Exception {
+ doTest();
+ }
+
+ public void testFunctions() throws Exception {
+ doTest();
+ }
+
+ public void testVariablesAsFunctions() throws Exception {
+ doTest();
+ }
+
+ private void doTest() throws Exception {
+ JetPsiChecker.setNamesHighlightingTest(true);
+ doTest(getTestName(false) + ".kt", false, true);
+ }
+
+ @Override
+ protected String getTestDataPath() {
+ return PluginTestCaseBase.getTestDataPathBase() + "/highlighter/";
+ }
+}