Snapshot af729d01433bb5bbd6ca93c0fdf9778b36d624ce from master branch of git://git.jetbrains.org/idea/community.git
Change-Id: I214dd066d0d27444a26166c0eae1a5aaf3705d49
diff --git a/java/java-tests/java-tests.iml b/java/java-tests/java-tests.iml
index eb7ea31..cc0afca 100644
--- a/java/java-tests/java-tests.iml
+++ b/java/java-tests/java-tests.iml
@@ -11,7 +11,7 @@
<orderEntry type="module" module-name="java-impl" />
<orderEntry type="module" module-name="idea-ui" />
<orderEntry type="module" module-name="community-resources" scope="RUNTIME" />
- <orderEntry type="module" module-name="execution-impl" scope="RUNTIME" />
+ <orderEntry type="module" module-name="execution-impl" />
<orderEntry type="module" module-name="platform-api" />
<orderEntry type="library" name="Velocity" level="project" />
<orderEntry type="module" module-name="java-i18n" />
@@ -27,10 +27,9 @@
<orderEntry type="module" module-name="eclipse" scope="TEST" />
<orderEntry type="module" module-name="execution-openapi" />
<orderEntry type="module" module-name="platform-tests" scope="TEST" />
- <orderEntry type="module" module-name="IntentionPowerPackPlugin" scope="TEST" />
- <orderEntry type="module" module-name="InspectionGadgetsPlugin" scope="TEST" />
<orderEntry type="module" module-name="java-indexing-api" scope="TEST" />
<orderEntry type="module" module-name="external-system-impl" scope="RUNTIME" />
+ <orderEntry type="module" module-name="junit_rt" scope="TEST" />
</component>
</module>
diff --git a/java/java-tests/testData/codeInsight/completion/methodChains/testBigrams2/TestCompletion.java b/java/java-tests/testData/codeInsight/completion/methodChains/testBigrams2/TestCompletion.java
new file mode 100644
index 0000000..1c73b7d
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/methodChains/testBigrams2/TestCompletion.java
@@ -0,0 +1,31 @@
+import java.jang.String;
+
+/**
+ * @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
+ */
+
+
+
+class PsiElement {
+ PsiFile getContainingFile() {
+ return null;
+ }
+}
+
+class PsiFile {
+ VirtualFile getVirtualFile() {
+ return null;
+ }
+}
+
+class VirtualFile {}
+
+
+public class TestCompletion {
+
+ PsiElement e;
+
+ public void method() {
+ VirtualFile vf = <caret>
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/completion/methodChains/testBigrams2/TestIndex.java b/java/java-tests/testData/codeInsight/completion/methodChains/testBigrams2/TestIndex.java
new file mode 100644
index 0000000..60472fb
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/methodChains/testBigrams2/TestIndex.java
@@ -0,0 +1,30 @@
+/**
+ * @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
+ */
+public class TestIndex {
+
+ public void statMethod(PsiElement e) {
+ e.getContainingFile().getVirtualFile();
+ e.getContainingFile().getVirtualFile();
+ e.getContainingFile().getVirtualFile();
+ e.getContainingFile().getVirtualFile();
+ e.getContainingFile().getVirtualFile();
+ e.getContainingFile().getVirtualFile();
+ e.getContainingFile().getVirtualFile();
+ e.getContainingFile().getVirtualFile();
+ }
+}
+
+class PsiElement {
+ PsiFile getContainingFile() {
+ return null;
+ }
+}
+
+class PsiFile {
+ VirtualFile getVirtualFile() {
+ return null;
+ }
+}
+
+class VirtualFile {}
diff --git a/java/java-tests/testData/codeInsight/completion/methodChains/testBigrams3/TestCompletion.java b/java/java-tests/testData/codeInsight/completion/methodChains/testBigrams3/TestCompletion.java
new file mode 100644
index 0000000..e698dd0
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/methodChains/testBigrams3/TestCompletion.java
@@ -0,0 +1,36 @@
+import java.jang.String;
+
+/**
+ * @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
+ */
+
+
+
+interface PsiFile extends PsiElement {
+}
+
+interface PsiElement {
+ PsiElement findElementAt(int position);
+}
+
+class PsiManager {
+ static PsiManager getInstance(Project p) {
+ return null;
+ }
+
+ PsiFile findFile(VirtualFile vf) {
+ return null;
+ }
+}
+
+interface VirtualFile {}
+
+interface Project {}
+
+
+public class TestCompletion {
+
+ public void method() {
+ PsiElement e = <caret>
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/completion/methodChains/testBigrams3/TestIndex.java b/java/java-tests/testData/codeInsight/completion/methodChains/testBigrams3/TestIndex.java
new file mode 100644
index 0000000..08dbf05
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/methodChains/testBigrams3/TestIndex.java
@@ -0,0 +1,38 @@
+/**
+ * @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
+ */
+public class TestIndex {
+ PsiElement e;
+
+ public void statMethod() {
+ e = PsiManager.getInstance(null).findFile(null).findElementAt(0);
+ e = PsiManager.getInstance(null).findFile(null).findElementAt(0);
+ e = PsiManager.getInstance(null).findFile(null).findElementAt(0);
+ e = PsiManager.getInstance(null).findFile(null).findElementAt(0);
+ e = PsiManager.getInstance(null).findFile(null).findElementAt(0);
+ e = PsiManager.getInstance(null).findFile(null).findElementAt(0);
+ e = PsiManager.getInstance(null).findFile(null).findElementAt(0);
+ e = PsiManager.getInstance(null).findFile(null).findElementAt(0);
+ }
+}
+
+interface PsiFile extends PsiElement {
+}
+
+interface PsiElement {
+ PsiElement findElementAt(int position);
+}
+
+class PsiManager {
+ static PsiManager getInstance(Project p) {
+ return null;
+ }
+
+ PsiFile findFile(VirtualFile vf) {
+ return null;
+ }
+}
+
+interface VirtualFile {}
+
+interface Project {}
diff --git a/java/java-tests/testData/codeInsight/completion/methodChains/testCyclingInstancesObtaining/TestCompletion.java b/java/java-tests/testData/codeInsight/completion/methodChains/testCyclingInstancesObtaining/TestCompletion.java
new file mode 100644
index 0000000..437e4b3
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/methodChains/testCyclingInstancesObtaining/TestCompletion.java
@@ -0,0 +1,43 @@
+import java.jang.String;
+
+/**
+ * @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
+ */
+
+class Project {
+ Object o;
+
+ void setObject(Object o) {
+ this.o = o;
+ }
+
+ <T> Object getObject(Class<T> tClass) {
+ return o;
+ }
+}
+
+class Manager {
+
+ Project p1;
+
+ Manager(Project p1) {
+ this.p1 = p1;
+ }
+
+ static Manager getManager(Project project) {
+ return (Manager) project.getObject(Manager.class);
+ }
+
+ Project getProject() {
+ return p1;
+ }
+
+}
+
+public class TestCompletion {
+
+ public void method() {
+ Manager m = <caret>;
+ Project p = m.getProject();
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/completion/methodChains/testCyclingInstancesObtaining/TestIndex.java b/java/java-tests/testData/codeInsight/completion/methodChains/testCyclingInstancesObtaining/TestIndex.java
new file mode 100644
index 0000000..309096a
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/methodChains/testCyclingInstancesObtaining/TestIndex.java
@@ -0,0 +1,61 @@
+public class TestIndex {
+
+ Manager manager = new Manager(new Project());
+
+ public void statMethod() {
+ manager.getProject();
+ manager.getProject();
+ manager.getProject();
+ manager.getProject();
+ manager.getProject();
+ manager.getProject();
+ manager.getProject();
+ }
+}
+
+class TestIndex2 {
+
+ Project p2 = new Project();
+
+ public void statMethod() {
+ Manager.getManager(p2);
+ Manager.getManager(p2);
+ Manager.getManager(p2);
+ Manager.getManager(p2);
+ Manager.getManager(p2);
+ Manager.getManager(p2);
+ Manager.getManager(p2);
+ Manager.getManager(p2);
+ }
+
+}
+
+class Project {
+ Object o;
+
+ void setObject(Object o) {
+ this.o = o;
+ }
+
+ <T> Object getObject(Class<T> tClass) {
+ return o;
+ }
+}
+
+class Manager {
+
+ Project p1;
+
+ Manager(Project p1) {
+ this.p1 = p1;
+ }
+
+ static Manager getManager(Project project) {
+ return (Manager) project.getObject(Manager.class);
+ }
+
+ Project getProject() {
+ return p1;
+ }
+
+}
diff --git a/java/java-tests/testData/codeInsight/completion/methodChains/testCyclingInstancesObtaining2/TestCompletion.java b/java/java-tests/testData/codeInsight/completion/methodChains/testCyclingInstancesObtaining2/TestCompletion.java
new file mode 100644
index 0000000..bca47d9
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/methodChains/testCyclingInstancesObtaining2/TestCompletion.java
@@ -0,0 +1,42 @@
+import java.jang.String;
+
+/**
+ * @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
+ */
+
+class Project {
+ Object o;
+
+ void setObject(Object o) {
+ this.o = o;
+ }
+
+ <T> Object getObject(Class<T> tClass) {
+ return o;
+ }
+}
+
+class Manager {
+
+ Project p1;
+
+ Manager(Project p1) {
+ this.p1 = p1;
+ }
+
+ static Manager getManager(Project project) {
+ return (Manager) project.getObject(Manager.class);
+ }
+
+ Project getProject() {
+ return p1;
+ }
+
+}
+
+public class TestCompletion {
+
+ public void method() {
+ Manager m = <caret>;
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/completion/methodChains/testCyclingInstancesObtaining2/TestIndex.java b/java/java-tests/testData/codeInsight/completion/methodChains/testCyclingInstancesObtaining2/TestIndex.java
new file mode 100644
index 0000000..309096a
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/methodChains/testCyclingInstancesObtaining2/TestIndex.java
@@ -0,0 +1,61 @@
+public class TestIndex {
+
+ Manager manager = new Manager(new Project());
+
+ public void statMethod() {
+ manager.getProject();
+ manager.getProject();
+ manager.getProject();
+ manager.getProject();
+ manager.getProject();
+ manager.getProject();
+ manager.getProject();
+ }
+}
+
+class TestIndex2 {
+
+ Project p2 = new Project();
+
+ public void statMethod() {
+ Manager.getManager(p2);
+ Manager.getManager(p2);
+ Manager.getManager(p2);
+ Manager.getManager(p2);
+ Manager.getManager(p2);
+ Manager.getManager(p2);
+ Manager.getManager(p2);
+ Manager.getManager(p2);
+ }
+
+}
+
+class Project {
+ Object o;
+
+ void setObject(Object o) {
+ this.o = o;
+ }
+
+ <T> Object getObject(Class<T> tClass) {
+ return o;
+ }
+}
+
+class Manager {
+
+ Project p1;
+
+ Manager(Project p1) {
+ this.p1 = p1;
+ }
+
+ static Manager getManager(Project project) {
+ return (Manager) project.getObject(Manager.class);
+ }
+
+ Project getProject() {
+ return p1;
+ }
+
+}
diff --git a/java/java-tests/testData/codeInsight/completion/methodChains/testCyclingMethodsNotShowed/TestCompletion.java b/java/java-tests/testData/codeInsight/completion/methodChains/testCyclingMethodsNotShowed/TestCompletion.java
new file mode 100644
index 0000000..d7d96f4
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/methodChains/testCyclingMethodsNotShowed/TestCompletion.java
@@ -0,0 +1,18 @@
+/**
+ * @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
+ */
+
+class PsiElement {
+ public PsiElement getPrevSibling() {
+ return null;
+ }
+ public PsiElement getParent() {
+ return null;
+ }
+}
+
+public class TestCompletion {
+ public void method(PsiElement e) {
+ PsiElement anotherElement = <caret>
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/completion/methodChains/testCyclingMethodsNotShowed/TestIndex.java b/java/java-tests/testData/codeInsight/completion/methodChains/testCyclingMethodsNotShowed/TestIndex.java
new file mode 100644
index 0000000..a5dcbbc
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/methodChains/testCyclingMethodsNotShowed/TestIndex.java
@@ -0,0 +1,25 @@
+/**
+ * @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
+ */
+public class TestIndex {
+
+ public void statMethod(PsiElement e) {
+ e.getParent();
+ e.getParent();
+ e.getParent();
+ e.getParent();
+ e.getPrevSibling();
+ e.getPrevSibling();
+ e.getPrevSibling();
+ e.getPrevSibling();
+ }
+}
+
+class PsiElement {
+ public PsiElement getPrevSibling() {
+ return null;
+ }
+ public PsiElement getParent() {
+ return null;
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/completion/methodChains/testGetterInContext/TestCompletion.java b/java/java-tests/testData/codeInsight/completion/methodChains/testGetterInContext/TestCompletion.java
new file mode 100644
index 0000000..49d2965
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/methodChains/testGetterInContext/TestCompletion.java
@@ -0,0 +1,22 @@
+import java.jang.String;
+
+/**
+ * @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
+ */
+
+interface Project {}
+
+interface PsiElement {
+ Project getProject();
+}
+
+public class TestCompletion {
+
+ private PsiElement getMyElement() {
+ return null;
+ }
+
+ public void method() {
+ Project p = <caret>
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/completion/methodChains/testGetterInContext/TestIndex.java b/java/java-tests/testData/codeInsight/completion/methodChains/testGetterInContext/TestIndex.java
new file mode 100644
index 0000000..960144d
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/methodChains/testGetterInContext/TestIndex.java
@@ -0,0 +1,22 @@
+/**
+ * @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
+ */
+public class TestIndex {
+
+ public void statMethod(PsiElement e) {
+ e.getProject();
+ e.getProject();
+ e.getProject();
+ e.getProject();
+ e.getProject();
+ e.getProject();
+ e.getProject();
+ e.getProject();
+ }
+}
+
+interface Project {}
+
+interface PsiElement {
+ Project getProject();
+}
diff --git a/java/java-tests/testData/codeInsight/completion/methodChains/testInnerClasses/TestCompletion.java b/java/java-tests/testData/codeInsight/completion/methodChains/testInnerClasses/TestCompletion.java
new file mode 100644
index 0000000..60f5870
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/methodChains/testInnerClasses/TestCompletion.java
@@ -0,0 +1,23 @@
+import java.jang.String;
+
+/**
+ * @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
+ */
+
+
+class JarFile {
+ class JarEntry {
+ }
+
+ JarEntry getEntry() {
+ return null;
+ }
+}
+
+
+public class TestCompletion {
+
+ public void method(JarFile j) {
+ JarFile.JarEntry e = <caret>
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/completion/methodChains/testInnerClasses/TestIndex.java b/java/java-tests/testData/codeInsight/completion/methodChains/testInnerClasses/TestIndex.java
new file mode 100644
index 0000000..02a384f
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/methodChains/testInnerClasses/TestIndex.java
@@ -0,0 +1,26 @@
+/**
+ * @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
+ */
+public class TestIndex {
+
+ public void statMethod(JarFile f) {
+ f.getEntry();
+ f.getEntry();
+ f.getEntry();
+ f.getEntry();
+ f.getEntry();
+ f.getEntry();
+ f.getEntry();
+ f.getEntry();
+ }
+}
+
+class JarFile {
+ class JarEntry {
+ }
+
+ JarEntry getEntry() {
+ return null;
+ }
+}
+
diff --git a/java/java-tests/testData/codeInsight/completion/methodChains/testMethodParameterCompletion/TestCompletion.java b/java/java-tests/testData/codeInsight/completion/methodChains/testMethodParameterCompletion/TestCompletion.java
new file mode 100644
index 0000000..3293660
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/methodChains/testMethodParameterCompletion/TestCompletion.java
@@ -0,0 +1,19 @@
+import java.jang.String;
+
+
+interface PsiElement {
+ PsiClass getContainingClass();
+}
+
+interface PsiClass extends PsiElement {}
+
+public class TestCompletion {
+
+ public void method(PsiElement e) {
+ int j = 1 + method123(<caret>);
+ }
+
+ public int method123(PsiClass c) {
+ return 0;
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/completion/methodChains/testMethodParameterCompletion/TestIndex.java b/java/java-tests/testData/codeInsight/completion/methodChains/testMethodParameterCompletion/TestIndex.java
new file mode 100644
index 0000000..dc06be4
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/methodChains/testMethodParameterCompletion/TestIndex.java
@@ -0,0 +1,22 @@
+/**
+ * @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
+ */
+public class TestIndex {
+
+ public void statMethod(PsiElement e) {
+ e.getContainingClass();
+ e.getContainingClass();
+ e.getContainingClass();
+ e.getContainingClass();
+ e.getContainingClass();
+ e.getContainingClass();
+ e.getContainingClass();
+ e.getContainingClass();
+ }
+}
+
+interface PsiElement {
+ PsiClass getContainingClass();
+}
+
+interface PsiClass extends PsiElement {}
diff --git a/java/java-tests/testData/codeInsight/completion/methodChains/testMethodReturnsSubclassOfTargetClassNotShowed2/TestCompletion.java b/java/java-tests/testData/codeInsight/completion/methodChains/testMethodReturnsSubclassOfTargetClassNotShowed2/TestCompletion.java
new file mode 100644
index 0000000..2b9ce15
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/methodChains/testMethodReturnsSubclassOfTargetClassNotShowed2/TestCompletion.java
@@ -0,0 +1,25 @@
+/**
+ * @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
+ */
+
+
+class PsiMethod implements PsiElement {
+}
+
+interface PsiElement {
+}
+
+class PsiClass {
+ public PsiMethod findMethodByName(String methodName) {
+ return null;
+ }
+}
+
+public class TestCompletion {
+
+ PsiClass c;
+
+ public void method() {
+ PsiElement element = <caret>
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/completion/methodChains/testMethodReturnsSubclassOfTargetClassNotShowed2/TestIndex.java b/java/java-tests/testData/codeInsight/completion/methodChains/testMethodReturnsSubclassOfTargetClassNotShowed2/TestIndex.java
new file mode 100644
index 0000000..95e4761
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/methodChains/testMethodReturnsSubclassOfTargetClassNotShowed2/TestIndex.java
@@ -0,0 +1,24 @@
+/**
+ * @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
+ */
+public class TestIndex {
+
+ public void statMethod(PsiClass c) {
+ c.findMethodByName("asd");
+ c.findMethodByName("asd");
+ c.findMethodByName("asd");
+ c.findMethodByName("asd");
+ }
+}
+
+class PsiMethod implements PsiElement {
+}
+
+interface PsiElement {
+}
+
+class PsiClass {
+ public PsiMethod findMethodByName(String methodName) {
+ return null;
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/completion/methodChains/testMethodsWithSameName/TestCompletion.java b/java/java-tests/testData/codeInsight/completion/methodChains/testMethodsWithSameName/TestCompletion.java
new file mode 100644
index 0000000..a2cb5fb
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/methodChains/testMethodsWithSameName/TestCompletion.java
@@ -0,0 +1,27 @@
+import java.jang.String;
+
+/**
+ * @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
+ */
+
+
+class ElementFactory {
+ PsiClassType createType(PsiClass c, Object obj) {
+ return null;
+ }
+
+ PsiClassType createType(PsiClass c) {
+ return null;
+ }
+}
+
+class PsiClassType {}
+
+class PsiClass {}
+
+public class TestCompletion {
+
+ public void method(ElementFactory f) {
+ PsiClassType t = <caret>
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/completion/methodChains/testMethodsWithSameName/TestIndex.java b/java/java-tests/testData/codeInsight/completion/methodChains/testMethodsWithSameName/TestIndex.java
new file mode 100644
index 0000000..b8f5084
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/methodChains/testMethodsWithSameName/TestIndex.java
@@ -0,0 +1,32 @@
+import java.lang.Object;
+
+/**
+ * @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
+ */
+public class TestIndex {
+
+ public void statMethod(ElementFactory ef) {
+ ef.createType(null);
+ ef.createType(null);
+ ef.createType(null);
+ ef.createType(null);
+ ef.createType(null, null);
+ ef.createType(null, null);
+ ef.createType(null, null);
+ ef.createType(null, null);
+ }
+}
+
+class ElementFactory {
+ PsiClassType createType(PsiClass c, Object obj) {
+ return null;
+ }
+
+ PsiClassType createType(PsiClass c) {
+ return null;
+ }
+}
+
+class PsiClassType {}
+
+class PsiClass {}
diff --git a/java/java-tests/testData/codeInsight/completion/methodChains/testNoWayToObtainVariableExplicitly/TestCompletion.java b/java/java-tests/testData/codeInsight/completion/methodChains/testNoWayToObtainVariableExplicitly/TestCompletion.java
new file mode 100644
index 0000000..07e4ba6
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/methodChains/testNoWayToObtainVariableExplicitly/TestCompletion.java
@@ -0,0 +1,19 @@
+import java.jang.String;
+
+/**
+ * @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
+ */
+
+class PsiManager {
+ Project getProject() {
+ return null;
+ }
+}
+class Project {}
+
+public class TestCompletion {
+
+ public void method() {
+ Project p = <caret>
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/completion/methodChains/testNoWayToObtainVariableExplicitly/TestIndex.java b/java/java-tests/testData/codeInsight/completion/methodChains/testNoWayToObtainVariableExplicitly/TestIndex.java
new file mode 100644
index 0000000..433180f
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/methodChains/testNoWayToObtainVariableExplicitly/TestIndex.java
@@ -0,0 +1,51 @@
+
+//
+// if component obtained in implicit way
+//
+
+public class TestIndex {
+
+
+ //
+ // simple test for spring like configuration
+ //
+
+ private PsiManager a;
+
+ public void setA(PsiManager a) {
+ this.a = a;
+ }
+
+ void m() {
+ a.getProject();
+ a.getProject();
+ }
+
+ void b() {
+ a.getProject();
+ }
+
+ void c() {
+ a.getProject();
+ }
+
+ void c22() {
+ a.getProject();
+ }
+
+ void c11() {
+ a.getProject();
+ }
+
+ void c1() {
+ a.getProject();
+ }
+}
+
+class PsiManager {
+ Project getProject() {
+ return null;
+ }
+}
+class Project {}
+
diff --git a/java/java-tests/testData/codeInsight/completion/methodChains/testOneChainContainsOther/TestCompletion.java b/java/java-tests/testData/codeInsight/completion/methodChains/testOneChainContainsOther/TestCompletion.java
new file mode 100644
index 0000000..20cc498
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/methodChains/testOneChainContainsOther/TestCompletion.java
@@ -0,0 +1,24 @@
+/**
+ * @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
+ */
+
+class PsiManager {
+ Project getProject() {
+ return null;
+ }
+}
+
+interface Project {
+ VirtualFile getBaseDir();
+}
+
+class VirtualFile {
+}
+
+public class TestCompletion {
+ PsiManager m;
+
+ public void method(Project p) {
+ VirtualFile projectBaseDir = <caret>
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/completion/methodChains/testOneChainContainsOther/TestIndex.java b/java/java-tests/testData/codeInsight/completion/methodChains/testOneChainContainsOther/TestIndex.java
new file mode 100644
index 0000000..258e098
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/methodChains/testOneChainContainsOther/TestIndex.java
@@ -0,0 +1,29 @@
+/**
+ * @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
+ */
+public class TestIndex {
+
+ public void statMethod(PsiManager m) {
+ m.getProject().getBaseDir();
+ m.getProject().getBaseDir();
+ m.getProject().getBaseDir();
+ m.getProject().getBaseDir();
+ m.getProject().getBaseDir();
+ m.getProject().getBaseDir();
+ m.getProject().getBaseDir();
+ m.getProject().getBaseDir();
+ }
+}
+
+class PsiManager {
+ Project getProject() {
+ return null;
+ }
+}
+
+interface Project {
+ VirtualFile getBaseDir();
+}
+
+class VirtualFile {
+}
diff --git a/java/java-tests/testData/codeInsight/completion/methodChains/testOneRelevantMethod/TestCompletion.java b/java/java-tests/testData/codeInsight/completion/methodChains/testOneRelevantMethod/TestCompletion.java
new file mode 100644
index 0000000..9f0019b
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/methodChains/testOneRelevantMethod/TestCompletion.java
@@ -0,0 +1,18 @@
+/**
+ * @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
+ */
+
+class Element {
+ public Project getProject() {
+ return null;
+ }
+}
+
+class Project {
+}
+
+public class TestCompletion {
+ public void method(Element e) {
+ Project project = <caret>
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/completion/methodChains/testOneRelevantMethod/TestIndex.java b/java/java-tests/testData/codeInsight/completion/methodChains/testOneRelevantMethod/TestIndex.java
new file mode 100644
index 0000000..8e3b581
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/methodChains/testOneRelevantMethod/TestIndex.java
@@ -0,0 +1,25 @@
+/**
+ * @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
+ */
+public class TestIndex {
+
+ public void statMethod(Element e) {
+ e.getProject();
+ e.getProject();
+ e.getProject();
+ e.getProject();
+ e.getProject();
+ e.getProject();
+ e.getProject();
+ e.getProject();
+ }
+}
+
+class Element {
+ public Project getProject() {
+ return null;
+ }
+}
+
+class Project {
+}
diff --git a/java/java-tests/testData/codeInsight/completion/methodChains/testReduceChain4/TestCompletion.java b/java/java-tests/testData/codeInsight/completion/methodChains/testReduceChain4/TestCompletion.java
new file mode 100644
index 0000000..7b1f980
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/methodChains/testReduceChain4/TestCompletion.java
@@ -0,0 +1,53 @@
+import java.jang.String;
+
+class B {
+ C getC() {
+ return null;
+ }
+
+ static B b = new B();
+
+ static B getB1() {
+ return b;
+ }
+ static B getB2() {
+ return b;
+ }
+ static B getB3() {
+ return b;
+ }
+ static B getB4() {
+ return b;
+ }
+ static B getB5() {
+ return b;
+ }
+ static B getB6() {
+ return b;
+ }
+ static B getB7() {
+ return b;
+ }
+ static B getB8() {
+ return b;
+ }
+ static B getB9() {
+ return b;
+ }
+ static B getB10() {
+ return b;
+ }
+ static B getB11() {
+ return b;
+ }
+}
+
+class C {}
+
+public class TestCompletion {
+
+ public void method() {
+ C c = <caret>
+ }
+
+}
diff --git a/java/java-tests/testData/codeInsight/completion/methodChains/testReduceChain4/TestIndex.java b/java/java-tests/testData/codeInsight/completion/methodChains/testReduceChain4/TestIndex.java
new file mode 100644
index 0000000..cf75c42
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/methodChains/testReduceChain4/TestIndex.java
@@ -0,0 +1,104 @@
+/**
+ * @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
+ */
+public class TestIndex {
+
+ public void statMethod1() {
+ B.getB1().getC();
+ B.getB1().getC();
+ B.getB1().getC();
+ }
+ public void statMethod2() {
+ B.getB2().getC();
+ B.getB2().getC();
+ B.getB2().getC();
+ }
+ public void statMethod3() {
+ B.getB3().getC();
+ B.getB3().getC();
+ B.getB3().getC();
+ }
+ public void statMethod4() {
+ B.getB4().getC();
+ B.getB4().getC();
+ B.getB4().getC();
+ }
+ public void statMethod5() {
+ B.getB5().getC();
+ B.getB5().getC();
+ B.getB5().getC();
+ }
+ public void statMethod6() {
+ B.getB6().getC();
+ B.getB6().getC();
+ B.getB6().getC();
+ }
+ public void statMethod7() {
+ B.getB7().getC();
+ B.getB7().getC();
+ B.getB7().getC();
+ }
+ public void statMethod8() {
+ B.getB8().getC();
+ B.getB8().getC();
+ B.getB8().getC();
+ }
+ public void statMethod9() {
+ B.getB9().getC();
+ B.getB9().getC();
+ B.getB9().getC();
+ }
+ public void statMethod10() {
+ B.getB10().getC();
+ B.getB10().getC();
+ B.getB10().getC();
+ }
+ public void statMethod11() {
+ B.getB11().getC();
+ B.getB11().getC();
+ B.getB11().getC();
+ }
+}
+class B {
+ C getC() {
+ return null;
+ }
+
+ static B b = new B();
+
+ static B getB1() {
+ return b;
+ }
+ static B getB2() {
+ return b;
+ }
+ static B getB3() {
+ return b;
+ }
+ static B getB4() {
+ return b;
+ }
+ static B getB5() {
+ return b;
+ }
+ static B getB6() {
+ return b;
+ }
+ static B getB7() {
+ return b;
+ }
+ static B getB8() {
+ return b;
+ }
+ static B getB9() {
+ return b;
+ }
+ static B getB10() {
+ return b;
+ }
+ static B getB11() {
+ return b;
+ }
+}
+
+class C {}
diff --git a/java/java-tests/testData/codeInsight/completion/methodChains/testRenderingIntroduceVariable/AfterCompletion.java b/java/java-tests/testData/codeInsight/completion/methodChains/testRenderingIntroduceVariable/AfterCompletion.java
new file mode 100644
index 0000000..908d39a
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/methodChains/testRenderingIntroduceVariable/AfterCompletion.java
@@ -0,0 +1,14 @@
+import java.jang.String;
+
+interface PsiManager {
+ Project getProject();
+}
+
+interface Project {}
+
+public class TestCompletion {
+ void m() {
+ PsiManager psiManager = null;
+ Project p = psiManager.getProject()
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/completion/methodChains/testRenderingIntroduceVariable/BeforeCompletion.java b/java/java-tests/testData/codeInsight/completion/methodChains/testRenderingIntroduceVariable/BeforeCompletion.java
new file mode 100644
index 0000000..ba8ae42
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/methodChains/testRenderingIntroduceVariable/BeforeCompletion.java
@@ -0,0 +1,13 @@
+import java.jang.String;
+
+interface PsiManager {
+ Project getProject();
+}
+
+interface Project {}
+
+public class TestCompletion {
+ void m() {
+ Project p = <caret>
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/completion/methodChains/testRenderingIntroduceVariable/TestIndex.java b/java/java-tests/testData/codeInsight/completion/methodChains/testRenderingIntroduceVariable/TestIndex.java
new file mode 100644
index 0000000..c416985
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/methodChains/testRenderingIntroduceVariable/TestIndex.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2000-2013 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.
+ */
+
+/**
+ * @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
+ */
+import java.lang.String;
+
+public class TestIndex {
+
+ PsiManager m;
+
+ void m() {
+ m.getProject();
+ m.getProject();
+ m.getProject();
+ m.getProject();
+ m.getProject();
+ m.getProject();
+ }
+}
+
+
+interface PsiManager {
+ Project getProject();
+}
+
+interface Project {}
diff --git a/java/java-tests/testData/codeInsight/completion/methodChains/testRenderingStaticMethods/AfterCompletion.java b/java/java-tests/testData/codeInsight/completion/methodChains/testRenderingStaticMethods/AfterCompletion.java
new file mode 100644
index 0000000..9c5d812
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/methodChains/testRenderingStaticMethods/AfterCompletion.java
@@ -0,0 +1,26 @@
+import java.jang.String;
+
+class JavaPsiFacade {
+ static JavaPsiFacade getInstance() {
+ return null;
+ }
+
+ PsiClass findClass() {
+ return null;
+ }
+}
+
+interface PsiElement {
+ PsiClass getContainingClass();
+}
+
+interface PsiClass extends PsiElement {
+}
+
+public class TestCompletion {
+
+ public void method(PsiElement e) {
+ PsiClass c = JavaPsiFacade.getInstance().findClass()
+ }
+
+}
diff --git a/java/java-tests/testData/codeInsight/completion/methodChains/testRenderingStaticMethods/BeforeCompletion.java b/java/java-tests/testData/codeInsight/completion/methodChains/testRenderingStaticMethods/BeforeCompletion.java
new file mode 100644
index 0000000..0370d36
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/methodChains/testRenderingStaticMethods/BeforeCompletion.java
@@ -0,0 +1,26 @@
+import java.jang.String;
+
+class JavaPsiFacade {
+ static JavaPsiFacade getInstance() {
+ return null;
+ }
+
+ PsiClass findClass() {
+ return null;
+ }
+}
+
+interface PsiElement {
+ PsiClass getContainingClass();
+}
+
+interface PsiClass extends PsiElement {
+}
+
+public class TestCompletion {
+
+ public void method(PsiElement e) {
+ PsiClass c = <caret>
+ }
+
+}
diff --git a/java/java-tests/testData/codeInsight/completion/methodChains/testRenderingStaticMethods/TestIndex.java b/java/java-tests/testData/codeInsight/completion/methodChains/testRenderingStaticMethods/TestIndex.java
new file mode 100644
index 0000000..755dda5
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/methodChains/testRenderingStaticMethods/TestIndex.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2000-2013 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.
+ */
+
+/**
+ * @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
+ */
+public class TestIndex {
+
+ void m() {
+ JavaPsiFacade.getInstance().findClass();
+ JavaPsiFacade.getInstance().findClass();
+ JavaPsiFacade.getInstance().findClass();
+ JavaPsiFacade.getInstance().findClass();
+ JavaPsiFacade.getInstance().findClass();
+ JavaPsiFacade.getInstance().findClass();
+ }
+}
+
+class JavaPsiFacade {
+ static JavaPsiFacade getInstance() {
+ return null;
+ }
+
+ PsiClass findClass() {
+ return null;
+ }
+}
+
+interface PsiElement {
+ PsiClass getContainingClass();
+}
+
+interface PsiClass extends PsiElement {
+}
diff --git a/java/java-tests/testData/codeInsight/completion/methodChains/testRenderingVariableInContextAndNotInContext/AfterCompletion.java b/java/java-tests/testData/codeInsight/completion/methodChains/testRenderingVariableInContextAndNotInContext/AfterCompletion.java
new file mode 100644
index 0000000..5298982
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/methodChains/testRenderingVariableInContextAndNotInContext/AfterCompletion.java
@@ -0,0 +1,16 @@
+import java.jang.String;
+import java.lang.String;
+
+interface PsiManager {
+ Project getProject(String asd, String zxc);
+}
+
+interface Project {}
+
+public class TestCompletion {
+ void m() {
+ String asd = "123";
+ PsiManager psiManager = null;
+ Project p = psiManager.getProject(asd, zxc)
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/completion/methodChains/testRenderingVariableInContextAndNotInContext/BeforeCompletion.java b/java/java-tests/testData/codeInsight/completion/methodChains/testRenderingVariableInContextAndNotInContext/BeforeCompletion.java
new file mode 100644
index 0000000..c3e90bb
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/methodChains/testRenderingVariableInContextAndNotInContext/BeforeCompletion.java
@@ -0,0 +1,15 @@
+import java.jang.String;
+import java.lang.String;
+
+interface PsiManager {
+ Project getProject(String asd, String zxc);
+}
+
+interface Project {}
+
+public class TestCompletion {
+ void m() {
+ String asd = "123";
+ Project p = <caret>
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/completion/methodChains/testRenderingVariableInContextAndNotInContext/TestIndex.java b/java/java-tests/testData/codeInsight/completion/methodChains/testRenderingVariableInContextAndNotInContext/TestIndex.java
new file mode 100644
index 0000000..e19f8ba
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/methodChains/testRenderingVariableInContextAndNotInContext/TestIndex.java
@@ -0,0 +1,22 @@
+import java.lang.String;
+
+public class TestIndex {
+
+ PsiManager m;
+
+ void m() {
+ m.getProject(null, null);
+ m.getProject(null, null);
+ m.getProject(null, null);
+ m.getProject(null, null);
+ m.getProject(null, null);
+ m.getProject(null, null);
+ }
+}
+
+
+interface PsiManager {
+ Project getProject(String asd, String zxc);
+}
+
+interface Project {}
diff --git a/java/java-tests/testData/codeInsight/completion/methodChains/testResultRelevance/TestCompletion.java b/java/java-tests/testData/codeInsight/completion/methodChains/testResultRelevance/TestCompletion.java
new file mode 100644
index 0000000..0370d36
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/methodChains/testResultRelevance/TestCompletion.java
@@ -0,0 +1,26 @@
+import java.jang.String;
+
+class JavaPsiFacade {
+ static JavaPsiFacade getInstance() {
+ return null;
+ }
+
+ PsiClass findClass() {
+ return null;
+ }
+}
+
+interface PsiElement {
+ PsiClass getContainingClass();
+}
+
+interface PsiClass extends PsiElement {
+}
+
+public class TestCompletion {
+
+ public void method(PsiElement e) {
+ PsiClass c = <caret>
+ }
+
+}
diff --git a/java/java-tests/testData/codeInsight/completion/methodChains/testResultRelevance/TestIndex.java b/java/java-tests/testData/codeInsight/completion/methodChains/testResultRelevance/TestIndex.java
new file mode 100644
index 0000000..67e94aa
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/methodChains/testResultRelevance/TestIndex.java
@@ -0,0 +1,37 @@
+/**
+ * @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
+ */
+public class TestIndex {
+
+ PsiElement e;
+
+ void m() {
+ e.getContainingClass();
+ e.getContainingClass();
+ e.getContainingClass();
+ e.getContainingClass();
+ JavaPsiFacade.getInstance().findClass();
+ JavaPsiFacade.getInstance().findClass();
+ JavaPsiFacade.getInstance().findClass();
+ JavaPsiFacade.getInstance().findClass();
+ JavaPsiFacade.getInstance().findClass();
+ JavaPsiFacade.getInstance().findClass();
+ }
+}
+
+class JavaPsiFacade {
+ static JavaPsiFacade getInstance() {
+ return null;
+ }
+
+ PsiClass findClass() {
+ return null;
+ }
+}
+
+interface PsiElement {
+ PsiClass getContainingClass();
+}
+
+interface PsiClass extends PsiElement {
+}
diff --git a/java/java-tests/testData/codeInsight/completion/methodChains/testResultRelevance3/TestCompletion.java b/java/java-tests/testData/codeInsight/completion/methodChains/testResultRelevance3/TestCompletion.java
new file mode 100644
index 0000000..9eed7d8
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/methodChains/testResultRelevance3/TestCompletion.java
@@ -0,0 +1,20 @@
+import java.jang.String;
+
+class TestCompletuin{
+}
+
+interface PsiManager {
+ Project getProject();
+}
+
+interface PsiElement {
+ Project getProject1();
+}
+
+interface Project {}
+
+public class TestCompletion {
+ void m(PsiElement e) {
+ Project p = <caret>
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/completion/methodChains/testResultRelevance3/TestIndex.java b/java/java-tests/testData/codeInsight/completion/methodChains/testResultRelevance3/TestIndex.java
new file mode 100644
index 0000000..823284e
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/methodChains/testResultRelevance3/TestIndex.java
@@ -0,0 +1,35 @@
+/**
+ * @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
+ */
+import java.lang.String;
+
+public class TestIndex {
+
+ PsiElement e;
+
+ PsiManager m;
+
+ void m() {
+ m.getProject();
+ m.getProject();
+ m.getProject();
+ m.getProject();
+ m.getProject();
+ m.getProject();
+ e.getProject1();
+ e.getProject1();
+ e.getProject1();
+ e.getProject1();
+ }
+}
+
+
+interface PsiManager {
+ Project getProject();
+}
+
+interface PsiElement {
+ Project getProject1();
+}
+
+interface Project {}
diff --git a/java/java-tests/testData/codeInsight/completion/methodChains/testResultsForSuperClassesNotShowed/TestCompletion.java b/java/java-tests/testData/codeInsight/completion/methodChains/testResultsForSuperClassesNotShowed/TestCompletion.java
new file mode 100644
index 0000000..8fdad22
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/methodChains/testResultsForSuperClassesNotShowed/TestCompletion.java
@@ -0,0 +1,24 @@
+import java.jang.String;
+
+/**
+ * @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
+ */
+
+class PsiElement {
+}
+
+class PsiClass extends PsiElement {
+}
+
+class PsiElementFactory {
+ public PsiClass createClass() {
+ return null;
+ }
+}
+
+public class TestCompletion {
+
+ public void method(PsiElementFactory f) {
+ PsiElement e = <caret>
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/completion/methodChains/testResultsForSuperClassesNotShowed/TestIndex.java b/java/java-tests/testData/codeInsight/completion/methodChains/testResultsForSuperClassesNotShowed/TestIndex.java
new file mode 100644
index 0000000..85376be
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/methodChains/testResultsForSuperClassesNotShowed/TestIndex.java
@@ -0,0 +1,26 @@
+/**
+ * @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
+ */
+public class TestIndex {
+
+ public void statMethod(PsiElementFactory f) {
+ f.createClass();
+ f.createClass();
+ f.createClass();
+ f.createClass();
+ f.createClass();
+ f.createClass();
+ }
+}
+
+class PsiElement {
+}
+
+class PsiClass extends PsiElement {
+}
+
+class PsiElementFactory {
+ public PsiClass createClass() {
+ return null;
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/completion/methodChains/testSearchByDirectInheritorsIfNoResults/TestCompletion.java b/java/java-tests/testData/codeInsight/completion/methodChains/testSearchByDirectInheritorsIfNoResults/TestCompletion.java
new file mode 100644
index 0000000..b2686c7
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/methodChains/testSearchByDirectInheritorsIfNoResults/TestCompletion.java
@@ -0,0 +1,24 @@
+import java.jang.String;
+
+/**
+ * @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
+ */
+
+
+class FileIndex {
+}
+
+class ProjectFileIndex extends FileIndex {
+ public static ProjectFileIndex getInstance(Project p) {
+ return null;
+ }
+}
+
+interface Project {}
+
+public class TestCompletion {
+
+ public void method() {
+ FileIndex fi = <caret>
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/completion/methodChains/testSearchByDirectInheritorsIfNoResults/TestIndex.java b/java/java-tests/testData/codeInsight/completion/methodChains/testSearchByDirectInheritorsIfNoResults/TestIndex.java
new file mode 100644
index 0000000..01a1599
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/methodChains/testSearchByDirectInheritorsIfNoResults/TestIndex.java
@@ -0,0 +1,28 @@
+/**
+ * @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
+ */
+public class TestIndex {
+
+ public void statMethod() {
+ ProjectFileIndex.getInstance(null);
+ ProjectFileIndex.getInstance(null);
+ ProjectFileIndex.getInstance(null);
+ ProjectFileIndex.getInstance(null);
+ ProjectFileIndex.getInstance(null);
+ ProjectFileIndex.getInstance(null);
+ ProjectFileIndex.getInstance(null);
+ ProjectFileIndex.getInstance(null);
+ }
+}
+
+class FileIndex {
+}
+
+class ProjectFileIndex extends FileIndex {
+ public static ProjectFileIndex getInstance(Project p) {
+ return null;
+ }
+}
+
+interface Project {}
+
diff --git a/java/java-tests/testData/codeInsight/completion/methodChains/testStaticMethod/TestCompletion.java b/java/java-tests/testData/codeInsight/completion/methodChains/testStaticMethod/TestCompletion.java
new file mode 100644
index 0000000..0d4e137
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/methodChains/testStaticMethod/TestCompletion.java
@@ -0,0 +1,19 @@
+/**
+ * @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
+ */
+
+class LocalFileSystem {
+ public LocalFileSystem returnSelf() {
+ return this;
+ }
+
+ public static LocalFileSystem getInstance() {
+ return null;
+ }
+}
+
+public class TestCompletion {
+ public void method(LocalFileSystem lfs) {
+ LocalFileSystem anotherLfs = <caret>
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/completion/methodChains/testStaticMethod/TestIndex.java b/java/java-tests/testData/codeInsight/completion/methodChains/testStaticMethod/TestIndex.java
new file mode 100644
index 0000000..0842d22
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/methodChains/testStaticMethod/TestIndex.java
@@ -0,0 +1,26 @@
+/**
+ * @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
+ */
+public class TestIndex {
+
+ public void statMethod(LocalFileSystemAware lfsa) {
+ lfsa.returnLFS();
+ lfsa.returnLFS();
+ lfsa.returnLFS();
+ lfsa.returnLFS();
+ LocalFileSystem.getInstance();
+ LocalFileSystem.getInstance();
+ }
+}
+
+class LocalFileSystem {
+ public static LocalFileSystem getInstance() {
+ return null;
+ }
+}
+
+class LocalFileSystemAware {
+ public LocalFileSystem returnLFS() {
+ return null;
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/completion/methodChains/testStaticMethodAndMethod/TestCompletion.java b/java/java-tests/testData/codeInsight/completion/methodChains/testStaticMethodAndMethod/TestCompletion.java
new file mode 100644
index 0000000..19f7791
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/methodChains/testStaticMethodAndMethod/TestCompletion.java
@@ -0,0 +1,25 @@
+/**
+ * @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
+ */
+
+class JavaPsiFacade {
+ public static PsiClass findClass(String qName) {
+ return null;
+ }
+}
+
+class PsiClass {
+
+}
+
+class PsiMethod {
+ public PsiClass getContainingClass() {
+ return null;
+ }
+}
+
+public class TestCompletion {
+ public void method(PsiMethod m) {
+ PsiClass someClass = <caret>
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/completion/methodChains/testStaticMethodAndMethod/TestIndex.java b/java/java-tests/testData/codeInsight/completion/methodChains/testStaticMethodAndMethod/TestIndex.java
new file mode 100644
index 0000000..57dad62
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/methodChains/testStaticMethodAndMethod/TestIndex.java
@@ -0,0 +1,35 @@
+/**
+ * @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
+ */
+public class TestIndex {
+
+ public void statMethod() {
+ JavaPsiFacade.findClass("asd");
+ JavaPsiFacade.findClass("asd");
+ JavaPsiFacade.findClass("asd");
+ }
+
+ public void statMethod(PsiMethod m) {
+ m.getContainingClass();
+ m.getContainingClass();
+ m.getContainingClass();
+ m.getContainingClass();
+ m.getContainingClass();
+ }
+}
+
+class JavaPsiFacade {
+ public static PsiClass findClass(String qName) {
+ return null;
+ }
+}
+
+class PsiClass {
+
+}
+
+class PsiMethod {
+ public PsiClass getContainingClass() {
+ return null;
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/completion/methodChains/testSuperClassMethodsCallings/TestCompletion.java b/java/java-tests/testData/codeInsight/completion/methodChains/testSuperClassMethodsCallings/TestCompletion.java
new file mode 100644
index 0000000..89c5bb4
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/methodChains/testSuperClassMethodsCallings/TestCompletion.java
@@ -0,0 +1,23 @@
+/**
+ * @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
+ */
+
+
+class Project {
+}
+
+interface PsiElement {
+ Project getProject();
+}
+
+class PsiMethod implements PsiElement {
+ public Project getProject() {
+ return null;
+ }
+}
+
+public class TestCompletion {
+ public void method(PsiMethod m) {
+ Project project = <caret>
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/completion/methodChains/testSuperClassMethodsCallings/TestIndex.java b/java/java-tests/testData/codeInsight/completion/methodChains/testSuperClassMethodsCallings/TestIndex.java
new file mode 100644
index 0000000..9f7b24e
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/methodChains/testSuperClassMethodsCallings/TestIndex.java
@@ -0,0 +1,30 @@
+/**
+ * @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
+ */
+public class TestIndex {
+
+ public void statMethod(PsiElement a, PsiElement b) {
+ a.getProject();
+ a.getProject();
+ a.getProject();
+ a.getProject();
+ b.getProject();
+ b.getProject();
+ b.getProject();
+ b.getProject();
+ }
+}
+
+
+class Project {
+}
+
+interface PsiElement {
+ Project getProject();
+}
+
+class PsiMethod implements PsiElement {
+ public Project getProject() {
+ return null;
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/completion/methodChains/testTwoVariablesWithOneTypeOrSuperType/TestCompletion.java b/java/java-tests/testData/codeInsight/completion/methodChains/testTwoVariablesWithOneTypeOrSuperType/TestCompletion.java
new file mode 100644
index 0000000..f65e19b
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/methodChains/testTwoVariablesWithOneTypeOrSuperType/TestCompletion.java
@@ -0,0 +1,31 @@
+/**
+ * @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
+ */
+
+class Project {
+}
+
+interface PsiElement {
+ Project getProject();
+}
+
+class PsiClass implements PsiElement {
+ public Project getProject() {
+ return null;
+ }
+}
+
+class PsiMethod implements PsiElement {
+ public Project getProject() {
+ return null;
+ }
+}
+
+
+public class TestCompletion {
+ PsiClass c = new PsiClass();
+
+ public void method(PsiMethod m) {
+ Project p = <caret>
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/completion/methodChains/testTwoVariablesWithOneTypeOrSuperType/TestIndex.java b/java/java-tests/testData/codeInsight/completion/methodChains/testTwoVariablesWithOneTypeOrSuperType/TestIndex.java
new file mode 100644
index 0000000..6b538a9
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/methodChains/testTwoVariablesWithOneTypeOrSuperType/TestIndex.java
@@ -0,0 +1,36 @@
+/**
+ * @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
+ */
+public class TestIndex {
+
+ public void statMethod(PsiClass c, PsiMethod m) {
+ c.getProject();
+ c.getProject();
+ c.getProject();
+ c.getProject();
+ m.getProject();
+ m.getProject();
+ m.getProject();
+ m.getProject();
+ }
+}
+
+
+class Project {
+}
+
+interface PsiElement {
+ Project getProject();
+}
+
+class PsiClass implements PsiElement {
+ public Project getProject() {
+ return null;
+ }
+}
+
+class PsiMethod implements PsiElement {
+ public Project getProject() {
+ return null;
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/completion/normal/AccessorViaCompletion.java b/java/java-tests/testData/codeInsight/completion/normal/AccessorViaCompletion.java
new file mode 100644
index 0000000..ed1d7f1
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/normal/AccessorViaCompletion.java
@@ -0,0 +1,5 @@
+public class A {
+ int field;
+
+ publ<caret>
+}
diff --git a/java/java-tests/testData/codeInsight/completion/normal/AccessorViaCompletion_after.java b/java/java-tests/testData/codeInsight/completion/normal/AccessorViaCompletion_after.java
new file mode 100644
index 0000000..1c4a395
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/normal/AccessorViaCompletion_after.java
@@ -0,0 +1,7 @@
+public class A {
+ int field;
+
+ public int getField() {
+ <caret><selection>return field;</selection>
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/completion/normal/CastQualifierForPrivateFieldReference.java b/java/java-tests/testData/codeInsight/completion/normal/CastQualifierForPrivateFieldReference.java
new file mode 100644
index 0000000..01256af
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/normal/CastQualifierForPrivateFieldReference.java
@@ -0,0 +1,8 @@
+class MyData {
+ private Set<String> myInitialized;
+
+ @Override
+ public boolean equals(Object obj) {
+ return obj instanceof MyData && myInitialized.equals(obj.myIniti<caret>)
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/completion/normal/CastQualifierForPrivateFieldReference_after.java b/java/java-tests/testData/codeInsight/completion/normal/CastQualifierForPrivateFieldReference_after.java
new file mode 100644
index 0000000..4f264d2
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/normal/CastQualifierForPrivateFieldReference_after.java
@@ -0,0 +1,8 @@
+class MyData {
+ private Set<String> myInitialized;
+
+ @Override
+ public boolean equals(Object obj) {
+ return obj instanceof MyData && myInitialized.equals(((MyData) obj).myInitialized<caret>)
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/completion/normalSorting/PreferInterfacesInImplements.java b/java/java-tests/testData/codeInsight/completion/normalSorting/PreferInterfacesInImplements.java
index 4809d42..03329ee 100644
--- a/java/java-tests/testData/codeInsight/completion/normalSorting/PreferInterfacesInImplements.java
+++ b/java/java-tests/testData/codeInsight/completion/normalSorting/PreferInterfacesInImplements.java
@@ -1,8 +1,6 @@
interface FooIntf {}
class FooClass {}
+class Foo {}
-class Goo implements Foo<caret> {
- int boo() {}
- int doo() {}
- int foo() {}
+class Goo implements Fo<caret> {
}
diff --git a/java/java-tests/testData/codeInsight/completion/smartType/second/FirstMethodWithParams.java b/java/java-tests/testData/codeInsight/completion/smartType/second/FirstMethodWithParams.java
new file mode 100644
index 0000000..0a2e513
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/smartType/second/FirstMethodWithParams.java
@@ -0,0 +1,15 @@
+class Bar {
+ Goo getGoo(int a);
+ Goo getGoo2(int a);
+}
+class Goo {}
+
+class Foo {
+ Bar getBar() {}
+ Bar getBar(int a) {}
+
+
+ {
+ Goo g = <caret>
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/staticPackageLocalMember/p1/A.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/staticPackageLocalMember/p1/A.java
new file mode 100644
index 0000000..c4db118
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/staticPackageLocalMember/p1/A.java
@@ -0,0 +1,6 @@
+package p1;
+
+public class A {
+ static int FOO = 0;
+ static void foo(){}
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/staticPackageLocalMember/p1/C.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/staticPackageLocalMember/p1/C.java
new file mode 100644
index 0000000..656481e
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/staticPackageLocalMember/p1/C.java
@@ -0,0 +1,16 @@
+package p1;
+
+import p2.B;
+
+public class C extends B {
+ void f(){
+ System.out.println(<error descr="'FOO' is not public in 'p1.A'. Cannot be accessed from outside package">FOO</error>);
+ <error descr="'foo()' is not public in 'p1.A'. Cannot be accessed from outside package">foo</error>();
+
+ System.out.println(A.FOO);
+ A.foo();
+
+ System.out.println(B.<error descr="'FOO' is not public in 'p1.A'. Cannot be accessed from outside package">FOO</error>);
+ B.<error descr="'foo()' is not public in 'p1.A'. Cannot be accessed from outside package">foo</error>();
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/staticPackageLocalMember/p2/B.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/staticPackageLocalMember/p2/B.java
new file mode 100644
index 0000000..cd8b95a
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/staticPackageLocalMember/p2/B.java
@@ -0,0 +1,6 @@
+package p2;
+
+import p1.A;
+
+public class B extends A {
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting6/Java5CastConventions.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting6/Java5CastConventions.java
new file mode 100644
index 0000000..dae77be
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting6/Java5CastConventions.java
@@ -0,0 +1,7 @@
+class Test {
+ public static void main(String[] args) {
+ Object o = null;
+ if (<error descr="Operator '==' cannot be applied to 'java.lang.Object', 'int'">o == 1</error>) {}
+ if (1 == o) {}
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting6/RedundantCastInConditionalExpression.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting6/RedundantCastInConditionalExpression.java
new file mode 100644
index 0000000..351526a
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting6/RedundantCastInConditionalExpression.java
@@ -0,0 +1,8 @@
+public class Foo {
+ public static void main(String[] args) {
+ final boolean b = false;
+ final Integer i = (<warning descr="Casting '3' to 'Integer' is redundant">Integer</warning>)3;
+ final short s = (short)(b ? i : (int)Integer.valueOf(3));
+ System.out.println(s);
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting6/UnhandledExceptions.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting6/UnhandledExceptions.java
new file mode 100644
index 0000000..54eac1e
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting6/UnhandledExceptions.java
@@ -0,0 +1,13 @@
+interface I<T extends Exception> {
+ void m() throws T;
+}
+
+class C {
+ void x(I<?> i) {
+ <error descr="Unhandled exception: java.lang.Exception">i.m();</error>
+ }
+
+ void y(I<? extends Exception> i) {
+ <error descr="Unhandled exception: java.lang.Exception">i.m();</error>
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/IDEA111420.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/IDEA111420.java
new file mode 100644
index 0000000..eafce26
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/IDEA111420.java
@@ -0,0 +1,10 @@
+import java.util.List;
+
+public class Test {
+ private static final <error descr="Incompatible types. Found: 'java.util.List<java.lang.Class<? extends java.io.Serializable & java.lang.Cloneable>>', required: 'java.util.List<java.lang.Class<?>>'">List<Class<?>> PRIMITIVE_ARRAY_TYPES = asList(byte[].class, int[].class);</error>
+ private static final List<?> PRIMITIVE_ARRAY_TYPES1 = asList(byte[].class, int[].class);
+
+ public static <T> List<T> asList(T... a) {
+ return null;
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/Java7CastConventions.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/Java7CastConventions.java
deleted file mode 100644
index 3703715..0000000
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/Java7CastConventions.java
+++ /dev/null
@@ -1,7 +0,0 @@
-class Test {
- public static void main(String[] args) {
- Object o = null;
- if (o == 1) {}
- if (1 == o) {}
- }
-}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/CaptureWildcardsInTypeCasts.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/CaptureWildcardsInTypeCasts.java
new file mode 100644
index 0000000..81bcec4
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/CaptureWildcardsInTypeCasts.java
@@ -0,0 +1,8 @@
+import java.util.Collection;
+
+class Foo {
+ private void test() {
+ Object x = null;
+ ((java.util.Collection<?>)x).add<error descr="'add(capture<?>)' in 'java.util.Collection' cannot be applied to '(java.lang.String)'">("")</error>;
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA107440.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA107440.java
new file mode 100644
index 0000000..a0c69e6
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA107440.java
@@ -0,0 +1,18 @@
+class GoodCodeRed {
+ static class ClassA {
+ }
+
+ static class Pair<T, N> {
+ }
+
+ <T extends ClassA, M extends T, N extends Number> void max(final M object, Pair<T, N> attribute, final N cnt) {
+ }
+
+ <T extends ClassA, M extends T, N extends String> void max(final M object, Pair<T, N> attribute, final N str) {
+ }
+
+
+ {
+ max(new ClassA(), new Pair<ClassA, Integer>(), 1);
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA109556.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA109556.java
new file mode 100644
index 0000000..7b2e68e
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA109556.java
@@ -0,0 +1,9 @@
+class Base { }
+class Extended extends Base {}
+
+class Test<T extends Base> {
+ <T extends Base, U extends T> void test(T x, Class<U> test) {}
+ {
+ <error descr="Inferred type 'Base' for type parameter 'U' is not within its bound; should extend 'Extended'">test(new Extended(), Base.class)</error>;
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA110568.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA110568.java
new file mode 100644
index 0000000..ed9eedd
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA110568.java
@@ -0,0 +1,20 @@
+import java.util.Collection;
+
+public class IncorrectError extends NarrowClass {
+ public Collection<String> bar() {
+ return super.doStuff();
+ }
+}
+
+interface Interface {
+ Collection<String> doStuff();
+}
+
+class NarrowClass extends BaseClass implements Interface {
+}
+
+class BaseClass {
+ public Collection doStuff() {
+ return null;
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA110869.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA110869.java
new file mode 100644
index 0000000..488d6c7
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA110869.java
@@ -0,0 +1,12 @@
+class A {
+}
+
+abstract class B {
+ public <T extends A> T getA(Class<T> aClass) {
+ return null;
+ }
+
+ void foo(Class<?> aClass) {
+ A a = <error descr="Inferred type '?' for type parameter 'T' is not within its bound; should extend 'A'">getA(aClass)</error>;
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA110947.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA110947.java
new file mode 100644
index 0000000..256f5e0
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA110947.java
@@ -0,0 +1,17 @@
+interface Result {}
+
+interface Command<R extends Result> {}
+
+interface Procedure<C extends Command<Result>> {
+}
+
+abstract class ProcedureService {
+ abstract <C extends Command<Result>> Class<? extends Procedure<Command<Result>>> getProcedure(Class<C> cmd);
+
+ public <C extends Command<Result>> void execute(Class<? extends Command> aClass) {
+ Class<Procedure<Command<Result>>> procedureClass = getProcedure(aClass);
+ <error descr="Incompatible types. Found: 'java.lang.Class<capture<? extends Command>>', required: 'java.lang.Class<Command>'">Class<Command> c = aClass;</error>
+ <error descr="Incompatible types. Found: 'java.lang.Class<capture<? extends Command>>', required: 'java.lang.Class<C>'">Class<C> c1 = aClass;</error>
+ }
+
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA111085.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA111085.java
new file mode 100644
index 0000000..e67e0d3
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA111085.java
@@ -0,0 +1,20 @@
+import java.io.*;
+import java.util.List;
+
+class Main {
+ public <T> T foo(String str, Class<T> classOfT) {
+ return null;
+ }
+
+ public <T> T foo(String str, Serializable typeOfT) {
+ return null;
+ }
+
+ {
+ asList(foo("", String[].class));
+ }
+
+ public static <T> List<T> asList(T... a) {
+ return null;
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA57289.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA57289.java
new file mode 100644
index 0000000..9f0063b
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA57289.java
@@ -0,0 +1,8 @@
+class C<T> {
+ void foo(C<C<?>> x) {
+ C<Object> c = bar(x);
+ }
+ <T> C<T> bar(C<? super C<T>> x){
+ return null;
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA57311.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA57311.java
index 2be9a4f..9ed409c 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA57311.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA57311.java
@@ -4,7 +4,7 @@
}
void bar(A<?> x){
- baz<error descr="'baz(A<A<?>>)' in 'A' cannot be applied to '(A<A<capture<?>>>)'">(x.foo())</error>;
+ baz<error descr="'baz(A<A<? extends S>>)' in 'A' cannot be applied to '(A<A<capture<?>>>)'">(x.foo())</error>;
}
<S> void baz(A<A<? extends S>> x){}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA57312.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA57312.java
new file mode 100644
index 0000000..70be0d2
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA57312.java
@@ -0,0 +1,11 @@
+class A<T> {
+ A<A<? super A<T>>> foo(){
+ return null;
+ }
+
+ void bar(A<?> x){
+ baz(x.foo());
+ }
+
+ <S> void baz(A<A<? super A<S>>> x){}
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA57325.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA57325.java
new file mode 100644
index 0000000..a498320
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA57325.java
@@ -0,0 +1,12 @@
+interface IA<T> {
+ IA<? extends T> foo();
+}
+
+class A {
+ void baz(IA<? extends Throwable> x) {
+ bar(x.foo());
+ }
+
+ <T extends Throwable> void bar(IA<T> a) {
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA57334.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA57334.java
new file mode 100644
index 0000000..ece1dd1
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA57334.java
@@ -0,0 +1,41 @@
+abstract class A<T, S> {
+ abstract <T> void foo(A<? extends T, ? extends T> x);
+ void bar(A<? extends Throwable, ? extends Exception> x){
+ foo(x);
+ }
+}
+
+abstract class A0<T, S> {
+ abstract <T> void foo(A0<? extends T, ? extends T> x);
+ void bar(A0<? extends Exception, ? extends Throwable> x){
+ foo(x);
+ }
+}
+
+abstract class A1<T, S> {
+ abstract <T> void foo(A1<? extends T, ? extends T> x);
+ void bar(A1<? extends Throwable, Exception> x){
+ foo(x);
+ }
+}
+
+abstract class A10<T, S> {
+ abstract <T> void foo(A10<? extends T, ? extends T> x);
+ void bar(A10<Throwable, Exception> x){
+ foo(x);
+ }
+}
+
+abstract class A2<T, S> {
+ abstract <T> void foo(A2<? super T, ? super T> x);
+ void bar(A2<? super Exception, ? super Throwable> x){
+ foo(x);
+ }
+}
+
+abstract class A20<T, S> {
+ abstract <T> void foo(A20<? super T, ? super T> x);
+ void bar(A20<? super Throwable, ? super Exception> x){
+ foo(x);
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA57391.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA57391.java
new file mode 100644
index 0000000..664b7c7
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA57391.java
@@ -0,0 +1,7 @@
+abstract class B<T> {
+ abstract <S extends T> void foo(T x, S y);
+}
+
+class A extends B<String> {
+ void foo(String x, String y) {}
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA57439.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA57439.java
new file mode 100644
index 0000000..544d6c1
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA57439.java
@@ -0,0 +1,43 @@
+class A<T> {}
+
+class B<T> extends A<A<T>> {
+ void bar(B<?> b, B<? extends String> eb, B<? super String> sb, B<String> s) {
+ foo(b);
+ foo(eb);
+ foo(sb);
+ foo(s);
+
+ <error descr="Inferred type 'capture<?>' for type parameter 'T' is not within its bound; should extend 'java.lang.String'">foo1(b)</error>;
+ foo1(eb);
+ <error descr="Inferred type 'capture<? super java.lang.String>' for type parameter 'T' is not within its bound; should extend 'java.lang.String'">foo1(sb)</error>;
+ foo1(s);
+
+ foo2(b);
+ foo2(eb);
+ foo2(sb);
+ foo2(s);
+
+ foo3<error descr="'foo3(A<A<? extends T>>)' in 'B' cannot be applied to '(B<capture<?>>)'">(b)</error>;
+ foo3<error descr="'foo3(A<A<? extends T>>)' in 'B' cannot be applied to '(B<capture<? extends java.lang.String>>)'">(eb)</error>;
+ foo3<error descr="'foo3(A<A<? extends T>>)' in 'B' cannot be applied to '(B<capture<? super java.lang.String>>)'">(sb)</error>;
+ foo3<error descr="'foo3(A<A<? extends java.lang.String>>)' in 'B' cannot be applied to '(B<java.lang.String>)'">(s)</error>;
+
+ foo4<error descr="'foo4(A<A<? super T>>)' in 'B' cannot be applied to '(B<capture<?>>)'">(b)</error>;
+ foo4<error descr="'foo4(A<A<? super T>>)' in 'B' cannot be applied to '(B<capture<? extends java.lang.String>>)'">(eb)</error>;
+ foo4<error descr="'foo4(A<A<? super T>>)' in 'B' cannot be applied to '(B<capture<? super java.lang.String>>)'">(sb)</error>;
+ foo4<error descr="'foo4(A<A<? super java.lang.String>>)' in 'B' cannot be applied to '(B<java.lang.String>)'">(s)</error>;
+
+ foo5(b);
+ foo5(eb);
+ foo5(sb);
+ foo5(s);
+ }
+
+
+ <T> void foo(A<A<T>> x) {}
+ <T extends String> void foo1(A<A<T>> x) {}
+ <T> void foo2(A<? extends A<T>> x) {}
+ <T> void foo3(A<A<? extends T>> x) {}
+ <T> void foo4(A<A<? super T>> x) {}
+ <T> void foo5(A<? super A<T>> x) {}
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA67672.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA67672.java
index db8282f..cd6b209 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA67672.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA67672.java
@@ -3,5 +3,5 @@
interface A
{
- <<error descr="'add(E)' in 'java.util.List' clashes with 'add(E)' in 'java.util.Collection'; both methods have same erasure, yet neither overrides the other"></error>T extends List<?> & Collection<? extends Cloneable>> void foo(T x);
+ <<error descr="'java.util.Collection' cannot be inherited with different type arguments: 'capture<?>' and 'capture<? extends java.lang.Cloneable>'"></error>T extends List<?> & Collection<? extends Cloneable>> void foo(T x);
}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA67682.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA67682.java
new file mode 100644
index 0000000..20b3bba
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA67682.java
@@ -0,0 +1,15 @@
+import java.util.List;
+
+abstract class B {
+ <T> void foo(List<List<String>[]> x) {
+ Object y1 = <error descr="Inconvertible types; cannot cast 'java.util.List<java.util.List<java.lang.String>[]>' to 'java.util.List<java.util.List<T>[]>'">(List<List<T>[]>)x</error>;
+ }
+
+ <T> void foo1(List<List<List<String>>[]> x) {
+ Object y1 = <error descr="Inconvertible types; cannot cast 'java.util.List<java.util.List<java.util.List<java.lang.String>>[]>' to 'java.util.List<java.util.List<java.util.List<T>>[]>'">(List<List<List<T>>[]>)x</error>;
+ }
+
+ <T> void foo2(List<String[]> x) {
+ Object y1 = <error descr="Inconvertible types; cannot cast 'java.util.List<java.lang.String[]>' to 'java.util.List<T[]>'">(List<T[]>)x</error>;
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA67744.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA67744.java
new file mode 100644
index 0000000..f0684d5
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA67744.java
@@ -0,0 +1,16 @@
+import java.util.List;
+
+abstract class B {
+ abstract <T> T[] foo(List<? super List<T>> x);
+ abstract <T> T foo0(List<? super List<T>> x);
+ abstract <T> T[] foo1(List<? extends List<T>> x);
+ abstract <T> T[] foo2(List<List<? super List<T>>> x);
+
+ void bar(List<List<?>> x, List<List<List<?>>> y){
+ foo(x) [0] = "";
+ foo1<error descr="'foo1(java.util.List<? extends java.util.List<T>>)' in 'B' cannot be applied to '(java.util.List<java.util.List<?>>)'">(x)</error> [0] = "";
+ foo2<error descr="'foo2(java.util.List<java.util.List<? super java.util.List<java.lang.Object>>>)' in 'B' cannot be applied to '(java.util.List<java.util.List<java.util.List<?>>>)'">(y)</error> [0] = "";
+
+ String s = foo0(x);
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA67835.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA67835.java
new file mode 100644
index 0000000..2def4a6
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA67835.java
@@ -0,0 +1,10 @@
+import java.util.List;
+
+class B {
+ void bar(List<String> x){
+ foo(x);
+ }
+ <T> T foo(List<? super T> x){
+ return null;
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IntersectionTypes.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IntersectionTypes.java
index a197bf0..b201ac5 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IntersectionTypes.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IntersectionTypes.java
@@ -8,7 +8,7 @@
}
void foo() {
- <error descr="Incompatible types. Found: 'java.util.List<java.lang.Class<? extends java.io.Serializable & java.lang.Comparable<?>>>', required: 'java.util.List<java.lang.Class<? extends java.io.Serializable>>'">List<Class<? extends Serializable>> l = <warning descr="Unchecked generics array creation for varargs parameter">this.asList</warning>(String.class, Integer.class);</error>
+ <error descr="Incompatible types. Found: 'java.util.List<java.lang.Class<? extends java.io.Serializable & java.lang.Comparable<? extends java.lang.Comparable<?>>>>', required: 'java.util.List<java.lang.Class<? extends java.io.Serializable>>'">List<Class<? extends Serializable>> l = <warning descr="Unchecked generics array creation for varargs parameter">this.asList</warning>(String.class, Integer.class);</error>
l.size();
List<? extends Object> objects = this.asList(new String(), new Integer(0));
objects.size();
@@ -146,7 +146,7 @@
}
public static final
- <error descr="Incompatible types. Found: 'java.util.List<java.lang.Class<? extends java.io.Serializable & java.lang.Comparable<?>>>', required: 'java.util.List<java.lang.Class<? extends java.io.Serializable>>'">List<Class<? extends Serializable>> SIMPLE_TYPES =
+ <error descr="Incompatible types. Found: 'java.util.List<java.lang.Class<? extends java.io.Serializable & java.lang.Comparable<? extends java.lang.Comparable<?>>>>', required: 'java.util.List<java.lang.Class<? extends java.io.Serializable>>'">List<Class<? extends Serializable>> SIMPLE_TYPES =
<warning descr="Unchecked generics array creation for varargs parameter">asList</warning>(String.class, Integer.class ,Long.class, Double.class, /*Date.class,*/
Boolean.class, Boolean.TYPE /*,String[].class */ /*,BigDecimal.class*/);</error>
@@ -179,3 +179,43 @@
class M extends MaximalType implements L{}
class M2 extends MaximalType implements L{}
/////////////
+
+
+class IDEA67676 {
+ interface I<<warning descr="Type parameter 'T' is never used">T</warning>> {}
+ interface A<T> extends I<A<T>>{}
+ interface Com2<T, U> {
+ void foo(T t, U u);
+ }
+ interface Com1<T> {
+ void foo(T t);
+ }
+
+ abstract class X {
+ abstract <T> T foo(T x, T y);
+
+ void bar(A<A2> x, A<B2> y) {
+ A<? extends Com2<? extends Com2<?, ?>, ? extends Com2<?, ?>>> f = foo(x, y);
+ f.hashCode();
+ }
+
+ void boo(A<A3> x, A<B3> y) {
+ A<? extends Com2<? extends Com2<?, ?>, ? extends Com2<?, ?>>> f = foo(x, y);
+ f.hashCode();
+ }
+
+ void baz(A<A1> x, A<B1> y) {
+ A<? extends Com1<? extends Com1<?>>> f = foo(x, y);
+ f.hashCode();
+ }
+ }
+
+ abstract class A1 implements Com1<A1> {}
+ abstract class B1 implements Com1<B1> {}
+
+ abstract class A2 implements Com2<A2, A2> {}
+ abstract class B2 implements Com2<B2, B2> {}
+
+ abstract class A3 implements Com2<A3, B3> {}
+ abstract class B3 implements Com2<B3, A3> {}
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/NoInferenceFromTypeCast.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/NoInferenceFromTypeCast.java
new file mode 100644
index 0000000..d655efd
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/NoInferenceFromTypeCast.java
@@ -0,0 +1,23 @@
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+
+
+interface A {}
+
+interface B extends A {}
+
+class Foo {
+ public <TA extends A> List<TA> getAs() {
+ return (List<TA>) getBs();
+ }
+
+ public <T extends B> List<T> getBs() {
+ return null;
+ }
+
+ void foo(Set<String> s) {}
+ {
+ foo(<error descr="Inconvertible types; cannot cast 'java.util.Set<java.lang.Object>' to 'java.util.Set<java.lang.String>'">(Set<String>)Collections.emptySet()</error>);
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/Variance.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/Variance.java
index a52f648..229e01d 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/Variance.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/Variance.java
@@ -39,7 +39,7 @@
k[0] = new VarianceTesting();
x.method()[0] = new VarianceTesting();
<error descr="Incompatible types. Found: 'VarianceTesting[]', required: 'capture<? extends VarianceTesting>[]'">x.arrayField = new VarianceTesting[10]</error>;
- l1.addAll<error descr="'addAll(java.util.Collection<? extends capture<? extends VarianceTesting>>)' in 'java.util.List' cannot be applied to '(java.util.ArrayList<VarianceTesting>)'">(new ArrayList<VarianceTesting>())</error>;
+ l1.addAll<error descr="'addAll(java.util.Collection<capture<? extends VarianceTesting>>)' in 'java.util.List' cannot be applied to '(java.util.ArrayList<VarianceTesting>)'">(new ArrayList<VarianceTesting>())</error>;
<error descr="Incompatible types. Found: 'java.util.ArrayList<java.lang.String>', required: 'java.util.List<? extends VarianceTesting>'">List<? extends VarianceTesting> l2 = new ArrayList<String>();</error>
List<? extends VarianceTesting> l3 = l2;
VarianceTesting t = l1.get(0);
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/SOEDuringInferenceFromParamBounds.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/SOEDuringInferenceFromParamBounds.java
index fe71e04..6d00eb3 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/SOEDuringInferenceFromParamBounds.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/SOEDuringInferenceFromParamBounds.java
@@ -3,5 +3,5 @@
public class SOE {
public static <K extends M, M extends Map<K,M>> M foo() {return null;}
- public static <K1 extends M1, M1 extends Map<K1,M1>> Map<K1, M1> foo1() {return foo();}
+ public static <K1 extends M1, M1 extends Map<K1,M1>> Map<K1, M1> foo1() {return <error descr="Inferred type 'java.util.Map<K1,M1>' for type parameter 'M' is not within its bound; should implement 'java.util.Map<K1,java.util.Map<K1,M1>>'">foo()</error>;}
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/CastInContexts.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/CastInContexts.java
index 1f577f8..b9d5d4b 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/CastInContexts.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/CastInContexts.java
@@ -22,6 +22,6 @@
}
{
- int i = <error descr="Inconvertible types; cannot cast '<lambda expression>' to 'int'">(int) ()-> 1</error>;
+ int i = (int) <error descr="int is not a functional interface">()-> 1</error>;
}
}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/FunctionalInterfaceAnnotation.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/FunctionalInterfaceAnnotation.java
index 05b2585..379e586 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/FunctionalInterfaceAnnotation.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/FunctionalInterfaceAnnotation.java
@@ -1,4 +1,4 @@
-<error descr="Multiple non-overriding abstract methods found">@FunctionalInterface</error>
+<warning descr="Multiple non-overriding abstract methods found">@FunctionalInterface</warning>
interface Test {
void foo();
void bar();
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/FunctionalInterfaceCheck.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/FunctionalInterfaceCheck.java
new file mode 100644
index 0000000..74537d4
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/FunctionalInterfaceCheck.java
@@ -0,0 +1,5 @@
+class Demo {
+ public static void main(String[] args) {
+ Runnable r = () -> <error descr="void is not a functional interface">() -> () -> {}</error>;
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/NoInferenceResult.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/NoInferenceResult.java
index b0656f5..7af6276 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/NoInferenceResult.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/NoInferenceResult.java
@@ -16,7 +16,7 @@
void test() {
m((String s1) -> <error descr="Target type of a lambda conversion must be an interface">(String s2) -> s1 + s2</error>);
- m(<error descr="Incompatible return type <lambda expression> in lambda expression">(String s1) -> {return (String s2) -> s1 + s2;}</error>);
+ m((String s1) -> {return <error descr="Target type of a lambda conversion must be an interface">(String s2) -> s1 + s2</error>;});
m((String s1) -> s1.length());
m((String s1) -> s1);
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/ReturnValue.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/ReturnValue.java
index 39ba57f..e23d2c7 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/ReturnValue.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/ReturnValue.java
@@ -48,7 +48,7 @@
}
{
- X<?> x = <error descr="No instance of type X<?> exists so that lambda expression can be type-checked">() -> 123</error>;
+ X<?> x = () -> 123;
X<? extends Number> x1 = () -> 123;
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/Underscores.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/Underscores.java
new file mode 100644
index 0000000..2d89ec3
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/Underscores.java
@@ -0,0 +1,16 @@
+class C {
+ void test() {
+ {
+ I <warning descr="Use of '_' as an identifier might not be supported in releases after Java 8">_</warning> = new I() { public void f(int i) { } };
+ accept(_);
+ }
+
+ {
+ accept(<error descr="Use of '_' as a lambda parameter name is not allowed">_</error> -> System.out.println(_));
+ accept((int <error descr="Use of '_' as a lambda parameter name is not allowed">_</error>) -> System.out.println(_));
+ }
+ }
+
+ interface I { void f(int i); }
+ void accept(I i) { i.f(42); }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createGetterOrSetter/afterCreateGetter.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createGetterOrSetter/afterCreateGetter.java
index 562b31c..ed7fe97 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createGetterOrSetter/afterCreateGetter.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createGetterOrSetter/afterCreateGetter.java
@@ -2,7 +2,7 @@
class A {
private String s;
- String getS() {
+ public String getS() {
return s;
}
}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createGetterOrSetter/afterCreateGetterAndSetter.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createGetterOrSetter/afterCreateGetterAndSetter.java
index a9b0739..3f55db3 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createGetterOrSetter/afterCreateGetterAndSetter.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createGetterOrSetter/afterCreateGetterAndSetter.java
@@ -2,11 +2,11 @@
class A {
private String s;
- String getS() {
+ public String getS() {
return s;
}
- void setS(String s) {
+ public void setS(String s) {
this.s = s;
}
}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createGetterOrSetter/afterCreateSetter.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createGetterOrSetter/afterCreateSetter.java
index 8be2cc6..e4be440 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createGetterOrSetter/afterCreateSetter.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createGetterOrSetter/afterCreateSetter.java
@@ -2,7 +2,7 @@
class A {
private String s;
- void setS(String s) {
+ public void setS(String s) {
this.s = s;
}
}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createGetterOrSetter/afterGetterForEnumField.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createGetterOrSetter/afterGetterForEnumField.java
index fbd6e4e..c7348b4 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createGetterOrSetter/afterGetterForEnumField.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createGetterOrSetter/afterGetterForEnumField.java
@@ -7,7 +7,7 @@
this._i = _i;
}
- private int get_i() {
+ public int get_i() {
return _i;
}
}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createGetterOrSetter/afterGetterOverride.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createGetterOrSetter/afterGetterOverride.java
new file mode 100644
index 0000000..34f84b4
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createGetterOrSetter/afterGetterOverride.java
@@ -0,0 +1,13 @@
+// "Create getter for 's'" "true"
+public class A extends Parent{
+ private String s;
+
+ @Override
+ public String getS() {
+ return s;
+ }
+}
+
+class Parent {
+ public String getS() {}
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createGetterOrSetter/beforeGetterOverride.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createGetterOrSetter/beforeGetterOverride.java
new file mode 100644
index 0000000..fa0b827
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createGetterOrSetter/beforeGetterOverride.java
@@ -0,0 +1,8 @@
+// "Create getter for 's'" "true"
+public class A extends Parent{
+ private String <caret>s;
+}
+
+class Parent {
+ public String getS() {}
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createPropertyFromUsage/afterFieldExist.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createPropertyFromUsage/afterFieldExist.java
index f20329a..e9baac3 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createPropertyFromUsage/afterFieldExist.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createPropertyFromUsage/afterFieldExist.java
@@ -6,7 +6,7 @@
setI(0);
}
- void setI(int i) {
+ public void setI(int i) {
this.i = i;
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createPropertyFromUsage/afterSimple.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createPropertyFromUsage/afterSimple.java
index 69c33eb..b28d93d 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createPropertyFromUsage/afterSimple.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createPropertyFromUsage/afterSimple.java
@@ -6,7 +6,7 @@
setI(0);
}
- void setI(int i) {
+ public void setI(int i) {
this.i = i;
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/moveFieldAssignmentToInitializer/beforeExprList.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/moveFieldAssignmentToInitializer/beforeExprList.java
new file mode 100644
index 0000000..9ff057b
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/moveFieldAssignmentToInitializer/beforeExprList.java
@@ -0,0 +1,10 @@
+// "Move assignment to field declaration" "false"
+class Wtf {
+ int myWtf;
+
+ void whatever() {
+ <caret>myWtf = Math,max(myWtf, getWtf());
+ }
+
+ int getWtf() { return 42; }
+}
diff --git a/java/java-tests/testData/codeInsight/generateConstructor/afterFieldPrefixCoincidence.java b/java/java-tests/testData/codeInsight/generateConstructor/afterFieldPrefixCoincidence.java
new file mode 100644
index 0000000..9ae5a0b
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/generateConstructor/afterFieldPrefixCoincidence.java
@@ -0,0 +1,8 @@
+class Parent {
+ Object menu;
+
+ Parent(Object menu) {
+ this.menu = menu;
+ }
+}
+
diff --git a/java/java-tests/testData/codeInsight/generateConstructor/beforeFieldPrefixCoincidence.java b/java/java-tests/testData/codeInsight/generateConstructor/beforeFieldPrefixCoincidence.java
new file mode 100644
index 0000000..e1a589c
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/generateConstructor/beforeFieldPrefixCoincidence.java
@@ -0,0 +1,5 @@
+class Parent {
+ Object menu;
+<caret>
+}
+
diff --git a/java/java-tests/testData/fileStructure/filtering/Matcher.java b/java/java-tests/testData/fileStructure/filtering/Matcher.java
new file mode 100644
index 0000000..a72f29d
--- /dev/null
+++ b/java/java-tests/testData/fileStructure/filtering/Matcher.java
@@ -0,0 +1,5 @@
+interface Matcher<caret> {
+ void _dispatchThread();
+ void __DispatchThread();
+ void dispatchThread();
+}
diff --git a/java/java-tests/testData/fileStructure/filtering/Matcher.tree b/java/java-tests/testData/fileStructure/filtering/Matcher.tree
new file mode 100644
index 0000000..38e43df
--- /dev/null
+++ b/java/java-tests/testData/fileStructure/filtering/Matcher.tree
@@ -0,0 +1,5 @@
+-Matcher.java
+ -Matcher
+ __DispatchThread(): void
+ _dispatchThread(): void
+ [dispatchThread(): void]
\ No newline at end of file
diff --git a/java/java-tests/testData/fileStructure/filtering/Matcher1.tree b/java/java-tests/testData/fileStructure/filtering/Matcher1.tree
index 0ec3613..468f244 100644
--- a/java/java-tests/testData/fileStructure/filtering/Matcher1.tree
+++ b/java/java-tests/testData/fileStructure/filtering/Matcher1.tree
@@ -1,3 +1,4 @@
-Matcher1.java
-Matcher1
[getIcon(): void]
+ isControlDown(): void
\ No newline at end of file
diff --git a/java/java-tests/testData/fileStructure/filtering/Matcher2.tree b/java/java-tests/testData/fileStructure/filtering/Matcher2.tree
index b2acfe7..d8ca13c 100644
--- a/java/java-tests/testData/fileStructure/filtering/Matcher2.tree
+++ b/java/java-tests/testData/fileStructure/filtering/Matcher2.tree
@@ -1,7 +1,10 @@
-Matcher2.java
-Matcher2
getIcon(): void
+ isControlDown(): void
-A
getIcon(): Icon
+ isCoin(): boolean
-B
[getIcon(): Icon]
+ isCoin(): boolean
\ No newline at end of file
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/BoxingImpliesNotNull.java b/java/java-tests/testData/inspection/dataFlow/fixture/BoxingImpliesNotNull.java
new file mode 100644
index 0000000..c19581f
--- /dev/null
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/BoxingImpliesNotNull.java
@@ -0,0 +1,14 @@
+import org.jetbrains.annotations.Nullable;
+
+class Baz {
+ Integer bar() { return 2; }
+
+ void g() {
+ @Nullable Integer foo = bar();
+ if (foo == null) {
+ foo = 0;
+ }
+ System.out.println(foo.intValue());
+ }
+
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/ContractAnnotation.java b/java/java-tests/testData/inspection/dataFlow/fixture/ContractAnnotation.java
new file mode 100644
index 0000000..f86d797
--- /dev/null
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/ContractAnnotation.java
@@ -0,0 +1,35 @@
+import org.jetbrains.annotations.Contract;
+import org.jetbrains.annotations.Nullable;
+
+import java.lang.*;
+import java.lang.AssertionError;
+import java.lang.IllegalArgumentException;
+
+public class AssertIsNotNull {
+ void bar(String s) {
+ if (<warning descr="Condition 's == null && trimIfNotNull(s) != null' is always 'false'">s == null && <warning descr="Condition 'trimIfNotNull(s) != null' is always 'false' when reached">trimIfNotNull(s) != null</warning></warning>) {
+ throw new AssertionError();
+ }
+
+ final Object o = call();
+ assertIsNotNull(o);
+ if(<warning descr="Condition 'o == null' is always 'false'">o == null</warning>) {}
+ }
+
+ @Contract("null -> fail")
+ static void assertIsNotNull(Object o) {
+ if (o == null) {
+ throw new IllegalArgumentException();
+ }
+ }
+
+ @Contract("null -> null; !null -> !null")
+ @Nullable static String trimIfNotNull(@Nullable String s) {
+ if (s == null) {
+ return null;
+ }
+ return s.trim();
+ }
+
+ Object call() {return new Object();}
+}
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/LargeIntegersAreNotEqualWhenBoxed.java b/java/java-tests/testData/inspection/dataFlow/fixture/LargeIntegersAreNotEqualWhenBoxed.java
new file mode 100644
index 0000000..64e270c
--- /dev/null
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/LargeIntegersAreNotEqualWhenBoxed.java
@@ -0,0 +1,7 @@
+class X {
+ public static void main(String[] args) {
+ int primitive = 1024;
+ Object object = primitive;
+ System.out.println(primitive == object);
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/NoGenericCCE.java b/java/java-tests/testData/inspection/dataFlow/fixture/NoGenericCCE.java
new file mode 100644
index 0000000..edb3bdc
--- /dev/null
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/NoGenericCCE.java
@@ -0,0 +1,8 @@
+import java.util.ArrayList;
+
+class X {
+ public static void main(String[] args) {
+ Object list = new ArrayList<>();
+ ArrayList<String> list1 = (ArrayList<String>) list;
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/ReportConstantReferences.java b/java/java-tests/testData/inspection/dataFlow/fixture/ReportConstantReferences.java
new file mode 100644
index 0000000..18849f5
--- /dev/null
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/ReportConstantReferences.java
@@ -0,0 +1,19 @@
+import org.jetbrains.annotations.NotNull;
+
+class Test {
+ private void test2(@NotNull Object bar) {
+
+ }
+ private Object test(Object foo, Object bar) {
+ if (foo == null) {
+ System.out.println(<warning descr="Value 'foo' is always 'null'"><caret>foo</warning>);
+ System.out.println(<warning descr="Value 'foo' is always 'null'">foo</warning>);
+ return <warning descr="Expression 'foo' might evaluate to null but is returned by the method which isn't declared as @Nullable">foo</warning>;
+ }
+ if (bar == null) {
+ test2(<warning descr="Argument 'bar' might be null">bar</warning>);
+ }
+ return foo;
+ }
+
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/ReportConstantReferences_NotInComplexAssignment.java b/java/java-tests/testData/inspection/dataFlow/fixture/ReportConstantReferences_NotInComplexAssignment.java
new file mode 100644
index 0000000..a13f0f1
--- /dev/null
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/ReportConstantReferences_NotInComplexAssignment.java
@@ -0,0 +1,6 @@
+class Test {
+ void foo() {
+ int x = 42;
+ <caret>x += 100;
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/ReportConstantReferences_ReplaceWithEnum.java b/java/java-tests/testData/inspection/dataFlow/fixture/ReportConstantReferences_ReplaceWithEnum.java
new file mode 100644
index 0000000..2ed16ce
--- /dev/null
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/ReportConstantReferences_ReplaceWithEnum.java
@@ -0,0 +1,7 @@
+class Test {
+ private void test() {
+ foo.MyEnum s = foo.MyEnum.FOO;
+ System.out.println(<caret><warning descr="Value 's' is always 'FOO'">s</warning>);
+ }
+
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/ReportConstantReferences_ReplaceWithEnum_after.java b/java/java-tests/testData/inspection/dataFlow/fixture/ReportConstantReferences_ReplaceWithEnum_after.java
new file mode 100644
index 0000000..29552fa
--- /dev/null
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/ReportConstantReferences_ReplaceWithEnum_after.java
@@ -0,0 +1,9 @@
+import foo.MyEnum;
+
+class Test {
+ private void test() {
+ foo.MyEnum s = foo.MyEnum.FOO;
+ System.out.println(MyEnum.FOO);
+ }
+
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/ReportConstantReferences_ReplaceWithIntConstant.java b/java/java-tests/testData/inspection/dataFlow/fixture/ReportConstantReferences_ReplaceWithIntConstant.java
new file mode 100644
index 0000000..5388bcd
--- /dev/null
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/ReportConstantReferences_ReplaceWithIntConstant.java
@@ -0,0 +1,10 @@
+class Test {
+ public static final int CONST = 23942;
+ private void test(int a) {
+ if (a == CONST) {
+ System.out.println(<caret><warning descr="Value 'a' is always 'CONST'">a</warning>);
+ }
+
+ }
+
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/ReportConstantReferences_ReplaceWithIntConstant_after.java b/java/java-tests/testData/inspection/dataFlow/fixture/ReportConstantReferences_ReplaceWithIntConstant_after.java
new file mode 100644
index 0000000..11feed5
--- /dev/null
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/ReportConstantReferences_ReplaceWithIntConstant_after.java
@@ -0,0 +1,10 @@
+class Test {
+ public static final int CONST = 23942;
+ private void test(int a) {
+ if (a == CONST) {
+ System.out.println(<caret>CONST);
+ }
+
+ }
+
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/ReportConstantReferences_ReplaceWithString.java b/java/java-tests/testData/inspection/dataFlow/fixture/ReportConstantReferences_ReplaceWithString.java
new file mode 100644
index 0000000..fcff484
--- /dev/null
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/ReportConstantReferences_ReplaceWithString.java
@@ -0,0 +1,8 @@
+class Test {
+ public static final String CONST = "foo bar";
+ private void test() {
+ String s = CONST;
+ System.out.println(<caret><warning descr="Value 's' is always 'CONST'">s</warning>);
+ }
+
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/ReportConstantReferences_ReplaceWithString_after.java b/java/java-tests/testData/inspection/dataFlow/fixture/ReportConstantReferences_ReplaceWithString_after.java
new file mode 100644
index 0000000..a462170
--- /dev/null
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/ReportConstantReferences_ReplaceWithString_after.java
@@ -0,0 +1,8 @@
+class Test {
+ public static final String CONST = "foo bar";
+ private void test() {
+ String s = CONST;
+ System.out.println(CONST);
+ }
+
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/ReportConstantReferences_Switch.java b/java/java-tests/testData/inspection/dataFlow/fixture/ReportConstantReferences_Switch.java
new file mode 100644
index 0000000..e48dc19
--- /dev/null
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/ReportConstantReferences_Switch.java
@@ -0,0 +1,22 @@
+class Test {
+ private void test() {
+ int state = 1;
+ switch (<warning descr="Value 'state' is always '1'">state</warning>) {
+ case 1: break;
+ }
+ }
+
+ private void test2(int state) {
+ switch (state) {
+ case ONE:
+ case TWO:
+ if (state == TWO) {
+ System.out.println("hello");
+ }
+ }
+ }
+
+ public static final int ONE = 1;
+ public static final int TWO = 2;
+
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/ReportConstantReferences_after.java b/java/java-tests/testData/inspection/dataFlow/fixture/ReportConstantReferences_after.java
new file mode 100644
index 0000000..feb147c
--- /dev/null
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/ReportConstantReferences_after.java
@@ -0,0 +1,19 @@
+import org.jetbrains.annotations.NotNull;
+
+class Test {
+ private void test2(@NotNull Object bar) {
+
+ }
+ private Object test(Object foo, Object bar) {
+ if (foo == null) {
+ System.out.println(<caret>null);
+ System.out.println(foo);
+ return foo;
+ }
+ if (bar == null) {
+ test2(bar);
+ }
+ return foo;
+ }
+
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/ThrowNull.java b/java/java-tests/testData/inspection/dataFlow/fixture/ThrowNull.java
new file mode 100644
index 0000000..e35aa2f
--- /dev/null
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/ThrowNull.java
@@ -0,0 +1,13 @@
+public class DataFlowBug {
+
+ public void add2() {
+ try {
+ throw null;
+ } catch (Throwable e) {
+ if (e instanceof NullPointerException) {
+ return;
+ }
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/inspection/redundantCast/generics/CaseThrowable/expected.xml b/java/java-tests/testData/inspection/redundantCast/generics/CaseThrowable/expected.xml
new file mode 100644
index 0000000..cef9cae
--- /dev/null
+++ b/java/java-tests/testData/inspection/redundantCast/generics/CaseThrowable/expected.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<problems>
+ <problem>
+ <file>Test.java</file>
+ <line>7</line>
+ <description>Casting <code>e</code> to <code>Ex</code> is redundant</description>
+ </problem>
+ <problem>
+ <file>Test.java</file>
+ <line>3</line>
+ <description>Casting <code>e</code> to <code>FileNotFoundEx</code> is redundant</description>
+ </problem>
+</problems>
diff --git a/java/java-tests/testData/inspection/redundantCast/generics/CaseThrowable/src/Test.java b/java/java-tests/testData/inspection/redundantCast/generics/CaseThrowable/src/Test.java
new file mode 100644
index 0000000..a260d3c
--- /dev/null
+++ b/java/java-tests/testData/inspection/redundantCast/generics/CaseThrowable/src/Test.java
@@ -0,0 +1,13 @@
+public class RedundantCast{
+ void m(IOEx e) throws IOEx {
+ throw (FileNotFoundEx)e;
+ }
+
+ void foo(RuntimeException e) {
+ throw (Ex)e;
+ }
+
+ static class Ex extends RuntimeException {}
+ static class IOEx extends Exception {}
+ static class FileNotFoundEx extends Exception {}
+}
diff --git a/java/java-tests/testData/inspection/redundantCast/generics/ForEachValue/expected.xml b/java/java-tests/testData/inspection/redundantCast/generics/ForEachValue/expected.xml
new file mode 100644
index 0000000..70d6f73
--- /dev/null
+++ b/java/java-tests/testData/inspection/redundantCast/generics/ForEachValue/expected.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<problems>
+ <problem>
+ <file>Test.java</file>
+ <line>7</line>
+ <description>Casting <code>list</code> to <code>ArrayList<String></code> is redundant</description>
+ </problem>
+</problems>
diff --git a/java/java-tests/testData/inspection/redundantCast/generics/ForEachValue/src/Test.java b/java/java-tests/testData/inspection/redundantCast/generics/ForEachValue/src/Test.java
new file mode 100644
index 0000000..db0b7d1
--- /dev/null
+++ b/java/java-tests/testData/inspection/redundantCast/generics/ForEachValue/src/Test.java
@@ -0,0 +1,12 @@
+import java.util.ArrayList;
+import java.util.List;
+
+public class RedundantCast {
+ void redundantCasts() {
+ List<String> list = new ArrayList<>();
+ for (String s : (ArrayList<String>) list) {}
+
+ Object o = new ArrayList<>();
+ for (String s : (ArrayList<String>) o) {}
+ }
+}
diff --git a/java/java-tests/testData/inspection/redundantCast/generics/InstanceOfChecks/expected.xml b/java/java-tests/testData/inspection/redundantCast/generics/InstanceOfChecks/expected.xml
new file mode 100644
index 0000000..bb05b01
--- /dev/null
+++ b/java/java-tests/testData/inspection/redundantCast/generics/InstanceOfChecks/expected.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<problems>
+ <problem>
+ <file>Test.java</file>
+ <line>8</line>
+ <description>Casting <code>o</code> to <code>List</code> is redundant</description>
+ </problem>
+</problems>
diff --git a/java/java-tests/testData/inspection/redundantCast/generics/InstanceOfChecks/src/Test.java b/java/java-tests/testData/inspection/redundantCast/generics/InstanceOfChecks/src/Test.java
new file mode 100644
index 0000000..06750c3
--- /dev/null
+++ b/java/java-tests/testData/inspection/redundantCast/generics/InstanceOfChecks/src/Test.java
@@ -0,0 +1,10 @@
+import java.util.ArrayList;
+import java.util.List;
+
+public class RedundantCast {
+ boolean redundantCasts(Object o) {
+ int p = 0;
+ if ((Number)p instanceof Integer) {}
+ return (List)o instanceof ArrayList;
+ }
+}
diff --git a/java/java-tests/testData/inspection/testOnly/constructor/expected.xml b/java/java-tests/testData/inspection/testOnly/constructor/expected.xml
new file mode 100644
index 0000000..6845ecd
--- /dev/null
+++ b/java/java-tests/testData/inspection/testOnly/constructor/expected.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<problems>
+<problem>
+ <file>B.java</file>
+ <line>5</line>
+ <method>
+ <name>A()</name>
+ <display_name>A()</display_name>
+ <package><default></package>
+ <class>
+ <name>A</name>
+ <display_name>A</display_name>
+ </class>
+ </method>
+ <description>Test-only method is called in production code</description>
+</problem>
+</problems>
diff --git a/java/java-tests/testData/inspection/testOnly/constructor/src/A.java b/java/java-tests/testData/inspection/testOnly/constructor/src/A.java
new file mode 100644
index 0000000..e96e056
--- /dev/null
+++ b/java/java-tests/testData/inspection/testOnly/constructor/src/A.java
@@ -0,0 +1,6 @@
+public class A {
+ @org.jetbrains.annotations.TestOnly
+ public A() {}
+
+ public A(String ignore) {}
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/inspection/testOnly/constructor/src/B.java b/java/java-tests/testData/inspection/testOnly/constructor/src/B.java
new file mode 100644
index 0000000..277a4cd
--- /dev/null
+++ b/java/java-tests/testData/inspection/testOnly/constructor/src/B.java
@@ -0,0 +1,8 @@
+import org.jetbrains.annotations.TestOnly;
+
+public class B {
+ public void foo() {
+ new A();
+ new A("ignore");
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/inspection/testOnly/insideInner/expected.xml b/java/java-tests/testData/inspection/testOnly/insideInner/expected.xml
new file mode 100644
index 0000000..d4d91ff
--- /dev/null
+++ b/java/java-tests/testData/inspection/testOnly/insideInner/expected.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<problems>
+<problem>
+ <file>A.java</file>
+ <line>17</line>
+ <method>
+ <name>void production()</name>
+ <display_name>production()</display_name>
+ <package><default></package>
+ <class>
+ <name>A</name>
+ <display_name>A</display_name>
+ </class>
+ </method>
+ <description>Test-only method is called in production code</description>
+</problem>
+</problems>
+
diff --git a/java/java-tests/testData/inspection/testOnly/insideInner/src/A.java b/java/java-tests/testData/inspection/testOnly/insideInner/src/A.java
new file mode 100644
index 0000000..5c3cd06
--- /dev/null
+++ b/java/java-tests/testData/inspection/testOnly/insideInner/src/A.java
@@ -0,0 +1,21 @@
+public class A {
+ @org.jetbrains.annotations.TestOnly
+ public void foo() {}
+
+ @org.jetbrains.annotations.TestOnly
+ public void test() {
+ new Runnable() {
+ public void run() {
+ foo();
+ }
+ };
+ }
+
+ public void production() {
+ new Runnable() {
+ public void run() {
+ foo();
+ }
+ };
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/inspection/testOnly/insideInner/src/C.java b/java/java-tests/testData/inspection/testOnly/insideInner/src/C.java
new file mode 100644
index 0000000..f7a8195
--- /dev/null
+++ b/java/java-tests/testData/inspection/testOnly/insideInner/src/C.java
@@ -0,0 +1,10 @@
+public class C {
+ @org.junit.Test
+ public void foo() {
+ new Runnable() {
+ public void run() {
+ new A().foo();
+ }
+ };
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/inspection/testOnly/insideInner/test/D.java b/java/java-tests/testData/inspection/testOnly/insideInner/test/D.java
new file mode 100644
index 0000000..85262a0
--- /dev/null
+++ b/java/java-tests/testData/inspection/testOnly/insideInner/test/D.java
@@ -0,0 +1,11 @@
+import org.jetbrains.annotations.TestOnly;
+
+public class D {
+ public void test() {
+ new Runnable() {
+ public void run() {
+ new A().foo();
+ }
+ };
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/inspection/testOnly/simple/expected.xml b/java/java-tests/testData/inspection/testOnly/simple/expected.xml
new file mode 100644
index 0000000..e58ea40
--- /dev/null
+++ b/java/java-tests/testData/inspection/testOnly/simple/expected.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<problems>
+<problem>
+ <file>A.java</file>
+ <line>6</line>
+ <method>
+ <name>void production()</name>
+ <display_name>production()</display_name>
+ <package><default></package>
+ <class>
+ <name>A</name>
+ <display_name>A</display_name>
+ </class>
+ </method>
+ <description>Test-only method is called in production code</description>
+</problem>
+
+<problem>
+ <file>B.java</file>
+ <line>3</line>
+ <method>
+ <name>void production()</name>
+ <display_name>production()</display_name>
+ <package><default></package>
+ <class>
+ <name>B</name>
+ <display_name>B</display_name>
+ </class>
+ </method>
+ <description>Test-only method is called in production code</description>
+</problem>
+</problems>
+
diff --git a/java/java-tests/testData/inspection/testOnly/simple/src/A.java b/java/java-tests/testData/inspection/testOnly/simple/src/A.java
new file mode 100644
index 0000000..3a35d40
--- /dev/null
+++ b/java/java-tests/testData/inspection/testOnly/simple/src/A.java
@@ -0,0 +1,8 @@
+public class A {
+ @org.jetbrains.annotations.TestOnly
+ public void test() {}
+
+ public void production() {
+ test();
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/inspection/testOnly/simple/src/B.java b/java/java-tests/testData/inspection/testOnly/simple/src/B.java
new file mode 100644
index 0000000..18096db
--- /dev/null
+++ b/java/java-tests/testData/inspection/testOnly/simple/src/B.java
@@ -0,0 +1,10 @@
+public class B {
+ public void production() {
+ new A().test();
+ }
+
+ @org.jetbrains.annotations.TestOnly
+ public void test() {
+ new A().test();
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/inspection/testOnly/simple/src/C.java b/java/java-tests/testData/inspection/testOnly/simple/src/C.java
new file mode 100644
index 0000000..f61a252
--- /dev/null
+++ b/java/java-tests/testData/inspection/testOnly/simple/src/C.java
@@ -0,0 +1,6 @@
+public class C {
+ @org.junit.Test
+ public void foo() {
+ new A().test();
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/inspection/testOnly/simple/test/D.java b/java/java-tests/testData/inspection/testOnly/simple/test/D.java
new file mode 100644
index 0000000..bb6fc91
--- /dev/null
+++ b/java/java-tests/testData/inspection/testOnly/simple/test/D.java
@@ -0,0 +1,7 @@
+import org.jetbrains.annotations.TestOnly;
+
+public class D {
+ public void foo() {
+ new A().test();
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/inspection/testOnly/unresolved/expected.xml b/java/java-tests/testData/inspection/testOnly/unresolved/expected.xml
new file mode 100644
index 0000000..4704d91
--- /dev/null
+++ b/java/java-tests/testData/inspection/testOnly/unresolved/expected.xml
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<problems/>
\ No newline at end of file
diff --git a/java/java-tests/testData/inspection/testOnly/unresolved/src/A.java b/java/java-tests/testData/inspection/testOnly/unresolved/src/A.java
new file mode 100644
index 0000000..99d3407
--- /dev/null
+++ b/java/java-tests/testData/inspection/testOnly/unresolved/src/A.java
@@ -0,0 +1,7 @@
+import org.jetbrains.annotations.TestOnly;
+
+public class A {
+ public void foo() {
+ unresolved();
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/inspection/testOnly/visibleForTesting/expected.xml b/java/java-tests/testData/inspection/testOnly/visibleForTesting/expected.xml
new file mode 100644
index 0000000..ea1f693
--- /dev/null
+++ b/java/java-tests/testData/inspection/testOnly/visibleForTesting/expected.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<problems>
+ <problem>
+ <file>B.java</file>
+ <line>3</line>
+ <description>Test-only method is called in production code</description>
+ </problem>
+</problems>
diff --git a/java/java-tests/testData/inspection/testOnly/visibleForTesting/src/A.java b/java/java-tests/testData/inspection/testOnly/visibleForTesting/src/A.java
new file mode 100644
index 0000000..c88fa9e
--- /dev/null
+++ b/java/java-tests/testData/inspection/testOnly/visibleForTesting/src/A.java
@@ -0,0 +1,16 @@
+public class A {
+ void publicMethod() {
+ invisibleMethod(1);
+ visibleMethod(1);
+ }
+
+ @com.google.common.annotations.VisibleForTesting()
+ void invisibleMethod(int a) {
+
+ }
+
+ @com.google.common.annotations.VisibleForTesting(visibility=com.google.common.annotations.VisibleForTesting.Visibility.PROTECTED)
+ void visibleMethod(int a) {
+
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/inspection/testOnly/visibleForTesting/src/B.java b/java/java-tests/testData/inspection/testOnly/visibleForTesting/src/B.java
new file mode 100644
index 0000000..ec069c8
--- /dev/null
+++ b/java/java-tests/testData/inspection/testOnly/visibleForTesting/src/B.java
@@ -0,0 +1,6 @@
+public class B {
+ void publicMethod() {
+ new A().invisibleMethod(2);
+ new A().visibleMethod(2);
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/inspection/testOnly/visibleForTesting/src/com/google/common/annotations/VisibleForTesting.java b/java/java-tests/testData/inspection/testOnly/visibleForTesting/src/com/google/common/annotations/VisibleForTesting.java
new file mode 100644
index 0000000..50a1589
--- /dev/null
+++ b/java/java-tests/testData/inspection/testOnly/visibleForTesting/src/com/google/common/annotations/VisibleForTesting.java
@@ -0,0 +1,14 @@
+package com.google.common.annotations;
+
+public @interface VisibleForTesting {
+ enum Visibility {
+ /** The element should be considered protected. */
+ PROTECTED,
+ /** The element should be considered package-private. */
+ PACKAGE,
+ /** The element should be considered private. */
+ PRIVATE
+ }
+
+ Visibility visibility() default Visibility.PRIVATE;
+}
diff --git a/java/java-tests/testData/inspection/testOnly/visibleForTesting/test/Test.java b/java/java-tests/testData/inspection/testOnly/visibleForTesting/test/Test.java
new file mode 100644
index 0000000..0ad7385
--- /dev/null
+++ b/java/java-tests/testData/inspection/testOnly/visibleForTesting/test/Test.java
@@ -0,0 +1,6 @@
+public class Test {
+ void publicMethod() {
+ new A().invisibleMethod(3);
+ new A().visibleMethod(3);
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/junit/configurations/commonConfiguration/apackage/SampleClass.java b/java/java-tests/testData/junit/configurations/commonConfiguration/apackage/SampleClass.java
new file mode 100644
index 0000000..e849e2b
--- /dev/null
+++ b/java/java-tests/testData/junit/configurations/commonConfiguration/apackage/SampleClass.java
@@ -0,0 +1,9 @@
+package apackage;
+
+import junit.framework.TestCase;
+
+public class SampleClass extends TestCase {
+ public void test1() {}
+
+ public static void main(String[] args){ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/junit/configurations/mock JUnit/junit/framework/TestCase.class b/java/java-tests/testData/junit/configurations/mock JUnit/junit/framework/TestCase.class
new file mode 100644
index 0000000..bdd44ce
--- /dev/null
+++ b/java/java-tests/testData/junit/configurations/mock JUnit/junit/framework/TestCase.class
Binary files differ
diff --git a/java/java-tests/testData/junit/configurations/mock JUnit/junit/framework/TestCase.java b/java/java-tests/testData/junit/configurations/mock JUnit/junit/framework/TestCase.java
new file mode 100644
index 0000000..eaa745c
--- /dev/null
+++ b/java/java-tests/testData/junit/configurations/mock JUnit/junit/framework/TestCase.java
@@ -0,0 +1,2 @@
+package junit.framework;
+public class TestCase {}
diff --git a/java/java-tests/testData/junit/configurations/mock JUnit/junit/framework/ThirdPartyClass.class b/java/java-tests/testData/junit/configurations/mock JUnit/junit/framework/ThirdPartyClass.class
new file mode 100644
index 0000000..1c51d38
--- /dev/null
+++ b/java/java-tests/testData/junit/configurations/mock JUnit/junit/framework/ThirdPartyClass.class
Binary files differ
diff --git a/java/java-tests/testData/junit/configurations/mock JUnit/junit/framework/ThirdPartyClass.java b/java/java-tests/testData/junit/configurations/mock JUnit/junit/framework/ThirdPartyClass.java
new file mode 100644
index 0000000..d4f54aa
--- /dev/null
+++ b/java/java-tests/testData/junit/configurations/mock JUnit/junit/framework/ThirdPartyClass.java
@@ -0,0 +1,2 @@
+package junit.framework;
+public class ThirdPartyClass extends TestCase {}
diff --git a/java/java-tests/testData/junit/configurations/module1/noTests/keep.dir b/java/java-tests/testData/junit/configurations/module1/noTests/keep.dir
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/java/java-tests/testData/junit/configurations/module1/noTests/keep.dir
diff --git a/java/java-tests/testData/junit/configurations/module1/test1/DerivedTest.java b/java/java-tests/testData/junit/configurations/module1/test1/DerivedTest.java
new file mode 100644
index 0000000..4669cc0
--- /dev/null
+++ b/java/java-tests/testData/junit/configurations/module1/test1/DerivedTest.java
@@ -0,0 +1,6 @@
+package test1;
+
+import junit.framework.ThirdPartyClass;
+
+public class DerivedTest extends ThirdPartyClass {
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/junit/configurations/module1/test1/InnerTest.java b/java/java-tests/testData/junit/configurations/module1/test1/InnerTest.java
new file mode 100644
index 0000000..c81e00c
--- /dev/null
+++ b/java/java-tests/testData/junit/configurations/module1/test1/InnerTest.java
@@ -0,0 +1,10 @@
+package test1;
+
+import junit.framework.TestCase;
+
+public class InnerTest {
+ public static class Inner extends TestCase {
+ public void test() {}
+ public static void main(String[] args) {}
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/junit/configurations/module1/test1/TestA.java b/java/java-tests/testData/junit/configurations/module1/test1/TestA.java
new file mode 100644
index 0000000..3f935be
--- /dev/null
+++ b/java/java-tests/testData/junit/configurations/module1/test1/TestA.java
@@ -0,0 +1,6 @@
+package test1;
+
+import junit.framework.TestCase;
+
+public class TestA extends TestCase {
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/junit/configurations/module1/test2/NotATest.java b/java/java-tests/testData/junit/configurations/module1/test2/NotATest.java
new file mode 100644
index 0000000..0095514
--- /dev/null
+++ b/java/java-tests/testData/junit/configurations/module1/test2/NotATest.java
@@ -0,0 +1,9 @@
+package test2;
+
+public class NotATest {
+ static class InnerApplication {
+ public static void main(String[] args) {
+
+ }
+ }
+}
diff --git a/java/java-tests/testData/junit/configurations/module2/noTests/keep.dir b/java/java-tests/testData/junit/configurations/module2/noTests/keep.dir
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/java/java-tests/testData/junit/configurations/module2/noTests/keep.dir
diff --git a/java/java-tests/testData/junit/configurations/module2/test1/TestA.java b/java/java-tests/testData/junit/configurations/module2/test1/TestA.java
new file mode 100644
index 0000000..3f935be
--- /dev/null
+++ b/java/java-tests/testData/junit/configurations/module2/test1/TestA.java
@@ -0,0 +1,6 @@
+package test1;
+
+import junit.framework.TestCase;
+
+public class TestA extends TestCase {
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/junit/configurations/module2/test2/Test2.java b/java/java-tests/testData/junit/configurations/module2/test2/Test2.java
new file mode 100644
index 0000000..dbb025b
--- /dev/null
+++ b/java/java-tests/testData/junit/configurations/module2/test2/Test2.java
@@ -0,0 +1,6 @@
+package test2;
+
+import junit.framework.TestCase;
+
+public class Test2 extends TestCase {
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/junit/configurations/module3/noTests/keep.dir b/java/java-tests/testData/junit/configurations/module3/noTests/keep.dir
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/java/java-tests/testData/junit/configurations/module3/noTests/keep.dir
diff --git a/java/java-tests/testData/junit/configurations/module3/test1/TestB.java b/java/java-tests/testData/junit/configurations/module3/test1/TestB.java
new file mode 100644
index 0000000..eab929e
--- /dev/null
+++ b/java/java-tests/testData/junit/configurations/module3/test1/TestB.java
@@ -0,0 +1,5 @@
+package test1;
+
+import junit.framework.TestCase;
+
+public class TestB extends TestCase {}
\ No newline at end of file
diff --git a/java/java-tests/testData/junit/configurations/module3/test2/NotATest2.java b/java/java-tests/testData/junit/configurations/module3/test2/NotATest2.java
new file mode 100644
index 0000000..d29b7c1
--- /dev/null
+++ b/java/java-tests/testData/junit/configurations/module3/test2/NotATest2.java
@@ -0,0 +1,3 @@
+package test2;
+
+public class NotATest2 {}
\ No newline at end of file
diff --git a/java/java-tests/testData/junit/configurations/module4/classes/keep.dir b/java/java-tests/testData/junit/configurations/module4/classes/keep.dir
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/java/java-tests/testData/junit/configurations/module4/classes/keep.dir
diff --git a/java/java-tests/testData/junit/configurations/module4/src/Application.java b/java/java-tests/testData/junit/configurations/module4/src/Application.java
new file mode 100644
index 0000000..19bdee8
--- /dev/null
+++ b/java/java-tests/testData/junit/configurations/module4/src/Application.java
@@ -0,0 +1,3 @@
+public class Application {
+ public static void main(String[] args){}
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/junit/configurations/module4/testClasses/keep.dir b/java/java-tests/testData/junit/configurations/module4/testClasses/keep.dir
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/java/java-tests/testData/junit/configurations/module4/testClasses/keep.dir
diff --git a/java/java-tests/testData/junit/configurations/module4/testSrc/TestApplication.java b/java/java-tests/testData/junit/configurations/module4/testSrc/TestApplication.java
new file mode 100644
index 0000000..3eae507
--- /dev/null
+++ b/java/java-tests/testData/junit/configurations/module4/testSrc/TestApplication.java
@@ -0,0 +1,6 @@
+import junit.framework.TestCase;
+
+public class TestApplication extends TestCase {
+ public void test() { }
+ public static void main(String[] args){ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/junit/configurations/module5/test1/Test5.java b/java/java-tests/testData/junit/configurations/module5/test1/Test5.java
new file mode 100644
index 0000000..1e6b71d
--- /dev/null
+++ b/java/java-tests/testData/junit/configurations/module5/test1/Test5.java
@@ -0,0 +1,7 @@
+package test1;
+
+import junit.framework.TestCase;
+
+public class Test5 extends TestCase {
+ public void test() {}
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/junit/configurations/outputs/general 1/keep.dir b/java/java-tests/testData/junit/configurations/outputs/general 1/keep.dir
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/java/java-tests/testData/junit/configurations/outputs/general 1/keep.dir
diff --git a/java/java-tests/testData/junit/configurations/outputs/general 2/keep.dir b/java/java-tests/testData/junit/configurations/outputs/general 2/keep.dir
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/java/java-tests/testData/junit/configurations/outputs/general 2/keep.dir
diff --git a/java/java-tests/testData/junit/configurations/outputs/general 3/keep.dir b/java/java-tests/testData/junit/configurations/outputs/general 3/keep.dir
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/java/java-tests/testData/junit/configurations/outputs/general 3/keep.dir
diff --git a/java/java-tests/testData/junit/configurations/outputs/general 4/keep.dir b/java/java-tests/testData/junit/configurations/outputs/general 4/keep.dir
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/java/java-tests/testData/junit/configurations/outputs/general 4/keep.dir
diff --git a/java/java-tests/testData/junit/configurations/outputs/tests1/keep.dir b/java/java-tests/testData/junit/configurations/outputs/tests1/keep.dir
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/java/java-tests/testData/junit/configurations/outputs/tests1/keep.dir
diff --git a/java/java-tests/testData/junit/configurations/outputs/tests2/keep.dir b/java/java-tests/testData/junit/configurations/outputs/tests2/keep.dir
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/java/java-tests/testData/junit/configurations/outputs/tests2/keep.dir
diff --git a/java/java-tests/testData/junit/configurations/outputs/tests3/keep.dir b/java/java-tests/testData/junit/configurations/outputs/tests3/keep.dir
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/java/java-tests/testData/junit/configurations/outputs/tests3/keep.dir
diff --git a/java/java-tests/testData/junit/configurations/outputs/tests4/keep.dir b/java/java-tests/testData/junit/configurations/outputs/tests4/keep.dir
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/java/java-tests/testData/junit/configurations/outputs/tests4/keep.dir
diff --git a/java/java-tests/testData/psi/formatter/java/SCR11296_after.java b/java/java-tests/testData/psi/formatter/java/SCR11296_after.java
index 502dc50..26c117d 100644
--- a/java/java-tests/testData/psi/formatter/java/SCR11296_after.java
+++ b/java/java-tests/testData/psi/formatter/java/SCR11296_after.java
@@ -1,9 +1,10 @@
class A {
/**
* The <code>String</code> class represents
- * character strings. All string literals in Java
- * programs, such as <code>"abc"</code>, are
- * implemented as instances of this class.
+ * character strings. All string literals in
+ * Java programs, such as <code>"abc"</code>,
+ * are implemented as instances of this
+ * class.
* Some text after empty line
*
* @author Lee Boynton
diff --git a/java/java-tests/testData/psi/resolve/method/generics/ToString.java b/java/java-tests/testData/psi/resolve/method/generics/ToString.java
new file mode 100644
index 0000000..a0d05e1
--- /dev/null
+++ b/java/java-tests/testData/psi/resolve/method/generics/ToString.java
@@ -0,0 +1,11 @@
+class SomeClass {
+ public static final Object OBJECT_OVERRIDDEN = new Object() {
+ public String toString() {
+ return "";
+ }
+ };
+
+ public String get() {
+ return OBJECT_OVERRIDDEN.toSt<ref>ring();
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/changeSignature/ParamJavadoc0.java b/java/java-tests/testData/refactoring/changeSignature/ParamJavadoc0.java
new file mode 100644
index 0000000..4ef8428
--- /dev/null
+++ b/java/java-tests/testData/refactoring/changeSignature/ParamJavadoc0.java
@@ -0,0 +1,14 @@
+class X {
+
+ /**
+ * Has a method called {@link #mymethod(int, int)}.
+ */
+ public class TestRefactorLink {
+ /**
+ @return nothing
+ @param y yparam
+ @param z zparam
+ */
+ public void <caret>mymethod(int y, int z) { }
+ }
+}
diff --git a/java/java-tests/testData/refactoring/changeSignature/ParamJavadoc0_after.java b/java/java-tests/testData/refactoring/changeSignature/ParamJavadoc0_after.java
new file mode 100644
index 0000000..9b53806
--- /dev/null
+++ b/java/java-tests/testData/refactoring/changeSignature/ParamJavadoc0_after.java
@@ -0,0 +1,14 @@
+class X {
+
+ /**
+ * Has a method called {@link #mymethod(int, int)}.
+ */
+ public class TestRefactorLink {
+ /**
+ @return nothing
+ * @param z zparam
+ * @param y yparam
+ */
+ public void mymethod(int z, int y) { }
+ }
+}
diff --git a/java/java-tests/testData/refactoring/changeSignature/PropagateParameter.java b/java/java-tests/testData/refactoring/changeSignature/PropagateParameter.java
index f3a85d2..f907b0d 100644
--- a/java/java-tests/testData/refactoring/changeSignature/PropagateParameter.java
+++ b/java/java-tests/testData/refactoring/changeSignature/PropagateParameter.java
@@ -6,4 +6,8 @@
int s;
subject(null);
}
+
+ void caller1() {
+ caller();
+ }
}
diff --git a/java/java-tests/testData/refactoring/changeSignature/PropagateParameter_after.java b/java/java-tests/testData/refactoring/changeSignature/PropagateParameter_after.java
index ff0cf08..42ac309 100644
--- a/java/java-tests/testData/refactoring/changeSignature/PropagateParameter_after.java
+++ b/java/java-tests/testData/refactoring/changeSignature/PropagateParameter_after.java
@@ -6,4 +6,8 @@
int s;
subject(null, b);
}
+
+ void caller1() {
+ caller();
+ }
}
diff --git a/java/java-tests/testData/refactoring/safeDelete/overrideAnnotation/after/Super.java b/java/java-tests/testData/refactoring/safeDelete/overrideAnnotation/after/Super.java
new file mode 100644
index 0000000..10bb0c8
--- /dev/null
+++ b/java/java-tests/testData/refactoring/safeDelete/overrideAnnotation/after/Super.java
@@ -0,0 +1,13 @@
+class Super {
+}
+
+class Child extends Super {
+ void foo() {
+ }
+}
+
+class Usage {
+ void bar(Child c) {
+ c.foo();
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/safeDelete/overrideAnnotation/before/Super.java b/java/java-tests/testData/refactoring/safeDelete/overrideAnnotation/before/Super.java
new file mode 100644
index 0000000..eb492f6
--- /dev/null
+++ b/java/java-tests/testData/refactoring/safeDelete/overrideAnnotation/before/Super.java
@@ -0,0 +1,15 @@
+class Super {
+ void fo<caret>o() {}
+}
+
+class Child extends Super {
+ @Override
+ void foo() {
+ }
+}
+
+class Usage {
+ void bar(Child c) {
+ c.foo();
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/safeDelete/superCall/after/Super.java b/java/java-tests/testData/refactoring/safeDelete/superCall/after/Super.java
new file mode 100644
index 0000000..10bb0c8
--- /dev/null
+++ b/java/java-tests/testData/refactoring/safeDelete/superCall/after/Super.java
@@ -0,0 +1,13 @@
+class Super {
+}
+
+class Child extends Super {
+ void foo() {
+ }
+}
+
+class Usage {
+ void bar(Child c) {
+ c.foo();
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/safeDelete/superCall/before/Super.java b/java/java-tests/testData/refactoring/safeDelete/superCall/before/Super.java
new file mode 100644
index 0000000..83463f9
--- /dev/null
+++ b/java/java-tests/testData/refactoring/safeDelete/superCall/before/Super.java
@@ -0,0 +1,14 @@
+class Super {
+ void f<caret>oo() {}
+}
+
+class Child extends Super {
+ {
+ foo();
+ }
+
+ @Override
+ void foo() {
+ super.foo();
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/CopyReferenceTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/CopyReferenceTest.groovy
index 7cc14eb..fbae4d1 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/CopyReferenceTest.groovy
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/CopyReferenceTest.groovy
@@ -49,6 +49,19 @@
class Goo { Foo }"""
}
+
+ public void "test paste correct signature to javadoc"() {
+ myFixture.configureByText "a.java", """
+class Foo {
+ void foo(int a) {}
+ void foo<caret>(byte a) {}
+}
+"""
+ performCopy()
+ myFixture.configureByText "b.java", "/** <caret> */"
+ performPaste()
+ myFixture.checkResult "/** Foo#foo(byte)<caret> */"
+ }
public void testFqnInImport() {
myFixture.addClass("package foo; public class Foo {}")
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/GenerateConstructorTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/GenerateConstructorTest.java
index 1aeb16c..3fb5b7c 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/GenerateConstructorTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/GenerateConstructorTest.java
@@ -50,6 +50,11 @@
public void testFinalFieldPreselection() throws Exception { doTest(true); }
public void testSubstitution() throws Exception { doTest(true); }
+ public void testFieldPrefixCoincidence() throws Exception {
+ CodeStyleSettingsManager.getInstance(getProject()).getCurrentSettings().FIELD_NAME_PREFIX = "m";
+ doTest();
+ }
+
private void doTest() throws Exception {
doTest(false);
}
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/GenerateJavadocTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/GenerateJavadocTest.java
index 272dd78..9761304 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/GenerateJavadocTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/GenerateJavadocTest.java
@@ -4,7 +4,6 @@
import com.intellij.openapi.actionSystem.IdeActions;
import com.intellij.openapi.editor.actionSystem.EditorActionHandler;
import com.intellij.openapi.editor.actionSystem.EditorActionManager;
-import com.intellij.openapi.fileEditor.impl.TrailingSpacesStripper;
import com.intellij.testFramework.PlatformTestCase;
/**
@@ -22,13 +21,12 @@
String name = getTestName(false);
configureByFile("/codeInsight/generateJavadoc/before" + name + ".java");
performAction();
- checkResultByFile("/codeInsight/generateJavadoc/after" + name + ".java", true);
+ checkResultByFile("/codeInsight/generateJavadoc/after" + name + ".java", false);
}
private void performAction() {
EditorActionManager actionManager = EditorActionManager.getInstance();
EditorActionHandler actionHandler = actionManager.getActionHandler(IdeActions.ACTION_EDITOR_ENTER);
actionHandler.execute(myEditor, DataManager.getInstance().getDataContext());
- TrailingSpacesStripper.stripIfNotCurrentLine(myEditor.getDocument(), false);
}
}
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/AbstractCompilerAwareTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/completion/AbstractCompilerAwareTest.java
new file mode 100644
index 0000000..ec1fa51
--- /dev/null
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/AbstractCompilerAwareTest.java
@@ -0,0 +1,30 @@
+package com.intellij.codeInsight.completion;
+
+import com.intellij.openapi.util.io.FileUtil;
+import com.intellij.psi.PsiType;
+import com.intellij.testFramework.fixtures.JavaCodeInsightFixtureTestCase;
+import com.sun.tools.javac.Main;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * @author Dmitry Batkovich
+ */
+public abstract class AbstractCompilerAwareTest extends JavaCodeInsightFixtureTestCase {
+ protected final File compileData(final String testCaseName, final String fileToCompile) {
+ final File compilerOutput = getCompilerOutputPath(testCaseName);
+ assertEquals(Main.compile(
+ new String[]{"-g:vars", "-d", compilerOutput.getAbsolutePath(), String.format("%s/%s/%s", getTestDataPath(), testCaseName, fileToCompile)}), 0);
+ return compilerOutput;
+ }
+
+ private static File getCompilerOutputPath(final String testCaseName) {
+ try {
+ return FileUtil.createTempDirectory(testCaseName, "_compiled");
+ }
+ catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaAutoPopupTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaAutoPopupTest.groovy
index 4524ed7..a4686a8 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaAutoPopupTest.groovy
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaAutoPopupTest.groovy
@@ -23,6 +23,8 @@
import com.intellij.codeInsight.lookup.LookupManager
import com.intellij.codeInsight.lookup.PsiTypeLookupItem
import com.intellij.codeInsight.lookup.impl.LookupImpl
+import com.intellij.codeInsight.template.Template
+import com.intellij.codeInsight.template.TemplateManager
import com.intellij.codeInsight.template.impl.TemplateManagerImpl
import com.intellij.ide.DataManager
import com.intellij.ide.ui.UISettings
@@ -1425,4 +1427,37 @@
assert lookup
}
+ public void "test typing during restart commit document"() {
+ def longText = "\nfoo(); bar();" * 100
+ myFixture.configureByText "a.java", "class Foo { void foo(int ab, int abde) { <caret>; $longText }}"
+ myFixture.type('a')
+ joinAutopopup()
+ myFixture.type('b')
+ myTester.joinCommit()
+ myFixture.type('c')
+ joinCompletion()
+ assert !lookup
+ }
+
+ public void "test no name autopopup in live template"() {
+ TemplateManagerImpl.setTemplateTesting(getProject(), getTestRootDisposable());
+ myFixture.configureByText 'a.java', '''class F {
+ String nameContainingIdentifier;
+<caret>
+}'''
+
+ final TemplateManager manager = TemplateManager.getInstance(getProject());
+ final Template template = manager.createTemplate("m", "user", 'void foo(String $V1$) {}');
+ template.addVariable("V1", "", '"s"', true);
+
+ edt {
+ CommandProcessor.instance.executeCommand project, {manager.startTemplate(myFixture.editor, template)}, null, null
+ }
+
+ type('name')
+ assert !myFixture.lookupElementStrings
+ assert !lookup
+ }
+
+
}
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavadocCompletionTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavadocCompletionTest.groovy
index 6c5c239..fedb91c 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavadocCompletionTest.groovy
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavadocCompletionTest.groovy
@@ -216,6 +216,41 @@
myFixture.assertPreferredCompletionItems 0, 'param', 'param param2'
}
+ public void "test suggest same param descriptions"() {
+ myFixture.configureByText "a.java", '''
+class Foo {
+ /**
+ * @param intParam so<caret> xxx
+ * @throws Foo
+ */
+ void foo2(int intParam, Object param2) { }
+
+ /**
+ * @param intParam some integer param
+ */
+ void foo(int intParam, Object param2) { }
+}
+'''
+ myFixture.completeBasic()
+ myFixture.assertPreferredCompletionItems 0, 'some', 'some integer param'
+ myFixture.lookup.currentItem = myFixture.lookupElements[1]
+ myFixture.type('\t')
+ myFixture.checkResult '''
+class Foo {
+ /**
+ * @param intParam some integer param<caret>
+ * @throws Foo
+ */
+ void foo2(int intParam, Object param2) { }
+
+ /**
+ * @param intParam some integer param
+ */
+ void foo(int intParam, Object param2) { }
+}
+'''
+ }
+
public void "test see super class"() {
myFixture.addClass("package foo; public interface Foo {}")
myFixture.addClass("package bar; public class Bar {} ")
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/MagicConstantCompletionTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/completion/MagicConstantCompletionTest.groovy
new file mode 100644
index 0000000..c7e4ba1
--- /dev/null
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/MagicConstantCompletionTest.groovy
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2000-2013 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 com.intellij.codeInsight.completion
+
+import com.intellij.psi.PsiClass
+import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase
+
+/**
+ * @author peter
+ */
+class MagicConstantCompletionTest extends LightCodeInsightFixtureTestCase {
+
+ public void "test in method argument"() {
+ addModifierList()
+ myFixture.configureByText "a.java", """
+class Foo {
+ static void foo(ModifierList ml) {
+ ml.hasModifierProperty(<caret>)
+ }
+}
+"""
+ myFixture.complete(CompletionType.SMART)
+ myFixture.assertPreferredCompletionItems 0, 'PROTECTED', 'PUBLIC'
+ }
+
+ public void "test nothing after dot"() {
+ addModifierList()
+ myFixture.configureByText "a.java", """
+class Foo {
+ static void foo(ModifierList ml) {
+ ml.hasModifierProperty(Foo.<caret>)
+ }
+}
+"""
+ assert !myFixture.complete(CompletionType.SMART)
+ }
+
+ private PsiClass addModifierList() {
+ myFixture.addClass """
+package org.intellij.lang.annotations;
+public @interface MagicConstant {
+ String[] stringValues() default {};
+}
+"""
+
+ myFixture.addClass """
+import org.intellij.lang.annotations.MagicConstant;
+
+interface PsiModifier {
+ @NonNls String PUBLIC = "public";
+ @NonNls String PROTECTED = "protected";
+
+ @MagicConstant(stringValues = { PUBLIC, PROTECTED })
+ @interface ModifierConstant { }
+}
+
+interface ModifierList {
+ boolean hasModifierProperty(@PsiModifier.ModifierConstant String m) {}
+}
+"""
+ }
+}
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/MethodChainsCompletionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/completion/MethodChainsCompletionTest.java
new file mode 100644
index 0000000..176575f
--- /dev/null
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/MethodChainsCompletionTest.java
@@ -0,0 +1,231 @@
+package com.intellij.codeInsight.completion;
+
+import com.intellij.JavaTestUtil;
+import com.intellij.codeInsight.completion.methodChains.completion.MethodsChainsCompletionContributor;
+import com.intellij.codeInsight.completion.methodChains.completion.lookup.ChainCompletionMethodCallLookupElement;
+import com.intellij.codeInsight.completion.methodChains.completion.lookup.WeightableChainLookupElement;
+import com.intellij.codeInsight.completion.methodChains.search.ChainRelevance;
+import com.intellij.codeInsight.lookup.LookupElement;
+import com.intellij.compilerOutputIndex.api.fs.FileVisitorService;
+import com.intellij.compilerOutputIndex.api.indexer.CompilerOutputIndexer;
+import com.intellij.ide.util.PropertiesComponent;
+import com.intellij.mock.MockProgressIndicator;
+import com.intellij.util.SmartList;
+
+import java.io.File;
+import java.util.List;
+
+/**
+ * @author Dmitry Batkovich
+ */
+public class MethodChainsCompletionTest extends AbstractCompilerAwareTest {
+ private final static String TEST_INDEX_FILE_NAME = "TestIndex.java";
+ private final static String TEST_COMPLETION_FILE_NAME = "TestCompletion.java";
+
+ private final static String BEFORE_COMPLETION_FILE = "BeforeCompletion.java";
+ private final static String AFTER_COMPLETION_FILE = "AfterCompletion.java";
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ protected String getTestDataPath() {
+ return JavaTestUtil.getJavaTestDataPath() + "/codeInsight/completion/methodChains/";
+ }
+
+ public void testOneRelevantMethod() {
+ assertAdvisorLookupElementEquals("e.getProject", 0, 8, 1, 0, assertOneElement(doCompletion()));
+ }
+
+ public void testCyclingMethodsNotShowed() {
+ assertEmpty(doCompletion());
+ }
+
+ public void testStaticMethod() {
+ final List<WeightableChainLookupElement> elements = doCompletion();
+ assertAdvisorLookupElementEquals("getInstance", 0, 2, 1, 0, assertOneElement(elements));
+ }
+
+ public void testStaticMethodAndMethod() {
+ final List<WeightableChainLookupElement> elements = doCompletion();
+ assertEquals(elements.size(), 2);
+ assertAdvisorLookupElementEquals("findClass", 0, 3, 1, 1, elements.get(1));
+ assertAdvisorLookupElementEquals("m.getContainingClass", 0, 5, 1, 0, elements.get(0));
+ }
+
+ public void testOneChainContainsOther() {
+ assertAdvisorLookupElementEquals("p.getBaseDir", 0, 8, 1, 0, assertOneElement(doCompletion()));
+ }
+
+ public void testTwoVariablesWithOneTypeOrSuperType() {
+ assertAdvisorLookupElementEquals("c.getProject", 0, 4, 1, 0, assertOneElement(doCompletion()));
+ }
+
+ public void testSuperClassMethodsCallings() {
+ assertAdvisorLookupElementEquals("m.getProject", 0, 8, 1, 0, assertOneElement(doCompletion()));
+ }
+
+ public void testMethodReturnsSubclassOfTargetClassNotShowed2() {
+ assertEmpty(doCompletion());
+ }
+
+ public void testResultsForSuperClassesNotShowed() {
+ assertEmpty(doCompletion());
+ }
+
+ public void testInnerClasses() {
+ assertAdvisorLookupElementEquals("j.getEntry", 0, 8, 1, 0, assertOneElement(doCompletion()));
+ }
+
+ public void testMethodsWithSameName() {
+ assertAdvisorLookupElementEquals("f.createType", 1, 8, 1, 0, assertOneElement(doCompletion()));
+ }
+
+ public void testBigrams2() {
+ final List<WeightableChainLookupElement> collection = doCompletion();
+ assertAdvisorLookupElementEquals("e.getContainingFile().getVirtualFile", 0, 8, 1, 0, assertOneElement(collection));
+ }
+
+ public void testBigrams3() {
+ final List<WeightableChainLookupElement> collection = doCompletion();
+ assertAdvisorLookupElementEquals("getInstance().findFile().findElementAt", 2, 8, 3, 0, assertOneElement(collection));
+ }
+
+ public void _testReduceChain4() {
+ final List<WeightableChainLookupElement> collection = doCompletion();
+ assertAdvisorLookupElementEquals("b.getC", 0, 33, 1, 0, assertOneElement(collection));
+ }
+
+ public void testGetterInContext() {
+ assertAdvisorLookupElementEquals("getMyElement().getProject", 0, 8, 1, 0, assertOneElement(doCompletion()));
+ }
+
+ public void testMethodParameterCompletion() {
+ assertOneElement(doCompletion());
+ }
+
+ public void testNoWayToObtainVariableExplicitly() {
+ assertOneElement(doCompletion());
+ }
+
+ public void testCyclingInstancesObtaining() {
+ assertEmpty(doCompletion());
+ }
+
+ public void testCyclingInstancesObtaining2() {
+ assertOneElement(doCompletion());
+ }
+
+ public void testResultRelevance() {
+ final List<WeightableChainLookupElement> advisorWeightableChainLookupElements = doCompletion();
+ assertEquals("e.getContainingClass", advisorWeightableChainLookupElements.get(0).getLookupString());
+ assertEquals("getInstance().findClass", advisorWeightableChainLookupElements.get(1).getLookupString());
+ }
+
+ public void testResultRelevance3() {
+ final List<WeightableChainLookupElement> advisorWeightableChainLookupElements = doCompletion();
+ assertSize(2, advisorWeightableChainLookupElements);
+ assertEquals("e.getProject1", advisorWeightableChainLookupElements.get(0).getLookupString());
+ assertEquals("psiManager.getProject", advisorWeightableChainLookupElements.get(1).getLookupString());
+ }
+
+ public void testRenderingVariableInContextAndNotInContext() {
+ doTestRendering();
+ }
+
+ public void testRenderingStaticMethods() {
+ doTestRendering();
+ }
+
+ public void testRenderingIntroduceVariable() {
+ doTestRendering();
+ }
+
+ public void assertAdvisorLookupElementEquals(final String lookupText,
+ final int unreachableParametersCount,
+ final int lastMethodWeight,
+ final int chainSize,
+ final int notMatchedStringVars,
+ final WeightableChainLookupElement actualLookupElement) {
+ assertLookupElementStringEquals(actualLookupElement, lookupText);
+ assertChainRelevanceEquals(actualLookupElement.getChainRelevance(), lastMethodWeight, chainSize, notMatchedStringVars,
+ unreachableParametersCount);
+ }
+
+ private static void assertLookupElementStringEquals(final LookupElement lookupElement, final String lookupText) {
+ assertEquals(lookupText, lookupElement.getLookupString());
+ }
+
+ private static void assertChainRelevanceEquals(final ChainRelevance chainRelevance,
+ final int lastMethodWeight,
+ final int chainSize,
+ final int notMatchedStringVars,
+ final int unreachableParametersCount) {
+ assertEquals(notMatchedStringVars, chainRelevance.getNotMatchedStringVars());
+ assertEquals(chainSize, chainRelevance.getChainSize());
+ assertEquals(unreachableParametersCount, chainRelevance.getUnreachableParametersCount());
+ assertEquals(lastMethodWeight, chainRelevance.getLastMethodOccurrences());
+ }
+
+ private void doTestRendering() {
+ PropertiesComponent.getInstance(getProject()).setValue(ChainCompletionMethodCallLookupElement.PROP_METHODS_CHAIN_COMPLETION_AUTO_COMPLETION, String.valueOf(true));
+ indexCompiledData(compileData(getName(), TEST_INDEX_FILE_NAME));
+ myFixture.configureByFiles(getBeforeCompletionFilePath());
+ myFixture.complete(CompletionType.BASIC, MethodsChainsCompletionContributor.INVOCATIONS_THRESHOLD);
+ PropertiesComponent.getInstance(getProject()).setValue(ChainCompletionMethodCallLookupElement.PROP_METHODS_CHAIN_COMPLETION_AUTO_COMPLETION, String.valueOf(false));
+ myFixture.checkResultByFile(getAfterCompletionFilePath());
+ }
+
+ private List<WeightableChainLookupElement> doCompletion() {
+ try {
+ indexCompiledData(compileData(getName(), TEST_INDEX_FILE_NAME));
+
+ final LookupElement[] allLookupElements = runCompletion();
+ final List<WeightableChainLookupElement> targetLookupElements = new SmartList<WeightableChainLookupElement>();
+ for (final LookupElement lookupElement : allLookupElements) {
+ if (lookupElement instanceof WeightableChainLookupElement) {
+ targetLookupElements.add((WeightableChainLookupElement)lookupElement);
+ }
+ }
+
+ return targetLookupElements;
+ }
+ finally {
+ final CompilerOutputIndexer indexer = CompilerOutputIndexer.getInstance(getProject());
+ indexer.projectClosed();
+ indexer.removeIndexes();
+ }
+ }
+
+ private LookupElement[] runCompletion() {
+ myFixture.configureByFiles(getTestCompletionFilePath());
+ final LookupElement[] lookupElements = myFixture.complete(CompletionType.BASIC, MethodsChainsCompletionContributor.INVOCATIONS_THRESHOLD);
+ return lookupElements == null ? LookupElement.EMPTY_ARRAY : lookupElements;
+ }
+
+ private void indexCompiledData(final File compilerOutput) {
+ final FileVisitorService.DirectoryClassFiles visitorService = new FileVisitorService.DirectoryClassFiles(compilerOutput);
+ final CompilerOutputIndexer indexer = CompilerOutputIndexer.getInstance(getProject());
+ indexer.projectOpened();
+ indexer.clear();
+ indexer.reindex(visitorService, new MockProgressIndicator());
+ }
+
+ private String getTestCompletionFilePath() {
+ return getName() + "/" + TEST_COMPLETION_FILE_NAME;
+ }
+
+ private String getBeforeCompletionFilePath() {
+ return getName() + "/" + BEFORE_COMPLETION_FILE;
+ }
+
+ private String getAfterCompletionFilePath() {
+ return getName() + "/" + AFTER_COMPLETION_FILE;
+ }
+}
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionOrderingTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionOrderingTest.groovy
index 8a1bfe6..64f2f02 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionOrderingTest.groovy
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionOrderingTest.groovy
@@ -257,7 +257,7 @@
}
public void testPreferInterfacesInImplements() {
- checkPreferredItems(0, "FooIntf", "FooClass");
+ checkPreferredItems(0, "FooIntf", "Foo", "FooClass");
}
public void testPreferClassesInExtends() {
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy
index 223da60..159c7b5 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy
@@ -192,41 +192,25 @@
public void testReferenceParameters() throws Exception {
configureByFile("ReferenceParameters.java");
assertNotNull(myItems);
- assertEquals(myItems.length, 2);
- assertEquals(myItems[0].getLookupString(), "AAAA");
- assertEquals(myItems[1].getLookupString(), "AAAB");
+ assert myFixture.lookupElementStrings == ['AAAA', 'AAAB']
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ CodeInsightSettings.getInstance().AUTOCOMPLETE_ON_CODE_COMPLETION = true
+ super.tearDown()
}
public void testConstructorName1() throws Exception{
- final CodeInsightSettings settings = CodeInsightSettings.getInstance();
- final boolean autocomplete_on_code_completion = settings.AUTOCOMPLETE_ON_CODE_COMPLETION;
- settings.AUTOCOMPLETE_ON_CODE_COMPLETION = false;
- configureByFile("ConstructorName1.java");
- assertNotNull(myItems);
- boolean failed = true;
- for (final LookupElement item : myItems) {
- if (item.getLookupString().equals("ABCDE")) {
- failed = false;
- }
- }
- assertFalse(failed);
- settings.AUTOCOMPLETE_ON_CODE_COMPLETION = autocomplete_on_code_completion;
+ CodeInsightSettings.getInstance().AUTOCOMPLETE_ON_CODE_COMPLETION = false
+ configure();
+ assert 'ABCDE' in myFixture.lookupElementStrings
}
public void testConstructorName2() throws Exception{
- final CodeInsightSettings settings = CodeInsightSettings.getInstance();
- final boolean autocomplete_on_code_completion = settings.AUTOCOMPLETE_ON_CODE_COMPLETION;
- settings.AUTOCOMPLETE_ON_CODE_COMPLETION = false;
- configureByFile("ConstructorName2.java");
- assertNotNull(myItems);
- boolean failed = true;
- for (final LookupElement item : myItems) {
- if (item.getLookupString().equals("ABCDE")) {
- failed = false;
- }
- }
- assertFalse(failed);
- settings.AUTOCOMPLETE_ON_CODE_COMPLETION = autocomplete_on_code_completion;
+ CodeInsightSettings.getInstance().AUTOCOMPLETE_ON_CODE_COMPLETION = false
+ configure();
+ assert 'ABCDE' in myFixture.lookupElementStrings
}
public void testObjectsInThrowsBlock() throws Exception {
@@ -918,6 +902,7 @@
public void testDontCastInstanceofedQualifier() throws Throwable { doTest(); }
public void testQualifierCastingWithUnknownAssignments() throws Throwable { doTest(); }
public void testQualifierCastingBeforeLt() throws Throwable { doTest(); }
+ public void testCastQualifierForPrivateFieldReference() throws Throwable { doTest(); }
public void testNoReturnInTernary() throws Throwable { doTest(); }
public void testOrAssignmentDfa() throws Throwable { doTest(); }
@@ -1340,6 +1325,29 @@
checkResult()
}
+ public void testAccessorViaCompletion() {
+ configure()
+
+ def getter = myFixture.lookupElements.find { it.lookupString == 'public int getField' }
+ def setter = myFixture.lookupElements.find { it.lookupString == 'public void setField' }
+ assert getter : myFixture.lookupElementStrings
+ assert setter : myFixture.lookupElementStrings
+
+ def p = LookupElementPresentation.renderElement(getter)
+ assert p.itemText == getter.lookupString
+ assert p.tailText == '() {...}'
+ assert !p.typeText
+
+ p = LookupElementPresentation.renderElement(setter)
+ assert p.itemText == setter.lookupString
+ assert p.tailText == '(field) {...}'
+ assert !p.typeText
+
+ lookup.currentItem = getter
+ myFixture.type('\n')
+ checkResult()
+ }
+
public void testBraceOnNextLine() {
codeStyleSettings.BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE
doTest()
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/SecondSmartTypeCompletionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/completion/SecondSmartTypeCompletionTest.java
index 3c2233e..8873c4a 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/SecondSmartTypeCompletionTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/SecondSmartTypeCompletionTest.java
@@ -38,6 +38,10 @@
configure();
assertStringItems("b.getGoo", "getBar().getGoo");
}
+ public void testFirstMethodWithParams() throws Throwable {
+ configure();
+ assertStringItems("getBar().getGoo", "getBar().getGoo2");
+ }
public void testSuggestArraysAsList() throws Throwable { doTest(); }
public void testSuggestArraysAsListWildcard() throws Throwable { doTest(); }
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/AdvHighlightingJdk7Test.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/AdvHighlightingJdk7Test.java
index 352048d..b35c8ff 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/AdvHighlightingJdk7Test.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/AdvHighlightingJdk7Test.java
@@ -18,13 +18,12 @@
import com.intellij.codeInspection.LocalInspectionTool;
import com.intellij.codeInspection.defUse.DefUseInspection;
import com.intellij.openapi.projectRoots.JavaSdkVersion;
-import com.intellij.openapi.projectRoots.JavaVersionService;
-import com.intellij.openapi.projectRoots.JavaVersionServiceImpl;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.testFramework.IdeaTestUtil;
import org.jetbrains.annotations.NonNls;
+import org.jetbrains.annotations.NotNull;
/**
* This class intended for "heavily-loaded" tests only, e.g. those need to setup separate project directory structure to run.
@@ -70,9 +69,9 @@
}
//ambiguous method calls
- private void doTestAmbiguous(JavaSdkVersion javaSdkVersion) throws Exception {
+ private void doTestAmbiguous(@NotNull JavaSdkVersion javaSdkVersion) throws Exception {
final String name = getTestName(true);
- ((JavaVersionServiceImpl)JavaVersionService.getInstance()).setTestVersion(javaSdkVersion, myTestRootDisposable);
+ IdeaTestUtil.setTestVersion(javaSdkVersion, getModule(), myTestRootDisposable);
doTest(BASE_PATH + name + "/pck/AmbiguousMethodCall.java", BASE_PATH + "/" + name, false, false);
}
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/AdvHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/AdvHighlightingTest.java
index 0e30c3d..0363b0f 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/AdvHighlightingTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/AdvHighlightingTest.java
@@ -105,6 +105,10 @@
doTest(BASE_PATH + "/accessibleMember/com/red/C.java", BASE_PATH + "/accessibleMember", false, false);
}
+ public void testStaticPackageLocalMember() throws Exception {
+ doTest(BASE_PATH + "/staticPackageLocalMember/p1/C.java", BASE_PATH + "/staticPackageLocalMember", false, false);
+ }
+
public void testOnDemandImportConflict() throws Exception {
doTest(BASE_PATH + "/onDemandImportConflict/Outer.java", BASE_PATH + "/onDemandImportConflict", false, false);
}
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java
index ec241b5..dda5aec 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java
@@ -20,8 +20,6 @@
import com.intellij.codeInspection.unusedImport.UnusedImportLocalInspection;
import com.intellij.codeInspection.unusedSymbol.UnusedSymbolLocalInspection;
import com.intellij.openapi.projectRoots.JavaSdkVersion;
-import com.intellij.openapi.projectRoots.JavaVersionService;
-import com.intellij.openapi.projectRoots.JavaVersionServiceImpl;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
import com.intellij.pom.java.LanguageLevel;
@@ -45,9 +43,9 @@
return getTestName(false).contains("Jdk14") ? IdeaTestUtil.getMockJdk14() : super.getProjectJDK();
}
- private void doTest(LanguageLevel languageLevel, JavaSdkVersion sdkVersion, boolean checkWarnings) {
+ private void doTest(@NotNull LanguageLevel languageLevel, @NotNull JavaSdkVersion sdkVersion, boolean checkWarnings) {
LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).setLanguageLevel(languageLevel);
- ((JavaVersionServiceImpl)JavaVersionService.getInstance()).setTestVersion(sdkVersion, myTestRootDisposable);
+ IdeaTestUtil.setTestVersion(sdkVersion, getModule(), myTestRootDisposable);
doTest(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, false);
}
private void doTest5(boolean checkWarnings) { doTest(LanguageLevel.JDK_1_5, JavaSdkVersion.JDK_1_6, checkWarnings); }
@@ -180,7 +178,8 @@
public void testTypeArgumentsGivenOnRawType() { doTest7Incompatibility(false); }
public void testSelectFromTypeParameter() { doTest5(false); }
public void testTypeArgumentsGivenOnAnonymousClassCreation() { doTest5(false); }
- //public void testIDEA94011() { doTest5(false); }
+
+ public void testIDEA94011() { doTest5(false); }
public void testDifferentTypeParamsInOverloadedMethods() { doTest5(true); }
public void testIDEA91626() { doTest5(true); }
public void testIDEA92022() { doTest5(false); }
@@ -244,6 +243,7 @@
public void testIllegalForwardReferenceInTypeParameterDefinition() throws Exception { doTest5(false);}
public void testIDEA57877() throws Exception { doTest5(false);}
+ public void testIDEA110568() throws Exception { doTest5(false);}
public void testTypeParamsCyclicInference() throws Exception { doTest5(false);}
public void testCaptureTopLevelWildcardsForConditionalExpression() throws Exception { doTest5(false);}
public void testGenericsOverrideMethodInRawInheritor() throws Exception { doTest5(false);}
@@ -290,6 +290,26 @@
public void testIDEA104160() {doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false);}
public void testSOEInLeastUpperClass() {doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false);}
+ public void testIDEA57334() {
+ doTest5(false);
+ }
+
+ public void testIDEA57325() { doTest5(false); }
+ public void testIDEA67835() { doTest5(false); }
+ public void testIDEA67744() { doTest5(false); }
+ public void testIDEA67682() { doTest5(false); }
+ public void testIDEA57391() { doTest5(false); }
+ public void testIDEA110869() { doTest5(false); }
+ public void testIDEA110947() { doTest5(false); }
+ public void testNoInferenceFromTypeCast() { doTest5(false); }
+ public void testCaptureWildcardsInTypeCasts() { doTest5(false); }
+ public void testIDEA111085() { doTest5(false); }
+ public void testIDEA109556() { doTest5(false); }
+ public void testIDEA107440() { doTest5(false); }
+ public void testIDEA57289() { doTest5(false); }
+ public void testIDEA57439() { doTest5(false); }
+ public void testIDEA57312() { doTest5(false); }
+
public void testJavaUtilCollections_NoVerify() throws Exception {
PsiClass collectionsClass = getJavaFacade().findClass("java.util.Collections", GlobalSearchScope.moduleWithLibrariesScope(getModule()));
assertNotNull(collectionsClass);
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingJdk6Test.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingJdk6Test.java
index 4b9afce..4af4e6b 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingJdk6Test.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingJdk6Test.java
@@ -21,9 +21,8 @@
import com.intellij.codeInspection.uncheckedWarnings.UncheckedWarningLocalInspection;
import com.intellij.codeInspection.unusedSymbol.UnusedSymbolLocalInspection;
import com.intellij.openapi.projectRoots.JavaSdkVersion;
-import com.intellij.openapi.projectRoots.JavaVersionService;
-import com.intellij.openapi.projectRoots.JavaVersionServiceImpl;
import com.intellij.pom.java.LanguageLevel;
+import com.intellij.testFramework.IdeaTestUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -36,7 +35,7 @@
private void doTest(boolean checkWarnings, boolean checkInfos, Class<?>... classes) {
setLanguageLevel(LanguageLevel.JDK_1_6);
- ((JavaVersionServiceImpl)JavaVersionService.getInstance()).setTestVersion(JavaSdkVersion.JDK_1_6, myTestRootDisposable);
+ IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_6, getModule(), myTestRootDisposable);
enableInspectionTools(classes);
doTest(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, checkInfos);
}
@@ -57,4 +56,7 @@
public void testIDEADEV11877() throws Exception { setLanguageLevel(LanguageLevel.JDK_1_6); doTest(false, false); }
public void testIDEA108285() throws Exception { setLanguageLevel(LanguageLevel.JDK_1_6); doTest(false, false); }
public void testClassObjectAccessibility() throws Exception { setLanguageLevel(LanguageLevel.JDK_1_6); doTest(false, false); }
+ public void testRedundantCastInConditionalExpression() throws Exception { setLanguageLevel(LanguageLevel.JDK_1_6); doTest(true, false); }
+ public void testJava5CastConventions() { setLanguageLevel(LanguageLevel.JDK_1_5); doTest(true, false); }
+ public void testUnhandledExceptions() { doTest(true, false); }
}
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingJdk7Test.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingJdk7Test.java
index 278de8c..2ed5078 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingJdk7Test.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingJdk7Test.java
@@ -30,10 +30,9 @@
import com.intellij.openapi.extensions.ExtensionPoint;
import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.projectRoots.JavaSdkVersion;
-import com.intellij.openapi.projectRoots.JavaVersionService;
-import com.intellij.openapi.projectRoots.JavaVersionServiceImpl;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.psi.PsiElement;
+import com.intellij.testFramework.IdeaTestUtil;
import org.jdom.Element;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -49,7 +48,7 @@
private void doTest(boolean checkWarnings, boolean checkInfos, Class<?>... classes) {
setLanguageLevel(LanguageLevel.JDK_1_7);
- ((JavaVersionServiceImpl)JavaVersionService.getInstance()).setTestVersion(JavaSdkVersion.JDK_1_7, myTestRootDisposable);
+ IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_7, getModule(), myTestRootDisposable);
enableInspectionTools(classes);
doTest(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, checkInfos);
}
@@ -157,7 +156,6 @@
public void testMethodReferences() { doTest(false, true, false); }
public void testUsedMethodsByMethodReferences() { doTest(true, true, false); }
public void testLambdaExpressions() { doTest(false, true, false); }
- public void testJava7CastConventions() { doTest(false, true, false); }
public void testUncheckedWarning() { doTest(true, false); }
public void testUncheckedWarningIDEA59290() { doTest(true, false); }
public void testUncheckedWarningIDEA70620() { doTest(true, false); }
@@ -180,4 +178,5 @@
public void testIDEA63731() { doTest(false, false); }
public void testIDEA62056() { doTest(false, false); }
public void testIDEA78916() { doTest(false, false); }
+ public void testIDEA111420() { doTest(false, false); }
}
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingTest.java
index c72853a..829ff89 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingTest.java
@@ -39,8 +39,6 @@
import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.fileTypes.StdFileTypes;
import com.intellij.openapi.projectRoots.JavaSdkVersion;
-import com.intellij.openapi.projectRoots.JavaVersionService;
-import com.intellij.openapi.projectRoots.JavaVersionServiceImpl;
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VirtualFile;
@@ -50,6 +48,7 @@
import com.intellij.psi.xml.XmlTag;
import com.intellij.psi.xml.XmlToken;
import com.intellij.psi.xml.XmlTokenType;
+import com.intellij.testFramework.IdeaTestUtil;
import org.jdom.Element;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -185,8 +184,8 @@
public void testUnused() { doTest(true, false); }
public void testQualifierBeforeClassName() { doTest(false, false); }
public void testQualifiedSuper() {
- ((JavaVersionServiceImpl)JavaVersionService.getInstance()).setTestVersion(JavaSdkVersion.JDK_1_6, myTestRootDisposable);
- doTest(false, false);
+ IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_6, getModule(), myTestRootDisposable);
+ doTest(false, false);
}
public void testIgnoreImplicitThisReferenceBeforeSuperSinceJdk7() throws Exception {
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GraphInferenceHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GraphInferenceHighlightingTest.java
index 5c0d7b4..84e60d5 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GraphInferenceHighlightingTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GraphInferenceHighlightingTest.java
@@ -17,8 +17,7 @@
import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase;
import com.intellij.openapi.projectRoots.JavaSdkVersion;
-import com.intellij.openapi.projectRoots.JavaVersionService;
-import com.intellij.openapi.projectRoots.JavaVersionServiceImpl;
+import com.intellij.testFramework.IdeaTestUtil;
import org.jetbrains.annotations.NonNls;
public class GraphInferenceHighlightingTest extends LightDaemonAnalyzerTestCase {
@@ -27,7 +26,7 @@
public void testNestedCalls() throws Exception {
doTest();
}
-
+
public void testNestedCallsSameMethod() throws Exception {
doTest();
}
@@ -85,7 +84,7 @@
}
private void doTest(final boolean checkWarnings) throws Exception {
- ((JavaVersionServiceImpl)JavaVersionService.getInstance()).setTestVersion(JavaSdkVersion.JDK_1_8, getTestRootDisposable());
+ IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_8, getModule(), getTestRootDisposable());
doTest(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, false);
}
}
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/LambdaHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/LambdaHighlightingTest.java
index d8c404b..6a30811 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/LambdaHighlightingTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/LambdaHighlightingTest.java
@@ -86,9 +86,11 @@
public void testVoidCompatibility() { doTest(); }
public void testConditionalInferenceFromOppositePart() { doTest(); }
public void testDeclaredTypeParameterBoundsAndUnboundedWildcard() { doTest(); }
- public void testConflictResolution() throws Exception {doTest();}
- public void testIDEA108195() throws Exception {doTest();}
- public void testDiamondInference() throws Exception { doTest();}
+ public void testConflictResolution() { doTest(); }
+ public void testIDEA108195() { doTest(); }
+ public void testDiamondInference() { doTest();}
+ public void testFunctionalInterfaceCheck() { doTest();}
+ public void testUnderscores() { doTest(true);}
private void doTest() {
doTest(false);
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/MethodRefHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/MethodRefHighlightingTest.java
index c47059e..9eecd70 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/MethodRefHighlightingTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/MethodRefHighlightingTest.java
@@ -19,8 +19,7 @@
import com.intellij.codeInspection.LocalInspectionTool;
import com.intellij.codeInspection.unusedSymbol.UnusedSymbolLocalInspection;
import com.intellij.openapi.projectRoots.JavaSdkVersion;
-import com.intellij.openapi.projectRoots.JavaVersionService;
-import com.intellij.openapi.projectRoots.JavaVersionServiceImpl;
+import com.intellij.testFramework.IdeaTestUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -89,7 +88,7 @@
}
private void doTest(boolean warnings) {
- ((JavaVersionServiceImpl)JavaVersionService.getInstance()).setTestVersion(JavaSdkVersion.JDK_1_8, getTestRootDisposable());
+ IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_8, getModule(), getTestRootDisposable());
doTest(BASE_PATH + "/" + getTestName(false) + ".java", warnings, false);
}
}
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/Normal8CompletionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/Normal8CompletionTest.groovy
similarity index 83%
rename from java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/Normal8CompletionTest.java
rename to java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/Normal8CompletionTest.groovy
index bb5f0a2..9fcddbb 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/Normal8CompletionTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/Normal8CompletionTest.groovy
@@ -39,4 +39,15 @@
configureByFile("SelfStaticsOnly.java");
assertStringItems("ba", "bar");
}
+
+ public void testFinishWithColon() {
+ myFixture.configureByText "a.java", """
+class Foo {{ Object o = Fo<caret>x }}
+"""
+ myFixture.completeBasic()
+ myFixture.type('::')
+ myFixture.checkResult """
+class Foo {{ Object o = Foo::<caret>x }}
+"""
+ }
}
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/CreateMethodFromUsageTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/CreateMethodFromUsageTest.groovy
index a1bbee0..3ce3fd7 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/CreateMethodFromUsageTest.groovy
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/CreateMethodFromUsageTest.groovy
@@ -76,6 +76,26 @@
}
+ public void "test prefer nearby return types"() {
+ configureFromFileText "a.java", """
+class Singleton {
+ boolean add(Object o) {}
+
+}
+class Usage {
+ void foo() {
+ Singleton.get<caret>Instance().add("a");
+ }
+
+}
+"""
+ TemplateManagerImpl.setTemplateTesting(project, testRootDisposable);
+ doAction("Create Method 'getInstance'")
+ def state = TemplateManagerImpl.getTemplateState(getEditor())
+ // parameter type
+ assert LookupManager.getActiveLookup(editor)?.currentItem?.lookupString == 'Singleton'
+ }
+
@Override
protected String getBasePath() {
return "/codeInsight/daemonCodeAnalyzer/quickFix/createMethodFromUsage";
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/editorActions/FixDocCommentTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/editorActions/FixDocCommentTest.groovy
index e5ff63b..183036b 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/editorActions/FixDocCommentTest.groovy
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/editorActions/FixDocCommentTest.groovy
@@ -34,7 +34,6 @@
expected: '''\
class Test {
/**
- * <caret>
* @param i
* @return
*/
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/folding/JavaFoldingTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/folding/JavaFoldingTest.groovy
index 3868cdb..76e465e 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/folding/JavaFoldingTest.groovy
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/folding/JavaFoldingTest.groovy
@@ -222,8 +222,11 @@
myFixture.addClass('interface Runnable3 { void run(); }')
myFixture.addClass('interface Runnable4 { void run(); }')
myFixture.addClass('abstract class MyAction { public abstract void run(); public void registerVeryCustomShortcutSet() {} }')
+ myFixture.addClass('abstract class MyAction2 { public abstract void run(); public void registerVeryCustomShortcutSet() {} }')
def text = """\
class Test {
+ MyAction2 action2;
+
void test() {
Runnable r = new Runnable() {
public void run() {
@@ -250,6 +253,11 @@
System.out.println();
}
}.registerVeryCustomShortcutSet();
+ action2 = new MyAction2() {
+ public void run() {
+ System.out.println();
+ }
+ }
}
void foo(Object o) {}
@@ -264,6 +272,7 @@
assert foldingModel.getCollapsedRegionAtOffset(text.indexOf("Runnable3(")).placeholderText == '(Runnable3) () -> { '
assert foldingModel.getCollapsedRegionAtOffset(text.indexOf("Runnable4(")).placeholderText == '() -> { '
assert foldingModel.getCollapsedRegionAtOffset(text.indexOf("MyAction(")).placeholderText == '(MyAction) () -> { '
+ assert foldingModel.getCollapsedRegionAtOffset(text.indexOf("MyAction2(")).placeholderText == '(MyAction2) () -> { '
}
public void "test closure folding when overriding one method of many"() {
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/intention/AddImportActionTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/intention/AddImportActionTest.groovy
index 6401afe..d06f122 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/intention/AddImportActionTest.groovy
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/intention/AddImportActionTest.groovy
@@ -100,6 +100,27 @@
'''
}
+ public void testUseOverrideContext() {
+ myFixture.addClass 'package foo; public class Log {}'
+ myFixture.addClass 'package bar; public class Log {}'
+ myFixture.addClass 'package goo; public class Super { public void foo(foo.Log log) {} }'
+ myFixture.configureByText 'a.java', '''\
+public class Foo extends goo.Super {
+ @Override
+ public void foo(Log<caret> log) {}
+}
+'''
+ importClass()
+ myFixture.checkResult '''import foo.Log;
+
+public class Foo extends goo.Super {
+ @Override
+ public void foo(Log<caret> log) {}
+}
+'''
+
+ }
+
public void testAnnotatedImport() {
myFixture.configureByText 'a.java', '''
import java.lang.annotation.*;
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/template/LiveTemplateTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/template/LiveTemplateTest.groovy
index 3ab71c0..12ed060 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/template/LiveTemplateTest.groovy
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/template/LiveTemplateTest.groovy
@@ -389,7 +389,7 @@
@Override
protected void invokeTestRunnable(final Runnable runnable) throws Exception {
- if (name in ["testNavigationActionsDontTerminateTemplate", "testTemplateWithEnd", "testDisappearingVar"]) {
+ if (name in ["testNavigationActionsDontTerminateTemplate", "testTemplateWithEnd", "testDisappearingVar", "test escape string characters in soutv"]) {
runnable.run();
return;
}
@@ -616,4 +616,28 @@
assert myFixture.lookupElementStrings == ['value', 'value1']
}
+ public void "test invoke surround template by tab"() {
+ myFixture.configureByText "a.txt", "B<caret>"
+ myFixture.type('\t')
+ myFixture.checkResult("{<caret>}")
+ }
+
+ public void "test escape string characters in soutv"() {
+ myFixture.configureByText "a.java", """
+class Foo {
+ {
+ soutv<caret>
+ }
+}
+"""
+ myFixture.type('\t"a"')
+ myFixture.checkResult """
+class Foo {
+ {
+ System.out.println("\\"a\\" = " + "a"<caret>);
+ }
+}
+"""
+ }
+
}
diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionAncientTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionAncientTest.java
index 583ccd5..6d9423a 100644
--- a/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionAncientTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionAncientTest.java
@@ -33,14 +33,18 @@
doTest(false);
}
private void doTest(boolean lowercase) {
- doTest("dataFlow/" + getTestName(lowercase), new DataFlowInspection());
+ DataFlowInspection inspection = new DataFlowInspection();
+ inspection.REPORT_CONSTANT_REFERENCE_VALUES = false;
+ doTest("dataFlow/" + getTestName(lowercase), inspection);
}
private void doTest15() {
doTest15(false);
}
private void doTest15(boolean lowercase) {
- doTest("dataFlow/" + getTestName(lowercase), new DataFlowInspection(), "java 1.5");
+ DataFlowInspection inspection = new DataFlowInspection();
+ inspection.REPORT_CONSTANT_REFERENCE_VALUES = false;
+ doTest("dataFlow/" + getTestName(lowercase), inspection, "java 1.5");
}
public void testNpe1() { doTest(true); }
@@ -115,5 +119,5 @@
public void testSwitchEnumCases() { doTest15(); }
public void testSCR15406() { doTest(); }
- //public void testIDEADEV11033() { doTest15(); } // added by max, 2007
+ public void testIDEADEV11033() { doTest15(); }
}
diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java
index c156581..6f9c7b0 100644
--- a/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java
@@ -31,6 +31,11 @@
* @author peter
*/
public class DataFlowInspectionTest extends LightCodeInsightFixtureTestCase {
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ myFixture.addClass("package org.jetbrains.annotations; public @interface Contract { String value(); }");
+ }
@Override
protected String getTestDataPath() {
@@ -40,6 +45,7 @@
private void doTest() {
final DataFlowInspection inspection = new DataFlowInspection();
inspection.SUGGEST_NULLABLE_ANNOTATIONS = true;
+ inspection.REPORT_CONSTANT_REFERENCE_VALUES = false;
myFixture.enableInspections(inspection);
myFixture.testHighlighting(true, false, true, getTestName(false) + ".java");
}
@@ -140,6 +146,42 @@
myFixture.testHighlighting(true, false, true, getTestName(false) + ".java");
}
+ public void testReportConstantReferences() {
+ doTestReplaceConstantReferences();
+ myFixture.launchAction(myFixture.findSingleIntention("Replace with 'null'"));
+ myFixture.checkResultByFile(getTestName(false) + "_after.java");
+ }
+
+ private void doTestReplaceConstantReferences() {
+ DataFlowInspection inspection = new DataFlowInspection();
+ inspection.SUGGEST_NULLABLE_ANNOTATIONS = true;
+ myFixture.enableInspections(inspection);
+ myFixture.testHighlighting(true, false, true, getTestName(false) + ".java");
+ }
+
+ public void testReportConstantReferences_ReplaceWithString() {
+ doTestReplaceConstantReferences();
+ myFixture.launchAction(myFixture.findSingleIntention("Replace with 'CONST'"));
+ myFixture.checkResultByFile(getTestName(false) + "_after.java");
+ }
+ public void testReportConstantReferences_ReplaceWithIntConstant() {
+ doTestReplaceConstantReferences();
+ myFixture.launchAction(myFixture.findSingleIntention("Replace with 'CONST'"));
+ myFixture.checkResultByFile(getTestName(false) + "_after.java");
+ }
+ public void testReportConstantReferences_ReplaceWithEnum() {
+ myFixture.addClass("package foo; public enum MyEnum { FOO }");
+ doTestReplaceConstantReferences();
+ myFixture.launchAction(myFixture.findSingleIntention("Replace with 'FOO'"));
+ myFixture.checkResultByFile(getTestName(false) + "_after.java");
+ }
+ public void testReportConstantReferences_NotInComplexAssignment() {
+ myFixture.addClass("package foo; public enum MyEnum { FOO }");
+ doTestReplaceConstantReferences();
+ assertEmpty(myFixture.filterAvailableIntentions("Replace with"));
+ }
+ public void testReportConstantReferences_Switch() { doTestReplaceConstantReferences(); }
+
public void testCheckFieldInitializers() {
doTest();
}
@@ -159,6 +201,7 @@
public void testTransientFinalField() { doTest(); }
public void _testSymmetricUncheckedCast() { doTest(); }
public void testNullCheckDoesntAffectUncheckedCast() { doTest(); }
+ public void testThrowNull() { doTest(); }
public void testNullableForeachVariable() {
setupCustomAnnotations();
@@ -238,4 +281,9 @@
myFixture.enableInspections(inspection);
myFixture.testHighlighting(true, false, true, getTestName(false) + ".java");
}
+
+ public void testContractAnnotation() { doTest(); }
+ public void testBoxingImpliesNotNull() { doTest(); }
+ public void testLargeIntegersAreNotEqualWhenBoxed() { doTest(); }
+ public void testNoGenericCCE() { doTest(); }
}
diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/EntryPointsConverterTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/EntryPointsConverterTest.java
index 104af74..35ed633 100644
--- a/java/java-tests/testSrc/com/intellij/codeInspection/EntryPointsConverterTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInspection/EntryPointsConverterTest.java
@@ -1,6 +1,6 @@
package com.intellij.codeInspection;
-import com.intellij.codeInspection.ex.EntryPointsManagerImpl;
+import com.intellij.codeInspection.ex.EntryPointsManagerBase;
import com.intellij.codeInspection.reference.SmartRefElementPointer;
import com.intellij.openapi.util.JDOMExternalizableStringList;
import com.intellij.openapi.util.JDOMUtil;
@@ -29,10 +29,10 @@
final Element entryPoints = setUpEntryPoint(type, fqName);
final HashMap<String, SmartRefElementPointer> persistentEntryPoints = new HashMap<String, SmartRefElementPointer>();
- EntryPointsManagerImpl.convert(entryPoints, persistentEntryPoints);
+ EntryPointsManagerBase.convert(entryPoints, persistentEntryPoints);
final Element testElement = new Element("comp");
- EntryPointsManagerImpl.writeExternal(testElement, persistentEntryPoints, new JDOMExternalizableStringList());
+ EntryPointsManagerBase.writeExternal(testElement, persistentEntryPoints, new JDOMExternalizableStringList());
final Element expectedEntryPoints = setUpEntryPoint(type, expectedFQName);
expectedEntryPoints.setAttribute("version", "2.0");
diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/RedundantCast15Test.java b/java/java-tests/testSrc/com/intellij/codeInspection/RedundantCast15Test.java
index a20b8d0..91afe58 100644
--- a/java/java-tests/testSrc/com/intellij/codeInspection/RedundantCast15Test.java
+++ b/java/java-tests/testSrc/com/intellij/codeInspection/RedundantCast15Test.java
@@ -3,10 +3,10 @@
import com.intellij.codeInspection.ex.LocalInspectionToolWrapper;
import com.intellij.codeInspection.redundantCast.RedundantCastInspection;
import com.intellij.openapi.projectRoots.JavaSdkVersion;
-import com.intellij.openapi.projectRoots.JavaVersionService;
-import com.intellij.openapi.projectRoots.JavaVersionServiceImpl;
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
+import com.intellij.openapi.roots.ModuleRootModificationUtil;
import com.intellij.pom.java.LanguageLevel;
+import com.intellij.testFramework.IdeaTestUtil;
import com.intellij.testFramework.InspectionTestCase;
public class RedundantCast15Test extends InspectionTestCase {
@@ -14,9 +14,9 @@
protected void setUp() throws Exception {
super.setUp();
LanguageLevelProjectExtension.getInstance(myJavaFacade.getProject()).setLanguageLevel(LanguageLevel.JDK_1_5);
+ ModuleRootModificationUtil.setModuleSdk(getModule(), getTestProjectSdk());
}
-
private void doTest() throws Exception {
final LocalInspectionToolWrapper toolWrapper = new LocalInspectionToolWrapper(new RedundantCastInspection());
doTest("redundantCast/generics/" + getTestName(false), toolWrapper, "java 1.5");
@@ -47,9 +47,12 @@
public void testRawCast1() throws Exception { doTest();}
public void testInferenceFromCast() throws Exception { doTest();}
public void testGetClassProcessing() throws Exception { doTest();}
+ public void testInstanceOfChecks() throws Exception { doTest();}
+ public void testForEachValue() throws Exception { doTest();}
+ public void testCaseThrowable() throws Exception { doTest();}
public void testTypeParameterAccessChecksJava7() throws Exception {
- ((JavaVersionServiceImpl)JavaVersionService.getInstance()).setTestVersion(JavaSdkVersion.JDK_1_7, getTestRootDisposable());
+ IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_7, getModule(), getTestRootDisposable());
doTest();
}
diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/TestOnlyInspectionTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/TestOnlyInspectionTest.java
new file mode 100644
index 0000000..e368d0e
--- /dev/null
+++ b/java/java-tests/testSrc/com/intellij/codeInspection/TestOnlyInspectionTest.java
@@ -0,0 +1,49 @@
+package com.intellij.codeInspection;
+
+import com.intellij.analysis.AnalysisScope;
+import com.intellij.codeInspection.ex.LocalInspectionToolWrapper;
+import com.intellij.codeInspection.testOnly.TestOnlyInspection;
+import com.intellij.openapi.vfs.LocalFileSystem;
+import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.testFramework.InspectionTestCase;
+import com.intellij.testFramework.PsiTestUtil;
+import org.jetbrains.annotations.NotNull;
+
+public class TestOnlyInspectionTest extends InspectionTestCase {
+ @Override
+ protected void setupRootModel(String testDir, VirtualFile[] sourceDir, String jdkName) {
+ super.setupRootModel(testDir, sourceDir, jdkName);
+ VirtualFile projectDir = LocalFileSystem.getInstance().findFileByPath(testDir);
+ VirtualFile test = projectDir.findChild("test");
+ if (test != null) PsiTestUtil.addSourceRoot(myModule, test, true);
+ }
+
+ @NotNull
+ @Override
+ protected AnalysisScope createAnalysisScope(VirtualFile sourceDir) {
+ return new AnalysisScope(myModule);
+ }
+
+ public void testSimple() throws Exception {
+ doTest();
+ }
+
+ public void testInsideInner() throws Exception {
+ doTest();
+ }
+
+ public void testConstructor() throws Exception {
+ doTest();
+ }
+
+ public void testVisibleForTesting() throws Exception { doTest(); }
+
+ public void testUnresolved() throws Exception {
+ doTest(); // shouldn't throw
+ }
+
+ private void doTest() throws Exception {
+ TestOnlyInspection i = new TestOnlyInspection();
+ doTest("testOnly/" + getTestName(true), new LocalInspectionToolWrapper(i), "java 1.5");
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/UnusedDeclarationTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/UnusedDeclarationTest.java
index 10604a1..8fc3860 100644
--- a/java/java-tests/testSrc/com/intellij/codeInspection/UnusedDeclarationTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInspection/UnusedDeclarationTest.java
@@ -17,7 +17,7 @@
import com.intellij.JavaTestUtil;
import com.intellij.codeInspection.deadCode.UnusedDeclarationInspection;
-import com.intellij.codeInspection.ex.EntryPointsManagerImpl;
+import com.intellij.codeInspection.ex.EntryPointsManagerBase;
import com.intellij.codeInspection.ex.GlobalInspectionToolWrapper;
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
import com.intellij.pom.java.LanguageLevel;
@@ -28,6 +28,7 @@
*/
public class UnusedDeclarationTest extends InspectionTestCase {
private UnusedDeclarationInspection myTool;
+ private GlobalInspectionToolWrapper myToolWrapper;
@Override
protected String getTestDataPath() {
@@ -37,11 +38,12 @@
@Override
protected void setUp() throws Exception {
super.setUp();
- myTool = new UnusedDeclarationInspection();
+ myToolWrapper = getUnusedDeclarationWrapper();
+ myTool = (UnusedDeclarationInspection)myToolWrapper.getTool();
}
private void doTest() {
- doTest("deadCode/" + getTestName(true), new GlobalInspectionToolWrapper(myTool));
+ doTest("deadCode/" + getTestName(true), myToolWrapper);
}
public void testSCR6067() {
@@ -127,12 +129,12 @@
public void testAdditionalAnnotations() {
final String testAnnotation = "Annotated";
- EntryPointsManagerImpl.getInstance(getProject()).ADDITIONAL_ANNOTATIONS.add(testAnnotation);
+ EntryPointsManagerBase.getInstance(getProject()).ADDITIONAL_ANNOTATIONS.add(testAnnotation);
try {
doTest();
}
finally {
- EntryPointsManagerImpl.getInstance(getProject()).ADDITIONAL_ANNOTATIONS.remove(testAnnotation);
+ EntryPointsManagerBase.getInstance(getProject()).ADDITIONAL_ANNOTATIONS.remove(testAnnotation);
}
}
diff --git a/java/java-tests/testSrc/com/intellij/execution/BaseConfigurationTestCase.java b/java/java-tests/testSrc/com/intellij/execution/BaseConfigurationTestCase.java
new file mode 100644
index 0000000..2ddd8d1
--- /dev/null
+++ b/java/java-tests/testSrc/com/intellij/execution/BaseConfigurationTestCase.java
@@ -0,0 +1,195 @@
+package com.intellij.execution;
+
+import com.intellij.execution.actions.ConfigurationContext;
+import com.intellij.execution.actions.ConfigurationFromContext;
+import com.intellij.execution.actions.RunConfigurationProducer;
+import com.intellij.execution.configurations.RunConfiguration;
+import com.intellij.execution.junit.JUnitConfiguration;
+import com.intellij.openapi.actionSystem.DataConstants;
+import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.application.ex.PathManagerEx;
+import com.intellij.openapi.module.Module;
+import com.intellij.openapi.module.ModuleManager;
+import com.intellij.openapi.module.ModuleUtilCore;
+import com.intellij.openapi.module.StdModuleTypes;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.roots.ModuleRootManager;
+import com.intellij.openapi.roots.ModuleRootModificationUtil;
+import com.intellij.openapi.vfs.LocalFileSystem;
+import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.psi.JavaPsiFacade;
+import com.intellij.psi.PsiClass;
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.search.GlobalSearchScope;
+import com.intellij.testFramework.IdeaTestCase;
+import com.intellij.testFramework.MapDataContext;
+import com.intellij.testFramework.PsiTestUtil;
+import com.intellij.testFramework.TempFiles;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+public abstract class BaseConfigurationTestCase extends IdeaTestCase {
+ protected TempFiles myTempFiles;
+ private final List<Module> myModulesToDispose = new ArrayList<Module>();
+ protected static final String MOCK_JUNIT = "mock JUnit";
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ myTempFiles = new TempFiles(myFilesToDelete);
+ }
+
+ protected void addModule(String path) throws IOException {
+ addModule(path, true);
+ }
+
+ protected void addModule(String path, boolean addSource) throws IOException {
+ VirtualFile module1Content = findFile(path);
+ createModule(module1Content, addSource);
+ }
+
+ protected void createModule(VirtualFile module1Content, boolean addSource) throws IOException {
+ Module module = createEmptyModule();
+ if (addSource) {
+ PsiTestUtil.addSourceRoot(module, module1Content, true);
+ }
+ else {
+ PsiTestUtil.addContentRoot(module, module1Content);
+ }
+
+ VirtualFile mockJUnit = findFile(MOCK_JUNIT);
+ ModuleRootModificationUtil.addModuleLibrary(module, mockJUnit.getUrl());
+ ModuleRootModificationUtil.setModuleSdk(module, ModuleRootManager.getInstance(myModule).getSdk());
+ GlobalSearchScope scope = GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module);
+ VirtualFile testCase = mockJUnit.findChild("junit").findChild("framework").findChild("TestCase.java");
+ assertNotNull(testCase);
+ assertTrue(scope.contains(testCase));
+ Module missingModule = createTempModule();
+ addDependency(module, missingModule);
+ ModuleManager.getInstance(myProject).disposeModule(missingModule);
+ }
+
+ protected Module createEmptyModule() throws IOException {
+ Module module = createTempModule();
+ myModulesToDispose.add(module);
+ return module;
+ }
+
+ private Module createTempModule() throws IOException {
+ return createTempModule(myTempFiles, myProject);
+ }
+
+ public static Module createTempModule(TempFiles tempFiles, final Project project) {
+ final String tempPath = tempFiles.createTempPath();
+ final Module[] module = new Module[1];
+ ApplicationManager.getApplication().runWriteAction(new Runnable() {
+ @Override
+ public void run() {
+ module[0] = ModuleManager.getInstance(project).newModule(tempPath, StdModuleTypes.JAVA.getId());
+ }
+ });
+ return module[0];
+ }
+
+ protected static VirtualFile findFile(String path) {
+ String filePath = PathManagerEx.getTestDataPath() + File.separator + "junit" + File.separator + "configurations" +
+ File.separator + path;
+ return LocalFileSystem.getInstance().findFileByPath(filePath.replace(File.separatorChar, '/'));
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ myModulesToDispose.clear();
+ super.tearDown();
+ }
+
+ protected void disposeModule(Module module) {
+ assertTrue(myModulesToDispose.remove(module));
+ ModuleManager.getInstance(myProject).disposeModule(module);
+ }
+
+ protected Module getModule1() {
+ return getModule(0);
+ }
+
+ protected Module getModule(int index) {
+ return myModulesToDispose.get(index);
+ }
+
+ protected Module getModule2() {
+ return getModule(1);
+ }
+
+ protected Module getModule4() {
+ return getModule(3);
+ }
+
+ protected Module getModule3() {
+ return getModule(2);
+ }
+
+ protected PsiClass findClass(Module module, String qualifiedName) {
+ return findClass(qualifiedName, GlobalSearchScope.moduleScope(module));
+ }
+
+ protected PsiClass findClass(String qualifiedName, GlobalSearchScope scope) {
+ return JavaPsiFacade.getInstance(myProject).findClass(qualifiedName, scope);
+ }
+
+ protected JUnitConfiguration createJUnitConfiguration(final PsiElement psiElement,
+ final Class producerClass,
+ final MapDataContext dataContext) {
+ ConfigurationContext context = createContext(psiElement, dataContext);
+ RunConfigurationProducer producer = RunConfigurationProducer.getInstance(producerClass);
+ assert producer != null;
+ ConfigurationFromContext fromContext = producer.createConfigurationFromContext(context);
+ return (JUnitConfiguration)fromContext.getConfiguration();
+ }
+
+ protected final <T extends RunConfiguration> T createConfiguration(PsiElement psiElement) {
+ return (T)createConfiguration(psiElement, new MapDataContext());
+ }
+
+ protected <T extends RunConfiguration> T createConfiguration(PsiElement psiElement, MapDataContext dataContext) {
+ ConfigurationContext context = createContext(psiElement, dataContext);
+ RunnerAndConfigurationSettings settings = context.getConfiguration();
+ return settings == null ? null : (T)settings.getConfiguration();
+ }
+
+ public ConfigurationContext createContext(PsiElement psiClass) {
+ MapDataContext dataContext = new MapDataContext();
+ return createContext(psiClass, dataContext);
+ }
+
+ public ConfigurationContext createContext(PsiElement psiClass, MapDataContext dataContext) {
+ dataContext.put(DataConstants.PROJECT, myProject);
+ if (dataContext.getData(DataConstants.MODULE) == null) {
+ dataContext.put(DataConstants.MODULE, ModuleUtilCore.findModuleForPsiElement(psiClass));
+ }
+ dataContext.put(Location.LOCATION, PsiLocation.fromPsiElement(psiClass));
+ return ConfigurationContext.getFromContext(dataContext);
+ }
+
+ protected void addDependency(Module module, Module dependency) {
+ ModuleRootModificationUtil.addDependency(module, dependency);
+ }
+
+ protected void checkPackage(String packageName, JUnitConfiguration configuration) {
+ assertEquals(packageName, configuration.getPersistentData().getPackageName());
+ }
+
+ protected void checkClassName(String className, JUnitConfiguration configuration) {
+ assertEquals(className, configuration.getPersistentData().getMainClassName());
+ }
+
+ protected void checkMethodName(String methodName, JUnitConfiguration configuration) {
+ assertEquals(methodName, configuration.getPersistentData().getMethodName());
+ }
+
+ protected void checkTestObject(String testObjectKey, JUnitConfiguration configuration) {
+ assertEquals(testObjectKey, configuration.getPersistentData().TEST_OBJECT);
+ }
+}
diff --git a/java/java-tests/testSrc/com/intellij/execution/ConfigurationRefactoringsTest.java b/java/java-tests/testSrc/com/intellij/execution/ConfigurationRefactoringsTest.java
new file mode 100644
index 0000000..a5d882c
--- /dev/null
+++ b/java/java-tests/testSrc/com/intellij/execution/ConfigurationRefactoringsTest.java
@@ -0,0 +1,237 @@
+package com.intellij.execution;
+
+import com.intellij.execution.application.ApplicationConfiguration;
+import com.intellij.execution.configurations.RunConfiguration;
+import com.intellij.execution.configurations.RuntimeConfigurationException;
+import com.intellij.execution.impl.RunnerAndConfigurationSettingsImpl;
+import com.intellij.execution.junit.AllInPackageConfigurationProducer;
+import com.intellij.execution.junit.JUnitConfiguration;
+import com.intellij.execution.junit.JUnitConfigurationType;
+import com.intellij.openapi.application.Result;
+import com.intellij.openapi.command.WriteCommandAction;
+import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.psi.*;
+import com.intellij.refactoring.PackageWrapper;
+import com.intellij.refactoring.move.moveClassesOrPackages.MoveClassesOrPackagesProcessor;
+import com.intellij.refactoring.move.moveClassesOrPackages.SingleSourceRootMoveDestination;
+import com.intellij.refactoring.move.moveMembers.MockMoveMembersOptions;
+import com.intellij.refactoring.move.moveMembers.MoveMembersProcessor;
+import com.intellij.refactoring.rename.RenameProcessor;
+import com.intellij.testFramework.MapDataContext;
+import com.intellij.util.containers.HashSet;
+
+import java.io.IOException;
+
+public class ConfigurationRefactoringsTest extends BaseConfigurationTestCase {
+ private static final String APPLICATION_CODE = "public class Application {" +
+ " public static void main(String[] args) {\n" +
+ " }" +
+ "}";
+ private static final String TEST_CODE = "import junit.framework.TestCase;" +
+ "public class ATest extends TestCase {" +
+ "public static void test() {}" +
+ "private void otherMethod() {}" +
+ "}";
+ private TestSources mySource;
+ private static final String NOT_A_TEST = "public class NotATest {" +
+ "public void test() {}" +
+ "}";
+ public void testRenameApplication() throws IOException {
+ PsiClass psiClass = mySource.createClass("Application", APPLICATION_CODE);
+ ApplicationConfiguration configuration = createConfiguration(psiClass);
+ assertNotNull(configuration);
+ rename(psiClass, "NewName");
+ try {
+ configuration.checkConfiguration();
+ }
+ catch (RuntimeConfigurationException e) {
+ assertTrue("Unexpected ConfigurationException: " + e ,false);
+ }
+ assertEquals("NewName", configuration.MAIN_CLASS_NAME);
+ }
+
+ public void testMoveApplication() throws IOException {
+ PsiClass psiClass = mySource.createClass("Application", APPLICATION_CODE);
+ ApplicationConfiguration configuration = createConfiguration(psiClass);
+ move(psiClass, "pkg");
+ try {
+ configuration.checkConfiguration();
+ }
+ catch (RuntimeConfigurationException e) {
+ assertTrue("Unexpected ConfigurationException: " + e ,false);
+ }
+
+ assertEquals("pkg.Application", configuration.MAIN_CLASS_NAME);
+ rename(JavaPsiFacade.getInstance(myProject).findPackage("pkg"), "pkg2");
+ assertEquals("pkg2.Application", configuration.MAIN_CLASS_NAME);
+ }
+
+ public void testRenameJUnitPackage() throws IOException {
+ PsiPackage psiPackage = mySource.createPackage("pkg");
+ JUnitConfiguration configuration = createJUnitConfiguration(psiPackage, AllInPackageConfigurationProducer.class, new MapDataContext());
+ rename(psiPackage, "pkg2");
+ checkPackage("pkg2", configuration);
+ PsiPackage outter = mySource.createPackage("outterPkg");
+ move(JavaPsiFacade.getInstance(myProject).findPackage("pkg2"), outter.getQualifiedName());
+ checkPackage("outterPkg.pkg2", configuration);
+ rename(outter, "outter2");
+ checkPackage("outter2.pkg2", configuration);
+ }
+
+ public void testRenameJUnitContainingPackage() throws IOException {
+ PsiClass psiClass = mySource.createClass("ATest", TEST_CODE);
+ JUnitConfiguration configuration = createConfiguration(psiClass);
+ PsiPackage psiPackage = mySource.createPackage("pkg");
+ move(psiClass, "pkg");
+ checkClassName("pkg.ATest", configuration);
+ rename(psiPackage, "newPkg");
+ checkClassName("newPkg.ATest", configuration);
+ psiPackage = mySource.findPackage("newPkg");
+
+ mySource.createPackage("pkg2");
+ move(psiPackage, "pkg2");
+ checkClassName("pkg2.newPkg.ATest", configuration);
+ }
+
+ public void testRefactorTestMethod() throws IOException {
+ PsiClass psiClass = mySource.createClass("ATest", TEST_CODE);
+ PsiMethod testMethod = psiClass.findMethodsByName("test", false)[0];
+ JUnitConfiguration configuration = createConfiguration(testMethod);
+ rename(testMethod, "test1");
+ checkMethodName("test1", configuration);
+ checkClassName("ATest", configuration);
+ assertEquals("ATest.test1", configuration.getName());
+ move(psiClass, "pkg");
+ checkClassName("pkg.ATest", configuration);
+ psiClass = configuration.getConfigurationModule().findClass(configuration.getPersistentData().getMainClassName());
+ rename(psiClass, "TestClassName");
+ assertEquals("TestClassName.test1", configuration.getName());
+ psiClass = configuration.getConfigurationModule().findClass(configuration.getPersistentData().getMainClassName());
+
+ PsiClass otherTest = mySource.createClass("ATest", TEST_CODE);
+ HashSet<PsiMember> members = new HashSet<PsiMember>();
+ members.add(psiClass.findMethodsByName("test1", false)[0]);
+ moveMembers(otherTest, members);
+ psiClass = configuration.getConfigurationModule().findClass(configuration.getPersistentData().getMainClassName());
+ checkMethodName("test1", configuration);
+ checkClassName("ATest", configuration);
+ assertEquals("ATest.test1", configuration.getName());
+
+ PsiMethod otherMethod = psiClass.findMethodsByName("otherMethod", false)[0];
+ rename(otherMethod, "newName");
+ checkMethodName("test1", configuration);
+ }
+
+ public void testRenameBadTestClass() throws IOException {
+ PsiClass psiClass = mySource.createClass("NotATest", NOT_A_TEST);
+ JUnitConfiguration configuration = new JUnitConfiguration("notATest", myProject, JUnitConfigurationType.getInstance().getConfigurationFactories()[0]);
+ configuration.setMainClass(psiClass);
+ configuration.setModule(configuration.getValidModules().iterator().next());
+
+
+ checkConfigurationException("NotATest isn't test class", configuration);
+
+ RunManagerEx.getInstanceEx(myProject).setTemporaryConfiguration(new RunnerAndConfigurationSettingsImpl(null, configuration, false));
+ rename(psiClass, "NotATest2");
+ JUnitConfiguration.Data data = configuration.getPersistentData();
+ assertEquals("NotATest2", data.getMainClassName());
+
+ data.METHOD_NAME = "test";
+ data.TEST_OBJECT = JUnitConfiguration.TEST_METHOD;
+ checkConfigurationException("Test method 'test' doesn't exist", configuration);
+ rename(psiClass.findMethodsByName("test", false)[0], "test2");
+ assertEquals("NotATest2", data.getMainClassName());
+ assertEquals("test2", data.getMethodName());
+ }
+
+ private void checkConfigurationException(String expectedExceptionMessage, JUnitConfiguration configuration) {
+ try {
+ configuration.checkConfiguration();
+ }
+ catch (RuntimeConfigurationException e) {
+ assertEquals(expectedExceptionMessage, e.getLocalizedMessage());
+ return;
+ }
+ assertTrue("ConfigurationException expected", false);
+ }
+
+ public void testRefactorOtherClass() throws IOException {
+ JUnitConfiguration configuration = createConfiguration(mySource.createClass("ATest", TEST_CODE));
+ PsiClass psiClass = mySource.createClass("Application", APPLICATION_CODE);
+ rename(psiClass, "NewName");
+ checkClassName("ATest", configuration);
+ mySource.createPackage("pkg");
+
+ psiClass = mySource.findClass("NewName");
+ move(psiClass, "pkg");
+ checkClassName("ATest", configuration);
+ }
+
+ private void moveMembers(final PsiClass otherTest, final HashSet<PsiMember> members) {
+ new WriteCommandAction(myProject) {
+ @Override
+ protected void run(final Result result) throws Throwable {
+ MockMoveMembersOptions options = new MockMoveMembersOptions(otherTest.getQualifiedName(), members);
+ new MoveMembersProcessor(myProject, null, options).run();
+ }
+ }.executeSilently();
+ }
+
+ private void initModule() throws IOException {
+ mySource.initModule();
+ mySource.copyJdkFrom(myModule);
+ mySource.addLibrary(findFile(MOCK_JUNIT));
+ }
+
+ private void move(final PsiElement psiElement, String packageName) {
+ VirtualFile pkgFile = mySource.createPackageDir(packageName);
+ final PsiDirectory toDir = PsiManager.getInstance(myProject).findDirectory(pkgFile);
+ new WriteCommandAction(myProject, psiElement.getContainingFile()) {
+ @Override
+ protected void run(final Result result) throws Throwable {
+ new MoveClassesOrPackagesProcessor(myProject, new PsiElement[]{psiElement},
+ new SingleSourceRootMoveDestination(
+ PackageWrapper.create(JavaDirectoryService.getInstance().getPackage(toDir)), toDir),
+ false, false, null).run();
+ }
+ }.executeSilently();
+ }
+
+ private void rename(final PsiElement psiElement, final String newName) {
+ new WriteCommandAction(myProject, psiElement.getContainingFile()) {
+ @Override
+ protected void run(final Result result) throws Throwable {
+ new RenameProcessor(myProject, psiElement, newName, false, false).run();
+ }
+ }.executeSilently();
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ mySource = new TestSources(myProject, myFilesToDelete);
+ initModule();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ mySource.tearDown();
+ mySource = null;
+ super.tearDown(); //To change body of overriden methods use Options | File Templates.
+ }
+
+ @Override
+ protected <T extends RunConfiguration> T createConfiguration(PsiElement psiClass, MapDataContext dataContext) {
+ T configuration = (T)super.createConfiguration(psiClass, dataContext);
+ RunManagerEx.getInstanceEx(myProject).setTemporaryConfiguration(new RunnerAndConfigurationSettingsImpl(null, configuration, false));
+ return configuration;
+ }
+
+ @Override
+ protected JUnitConfiguration createJUnitConfiguration(final PsiElement psiElement, final Class producerClass, final MapDataContext dataContext) {
+ final JUnitConfiguration configuration = super.createJUnitConfiguration(psiElement, producerClass, dataContext);
+ RunManagerEx.getInstanceEx(myProject).setTemporaryConfiguration(new RunnerAndConfigurationSettingsImpl(null, configuration, false));
+ return configuration;
+ }
+}
diff --git a/java/java-tests/testSrc/com/intellij/execution/ConfigurationsTest.java b/java/java-tests/testSrc/com/intellij/execution/ConfigurationsTest.java
new file mode 100644
index 0000000..f6246d4
--- /dev/null
+++ b/java/java-tests/testSrc/com/intellij/execution/ConfigurationsTest.java
@@ -0,0 +1,569 @@
+package com.intellij.execution;
+
+import com.intellij.execution.application.ApplicationConfigurable;
+import com.intellij.execution.application.ApplicationConfiguration;
+import com.intellij.execution.application.ApplicationConfigurationType;
+import com.intellij.execution.configurations.*;
+import com.intellij.execution.executors.DefaultRunExecutor;
+import com.intellij.execution.junit.*;
+import com.intellij.execution.junit2.configuration.JUnitConfigurable;
+import com.intellij.execution.junit2.configuration.JUnitConfigurationModel;
+import com.intellij.execution.runners.ExecutionEnvironment;
+import com.intellij.execution.testframework.TestSearchScope;
+import com.intellij.execution.ui.CommonJavaParametersPanel;
+import com.intellij.openapi.module.Module;
+import com.intellij.openapi.module.ModuleManager;
+import com.intellij.openapi.options.Configurable;
+import com.intellij.openapi.options.ConfigurationException;
+import com.intellij.openapi.projectRoots.Sdk;
+import com.intellij.openapi.roots.CompilerModuleExtension;
+import com.intellij.openapi.roots.ContentEntry;
+import com.intellij.openapi.roots.ModuleRootManager;
+import com.intellij.openapi.roots.ModuleRootModificationUtil;
+import com.intellij.openapi.ui.LabeledComponent;
+import com.intellij.openapi.util.*;
+import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.openapi.vfs.JarFileSystem;
+import com.intellij.openapi.vfs.LocalFileSystem;
+import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.psi.*;
+import com.intellij.psi.search.GlobalSearchScope;
+import com.intellij.rt.execution.junit.JUnitStarter;
+import com.intellij.rt.execution.junit.segments.SegmentedOutputStream;
+import com.intellij.testFramework.IdeaTestUtil;
+import com.intellij.testFramework.MapDataContext;
+import com.intellij.testFramework.PsiTestUtil;
+import com.intellij.ui.EditorTextFieldWithBrowseButton;
+import com.intellij.util.Assertion;
+import com.intellij.util.PathUtil;
+import com.intellij.util.containers.ContainerUtil;
+import junit.framework.TestCase;
+import org.jdom.Element;
+import org.jetbrains.annotations.NotNull;
+
+import javax.swing.*;
+import java.io.*;
+import java.util.*;
+
+public class ConfigurationsTest extends BaseConfigurationTestCase {
+ private final Assertion CHECK = new Assertion();
+
+ private Sdk myJdk;
+ private static final String INNER_TEST_NAME = "test1.InnerTest.Inner";
+ private static final String RT_INNER_TEST_NAME = "test1.InnerTest$Inner";
+ private static final Executor MOCK_EXECUTOR = new DefaultRunExecutor() {
+ @NotNull
+ @Override
+ public String getId() {
+ return "mock";
+ }
+ };
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ addModule("module1");
+ addModule("module2");
+ addModule("module3");
+ assignJdk(getModule1());
+ }
+
+ public void testCreateConfiguration() throws IOException, ExecutionException {
+ Module module1 = getModule1();
+ PsiClass psiClass = findTestA(module1);
+ JUnitConfiguration configuration = createConfiguration(psiClass);
+ assertEquals(Collections.singleton(module1), new HashSet(Arrays.asList(configuration.getModules())));
+ checkClassName(psiClass.getQualifiedName(), configuration);
+ assertEquals(psiClass.getName(), configuration.getName());
+ checkTestObject(JUnitConfiguration.TEST_CLASS, configuration);
+ Module module2 = getModule2();
+ CHECK.compareUnordered(new Module[]{module1, module2}, configuration.getValidModules());
+
+ PsiClass innerTest = findClass(module1, INNER_TEST_NAME);
+ configuration = createJUnitConfiguration(innerTest, TestClassConfigurationProducer.class, new MapDataContext());
+ checkClassName(RT_INNER_TEST_NAME, configuration);
+ checkCanRun(configuration);
+
+ PsiMethod[] testMethod = innerTest.findMethodsByName("test", false);
+ assertEquals(1, testMethod.length);
+ configuration = createConfiguration(testMethod[0]);
+ checkClassName(RT_INNER_TEST_NAME, configuration);
+ checkMethodName("test", configuration);
+ checkTestObject(JUnitConfiguration.TEST_METHOD, configuration);
+ checkCanRun(configuration);
+
+ PsiMethod mainMethod = innerTest.findMethodsByName("main", false)[0];
+ ApplicationConfiguration appConfiguration = createConfiguration(mainMethod);
+ assertEquals(RT_INNER_TEST_NAME, appConfiguration.MAIN_CLASS_NAME);
+ checkCanRun(configuration);
+ }
+
+ public void testModulesSelector() throws ConfigurationException {
+ if (IdeaTestUtil.COVERAGE_ENABLED_BUILD) return;
+
+ Module module1 = getModule1();
+ Module module2 = getModule2();
+ JUnitConfigurable editor = new JUnitConfigurable(myProject);
+ try {
+ JUnitConfiguration configuration = createConfiguration(findTestA(module2));
+ editor.getComponent(); // To get all the watchers installed.
+ Configurable configurable = new RunConfigurationConfigurableAdapter(editor, configuration);
+ JComboBox comboBox = editor.getModulesComponent();
+ configurable.reset();
+ assertFalse(configurable.isModified());
+ assertEquals(module2.getName(), ((Module)comboBox.getSelectedItem()).getName());
+ assertEquals(ModuleManager.getInstance(myProject).getModules().length + 1, comboBox.getModel().getSize()); //no module
+ comboBox.setSelectedItem(module1);
+ assertTrue(configurable.isModified());
+ configurable.apply();
+ assertFalse(configurable.isModified());
+ assertEquals(Collections.singleton(module1), new HashSet(Arrays.asList(configuration.getModules())));
+ }
+ finally {
+ Disposer.dispose(editor);
+ }
+ }
+
+ public void testCantCreateConfiguration() {
+ PsiClass objectClass =
+ JavaPsiFacade.getInstance(myProject).findClass(CommonClassNames.JAVA_LANG_OBJECT, GlobalSearchScope.allScope(myProject));
+ assertNull(createConfiguration(objectClass));
+ assertNull(createConfiguration(JUnitUtil.getContainingPackage(objectClass)));
+ }
+
+ public void testRunningJUnit() throws ExecutionException {
+ PsiClass testA = findTestA(getModule1());
+ JUnitConfiguration configuration = createConfiguration(testA);
+ JavaParameters parameters = checkCanRun(configuration);
+ CHECK.empty(parameters.getVMParametersList().getList());
+ assertTrue(JUnitStarter.checkVersion(parameters.getProgramParametersList().getArray(),
+ new SegmentedOutputStream(System.out)));
+ assertTrue(parameters.getProgramParametersList().getList().contains(testA.getQualifiedName()));
+ assertEquals(JUnitStarter.class.getName(), parameters.getMainClass());
+ assertEquals(myJdk.getHomeDirectory().getPresentableUrl(), parameters.getJdkPath());
+ }
+
+ public void testRunningAllInPackage() throws IOException, ExecutionException {
+ Module module1 = getModule1();
+ GlobalSearchScope module1AndLibraries = GlobalSearchScope.moduleWithLibrariesScope(module1);
+ PsiClass testCase = findClass(TestCase.class.getName(), module1AndLibraries);
+ PsiClass psiClass = findTestA(module1);
+ PsiClass psiClass2 = findTestA(getModule2());
+ PsiClass derivedTest = findClass(module1, "test1.DerivedTest");
+ PsiClass baseTestCase = findClass("junit.framework.ThirdPartyClass", module1AndLibraries);
+ PsiClass testB = findClass(getModule3(), "test1.TestB");
+ assertNotNull(testCase);
+ assertNotNull(derivedTest);
+ assertNotNull(psiClass);
+ assertTrue(psiClass.isInheritor(testCase, false));
+ assertEquals(baseTestCase, derivedTest.getSuperClass());
+ assertTrue(baseTestCase.isInheritor(testCase, true));
+ assertTrue(derivedTest.isInheritor(testCase, true));
+ PsiPackage psiPackage = JUnitUtil.getContainingPackage(psiClass);
+ JUnitConfiguration configuration = createConfiguration(psiPackage, module1);
+ JavaParameters parameters = checkCanRun(configuration);
+ List<String> lines = extractAllInPackageTests(parameters, psiPackage);
+ CHECK.compareUnordered(
+ new Object[]{psiClass.getQualifiedName(), psiClass2.getQualifiedName(), derivedTest.getQualifiedName(), RT_INNER_TEST_NAME,
+ testB.getQualifiedName()},
+ lines);
+ }
+
+ public void testRunAllInPackageWhenPackageIsEmptyInModule() throws ExecutionException {
+ assignJdk(getModule2());
+ JUnitConfiguration configuration =
+ new JUnitConfiguration("", myProject, JUnitConfigurationType.getInstance().getConfigurationFactories()[0]);
+ configuration.getPersistentData().TEST_OBJECT = JUnitConfiguration.TEST_PACKAGE;
+ configuration.getPersistentData().PACKAGE_NAME = "test2";
+ configuration.getPersistentData().setScope(TestSearchScope.WHOLE_PROJECT);
+ assertEmpty(configuration.getModules());
+ checkCanRun(configuration);
+ configuration.getPersistentData().PACKAGE_NAME = "noTests";
+// checkCantRun(configuration, "No tests found in the package '");
+
+ configuration.getPersistentData().PACKAGE_NAME = "com.abcent";
+ checkCantRun(configuration, "Package 'com.abcent' not found");
+ }
+
+ public void testAllInPackageForCommonAncestorModule() throws IOException, ExecutionException {
+ disposeModule(getModule2());
+ addModule("module5", true);
+ Module ancestor = getModule1();
+ Module child1 = getModule2();
+ Module child2 = getModule3();
+ addDependency(ancestor, child1);
+ addDependency(ancestor, child2);
+ PsiPackage psiPackage = JavaPsiFacade.getInstance(myProject).findPackage("test1");
+ JUnitConfiguration configuration = createJUnitConfiguration(psiPackage, AllInPackageConfigurationProducer.class, new MapDataContext());
+ configuration.getPersistentData().setScope(TestSearchScope.WHOLE_PROJECT);
+ assertNotNull(configuration);
+ checkPackage(psiPackage.getQualifiedName(), configuration);
+ assertEmpty(configuration.getModules());
+ JavaParameters parameters = checkCanRun(configuration);
+ List<String> tests = extractAllInPackageTests(parameters, psiPackage);
+ String childTest1 = findClass(child1, "test1.TestB").getQualifiedName();
+ String childTest2 = findClass(child2, "test1.Test5").getQualifiedName();
+ String ancestorTest = findClass(ancestor, "test1.TestA").getQualifiedName();
+ CHECK.containsAll(tests, new Object[]{ancestorTest, childTest1, childTest2});
+ }
+
+ public void testClasspathConfiguration() throws CantRunException {
+ JavaParameters parameters = new JavaParameters();
+ RunConfigurationModule module = new JavaRunConfigurationModule(myProject, false);
+ Module module1 = getModule1();
+ Module module2 = getModule2();
+ addDependency(module1, module2);
+ Module module3 = getModule3();
+ addDependency(module2, module3);
+ addDependency(module1, module3);
+ addOutputs(module1, 1);
+ addOutputs(module2, 2);
+ addOutputs(module3, 3);
+ module.setModule(module1);
+ parameters.configureByModule(module.getModule(), JavaParameters.JDK_AND_CLASSES_AND_TESTS);
+ ArrayList<String> classPath = new ArrayList<String>();
+ StringTokenizer tokenizer = new StringTokenizer(parameters.getClassPath().getPathsString(), File.pathSeparator);
+ while (tokenizer.hasMoreTokens()) {
+ String token = tokenizer.nextToken();
+ classPath.add(token);
+ }
+ CHECK.singleOccurence(classPath, getOutput(module1, false));
+ CHECK.singleOccurence(classPath, getOutput(module1, false));
+ CHECK.singleOccurence(classPath, getOutput(module1, true));
+ CHECK.singleOccurence(classPath, getOutput(module2, false));
+ CHECK.singleOccurence(classPath, getOutput(module2, true));
+ CHECK.singleOccurence(classPath, getOutput(module3, false));
+ CHECK.singleOccurence(classPath, getOutput(module3, true));
+ CHECK.singleOccurence(classPath, getFSPath(findFile(MOCK_JUNIT)));
+ }
+
+ public void testExternalizeJUnitConfiguration() throws WriteExternalException, InvalidDataException {
+ JUnitConfiguration configuration = createConfiguration(findTestA(getModule1()));
+ Element element = new Element("cfg");
+ configuration.writeExternal(element);
+ JUnitConfiguration newCfg =
+ new JUnitConfiguration(null, myProject, JUnitConfigurationType.getInstance().getConfigurationFactories()[0]);
+
+ newCfg.readExternal(element);
+ checkTestObject(configuration.getPersistentData().TEST_OBJECT, newCfg);
+ assertEquals(Collections.singleton(getModule1()), new HashSet(Arrays.asList(newCfg.getModules())));
+ checkClassName(configuration.getPersistentData().getMainClassName(), newCfg);
+ }
+
+ public void testTestClassPathWhenRunningConfigurations() throws IOException, ExecutionException {
+ addModule("module4", false);
+ Module module4 = getModule4();
+ assignJdk(module4);
+ addSourcePath(module4, "testSrc", true);
+ addSourcePath(module4, "src", false);
+ String output = setCompilerOutput(module4, "classes", false);
+ String testOuput = setCompilerOutput(module4, "testClasses", true);
+
+ ApplicationConfiguration applicationConfiguration = createConfiguration(findClass(module4, "Application"));
+ JavaParameters parameters = checkCanRun(applicationConfiguration);
+ String classPath = parameters.getClassPath().getPathsString();
+ checkDoesNotContain(classPath, testOuput);
+ checkContains(classPath, output);
+
+ JUnitConfiguration junitConfiguration =
+ createJUnitConfiguration(findClass(module4, "TestApplication"), TestClassConfigurationProducer.class, new MapDataContext());
+ parameters = checkCanRun(junitConfiguration);
+ classPath = parameters.getClassPath().getPathsString();
+ checkContains(classPath, testOuput);
+ checkContains(classPath, output);
+
+ applicationConfiguration.MAIN_CLASS_NAME = junitConfiguration.getPersistentData().getMainClassName();
+ classPath = checkCanRun(applicationConfiguration).getClassPath().getPathsString();
+ checkContains(classPath, testOuput);
+ checkContains(classPath, output);
+ }
+
+ public void testSameTestAndCommonOutput() throws IOException, ExecutionException {
+ addModule("module4", false);
+ Module module = getModule4();
+ assignJdk(module);
+ addSourcePath(module, "src", false);
+ addSourcePath(module, "testSrc", false);
+ String output = setCompilerOutput(module, "classes", false);
+ assertEquals(output, setCompilerOutput(module, "classes", true));
+
+ RunConfiguration configuration = createConfiguration(findClass(module, "Application"));
+ JavaParameters javaParameters = checkCanRun(configuration);
+ checkContains(javaParameters.getClassPath().getPathsString(), output);
+
+ configuration = createConfiguration(findClass(module, "TestApplication"));
+ javaParameters = checkCanRun(configuration);
+ checkContains(javaParameters.getClassPath().getPathsString(), output);
+ }
+
+ public void testCreatingApplicationConfiguration() throws ConfigurationException {
+ if (IdeaTestUtil.COVERAGE_ENABLED_BUILD) return;
+
+ ApplicationConfiguration configuration = new ApplicationConfiguration(null, myProject, ApplicationConfigurationType.getInstance());
+ ApplicationConfigurable editor = new ApplicationConfigurable(myProject);
+ try {
+ editor.getComponent(); // To get all the watchers installed.
+ Configurable configurable = new RunConfigurationConfigurableAdapter(editor, configuration);
+ configurable.reset();
+ CommonJavaParametersPanel javaParameters = editor.getCommonProgramParameters();
+ javaParameters.setProgramParameters("prg");
+ javaParameters.setVMParameters("vm");
+ javaParameters.setWorkingDirectory("dir");
+ assertTrue(configurable.isModified());
+ configurable.apply();
+ assertEquals("prg", configuration.getProgramParameters());
+ assertEquals("vm", configuration.getVMParameters());
+ assertEquals("dir", configuration.getWorkingDirectory());
+ }
+ finally {
+ Disposer.dispose(editor);
+ }
+ }
+
+ public void testCreateInnerPackageLocalApplication() throws ExecutionException {
+ PsiClass psiClass = findClass(getModule1(), "test2.NotATest.InnerApplication");
+ assertNotNull(psiClass);
+ ApplicationConfiguration configuration = createConfiguration(psiClass);
+ assertEquals("test2.NotATest$InnerApplication", configuration.MAIN_CLASS_NAME);
+ checkCanRun(configuration);
+ }
+
+ public void testEditJUnitConfiguration() throws ConfigurationException {
+ if (IdeaTestUtil.COVERAGE_ENABLED_BUILD) return;
+
+ PsiClass testA = findTestA(getModule2());
+ JUnitConfiguration configuration = createConfiguration(testA);
+ JUnitConfigurable editor = new JUnitConfigurable(myProject);
+ try {
+ Configurable configurable = new RunConfigurationConfigurableAdapter(editor, configuration);
+ configurable.reset();
+ final EditorTextFieldWithBrowseButton component =
+ ((LabeledComponent<EditorTextFieldWithBrowseButton>)editor.getTestLocation(JUnitConfigurationModel.CLASS)).getComponent();
+ assertEquals(testA.getQualifiedName(), component.getText());
+ PsiClass otherTest = findClass(getModule2(), "test2.Test2");
+ component.setText(otherTest.getQualifiedName());
+ configurable.apply();
+ assertEquals(otherTest.getName(), configuration.getName());
+ String specialName = "My name";
+ configuration.setName(specialName);
+ configuration.setNameChangedByUser(true);
+ configurable.reset();
+ component.setText(testA.getQualifiedName());
+ configurable.apply();
+ assertEquals(specialName, configuration.getName());
+ }
+ finally {
+ Disposer.dispose(editor);
+ }
+ }
+
+ public void testRunThridPartyApplication() throws ExecutionException {
+ ApplicationConfiguration configuration =
+ new ApplicationConfiguration("Thrid party", myProject, ApplicationConfigurationType.getInstance());
+ configuration.setModule(getModule1());
+ configuration.MAIN_CLASS_NAME = "thrid.party.Main";
+ checkCanRun(configuration);
+ }
+
+ public void testAllInPackageForProject() throws IOException, ExecutionException {
+ // module1 -> module2 -> module3
+ // module5
+ addModule("module5");
+ addDependency(getModule1(), getModule2());
+ addDependency(getModule2(), getModule3());
+ String[][] outputs = new String[4][];
+ for (int i = 0; i < 4; i++) {
+ outputs[i] = addOutputs(getModule(i), i + 1);
+ }
+
+
+ PsiPackage defaultPackage = JavaPsiFacade.getInstance(myProject).findPackage("");
+ JUnitConfiguration configuration =
+ createJUnitConfiguration(defaultPackage, AllInPackageConfigurationProducer.class, new MapDataContext());
+ configuration.getPersistentData().setScope(TestSearchScope.WHOLE_PROJECT);
+ JavaParameters javaParameters = checkCanRun(configuration);
+ String classPath = javaParameters.getClassPath().getPathsString();
+ assertEquals(-1, classPath.indexOf(JarFileSystem.PROTOCOL_PREFIX));
+ assertEquals(-1, classPath.indexOf(LocalFileSystem.PROTOCOL_PREFIX));
+ for (int i = 0; i < 4; i++) {
+ checkContains(classPath, outputs[i][0]);
+ checkContains(classPath, outputs[i][1]);
+ }
+ }
+
+ private void assignJdk(Module module) {
+ myJdk = ModuleRootManager.getInstance(myModule).getSdk();
+ ModuleRootModificationUtil.setModuleSdk(module, myJdk);
+ }
+
+ private static String getOutput(Module module1, boolean test) {
+ CompilerModuleExtension compilerModuleExtension = CompilerModuleExtension.getInstance(module1);
+ assertNotNull(compilerModuleExtension);
+ VirtualFile output = test ? compilerModuleExtension.getCompilerOutputPathForTests() : compilerModuleExtension.getCompilerOutputPath();
+ return getFSPath(output);
+ }
+
+ private static String getFSPath(VirtualFile output) {
+ return PathUtil.getLocalPath(output);
+ }
+
+ private String[] addOutputs(Module module, int index) {
+ String[] outputs = new String[2];
+ String prefix = "outputs" + File.separatorChar;
+ VirtualFile generalOutput = findFile(prefix + "general " + index);
+ VirtualFile testOutput = findFile(prefix + "tests" + index);
+ outputs[0] = generalOutput.getPresentableUrl();
+ outputs[1] = testOutput.getPresentableUrl();
+ PsiTestUtil.setCompilerOutputPath(module, generalOutput.getUrl(), false);
+ PsiTestUtil.setCompilerOutputPath(module, testOutput.getUrl(), true);
+ return outputs;
+ }
+
+ private JavaParameters checkCanRun(RunConfiguration configuration) throws ExecutionException {
+ final RunProfileState state;
+ state = configuration.getState(MOCK_EXECUTOR, new ExecutionEnvironment(new MockProfile(), MOCK_EXECUTOR, myProject, null));
+ assertNotNull(state);
+ assertTrue(state instanceof JavaCommandLine);
+ if (state instanceof TestPackage) {
+ final JavaParameters parameters = ((TestPackage)state).getJavaParameters();
+ ((TestPackage)state).findTests();
+ }
+ try {
+ configuration.checkConfiguration();
+ }
+ catch (RuntimeConfigurationError e) {
+ fail("cannot run: " + e.getMessage());
+ }
+ catch (RuntimeConfigurationException e) {
+ //ignore
+ }
+ return ((JavaCommandLine)state).getJavaParameters();
+ }
+
+ private void checkCantRun(RunConfiguration configuration, String reasonBegining) throws ExecutionException {
+ //MockRunRequest request = new MockRunRequest(myProject);
+ //CantRunException rejectReason;
+ //try {
+ // configuration.runRequested(request);
+ // rejectReason = request.myRejectReason;
+ //}
+ //catch (CantRunException e) {
+ // rejectReason = e;
+ //}
+ //if (rejectReason == null) fail("Should not run");
+ //rejectReason.getMessage().startsWith(reasonBegining);
+
+ try {
+ configuration.checkConfiguration();
+ }
+ catch (RuntimeConfigurationError e) {
+ assertTrue(e.getLocalizedMessage().startsWith(reasonBegining));
+ return;
+ }
+ catch (RuntimeConfigurationException e) {
+
+ }
+
+ final RunProfileState state = configuration
+ .getState(MOCK_EXECUTOR, new ExecutionEnvironment(new MockProfile(), MOCK_EXECUTOR, myProject, null));
+ assertTrue(state instanceof JavaCommandLine);
+
+ try {
+ ((JavaCommandLine)state).getJavaParameters();
+ }
+ catch (Throwable e) {
+ assertTrue(e.getLocalizedMessage().startsWith(reasonBegining));
+ return;
+ }
+
+ fail("Should not run");
+ }
+
+ private static String setCompilerOutput(Module module, String path, boolean testOutput) {
+ VirtualFile output = ModuleRootManager.getInstance(module).getContentEntries()[0].getFile().findChild(path);
+ assertNotNull(output);
+ PsiTestUtil.setCompilerOutputPath(module, output.getUrl(), testOutput);
+ return output.getPath().replace('/', File.separatorChar);
+ }
+
+ private static void addSourcePath(Module module, String path, boolean testSource) {
+ final ContentEntry entry = ModuleRootManager.getInstance(module).getContentEntries()[0];
+ VirtualFile child = entry.getFile().findChild(path);
+ assertNotNull(child);
+ PsiTestUtil.addSourceRoot(module, child, testSource);
+ }
+
+ private JUnitConfiguration createConfiguration(PsiPackage psiPackage, Module module) {
+ JUnitConfiguration configuration =
+ new JUnitConfiguration("", myProject, JUnitConfigurationType.getInstance().getConfigurationFactories()[0]);
+ configuration.getPersistentData().TEST_OBJECT = JUnitConfiguration.TEST_PACKAGE;
+ configuration.getPersistentData().PACKAGE_NAME = psiPackage.getQualifiedName();
+ configuration.getPersistentData().setScope(TestSearchScope.WHOLE_PROJECT);
+ configuration.setModule(module);
+ return configuration;
+ }
+
+ private PsiClass findTestA(Module module) {
+ return findClass(module, "test1.TestA");
+ }
+
+ private static List<String> readLinesFrom(File file) throws IOException {
+ if (!file.exists()) file.createNewFile();
+ ArrayList<String> result = new ArrayList<String>();
+ BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
+ try {
+ String line;
+ while ((line = reader.readLine()) != null) result.add(line);
+ return result;
+ }
+ finally {
+ reader.close();
+ }
+ }
+
+ private static List<String> extractAllInPackageTests(JavaParameters parameters, PsiPackage psiPackage)
+ throws IOException {
+ String filePath = ContainerUtil.find(parameters.getProgramParametersList().getArray(), new Condition<String>() {
+ @Override
+ public boolean value(String value) {
+ return StringUtil.startsWithChar(value, '@');
+ }
+ }).substring(1);
+ List<String> lines = readLinesFrom(new File(filePath));
+ assertEquals(psiPackage.getQualifiedName(), lines.get(0));
+ //lines.remove(0);
+ lines.remove(0);
+ return lines;
+ }
+
+ private static void checkContains(String string, String fragment) {
+ assertTrue(fragment + " in " + string, string.indexOf(fragment) >= 0);
+ }
+
+ private static void checkDoesNotContain(String string, String fragment) {
+ assertFalse(fragment + " in " + string, string.indexOf(fragment) >= 0);
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ myJdk = null;
+ super.tearDown();
+ }
+
+ private static class MockProfile implements RunProfile {
+ @Override
+ public RunProfileState getState(@NotNull final Executor executor, @NotNull final ExecutionEnvironment env) throws ExecutionException {
+ return null;
+ }
+
+ @Override
+ public Icon getIcon() {
+ return null;
+ }
+
+ @Override
+ public String getName() {
+ return null;
+ }
+ }
+}
diff --git a/java/java-tests/testSrc/com/intellij/execution/TestSources.java b/java/java-tests/testSrc/com/intellij/execution/TestSources.java
new file mode 100644
index 0000000..3cb571c
--- /dev/null
+++ b/java/java-tests/testSrc/com/intellij/execution/TestSources.java
@@ -0,0 +1,98 @@
+package com.intellij.execution;
+
+import com.intellij.openapi.module.Module;
+import com.intellij.openapi.module.ModuleManager;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.roots.ModuleRootManager;
+import com.intellij.openapi.roots.ModuleRootModificationUtil;
+import com.intellij.openapi.vfs.LocalFileSystem;
+import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.psi.JavaPsiFacade;
+import com.intellij.psi.PsiClass;
+import com.intellij.psi.PsiPackage;
+import com.intellij.psi.search.GlobalSearchScope;
+import com.intellij.testFramework.PsiTestUtil;
+import com.intellij.testFramework.TempFiles;
+import org.jetbrains.annotations.Nullable;
+
+import java.io.*;
+import java.util.Collection;
+
+public class TestSources {
+ private final Project myProject;
+ private final TempFiles myTempFiles;
+ private File mySrc;
+ private Module myModule;
+
+ public TestSources(Project project, Collection<File> filesToDelete) {
+ myProject = project;
+ myTempFiles = new TempFiles(filesToDelete);
+ }
+
+ public void tearDown() {
+ if (myModule != null) {
+ disposeModule(myModule);
+ myModule = null;
+ }
+ }
+
+ public PsiPackage createPackage(String name) {
+ File dir = new File(mySrc, name);
+ dir.mkdir();
+ LocalFileSystem.getInstance().refreshAndFindFileByIoFile(dir);
+ return findPackage(name);
+ }
+
+ public PsiPackage findPackage(String name) {
+ return JavaPsiFacade.getInstance(myProject).findPackage(name);
+ }
+
+ @Nullable
+ public PsiClass createClass(String className, String code) throws FileNotFoundException {
+ File file = new File(mySrc, className + ".java");
+ PrintStream stream = new PrintStream(new FileOutputStream(file));
+ try {
+ stream.println(code);
+ }
+ finally {
+ stream.close();
+ }
+ LocalFileSystem.getInstance().refreshAndFindFileByIoFile(file);
+ return JavaPsiFacade.getInstance(myProject).findClass(className, GlobalSearchScope.allScope(myProject));
+ }
+
+ public void initModule() throws IOException {
+ if (myModule != null) disposeModule(myModule);
+ mySrc = myTempFiles.createTempDir();
+ myModule = BaseConfigurationTestCase.createTempModule(myTempFiles, myProject);
+ VirtualFile moduleContent = TempFiles.getVFileByFile(mySrc);
+ PsiTestUtil.addSourceRoot(myModule, moduleContent);
+
+ Module tempModule = BaseConfigurationTestCase.createTempModule(myTempFiles, myProject);
+ ModuleRootModificationUtil.addDependency(myModule, tempModule);
+ disposeModule(tempModule);
+ }
+
+ private void disposeModule(Module tempModule) {
+ ModuleManager.getInstance(myProject).disposeModule(tempModule);
+ }
+
+ public void copyJdkFrom(Module module) {
+ ModuleRootModificationUtil.setModuleSdk(myModule, ModuleRootManager.getInstance(module).getSdk());
+ }
+
+ public void addLibrary(VirtualFile lib) {
+ ModuleRootModificationUtil.addModuleLibrary(myModule, lib.getUrl());
+ }
+
+ public VirtualFile createPackageDir(String packageName) {
+ File pkg = new File(mySrc, packageName);
+ pkg.mkdirs();
+ VirtualFile pkgFile = TempFiles.getVFileByFile(pkg);
+ return pkgFile;
+ }
+
+ public PsiClass findClass(String fqName) {
+ return JavaPsiFacade.getInstance(myProject).findClass(fqName, GlobalSearchScope.moduleScope(myModule));
+ }
+}
diff --git a/java/java-tests/testSrc/com/intellij/execution/actions/BaseRunConfigurationActionTest.java b/java/java-tests/testSrc/com/intellij/execution/actions/BaseRunConfigurationActionTest.java
new file mode 100644
index 0000000..b02e830
--- /dev/null
+++ b/java/java-tests/testSrc/com/intellij/execution/actions/BaseRunConfigurationActionTest.java
@@ -0,0 +1,56 @@
+package com.intellij.execution.actions;
+
+import com.intellij.execution.application.ApplicationConfiguration;
+import com.intellij.execution.application.ApplicationConfigurationType;
+import com.intellij.execution.configurations.LocatableConfiguration;
+import com.intellij.execution.junit.JUnitConfiguration;
+import com.intellij.execution.junit.JUnitConfigurationType;
+import com.intellij.testFramework.LightIdeaTestCase;
+
+public class BaseRunConfigurationActionTest extends LightIdeaTestCase {
+ public void testRunApplicationName() {
+ ApplicationConfiguration configuration = new ApplicationConfiguration(null, getProject(), ApplicationConfigurationType.getInstance());
+
+ configuration.MAIN_CLASS_NAME = "com.comp.AClass";
+ configuration.setGeneratedName();
+ checkSuggestedName("AClass.main()", configuration);
+
+ configuration.setName("Other name");
+ configuration.setNameChangedByUser(true);
+ checkSuggestedName("Other name", configuration);
+
+ configuration.setName("1234567890123456789012345 other long name");
+ checkSuggestedName("12345678901234567890...", configuration);
+
+ configuration.MAIN_CLASS_NAME = "com.comp.A12345678901234567890123LongName";
+ configuration.setGeneratedName();
+ checkSuggestedName("A1234567890123....main()", configuration);
+ }
+
+ public void testRunTestMethodName() {
+ JUnitConfiguration configuration = new JUnitConfiguration(null, getProject(), JUnitConfigurationType.getInstance().getConfigurationFactories()[0]);
+ JUnitConfiguration.Data data = configuration.getPersistentData();
+
+ data.MAIN_CLASS_NAME = "com.comp.ATestClass";
+ configuration.setGeneratedName();
+ checkSuggestedName("ATestClass", configuration);
+
+ configuration.setName("Other name");
+ configuration.setNameChangedByUser(true);
+ checkSuggestedName("Other name", configuration);
+
+ data.METHOD_NAME = "testSmth";
+ data.TEST_OBJECT = JUnitConfiguration.TEST_METHOD;
+ configuration.setGeneratedName();
+ checkSuggestedName("testSmth()", configuration);
+
+ data.METHOD_NAME = "12345678901234567890";
+ configuration.setGeneratedName();
+ checkSuggestedName("123456789012345678...()", configuration);
+ }
+
+ private static void checkSuggestedName(String expectedName, LocatableConfiguration configuration) {
+ String suggestedName = BaseRunConfigurationAction.suggestRunActionName(configuration);
+ assertEquals(expectedName, suggestedName);
+ }
+}
diff --git a/java/java-tests/testSrc/com/intellij/execution/actions/ContextConfigurationTest.java b/java/java-tests/testSrc/com/intellij/execution/actions/ContextConfigurationTest.java
new file mode 100644
index 0000000..ab75166
--- /dev/null
+++ b/java/java-tests/testSrc/com/intellij/execution/actions/ContextConfigurationTest.java
@@ -0,0 +1,163 @@
+package com.intellij.execution.actions;
+
+import com.intellij.execution.BaseConfigurationTestCase;
+import com.intellij.execution.RunManagerEx;
+import com.intellij.execution.RunnerAndConfigurationSettings;
+import com.intellij.execution.application.ApplicationConfiguration;
+import com.intellij.execution.junit.*;
+import com.intellij.execution.testframework.TestSearchScope;
+import com.intellij.openapi.actionSystem.DataConstants;
+import com.intellij.openapi.actionSystem.ex.DataConstantsEx;
+import com.intellij.openapi.module.Module;
+import com.intellij.openapi.module.ModuleUtil;
+import com.intellij.psi.PsiClass;
+import com.intellij.psi.PsiMethod;
+import com.intellij.psi.PsiPackage;
+import com.intellij.testFramework.MapDataContext;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+
+public class ContextConfigurationTest extends BaseConfigurationTestCase {
+ private static final String PACKAGE_NAME = "apackage";
+ private static final String SHORT_CLASS_NAME = "SampleClass";
+ private static final String CLASS_NAME = PACKAGE_NAME + "." + SHORT_CLASS_NAME;
+ private static final String METHOD_NAME = "test1";
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ addModule("commonConfiguration");
+ }
+
+ public void testJUnitMethodTest() {
+ PsiClass psiClass = findClass(getModule1(), CLASS_NAME);
+ PsiMethod testMethod = psiClass.findMethodsByName(METHOD_NAME, false)[0];
+ JUnitConfiguration configuration = (JUnitConfiguration)createConfiguration(testMethod);
+ checkTestObject(JUnitConfiguration.TEST_METHOD, configuration);
+ checkClassName(CLASS_NAME, configuration);
+ checkMethodName(METHOD_NAME, configuration);
+ checkPackage(PACKAGE_NAME, configuration);
+ checkGeneretedName(configuration, SHORT_CLASS_NAME + "." + METHOD_NAME);
+ }
+
+ public void testJUnitClassTest() {
+ PsiClass psiClass = findClass(getModule1(), CLASS_NAME);
+ final MapDataContext dataContext = new MapDataContext();
+ JUnitConfiguration configuration = createJUnitConfiguration(psiClass, TestClassConfigurationProducer.class, dataContext);
+ checkTestObject(JUnitConfiguration.TEST_CLASS, configuration);
+ checkClassName(CLASS_NAME, configuration);
+ checkPackage(PACKAGE_NAME, configuration);
+ checkGeneretedName(configuration, SHORT_CLASS_NAME);
+ }
+
+
+ public void testRecreateJUnitClass() throws IOException {
+ createEmptyModule();
+ addDependency(getModule2(), getModule1());
+ PsiClass psiClass = findClass(getModule1(), CLASS_NAME);
+ PsiPackage psiPackage = JUnitUtil.getContainingPackage(psiClass);
+ JUnitConfiguration configuration = createJUnitConfiguration(psiPackage, AllInPackageConfigurationProducer.class, new MapDataContext());
+ configuration.getPersistentData().setScope(TestSearchScope.MODULE_WITH_DEPENDENCIES);
+ configuration.setModule(getModule2());
+ MapDataContext dataContext = new MapDataContext();
+ dataContext.put(DataConstantsEx.RUNTIME_CONFIGURATION, configuration);
+ configuration = createJUnitConfiguration(psiClass, TestClassConfigurationProducer.class, dataContext);
+ checkClassName(psiClass.getQualifiedName(), configuration);
+ assertEquals(Collections.singleton(getModule2()), new HashSet(Arrays.asList(configuration.getModules())));
+ }
+
+ public void testJUnitPackage() {
+ PsiClass psiClass = findClass(getModule1(), CLASS_NAME);
+ PsiPackage psiPackage = JUnitUtil.getContainingPackage(psiClass);
+ final MapDataContext dataContext = new MapDataContext();
+ final Module module = ModuleUtil.findModuleForPsiElement(psiClass);
+ dataContext.put(DataConstants.MODULE, module);
+ JUnitConfiguration configuration = createJUnitConfiguration(psiPackage, AllInPackageConfigurationProducer.class, dataContext);
+ checkTestObject(JUnitConfiguration.TEST_PACKAGE, configuration);
+ checkPackage(PACKAGE_NAME, configuration);
+ checkGeneretedName(configuration, PACKAGE_NAME + " in " + module.getName());
+ }
+
+ public void testJUnitDefaultPackage() {
+ PsiClass psiClass = findClass(getModule1(), CLASS_NAME);
+ PsiPackage psiPackage = JUnitUtil.getContainingPackage(psiClass);
+ PsiPackage defaultPackage = psiPackage.getParentPackage();
+ final Module module = ModuleUtil.findModuleForPsiElement(psiClass);
+ final MapDataContext dataContext = new MapDataContext();
+ dataContext.put(DataConstants.MODULE, module);
+ JUnitConfiguration configuration = createJUnitConfiguration(defaultPackage, AllInPackageConfigurationProducer.class, dataContext);
+ checkTestObject(JUnitConfiguration.TEST_PACKAGE, configuration);
+ checkPackage("", configuration);
+ checkGeneretedName(configuration, "All in " + module.getName());
+ }
+
+ public void testApplication() {
+ PsiClass psiClass = findClass(getModule1(), CLASS_NAME);
+ PsiMethod psiMethod = psiClass.findMethodsByName("main", false)[0];
+ ApplicationConfiguration configuration = createConfiguration(psiMethod);
+ assertEquals(CLASS_NAME, configuration.MAIN_CLASS_NAME);
+ assertEquals(configuration.suggestedName(), configuration.getName());
+ assertEquals(SHORT_CLASS_NAME, configuration.getName());
+ }
+
+ public void testReusingConfiguration() {
+ RunManagerEx runManager = RunManagerEx.getInstanceEx(myProject);
+ PsiClass psiClass = findClass(getModule1(), CLASS_NAME);
+ PsiPackage psiPackage = JUnitUtil.getContainingPackage(psiClass);
+
+ ConfigurationContext context = createContext(psiClass);
+ assertEquals(null, context.findExisting());
+ RunnerAndConfigurationSettings testClass = context.getConfiguration();
+ runManager.addConfiguration(testClass, false);
+ context = createContext(psiClass);
+ assertSame(testClass, context.findExisting());
+
+ runManager.setSelectedConfiguration(testClass);
+ context = createContext(psiPackage);
+ assertEquals(null, context.findExisting());
+ RunnerAndConfigurationSettings testPackage = context.getConfiguration();
+ runManager.addConfiguration(testPackage, false);
+ context = createContext(psiPackage);
+ assertSame(testPackage, context.findExisting());
+ assertSame(testClass, runManager.getSelectedConfiguration());
+ runManager.setSelectedConfiguration(context.findExisting());
+ assertSame(testPackage, runManager.getSelectedConfiguration());
+ }
+
+ public void testJUnitGeneratedName() {
+ PsiClass psiClass = findClass(getModule1(), CLASS_NAME);
+ PsiPackage psiPackage = JUnitUtil.getContainingPackage(psiClass);
+ JUnitConfiguration configuration = new JUnitConfiguration(null, myProject, JUnitConfigurationType.getInstance().getConfigurationFactories()[0]);
+ JUnitConfiguration.Data data = configuration.getPersistentData();
+ data.PACKAGE_NAME = psiPackage.getQualifiedName();
+ data.TEST_OBJECT = JUnitConfiguration.TEST_PACKAGE;
+ assertEquals(PACKAGE_NAME, configuration.suggestedName());
+ data.PACKAGE_NAME = "not.existing.pkg";
+ assertEquals("not.existing.pkg", configuration.suggestedName());
+
+ data.TEST_OBJECT = JUnitConfiguration.TEST_CLASS;
+ data.MAIN_CLASS_NAME = psiClass.getQualifiedName();
+ assertEquals(SHORT_CLASS_NAME, configuration.suggestedName());
+ data.MAIN_CLASS_NAME = "not.existing.TestClass";
+ assertEquals("TestClass", configuration.suggestedName());
+ data.MAIN_CLASS_NAME = "pkg.TestClass.";
+ assertEquals("pkg.TestClass.", configuration.suggestedName());
+ data.MAIN_CLASS_NAME = "TestClass";
+ assertEquals("TestClass", configuration.suggestedName());
+
+ data.TEST_OBJECT = JUnitConfiguration.TEST_METHOD;
+ data.MAIN_CLASS_NAME = psiClass.getQualifiedName();
+ data.METHOD_NAME = METHOD_NAME;
+ assertEquals(SHORT_CLASS_NAME + "." + METHOD_NAME, configuration.suggestedName());
+ data.MAIN_CLASS_NAME = "not.existing.TestClass";
+ assertEquals("TestClass." + METHOD_NAME, configuration.suggestedName());
+ }
+
+ private static void checkGeneretedName(JUnitConfiguration configuration, String name) {
+ assertEquals(configuration.suggestedName(), configuration.getName());
+ assertEquals(name, configuration.getName());
+ }
+}
diff --git a/java/java-tests/testSrc/com/intellij/execution/filters/ExceptionWorkerTest.java b/java/java-tests/testSrc/com/intellij/execution/filters/ExceptionWorkerTest.java
new file mode 100644
index 0000000..f7c56c5
--- /dev/null
+++ b/java/java-tests/testSrc/com/intellij/execution/filters/ExceptionWorkerTest.java
@@ -0,0 +1,66 @@
+package com.intellij.execution.filters;
+
+import com.intellij.openapi.editor.Document;
+import com.intellij.openapi.editor.EditorFactory;
+import com.intellij.openapi.util.TextRange;
+import com.intellij.psi.search.GlobalSearchScope;
+import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase;
+import com.intellij.util.Consumer;
+
+import java.util.ArrayList;
+
+/**
+ * @author gregsh
+ */
+public class ExceptionWorkerTest extends LightCodeInsightFixtureTestCase {
+
+ public void testParsing() {
+ myFixture.addClass("package com.sample;\n" +
+ "\n" +
+ "/**\n" +
+ " * Created with IntelliJ IDEA.\n" +
+ " * User: jetbrains\n" +
+ " * Date: 11/26/12\n" +
+ " * Time: 6:08 PM\n" +
+ " * To change this template use File | Settings | File Templates.\n" +
+ " */\n" +
+ "public class RunningMain {\n" +
+ " public static void main(String[] args) throws Exception {\n" +
+ " try {\n" +
+ " func1();\n" +
+ " }\n" +
+ " finally {\n" +
+ "\n" +
+ " }\n" +
+ " }\n" +
+ "\n" +
+ " static void func1() {\n" +
+ " try {\n" +
+ " func();\n" +
+ " }\n" +
+ " finally {\n" +
+ "\n" +
+ " }\n" +
+ " }\n" +
+ "\n" +
+ " static void func() {\n" +
+ " throw new NullPointerException();\n" +
+ " }\n" +
+ "}\n");
+
+ final String testData = "Exception in thread \"main\" java.lang.NullPointerException\n" +
+ "\tat com.sample.RunningMain.func(RunningMain.java:30)\n" +
+ "\tat com.sample.RunningMain.func1(RunningMain.java:22)\n" +
+ "\tat com.sample.RunningMain.main(RunningMain.java:13)\n";
+ final Document document = EditorFactory.getInstance().createDocument(testData);
+ FilterMixin filter = (FilterMixin)new ExceptionExFilterFactory().create(GlobalSearchScope.projectScope(getProject()));
+ final ArrayList<String> result = new ArrayList<String>();
+ filter.applyHeavyFilter(document, 0, 0, new Consumer<FilterMixin.AdditionalHighlight>() {
+ @Override
+ public void consume(FilterMixin.AdditionalHighlight highlight) {
+ result.add(new TextRange(highlight.getStart(), highlight.getEnd()-1).substring(testData));
+ }
+ });
+ assertSameElements(result, "com.sample.RunningMain.func1", "com.sample.RunningMain.main");
+ }
+}
diff --git a/java/java-tests/testSrc/com/intellij/execution/impl/RunConfigurableTest.java b/java/java-tests/testSrc/com/intellij/execution/impl/RunConfigurableTest.java
new file mode 100644
index 0000000..0591489
--- /dev/null
+++ b/java/java-tests/testSrc/com/intellij/execution/impl/RunConfigurableTest.java
@@ -0,0 +1,717 @@
+package com.intellij.execution.impl;
+
+import com.intellij.execution.application.ApplicationConfigurationType;
+import com.intellij.execution.configurations.ConfigurationType;
+import com.intellij.execution.configurations.UnknownConfigurationType;
+import com.intellij.execution.junit.JUnitConfigurationType;
+import com.intellij.ide.util.PropertiesComponent;
+import com.intellij.openapi.util.InvalidDataException;
+import com.intellij.openapi.util.JDOMUtil;
+import com.intellij.openapi.util.Trinity;
+import com.intellij.testFramework.LightIdeaTestCase;
+import com.intellij.ui.RowsDnDSupport;
+import com.intellij.ui.treeStructure.Tree;
+import org.jdom.Element;
+
+import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.tree.TreePath;
+import java.util.ArrayList;
+import java.util.List;
+
+import static com.intellij.execution.impl.RunConfigurable.NodeKind.*;
+import static com.intellij.ui.RowsDnDSupport.RefinedDropSupport.Position.*;
+
+/**
+ * User: Vassiliy.Kudryashov
+ */
+public class RunConfigurableTest extends LightIdeaTestCase {
+ private static final RunConfigurable.NodeKind[] ORDER = {
+ CONFIGURATION_TYPE,//Application
+ FOLDER,//1
+ CONFIGURATION, CONFIGURATION, CONFIGURATION, CONFIGURATION, CONFIGURATION,
+ TEMPORARY_CONFIGURATION, TEMPORARY_CONFIGURATION,
+ FOLDER,//2
+ TEMPORARY_CONFIGURATION,
+ FOLDER,//3
+ CONFIGURATION,
+ TEMPORARY_CONFIGURATION,
+ CONFIGURATION_TYPE,//JUnit
+ FOLDER,//4
+ CONFIGURATION, CONFIGURATION,
+ FOLDER,//5
+ CONFIGURATION, CONFIGURATION,
+ TEMPORARY_CONFIGURATION,
+ UNKNOWN//Defaults
+ };
+ private MockRunConfigurable myConfigurable;
+ private Tree myTree;
+ private DefaultMutableTreeNode myRoot;
+ private RunConfigurable.MyTreeModel myModel;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ myConfigurable = new MockRunConfigurable(createRunManager(JDOMUtil.loadDocument(FOLDERS_CONFIGURATION).getRootElement()));
+ myTree = myConfigurable.myTree;
+ myRoot = myConfigurable.myRoot;
+ myModel = myConfigurable.myTreeModel;
+ doExpand();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ myConfigurable.disposeUIResources();
+ myConfigurable = null;
+ myTree = null;
+ myRoot = null;
+ myModel = null;
+ super.tearDown();
+ }
+
+ public void testDND() throws Exception {
+ int[] never = {-1, 0, 14, 22, 23, 999};
+ for (int i = -1; i < 17; i++) {
+ for (int j : never) {
+ if ((j == 14 || j == 21) && i == j) {
+ continue;
+ }
+ assertCannot(j,i,ABOVE);
+ assertCannot(j,i,INTO);
+ assertCannot(j,i,BELOW);
+ }
+ }
+ assertCan(3, 3, BELOW);
+ assertCan(3, 3, ABOVE);
+ assertCannot(3, 2, BELOW);
+ assertCan(3, 2, ABOVE);
+ assertCannot(3, 1, BELOW);
+ assertCannot(3, 0, BELOW);
+ assertCan(2, 14, ABOVE);
+ assertCan(1, 14, ABOVE);
+ assertCan(1, 11, ABOVE);
+ assertCannot(1, 10, ABOVE);
+ assertCannot(1, 10, BELOW);
+ assertCannot(8, 6, ABOVE);
+ assertCan(8, 6, BELOW);
+ assertCannot(5, 7, BELOW);
+ assertCan(5, 7, ABOVE);
+ assertCannot(15, 11, INTO);
+ assertCannot(18, 21, ABOVE);
+ assertCan(15, 21, ABOVE);
+
+ assertTrue(myModel.isDropInto(myTree, 2, 9));
+ assertTrue(myModel.isDropInto(myTree, 2, 1));
+ assertTrue(myModel.isDropInto(myTree, 12, 9));
+ assertTrue(myModel.isDropInto(myTree, 12, 1));
+ assertFalse(myModel.isDropInto(myTree, 999, 9));
+ assertFalse(myModel.isDropInto(myTree, 999, 1));
+ assertFalse(myModel.isDropInto(myTree, 2, 999));
+ assertFalse(myModel.isDropInto(myTree, 2, -1));
+ }
+
+ private void doExpand() {
+ List<DefaultMutableTreeNode> toExpand = new ArrayList<DefaultMutableTreeNode>();
+ RunConfigurable.collectNodesRecursively(myRoot, toExpand, FOLDER);
+ assertEquals(toExpand.size(), 5);
+ List<DefaultMutableTreeNode> toExpand2 = new ArrayList<DefaultMutableTreeNode>();
+ RunConfigurable.collectNodesRecursively(myRoot, toExpand2, CONFIGURATION_TYPE);
+ toExpand.addAll(toExpand2);
+ for (DefaultMutableTreeNode node : toExpand) {
+ myTree.expandPath(new TreePath(node.getPath()));
+ }
+ for (int i = 0; i < ORDER.length; i++) {
+ DefaultMutableTreeNode node = (DefaultMutableTreeNode)myTree.getPathForRow(i).getLastPathComponent();
+ assertEquals("Row #" + i, RunConfigurable.getKind(node), ORDER[i]);
+ }
+ }
+
+ private void assertCan(int oldIndex, int newIndex, RowsDnDSupport.RefinedDropSupport.Position position) {
+ assertDrop(oldIndex, newIndex, position, true);
+ }
+
+ private void assertCannot(int oldIndex, int newIndex, RowsDnDSupport.RefinedDropSupport.Position position) {
+ assertDrop(oldIndex, newIndex, position, false);
+ }
+
+ private void assertDrop(int oldIndex, int newIndex, RowsDnDSupport.RefinedDropSupport.Position position, boolean canDrop) {
+ StringBuilder message = new StringBuilder();
+ message.append("(").append(oldIndex).append(")").append(myTree.getPathForRow(oldIndex)).append("->");
+ message.append("(").append(newIndex).append(")").append(myTree.getPathForRow(newIndex)).append(position);
+ if (canDrop) {
+ assertTrue(message.toString(), myModel.canDrop(oldIndex, newIndex, position));
+ }
+ else {
+ assertFalse(message.toString(), myModel.canDrop(oldIndex, newIndex, position));
+ }
+ }
+
+ public void testMoveUpDown() {
+ checkPositionToMove(0, 1, null);
+ checkPositionToMove(2, 1, Trinity.create(2, 3, BELOW));
+ checkPositionToMove(2, -1, null);
+ checkPositionToMove(14, 1, null);
+ checkPositionToMove(14, -1, null);
+ checkPositionToMove(15, -1, null);
+ checkPositionToMove(16, -1, null);
+ checkPositionToMove(3, -1, Trinity.create(3, 2, ABOVE));
+ checkPositionToMove(6, 1, Trinity.create(6, 9, BELOW));
+ checkPositionToMove(7, 1, Trinity.create(7, 8, BELOW));
+ checkPositionToMove(10, -1, Trinity.create(10, 8, BELOW));
+ checkPositionToMove(8, 1, Trinity.create(8, 9, BELOW));
+ checkPositionToMove(21, -1, Trinity.create(21, 20, BELOW));
+ checkPositionToMove(21, 1, null);
+ checkPositionToMove(20, 1, Trinity.create(20, 21, ABOVE));
+ checkPositionToMove(20, -1, Trinity.create(20, 19, ABOVE));
+ checkPositionToMove(19, 1, Trinity.create(19, 20, BELOW));
+ checkPositionToMove(19, -1, Trinity.create(19, 17, BELOW));
+ checkPositionToMove(17, -1, Trinity.create(17, 16, ABOVE));
+ checkPositionToMove(17, 1, Trinity.create(17, 18, BELOW));
+ }
+
+ private void checkPositionToMove(int selectedRow,
+ int direction,
+ Trinity<Integer, Integer, RowsDnDSupport.RefinedDropSupport.Position> expected) {
+ myTree.setSelectionRow(selectedRow);
+ assertEquals(expected, myConfigurable.getAvailableDropPosition(direction));
+ }
+
+ private static RunManagerImpl createRunManager(Element element) throws InvalidDataException {
+ RunManagerImpl runManager = new RunManagerImpl(getProject(), PropertiesComponent.getInstance());
+ runManager.initializeConfigurationTypes(new ConfigurationType[]{ApplicationConfigurationType.getInstance(),
+ JUnitConfigurationType.getInstance(), UnknownConfigurationType.INSTANCE});
+ runManager.initComponent();
+ runManager.readExternal(element);
+ return runManager;
+ }
+
+ private static class MockRunConfigurable extends RunConfigurable {
+ private final RunManagerImpl myTestManager;
+
+ private MockRunConfigurable(RunManagerImpl runManager) {
+ super(getProject());
+ myTestManager = runManager;
+ createComponent();
+ }
+
+ @Override
+ RunManagerImpl getRunManager() {
+ return myTestManager;
+ }
+ }
+
+ /*
+00 Application
+01 1
+02 CodeGenerator
+03 Renamer
+04 UI
+05 AuTest
+06 Simples
+07 OutAndErr (tmp)
+08 C148C_TersePrincess (tmp)
+09 2
+10 Periods (tmp)
+11 3
+12 C148E_Porcelain
+13 ErrAndOut (tmp)
+14 JUnit
+15 4
+16 All in titled
+17 All in titled2
+18 5
+19 All in titled3
+20 All in titled4
+21 All in titled5
+16 Defaults
+ ...
+ */
+ private static final String FOLDERS_CONFIGURATION = " <component name=\"RunManager\" selected=\"Application.UI\">\n" +
+ " <configuration default=\"false\" name=\"OutAndErr\" type=\"Application\" factoryName=\"Application\" folderName=\"1\" temporary=\"true\">\n" +
+ " <extension name=\"coverage\" enabled=\"false\" merge=\"false\" sample_coverage=\"true\" runner=\"idea\" />\n" +
+ " <option name=\"MAIN_CLASS_NAME\" value=\"OutAndErr\" />\n" +
+ " <option name=\"VM_PARAMETERS\" value=\"\" />\n" +
+ " <option name=\"PROGRAM_PARAMETERS\" value=\"\" />\n" +
+ " <option name=\"WORKING_DIRECTORY\" value=\"file://$PROJECT_DIR$\" />\n" +
+ " <option name=\"ALTERNATIVE_JRE_PATH_ENABLED\" value=\"false\" />\n" +
+ " <option name=\"ALTERNATIVE_JRE_PATH\" value=\"\" />\n" +
+ " <option name=\"ENABLE_SWING_INSPECTOR\" value=\"false\" />\n" +
+ " <option name=\"ENV_VARIABLES\" />\n" +
+ " <option name=\"PASS_PARENT_ENVS\" value=\"true\" />\n" +
+ " <module name=\"titled\" />\n" +
+ " <envs />\n" +
+ " <RunnerSettings RunnerId=\"Debug\">\n" +
+ " <option name=\"DEBUG_PORT\" value=\"\" />\n" +
+ " <option name=\"TRANSPORT\" value=\"0\" />\n" +
+ " <option name=\"LOCAL\" value=\"true\" />\n" +
+ " </RunnerSettings>\n" +
+ " <RunnerSettings RunnerId=\"Run\" />\n" +
+ " <ConfigurationWrapper RunnerId=\"Debug\" />\n" +
+ " <ConfigurationWrapper RunnerId=\"Run\" />\n" +
+ " <method />\n" +
+ " </configuration>\n" +
+ " <configuration default=\"false\" name=\"C148C_TersePrincess\" type=\"Application\" factoryName=\"Application\" folderName=\"1\" temporary=\"true\">\n" +
+ " <extension name=\"coverage\" enabled=\"false\" merge=\"false\" sample_coverage=\"true\" runner=\"idea\" />\n" +
+ " <option name=\"MAIN_CLASS_NAME\" value=\"C148C_TersePrincess\" />\n" +
+ " <option name=\"VM_PARAMETERS\" value=\"\" />\n" +
+ " <option name=\"PROGRAM_PARAMETERS\" value=\"\" />\n" +
+ " <option name=\"WORKING_DIRECTORY\" value=\"file://$PROJECT_DIR$\" />\n" +
+ " <option name=\"ALTERNATIVE_JRE_PATH_ENABLED\" value=\"false\" />\n" +
+ " <option name=\"ALTERNATIVE_JRE_PATH\" value=\"\" />\n" +
+ " <option name=\"ENABLE_SWING_INSPECTOR\" value=\"false\" />\n" +
+ " <option name=\"ENV_VARIABLES\" />\n" +
+ " <option name=\"PASS_PARENT_ENVS\" value=\"true\" />\n" +
+ " <module name=\"titled\" />\n" +
+ " <envs />\n" +
+ " <RunnerSettings RunnerId=\"Debug\">\n" +
+ " <option name=\"DEBUG_PORT\" value=\"\" />\n" +
+ " <option name=\"TRANSPORT\" value=\"0\" />\n" +
+ " <option name=\"LOCAL\" value=\"true\" />\n" +
+ " </RunnerSettings>\n" +
+ " <RunnerSettings RunnerId=\"Run\" />\n" +
+ " <ConfigurationWrapper RunnerId=\"Debug\" />\n" +
+ " <ConfigurationWrapper RunnerId=\"Run\" />\n" +
+ " <method />\n" +
+ " </configuration>\n" +
+ " <configuration default=\"false\" name=\"Periods\" type=\"Application\" factoryName=\"Application\" folderName=\"2\" temporary=\"true\">\n" +
+ " <extension name=\"coverage\" enabled=\"false\" merge=\"false\" sample_coverage=\"true\" runner=\"idea\">\n" +
+ " <pattern>\n" +
+ " <option name=\"PATTERN\" value=\"v.*\" />\n" +
+ " <option name=\"ENABLED\" value=\"true\" />\n" +
+ " </pattern>\n" +
+ " </extension>\n" +
+ " <option name=\"MAIN_CLASS_NAME\" value=\"v.Periods\" />\n" +
+ " <option name=\"VM_PARAMETERS\" value=\"\" />\n" +
+ " <option name=\"PROGRAM_PARAMETERS\" value=\"\" />\n" +
+ " <option name=\"WORKING_DIRECTORY\" value=\"file://$PROJECT_DIR$\" />\n" +
+ " <option name=\"ALTERNATIVE_JRE_PATH_ENABLED\" value=\"false\" />\n" +
+ " <option name=\"ALTERNATIVE_JRE_PATH\" value=\"\" />\n" +
+ " <option name=\"ENABLE_SWING_INSPECTOR\" value=\"false\" />\n" +
+ " <option name=\"ENV_VARIABLES\" />\n" +
+ " <option name=\"PASS_PARENT_ENVS\" value=\"true\" />\n" +
+ " <module name=\"titled\" />\n" +
+ " <envs />\n" +
+ " <RunnerSettings RunnerId=\"Debug\">\n" +
+ " <option name=\"DEBUG_PORT\" value=\"\" />\n" +
+ " <option name=\"TRANSPORT\" value=\"0\" />\n" +
+ " <option name=\"LOCAL\" value=\"true\" />\n" +
+ " </RunnerSettings>\n" +
+ " <RunnerSettings RunnerId=\"Run\" />\n" +
+ " <ConfigurationWrapper RunnerId=\"Debug\" />\n" +
+ " <ConfigurationWrapper RunnerId=\"Run\" />\n" +
+ " <method />\n" +
+ " </configuration>\n" +
+ " <configuration default=\"false\" name=\"ErrAndOut\" type=\"Application\" factoryName=\"Application\" folderName=\"3\" temporary=\"true\">\n" +
+ " <extension name=\"coverage\" enabled=\"false\" merge=\"false\" sample_coverage=\"true\" runner=\"idea\" />\n" +
+ " <option name=\"MAIN_CLASS_NAME\" value=\"ErrAndOut\" />\n" +
+ " <option name=\"VM_PARAMETERS\" value=\"\" />\n" +
+ " <option name=\"PROGRAM_PARAMETERS\" value=\"\" />\n" +
+ " <option name=\"WORKING_DIRECTORY\" value=\"file://$PROJECT_DIR$\" />\n" +
+ " <option name=\"ALTERNATIVE_JRE_PATH_ENABLED\" value=\"false\" />\n" +
+ " <option name=\"ALTERNATIVE_JRE_PATH\" value=\"\" />\n" +
+ " <option name=\"ENABLE_SWING_INSPECTOR\" value=\"false\" />\n" +
+ " <option name=\"ENV_VARIABLES\" />\n" +
+ " <option name=\"PASS_PARENT_ENVS\" value=\"true\" />\n" +
+ " <module name=\"titled\" />\n" +
+ " <envs />\n" +
+ " <RunnerSettings RunnerId=\"Debug\">\n" +
+ " <option name=\"DEBUG_PORT\" value=\"\" />\n" +
+ " <option name=\"TRANSPORT\" value=\"0\" />\n" +
+ " <option name=\"LOCAL\" value=\"true\" />\n" +
+ " </RunnerSettings>\n" +
+ " <RunnerSettings RunnerId=\"Run\" />\n" +
+ " <ConfigurationWrapper RunnerId=\"Debug\" />\n" +
+ " <ConfigurationWrapper RunnerId=\"Run\" />\n" +
+ " <method />\n" +
+ " </configuration>\n" +
+ " <configuration default=\"true\" type=\"MavenRunConfiguration\" factoryName=\"Maven\">\n" +
+ " <MavenSettings>\n" +
+ " <option name=\"myGeneralSettings\" />\n" +
+ " <option name=\"myRunnerSettings\" />\n" +
+ " <option name=\"myRunnerParameters\">\n" +
+ " <MavenRunnerParameters>\n" +
+ " <option name=\"profiles\">\n" +
+ " <set />\n" +
+ " </option>\n" +
+ " <option name=\"goals\">\n" +
+ " <list />\n" +
+ " </option>\n" +
+ " <option name=\"profilesMap\">\n" +
+ " <map />\n" +
+ " </option>\n" +
+ " <option name=\"workingDirPath\" value=\"\" />\n" +
+ " </MavenRunnerParameters>\n" +
+ " </option>\n" +
+ " </MavenSettings>\n" +
+ " <method />\n" +
+ " </configuration>\n" +
+ " <configuration default=\"true\" type=\"JUnit\" factoryName=\"JUnit\">\n" +
+ " <extension name=\"coverage\" enabled=\"false\" merge=\"false\" sample_coverage=\"true\" runner=\"idea\" />\n" +
+ " <module name=\"\" />\n" +
+ " <option name=\"ALTERNATIVE_JRE_PATH_ENABLED\" value=\"false\" />\n" +
+ " <option name=\"ALTERNATIVE_JRE_PATH\" value=\"\" />\n" +
+ " <option name=\"PACKAGE_NAME\" />\n" +
+ " <option name=\"MAIN_CLASS_NAME\" value=\"\" />\n" +
+ " <option name=\"METHOD_NAME\" value=\"\" />\n" +
+ " <option name=\"TEST_OBJECT\" value=\"class\" />\n" +
+ " <option name=\"VM_PARAMETERS\" value=\"-ea\" />\n" +
+ " <option name=\"PARAMETERS\" value=\"\" />\n" +
+ " <option name=\"WORKING_DIRECTORY\" value=\"file://$PROJECT_DIR$\" />\n" +
+ " <option name=\"ENV_VARIABLES\" />\n" +
+ " <option name=\"PASS_PARENT_ENVS\" value=\"true\" />\n" +
+ " <option name=\"TEST_SEARCH_SCOPE\">\n" +
+ " <value defaultName=\"moduleWithDependencies\" />\n" +
+ " </option>\n" +
+ " <envs />\n" +
+ " <patterns />\n" +
+ " <method>\n" +
+ " <option name=\"Make\" enabled=\"false\" />\n" +
+ " </method>\n" +
+ " </configuration>\n" +
+ " <configuration default=\"true\" type=\"Application\" factoryName=\"Application\">\n" +
+ " <extension name=\"coverage\" enabled=\"false\" merge=\"false\" sample_coverage=\"true\" runner=\"idea\" />\n" +
+ " <option name=\"MAIN_CLASS_NAME\" value=\"\" />\n" +
+ " <option name=\"VM_PARAMETERS\" value=\"\" />\n" +
+ " <option name=\"PROGRAM_PARAMETERS\" value=\"\" />\n" +
+ " <option name=\"WORKING_DIRECTORY\" value=\"file://$PROJECT_DIR$\" />\n" +
+ " <option name=\"ALTERNATIVE_JRE_PATH_ENABLED\" value=\"false\" />\n" +
+ " <option name=\"ALTERNATIVE_JRE_PATH\" value=\"\" />\n" +
+ " <option name=\"ENABLE_SWING_INSPECTOR\" value=\"false\" />\n" +
+ " <option name=\"ENV_VARIABLES\" />\n" +
+ " <option name=\"PASS_PARENT_ENVS\" value=\"true\" />\n" +
+ " <module name=\"\" />\n" +
+ " <envs />\n" +
+ " <method />\n" +
+ " </configuration>\n" +
+ " <configuration default=\"false\" name=\"CodeGenerator\" type=\"Application\" factoryName=\"Application\" folderName=\"1\">\n" +
+ " <extension name=\"coverage\" enabled=\"false\" merge=\"false\" sample_coverage=\"true\" runner=\"idea\">\n" +
+ " <pattern>\n" +
+ " <option name=\"PATTERN\" value=\"codegen.*\" />\n" +
+ " <option name=\"ENABLED\" value=\"true\" />\n" +
+ " </pattern>\n" +
+ " </extension>\n" +
+ " <option name=\"MAIN_CLASS_NAME\" value=\"codegen.CodeGenerator\" />\n" +
+ " <option name=\"VM_PARAMETERS\" value=\"\" />\n" +
+ " <option name=\"PROGRAM_PARAMETERS\" value=\"\" />\n" +
+ " <option name=\"WORKING_DIRECTORY\" value=\"file://$PROJECT_DIR$\" />\n" +
+ " <option name=\"ALTERNATIVE_JRE_PATH_ENABLED\" value=\"false\" />\n" +
+ " <option name=\"ALTERNATIVE_JRE_PATH\" value=\"\" />\n" +
+ " <option name=\"ENABLE_SWING_INSPECTOR\" value=\"false\" />\n" +
+ " <option name=\"ENV_VARIABLES\" />\n" +
+ " <option name=\"PASS_PARENT_ENVS\" value=\"true\" />\n" +
+ " <module name=\"titled\" />\n" +
+ " <envs />\n" +
+ " <RunnerSettings RunnerId=\"Run\" />\n" +
+ " <ConfigurationWrapper RunnerId=\"Run\" />\n" +
+ " <method />\n" +
+ " </configuration>\n" +
+ " <configuration default=\"false\" name=\"Renamer\" type=\"Application\" factoryName=\"Application\" folderName=\"1\">\n" +
+ " <extension name=\"coverage\" enabled=\"false\" merge=\"false\" sample_coverage=\"true\" runner=\"idea\" />\n" +
+ " <option name=\"MAIN_CLASS_NAME\" value=\"Renamer\" />\n" +
+ " <option name=\"VM_PARAMETERS\" value=\"\" />\n" +
+ " <option name=\"PROGRAM_PARAMETERS\" value=\"\" />\n" +
+ " <option name=\"WORKING_DIRECTORY\" value=\"file://$PROJECT_DIR$\" />\n" +
+ " <option name=\"ALTERNATIVE_JRE_PATH_ENABLED\" value=\"false\" />\n" +
+ " <option name=\"ALTERNATIVE_JRE_PATH\" value=\"\" />\n" +
+ " <option name=\"ENABLE_SWING_INSPECTOR\" value=\"false\" />\n" +
+ " <option name=\"ENV_VARIABLES\" />\n" +
+ " <option name=\"PASS_PARENT_ENVS\" value=\"true\" />\n" +
+ " <module name=\"titled\" />\n" +
+ " <envs />\n" +
+ " <RunnerSettings RunnerId=\"Debug\">\n" +
+ " <option name=\"DEBUG_PORT\" value=\"\" />\n" +
+ " <option name=\"TRANSPORT\" value=\"0\" />\n" +
+ " <option name=\"LOCAL\" value=\"true\" />\n" +
+ " </RunnerSettings>\n" +
+ " <RunnerSettings RunnerId=\"Run\" />\n" +
+ " <ConfigurationWrapper RunnerId=\"Debug\" />\n" +
+ " <ConfigurationWrapper RunnerId=\"Run\" />\n" +
+ " <method />\n" +
+ " </configuration>\n" +
+ " <configuration default=\"false\" name=\"UI\" type=\"Application\" factoryName=\"Application\" folderName=\"1\">\n" +
+ " <extension name=\"coverage\" enabled=\"false\" merge=\"false\" sample_coverage=\"true\" runner=\"idea\" />\n" +
+ " <option name=\"MAIN_CLASS_NAME\" value=\"UI\" />\n" +
+ " <option name=\"VM_PARAMETERS\" value=\"\" />\n" +
+ " <option name=\"PROGRAM_PARAMETERS\" value=\"\" />\n" +
+ " <option name=\"WORKING_DIRECTORY\" value=\"file://$PROJECT_DIR$\" />\n" +
+ " <option name=\"ALTERNATIVE_JRE_PATH_ENABLED\" value=\"false\" />\n" +
+ " <option name=\"ALTERNATIVE_JRE_PATH\" value=\"\" />\n" +
+ " <option name=\"ENABLE_SWING_INSPECTOR\" value=\"false\" />\n" +
+ " <option name=\"ENV_VARIABLES\" />\n" +
+ " <option name=\"PASS_PARENT_ENVS\" value=\"true\" />\n" +
+ " <module name=\"titled\" />\n" +
+ " <envs />\n" +
+ " <RunnerSettings RunnerId=\"Debug\">\n" +
+ " <option name=\"DEBUG_PORT\" value=\"\" />\n" +
+ " <option name=\"TRANSPORT\" value=\"0\" />\n" +
+ " <option name=\"LOCAL\" value=\"true\" />\n" +
+ " </RunnerSettings>\n" +
+ " <RunnerSettings RunnerId=\"Run\" />\n" +
+ " <ConfigurationWrapper RunnerId=\"Debug\" />\n" +
+ " <ConfigurationWrapper RunnerId=\"Run\" />\n" +
+ " <method />\n" +
+ " </configuration>\n" +
+ " <configuration default=\"false\" name=\"AuTest\" type=\"Application\" factoryName=\"Application\" folderName=\"1\">\n" +
+ " <extension name=\"coverage\" enabled=\"false\" merge=\"false\" sample_coverage=\"true\" runner=\"idea\">\n" +
+ " <pattern>\n" +
+ " <option name=\"PATTERN\" value=\"au.*\" />\n" +
+ " <option name=\"ENABLED\" value=\"true\" />\n" +
+ " </pattern>\n" +
+ " </extension>\n" +
+ " <option name=\"MAIN_CLASS_NAME\" value=\"au.AuTest\" />\n" +
+ " <option name=\"VM_PARAMETERS\" value=\"\" />\n" +
+ " <option name=\"PROGRAM_PARAMETERS\" value=\"\" />\n" +
+ " <option name=\"WORKING_DIRECTORY\" value=\"file://$PROJECT_DIR$\" />\n" +
+ " <option name=\"ALTERNATIVE_JRE_PATH_ENABLED\" value=\"false\" />\n" +
+ " <option name=\"ALTERNATIVE_JRE_PATH\" value=\"\" />\n" +
+ " <option name=\"ENABLE_SWING_INSPECTOR\" value=\"false\" />\n" +
+ " <option name=\"ENV_VARIABLES\" />\n" +
+ " <option name=\"PASS_PARENT_ENVS\" value=\"true\" />\n" +
+ " <module name=\"titled\" />\n" +
+ " <envs />\n" +
+ " <RunnerSettings RunnerId=\"Debug\">\n" +
+ " <option name=\"DEBUG_PORT\" value=\"\" />\n" +
+ " <option name=\"TRANSPORT\" value=\"0\" />\n" +
+ " <option name=\"LOCAL\" value=\"true\" />\n" +
+ " </RunnerSettings>\n" +
+ " <RunnerSettings RunnerId=\"Run\" />\n" +
+ " <ConfigurationWrapper RunnerId=\"Debug\" />\n" +
+ " <ConfigurationWrapper RunnerId=\"Run\" />\n" +
+ " <method />\n" +
+ " </configuration>\n" +
+ " <configuration default=\"false\" name=\"Simples\" type=\"Application\" factoryName=\"Application\" folderName=\"1\">\n" +
+ " <extension name=\"coverage\" enabled=\"false\" merge=\"false\" sample_coverage=\"true\" runner=\"idea\" />\n" +
+ " <option name=\"MAIN_CLASS_NAME\" value=\"Simples\" />\n" +
+ " <option name=\"VM_PARAMETERS\" value=\"\" />\n" +
+ " <option name=\"PROGRAM_PARAMETERS\" value=\"\" />\n" +
+ " <option name=\"WORKING_DIRECTORY\" value=\"file://$PROJECT_DIR$\" />\n" +
+ " <option name=\"ALTERNATIVE_JRE_PATH_ENABLED\" value=\"false\" />\n" +
+ " <option name=\"ALTERNATIVE_JRE_PATH\" value=\"\" />\n" +
+ " <option name=\"ENABLE_SWING_INSPECTOR\" value=\"false\" />\n" +
+ " <option name=\"ENV_VARIABLES\" />\n" +
+ " <option name=\"PASS_PARENT_ENVS\" value=\"true\" />\n" +
+ " <module name=\"titled\" />\n" +
+ " <envs />\n" +
+ " <RunnerSettings RunnerId=\"Debug\">\n" +
+ " <option name=\"DEBUG_PORT\" value=\"\" />\n" +
+ " <option name=\"TRANSPORT\" value=\"0\" />\n" +
+ " <option name=\"LOCAL\" value=\"true\" />\n" +
+ " </RunnerSettings>\n" +
+ " <RunnerSettings RunnerId=\"Run\" />\n" +
+ " <ConfigurationWrapper RunnerId=\"Debug\" />\n" +
+ " <ConfigurationWrapper RunnerId=\"Run\" />\n" +
+ " <method />\n" +
+ " </configuration>\n" +
+ " <configuration default=\"false\" name=\"C148E_Porcelain\" type=\"Application\" factoryName=\"Application\" folderName=\"3\">\n" +
+ " <extension name=\"coverage\" enabled=\"false\" merge=\"false\" sample_coverage=\"true\" runner=\"idea\" />\n" +
+ " <option name=\"MAIN_CLASS_NAME\" value=\"C148E_Porcelain\" />\n" +
+ " <option name=\"VM_PARAMETERS\" value=\"\" />\n" +
+ " <option name=\"PROGRAM_PARAMETERS\" value=\"\" />\n" +
+ " <option name=\"WORKING_DIRECTORY\" value=\"file://$PROJECT_DIR$\" />\n" +
+ " <option name=\"ALTERNATIVE_JRE_PATH_ENABLED\" value=\"false\" />\n" +
+ " <option name=\"ALTERNATIVE_JRE_PATH\" value=\"\" />\n" +
+ " <option name=\"ENABLE_SWING_INSPECTOR\" value=\"false\" />\n" +
+ " <option name=\"ENV_VARIABLES\" />\n" +
+ " <option name=\"PASS_PARENT_ENVS\" value=\"true\" />\n" +
+ " <module name=\"titled\" />\n" +
+ " <envs />\n" +
+ " <RunnerSettings RunnerId=\"Debug\">\n" +
+ " <option name=\"DEBUG_PORT\" value=\"\" />\n" +
+ " <option name=\"TRANSPORT\" value=\"0\" />\n" +
+ " <option name=\"LOCAL\" value=\"true\" />\n" +
+ " </RunnerSettings>\n" +
+ " <RunnerSettings RunnerId=\"Run\" />\n" +
+ " <ConfigurationWrapper RunnerId=\"Debug\" />\n" +
+ " <ConfigurationWrapper RunnerId=\"Run\" />\n" +
+ " <method />\n" +
+ " </configuration>\n" +
+ " <configuration default=\"false\" name=\"All in titled\" type=\"JUnit\" factoryName=\"JUnit\" folderName=\"4\">\n" +
+ " <output_file path=\"C:/tst.txt\" is_save=\"true\" />\n" +
+ " <extension name=\"coverage\" enabled=\"false\" merge=\"false\" sample_coverage=\"true\" runner=\"idea\" />\n" +
+ " <module name=\"titled\" />\n" +
+ " <option name=\"ALTERNATIVE_JRE_PATH_ENABLED\" value=\"false\" />\n" +
+ " <option name=\"ALTERNATIVE_JRE_PATH\" value=\"\" />\n" +
+ " <option name=\"PACKAGE_NAME\" value=\"\" />\n" +
+ " <option name=\"MAIN_CLASS_NAME\" value=\"\" />\n" +
+ " <option name=\"METHOD_NAME\" value=\"\" />\n" +
+ " <option name=\"TEST_OBJECT\" value=\"package\" />\n" +
+ " <option name=\"VM_PARAMETERS\" value=\"-ea\" />\n" +
+ " <option name=\"PARAMETERS\" value=\"\" />\n" +
+ " <option name=\"WORKING_DIRECTORY\" value=\"file://$PROJECT_DIR$\" />\n" +
+ " <option name=\"ENV_VARIABLES\" />\n" +
+ " <option name=\"PASS_PARENT_ENVS\" value=\"true\" />\n" +
+ " <option name=\"TEST_SEARCH_SCOPE\">\n" +
+ " <value defaultName=\"moduleWithDependencies\" />\n" +
+ " </option>\n" +
+ " <envs />\n" +
+ " <patterns />\n" +
+ " <RunnerSettings RunnerId=\"Debug\">\n" +
+ " <option name=\"DEBUG_PORT\" value=\"\" />\n" +
+ " <option name=\"TRANSPORT\" value=\"0\" />\n" +
+ " <option name=\"LOCAL\" value=\"true\" />\n" +
+ " </RunnerSettings>\n" +
+ " <RunnerSettings RunnerId=\"Run\" />\n" +
+ " <ConfigurationWrapper RunnerId=\"Debug\" />\n" +
+ " <ConfigurationWrapper RunnerId=\"Run\" />\n" +
+ " <method>\n" +
+ " <option name=\"Make\" enabled=\"true\" />\n" +
+ " </method>\n" +
+ " </configuration>\n" +
+ " <configuration default=\"false\" name=\"All in titled2\" type=\"JUnit\" factoryName=\"JUnit\" folderName=\"4\">\n" +
+ " <output_file path=\"C:/tst.txt\" is_save=\"true\" />\n" +
+ " <extension name=\"coverage\" enabled=\"false\" merge=\"false\" sample_coverage=\"true\" runner=\"idea\" />\n" +
+ " <module name=\"titled\" />\n" +
+ " <option name=\"ALTERNATIVE_JRE_PATH_ENABLED\" value=\"false\" />\n" +
+ " <option name=\"ALTERNATIVE_JRE_PATH\" value=\"\" />\n" +
+ " <option name=\"PACKAGE_NAME\" value=\"\" />\n" +
+ " <option name=\"MAIN_CLASS_NAME\" value=\"\" />\n" +
+ " <option name=\"METHOD_NAME\" value=\"\" />\n" +
+ " <option name=\"TEST_OBJECT\" value=\"package\" />\n" +
+ " <option name=\"VM_PARAMETERS\" value=\"-ea\" />\n" +
+ " <option name=\"PARAMETERS\" value=\"\" />\n" +
+ " <option name=\"WORKING_DIRECTORY\" value=\"file://$PROJECT_DIR$\" />\n" +
+ " <option name=\"ENV_VARIABLES\" />\n" +
+ " <option name=\"PASS_PARENT_ENVS\" value=\"true\" />\n" +
+ " <option name=\"TEST_SEARCH_SCOPE\">\n" +
+ " <value defaultName=\"moduleWithDependencies\" />\n" +
+ " </option>\n" +
+ " <envs />\n" +
+ " <patterns />\n" +
+ " <RunnerSettings RunnerId=\"Debug\">\n" +
+ " <option name=\"DEBUG_PORT\" value=\"\" />\n" +
+ " <option name=\"TRANSPORT\" value=\"0\" />\n" +
+ " <option name=\"LOCAL\" value=\"true\" />\n" +
+ " </RunnerSettings>\n" +
+ " <RunnerSettings RunnerId=\"Run\" />\n" +
+ " <ConfigurationWrapper RunnerId=\"Debug\" />\n" +
+ " <ConfigurationWrapper RunnerId=\"Run\" />\n" +
+ " <method>\n" +
+ " <option name=\"Make\" enabled=\"true\" />\n" +
+ " </method>\n" +
+ " </configuration>\n" +
+ " <configuration default=\"false\" name=\"All in titled3\" type=\"JUnit\" factoryName=\"JUnit\" folderName=\"5\">\n" +
+ " <output_file path=\"C:/tst.txt\" is_save=\"true\" />\n" +
+ " <extension name=\"coverage\" enabled=\"false\" merge=\"false\" sample_coverage=\"true\" runner=\"idea\" />\n" +
+ " <module name=\"titled\" />\n" +
+ " <option name=\"ALTERNATIVE_JRE_PATH_ENABLED\" value=\"false\" />\n" +
+ " <option name=\"ALTERNATIVE_JRE_PATH\" value=\"\" />\n" +
+ " <option name=\"PACKAGE_NAME\" value=\"\" />\n" +
+ " <option name=\"MAIN_CLASS_NAME\" value=\"\" />\n" +
+ " <option name=\"METHOD_NAME\" value=\"\" />\n" +
+ " <option name=\"TEST_OBJECT\" value=\"package\" />\n" +
+ " <option name=\"VM_PARAMETERS\" value=\"-ea\" />\n" +
+ " <option name=\"PARAMETERS\" value=\"\" />\n" +
+ " <option name=\"WORKING_DIRECTORY\" value=\"file://$PROJECT_DIR$\" />\n" +
+ " <option name=\"ENV_VARIABLES\" />\n" +
+ " <option name=\"PASS_PARENT_ENVS\" value=\"true\" />\n" +
+ " <option name=\"TEST_SEARCH_SCOPE\">\n" +
+ " <value defaultName=\"moduleWithDependencies\" />\n" +
+ " </option>\n" +
+ " <envs />\n" +
+ " <patterns />\n" +
+ " <RunnerSettings RunnerId=\"Debug\">\n" +
+ " <option name=\"DEBUG_PORT\" value=\"\" />\n" +
+ " <option name=\"TRANSPORT\" value=\"0\" />\n" +
+ " <option name=\"LOCAL\" value=\"true\" />\n" +
+ " </RunnerSettings>\n" +
+ " <RunnerSettings RunnerId=\"Run\" />\n" +
+ " <ConfigurationWrapper RunnerId=\"Debug\" />\n" +
+ " <ConfigurationWrapper RunnerId=\"Run\" />\n" +
+ " <method>\n" +
+ " <option name=\"Make\" enabled=\"true\" />\n" +
+ " </method>\n" +
+ " </configuration>\n" +
+ " <configuration default=\"false\" name=\"All in titled4\" type=\"JUnit\" factoryName=\"JUnit\" folderName=\"5\">\n" +
+ " <output_file path=\"C:/tst.txt\" is_save=\"true\" />\n" +
+ " <extension name=\"coverage\" enabled=\"false\" merge=\"false\" sample_coverage=\"true\" runner=\"idea\" />\n" +
+ " <module name=\"titled\" />\n" +
+ " <option name=\"ALTERNATIVE_JRE_PATH_ENABLED\" value=\"false\" />\n" +
+ " <option name=\"ALTERNATIVE_JRE_PATH\" value=\"\" />\n" +
+ " <option name=\"PACKAGE_NAME\" value=\"\" />\n" +
+ " <option name=\"MAIN_CLASS_NAME\" value=\"\" />\n" +
+ " <option name=\"METHOD_NAME\" value=\"\" />\n" +
+ " <option name=\"TEST_OBJECT\" value=\"package\" />\n" +
+ " <option name=\"VM_PARAMETERS\" value=\"-ea\" />\n" +
+ " <option name=\"PARAMETERS\" value=\"\" />\n" +
+ " <option name=\"WORKING_DIRECTORY\" value=\"file://$PROJECT_DIR$\" />\n" +
+ " <option name=\"ENV_VARIABLES\" />\n" +
+ " <option name=\"PASS_PARENT_ENVS\" value=\"true\" />\n" +
+ " <option name=\"TEST_SEARCH_SCOPE\">\n" +
+ " <value defaultName=\"moduleWithDependencies\" />\n" +
+ " </option>\n" +
+ " <envs />\n" +
+ " <patterns />\n" +
+ " <RunnerSettings RunnerId=\"Debug\">\n" +
+ " <option name=\"DEBUG_PORT\" value=\"\" />\n" +
+ " <option name=\"TRANSPORT\" value=\"0\" />\n" +
+ " <option name=\"LOCAL\" value=\"true\" />\n" +
+ " </RunnerSettings>\n" +
+ " <RunnerSettings RunnerId=\"Run\" />\n" +
+ " <ConfigurationWrapper RunnerId=\"Debug\" />\n" +
+ " <ConfigurationWrapper RunnerId=\"Run\" />\n" +
+ " <method>\n" +
+ " <option name=\"Make\" enabled=\"true\" />\n" +
+ " </method>\n" +
+ " </configuration>\n" +
+ " <configuration default=\"false\" name=\"All in titled5\" type=\"JUnit\" factoryName=\"JUnit\" temporary=\"true\">\n" +
+ " <output_file path=\"C:/tst.txt\" is_save=\"true\" />\n" +
+ " <extension name=\"coverage\" enabled=\"false\" merge=\"false\" sample_coverage=\"true\" runner=\"idea\" />\n" +
+ " <module name=\"titled\" />\n" +
+ " <option name=\"ALTERNATIVE_JRE_PATH_ENABLED\" value=\"false\" />\n" +
+ " <option name=\"ALTERNATIVE_JRE_PATH\" value=\"\" />\n" +
+ " <option name=\"PACKAGE_NAME\" value=\"\" />\n" +
+ " <option name=\"MAIN_CLASS_NAME\" value=\"\" />\n" +
+ " <option name=\"METHOD_NAME\" value=\"\" />\n" +
+ " <option name=\"TEST_OBJECT\" value=\"package\" />\n" +
+ " <option name=\"VM_PARAMETERS\" value=\"-ea\" />\n" +
+ " <option name=\"PARAMETERS\" value=\"\" />\n" +
+ " <option name=\"WORKING_DIRECTORY\" value=\"file://$PROJECT_DIR$\" />\n" +
+ " <option name=\"ENV_VARIABLES\" />\n" +
+ " <option name=\"PASS_PARENT_ENVS\" value=\"true\" />\n" +
+ " <option name=\"TEST_SEARCH_SCOPE\">\n" +
+ " <value defaultName=\"moduleWithDependencies\" />\n" +
+ " </option>\n" +
+ " <envs />\n" +
+ " <patterns />\n" +
+ " <RunnerSettings RunnerId=\"Debug\">\n" +
+ " <option name=\"DEBUG_PORT\" value=\"\" />\n" +
+ " <option name=\"TRANSPORT\" value=\"0\" />\n" +
+ " <option name=\"LOCAL\" value=\"true\" />\n" +
+ " </RunnerSettings>\n" +
+ " <RunnerSettings RunnerId=\"Run\" />\n" +
+ " <ConfigurationWrapper RunnerId=\"Debug\" />\n" +
+ " <ConfigurationWrapper RunnerId=\"Run\" />\n" +
+ " <method>\n" +
+ " <option name=\"Make\" enabled=\"true\" />\n" +
+ " </method>\n" +
+ " </configuration>\n" +
+ " <list size=\"16\">\n" +
+ " <item index=\"0\" class=\"java.lang.String\" itemvalue=\"Application.CodeGenerator\" />\n" +
+ " <item index=\"1\" class=\"java.lang.String\" itemvalue=\"Application.Renamer\" />\n" +
+ " <item index=\"2\" class=\"java.lang.String\" itemvalue=\"Application.UI\" />\n" +
+ " <item index=\"3\" class=\"java.lang.String\" itemvalue=\"Application.AuTest\" />\n" +
+ " <item index=\"4\" class=\"java.lang.String\" itemvalue=\"Application.Simples\" />\n" +
+ " <item index=\"5\" class=\"java.lang.String\" itemvalue=\"Application.OutAndErr\" />\n" +
+ " <item index=\"6\" class=\"java.lang.String\" itemvalue=\"Application.C148C_TersePrincess\" />\n" +
+ " <item index=\"7\" class=\"java.lang.String\" itemvalue=\"Application.Periods\" />\n" +
+ " <item index=\"8\" class=\"java.lang.String\" itemvalue=\"Application.C148E_Porcelain\" />\n" +
+ " <item index=\"9\" class=\"java.lang.String\" itemvalue=\"Application.ErrAndOut\" />\n" +
+ " <item index=\"10\" class=\"java.lang.String\" itemvalue=\"JUnit.All in titled\" />\n" +
+ " <item index=\"11\" class=\"java.lang.String\" itemvalue=\"JUnit.All in titled2\" />\n" +
+ " <item index=\"12\" class=\"java.lang.String\" itemvalue=\"JUnit.All in titled3\" />\n" +
+ " <item index=\"13\" class=\"java.lang.String\" itemvalue=\"JUnit.All in titled4\" />\n" +
+ " <item index=\"14\" class=\"java.lang.String\" itemvalue=\"JUnit.All in titled5\" />\n" +
+ " </list>\n" +
+ " <recent_temporary>\n" +
+ " <list size=\"4\">\n" +
+ " <item index=\"0\" class=\"java.lang.String\" itemvalue=\"Application.ErrAndOut\" />\n" +
+ " <item index=\"1\" class=\"java.lang.String\" itemvalue=\"Application.Periods\" />\n" +
+ " <item index=\"2\" class=\"java.lang.String\" itemvalue=\"Application.OutAndErr\" />\n" +
+ " <item index=\"3\" class=\"java.lang.String\" itemvalue=\"Application.C148C_TersePrincess\" />\n" +
+ " </list>\n" +
+ " </recent_temporary>\n" +
+ " <configuration name=\"<template>\" type=\"WebApp\" default=\"true\" selected=\"false\">\n" +
+ " <Host>localhost</Host>\n" +
+ " <Port>5050</Port>\n" +
+ " </configuration>\n" +
+ " </component>\n";
+}
diff --git a/java/java-tests/testSrc/com/intellij/ide/fileStructure/JavaFileStructureFilteringTest.java b/java/java-tests/testSrc/com/intellij/ide/fileStructure/JavaFileStructureFilteringTest.java
index 6f567f8..95e80d2 100644
--- a/java/java-tests/testSrc/com/intellij/ide/fileStructure/JavaFileStructureFilteringTest.java
+++ b/java/java-tests/testSrc/com/intellij/ide/fileStructure/JavaFileStructureFilteringTest.java
@@ -38,10 +38,10 @@
public void testSelectLeafFirst3() throws Exception {checkTree("clear");}
public void testSelectLeafFirst4() throws Exception {checkTree("clear");}
- @Bombed(user = "peter", month = Calendar.JULY, day = 10)
+ public void testMatcher() throws Exception {checkTree("dis");}
+
public void testMatcher1() throws Exception {checkTree("ico");}
- @Bombed(user = "peter", month = Calendar.JULY, day = 10)
public void testMatcher2() throws Exception {checkTree("ico");}
- @Bombed(user = "peter", month = Calendar.JULY, day = 10)
+ @Bombed(user = "peter", month = Calendar.AUGUST, day = 20)
public void testAnonymousMatcher2() throws Exception {checkTree("ico");}
}
diff --git a/java/java-tests/testSrc/com/intellij/ide/fileTemplates/FileTemplatesTest.groovy b/java/java-tests/testSrc/com/intellij/ide/fileTemplates/FileTemplatesTest.groovy
new file mode 100644
index 0000000..fb06e42
--- /dev/null
+++ b/java/java-tests/testSrc/com/intellij/ide/fileTemplates/FileTemplatesTest.groovy
@@ -0,0 +1,133 @@
+package com.intellij.ide.fileTemplates
+import com.intellij.ide.fileTemplates.impl.CustomFileTemplate
+import com.intellij.openapi.Disposable
+import com.intellij.openapi.application.ex.PathManagerEx
+import com.intellij.openapi.roots.ModuleRootManager
+import com.intellij.openapi.util.io.FileUtil
+import com.intellij.openapi.util.text.StringUtil
+import com.intellij.openapi.vfs.LocalFileSystem
+import com.intellij.openapi.vfs.VirtualFile
+import com.intellij.psi.JavaDirectoryService
+import com.intellij.psi.PsiClass
+import com.intellij.psi.PsiDirectory
+import com.intellij.psi.PsiManager
+import com.intellij.testFramework.IdeaTestCase
+import com.intellij.testFramework.PsiTestUtil
+import com.intellij.util.properties.EncodingAwareProperties
+
+public class FileTemplatesTest extends IdeaTestCase {
+ public void testAllTemplates() throws Exception {
+ final File testsDir = new File(PathManagerEx.getTestDataPath()+"/ide/fileTemplates");
+
+ final String includeTemplateName = "include1.inc";
+ final String includeTemplateExtension = "txt";
+ final String customIncludeFileName = includeTemplateName + "." + includeTemplateExtension;
+ final File customInclude = new File(testsDir, customIncludeFileName);
+ final String includeText = FileUtil.loadFile(customInclude, FileTemplate.ourEncoding);
+
+ final FileTemplateManager templateManager = FileTemplateManager.getInstance();
+ final ArrayList<FileTemplate> originalIncludes = new ArrayList<FileTemplate>(Arrays.asList(templateManager.getAllPatterns()));
+ try {
+ // configure custom include
+ final List<FileTemplate> allIncludes = new ArrayList<FileTemplate>(originalIncludes);
+ final CustomFileTemplate custom = new CustomFileTemplate(includeTemplateName, includeTemplateExtension);
+ custom.setText(includeText);
+ allIncludes.add(custom);
+ templateManager.setTemplates(FileTemplateManager.INCLUDES_TEMPLATES_CATEGORY, allIncludes);
+
+ final String txt = ".txt";
+ File[] children = testsDir.listFiles(new FilenameFilter() {
+ @Override
+ public boolean accept(File dir, String name) {
+ return name.endsWith(".out"+txt);
+ }
+ });
+
+ assertTrue(children.length > 0);
+ for (File resultFile : children) {
+ String name = resultFile.getName();
+ String base = name.substring(0, name.length() - txt.length() - ".out".length());
+ File propFile = new File(resultFile.getParent(), base + ".prop" + txt);
+ File inFile = new File(resultFile.getParent(), base + txt);
+
+ String inputText = FileUtil.loadFile(inFile, FileTemplate.ourEncoding);
+ String outputText = FileUtil.loadFile(resultFile, FileTemplate.ourEncoding);
+
+ EncodingAwareProperties properties = new EncodingAwareProperties();
+
+ properties.load(propFile, FileTemplate.ourEncoding);
+
+ System.out.println(resultFile.getName());
+ doTestTemplate(inputText, properties, outputText, resultFile.getParent());
+ }
+ }
+ finally {
+ templateManager.setTemplates(FileTemplateManager.INCLUDES_TEMPLATES_CATEGORY, originalIncludes);
+ }
+ }
+
+ private static void doTestTemplate(String inputString, Properties properties, String expected, String dir) throws Exception {
+ inputString = StringUtil.convertLineSeparators(inputString);
+ expected = StringUtil.convertLineSeparators(expected);
+
+ final String result = FileTemplateUtil.mergeTemplate(properties, inputString, false);
+ assertEquals(expected, result);
+
+ List attrs = Arrays.asList(FileTemplateUtil.calculateAttributes(inputString, new Properties(), false));
+ assertTrue(properties.size() <= attrs.size());
+ Enumeration e = properties.propertyNames();
+ while (e.hasMoreElements()) {
+ String s = (String)e.nextElement();
+ assertTrue("Attribute '" + s + "' not found in properties", attrs.contains(s));
+ }
+ }
+
+ public void testFindFileByUrl() throws Exception {
+ FileTemplate catchBodyTemplate = FileTemplateManager.getInstance().getCodeTemplate(JavaTemplateUtil.TEMPLATE_CATCH_BODY);
+ assertNotNull(catchBodyTemplate);
+ }
+
+ public void "test collect undefined attribute names"() {
+ FileTemplate template = addTestTemplate("myclass", '${ABC} ${DEF} ${NAME}')
+ Properties properties = new Properties()
+ properties.NAME = 'zzz'
+ assert template.getUnsetAttributes(properties) as Set == ['ABC', 'DEF'] as Set
+ }
+
+ public void "test collect undefined attribute names from included templates"() {
+ def included = addTestTemplate("included", '${ABC} ${DEF}')
+ assert included == FileTemplateManager.instance.getTemplate("included.java")
+
+ FileTemplate template = addTestTemplate("myclass", '#parse("included.java") ${DEF} ${NAME}')
+ Properties properties = new Properties()
+ properties.NAME = 'zzz'
+ assert template.getUnsetAttributes(properties) as Set == ['ABC', 'DEF'] as Set
+ }
+
+ public void testDefaultPackage() throws Exception {
+ String name = "myclass";
+ FileTemplate template = addTestTemplate(name, 'package ${PACKAGE_NAME}; public class ${NAME} {}')
+
+ File temp = FileUtil.createTempDirectory(getTestName(true), "");
+
+ myFilesToDelete.add(temp);
+ final VirtualFile tempDir = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(temp);
+
+ PsiTestUtil.addSourceRoot(getModule(), tempDir);
+
+ VirtualFile sourceRoot = ModuleRootManager.getInstance(getModule()).getSourceRoots()[0];
+ PsiDirectory psiDirectory = PsiManager.getInstance(getProject()).findDirectory(sourceRoot);
+
+ PsiClass psiClass = JavaDirectoryService.getInstance().createClass(psiDirectory, "XXX", name);
+ assertNotNull(psiClass);
+ assertEquals("public class XXX {\n}", psiClass.getContainingFile().getText());
+ FileTemplateManager.getInstance().removeTemplate(template);
+ }
+
+ private FileTemplate addTestTemplate(String name, String text) {
+ FileTemplate template = FileTemplateManager.getInstance().addTemplate(name, "java");
+ disposeOnTearDown({ FileTemplateManager.getInstance().removeTemplate(template) } as Disposable)
+ template.setText(text);
+ template
+ }
+}
diff --git a/java/java-tests/testSrc/com/intellij/ide/fileTemplates/FileTemplatesTest.java b/java/java-tests/testSrc/com/intellij/ide/fileTemplates/FileTemplatesTest.java
deleted file mode 100644
index 1725861..0000000
--- a/java/java-tests/testSrc/com/intellij/ide/fileTemplates/FileTemplatesTest.java
+++ /dev/null
@@ -1,119 +0,0 @@
-package com.intellij.ide.fileTemplates;
-
-import com.intellij.ide.fileTemplates.impl.CustomFileTemplate;
-import com.intellij.openapi.application.ex.PathManagerEx;
-import com.intellij.openapi.roots.ModuleRootManager;
-import com.intellij.openapi.util.io.FileUtil;
-import com.intellij.openapi.util.text.StringUtil;
-import com.intellij.openapi.vfs.LocalFileSystem;
-import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.psi.JavaDirectoryService;
-import com.intellij.psi.PsiClass;
-import com.intellij.psi.PsiDirectory;
-import com.intellij.psi.PsiManager;
-import com.intellij.testFramework.IdeaTestCase;
-import com.intellij.testFramework.PsiTestUtil;
-import com.intellij.util.properties.EncodingAwareProperties;
-
-import java.io.File;
-import java.io.FilenameFilter;
-import java.util.*;
-
-@SuppressWarnings({"HardCodedStringLiteral"})
-public class FileTemplatesTest extends IdeaTestCase {
- public void testAllTemplates() throws Exception {
- final File testsDir = new File(PathManagerEx.getTestDataPath()+"/ide/fileTemplates");
-
- final String includeTemplateName = "include1.inc";
- final String includeTemplateExtension = "txt";
- final String customIncludeFileName = includeTemplateName + "." + includeTemplateExtension;
- final File customInclude = new File(testsDir, customIncludeFileName);
- final String includeText = FileUtil.loadFile(customInclude, FileTemplate.ourEncoding);
-
- final FileTemplateManager templateManager = FileTemplateManager.getInstance();
- final ArrayList<FileTemplate> originalIncludes = new ArrayList<FileTemplate>(Arrays.asList(templateManager.getAllPatterns()));
- try {
- // configure custom include
- final List<FileTemplate> allIncludes = new ArrayList<FileTemplate>(originalIncludes);
- final CustomFileTemplate custom = new CustomFileTemplate(includeTemplateName, includeTemplateExtension);
- custom.setText(includeText);
- allIncludes.add(custom);
- templateManager.setTemplates(FileTemplateManager.INCLUDES_TEMPLATES_CATEGORY, allIncludes);
-
- final String txt = ".txt";
- File[] children = testsDir.listFiles(new FilenameFilter() {
- @Override
- public boolean accept(File dir, String name) {
- return name.endsWith(".out"+txt);
- }
- });
-
- assertTrue(children.length > 0);
- for (File resultFile : children) {
- String name = resultFile.getName();
- String base = name.substring(0, name.length() - txt.length() - ".out".length());
- File propFile = new File(resultFile.getParent(), base + ".prop" + txt);
- File inFile = new File(resultFile.getParent(), base + txt);
-
- String inputText = FileUtil.loadFile(inFile, FileTemplate.ourEncoding);
- String outputText = FileUtil.loadFile(resultFile, FileTemplate.ourEncoding);
-
- EncodingAwareProperties properties = new EncodingAwareProperties();
-
- properties.load(propFile, FileTemplate.ourEncoding);
-
- System.out.println(resultFile.getName());
- doTestTemplate(inputText, properties, outputText, resultFile.getParent());
- }
- }
- finally {
- templateManager.setTemplates(FileTemplateManager.INCLUDES_TEMPLATES_CATEGORY, originalIncludes);
- }
- }
-
- private static void doTestTemplate(String inputString, Properties properties, String expected, String dir) throws Exception {
- inputString = StringUtil.convertLineSeparators(inputString);
- expected = StringUtil.convertLineSeparators(expected);
-
- final String result = FileTemplateUtil.mergeTemplate(properties, inputString, false);
- assertEquals(expected, result);
-
- List attrs = Arrays.asList(FileTemplateUtil.calculateAttributes(inputString, new Properties(), false));
- assertTrue(properties.size() <= attrs.size());
- Enumeration e = properties.propertyNames();
- while (e.hasMoreElements()) {
- String s = (String)e.nextElement();
- assertTrue("Attribute '" + s + "' not found in properties", attrs.contains(s));
- }
- }
-
- public void testFindFileByUrl() throws Exception {
- FileTemplate catchBodyTemplate = FileTemplateManager.getInstance().getCodeTemplate(JavaTemplateUtil.TEMPLATE_CATCH_BODY);
- assertNotNull(catchBodyTemplate);
- }
-
- public void testDefaultPackage() throws Exception {
- String name = "myclass";
- FileTemplate template = FileTemplateManager.getInstance().addInternal(name/*+"ForTest"*/, "java");
- try {
- template.setText("package ${PACKAGE_NAME}; public class ${NAME} {}");
-
- File temp = FileUtil.createTempDirectory(getTestName(true), "");
-
- myFilesToDelete.add(temp);
- final VirtualFile tempDir = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(temp);
-
- PsiTestUtil.addSourceRoot(getModule(), tempDir);
-
- VirtualFile sourceRoot = ModuleRootManager.getInstance(getModule()).getSourceRoots()[0];
- PsiDirectory psiDirectory = PsiManager.getInstance(getProject()).findDirectory(sourceRoot);
-
- PsiClass psiClass = JavaDirectoryService.getInstance().createClass(psiDirectory, "XXX", name);
- assertNotNull(psiClass);
- assertEquals("public class XXX {\n}", psiClass.getContainingFile().getText());
- }
- finally {
- FileTemplateManager.getInstance().removeTemplate(template);
- }
- }
-}
diff --git a/java/java-tests/testSrc/com/intellij/index/StringIndex.java b/java/java-tests/testSrc/com/intellij/index/StringIndex.java
index e48d5be..a12f58f 100644
--- a/java/java-tests/testSrc/com/intellij/index/StringIndex.java
+++ b/java/java-tests/testSrc/com/intellij/index/StringIndex.java
@@ -33,7 +33,7 @@
}
public void update(final String path, @Nullable String content, @Nullable String oldContent) throws StorageException {
- myIndex.update(path.hashCode(), toInput(path, content));
+ myIndex.update(path.hashCode(), toInput(path, content)).compute();
}
@Nullable
diff --git a/java/java-tests/testSrc/com/intellij/navigation/ChooseByNameTest.groovy b/java/java-tests/testSrc/com/intellij/navigation/ChooseByNameTest.groovy
index 0e82ee3..613a538 100644
--- a/java/java-tests/testSrc/com/intellij/navigation/ChooseByNameTest.groovy
+++ b/java/java-tests/testSrc/com/intellij/navigation/ChooseByNameTest.groovy
@@ -156,7 +156,7 @@
elements = set as List
semaphore.up()
} as Consumer<Set<?>>)
- if (!semaphore.waitFor(1000)) {
+ if (!semaphore.waitFor(10000)) {
printThreadDump()
fail()
}
diff --git a/java/java-tests/testSrc/com/intellij/psi/MiscPsiTest.java b/java/java-tests/testSrc/com/intellij/psi/MiscPsiTest.java
index e972b4f..2a89e21 100644
--- a/java/java-tests/testSrc/com/intellij/psi/MiscPsiTest.java
+++ b/java/java-tests/testSrc/com/intellij/psi/MiscPsiTest.java
@@ -1,6 +1,7 @@
package com.intellij.psi;
import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.command.WriteCommandAction;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
@@ -8,32 +9,28 @@
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.psi.impl.source.tree.LazyParseableElement;
-import com.intellij.testFramework.PlatformTestCase;
-import com.intellij.testFramework.PsiTestCase;
-import com.intellij.testFramework.PsiTestUtil;
+import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase;
-@PlatformTestCase.WrapInCommand
-public class MiscPsiTest extends PsiTestCase{
- private VirtualFile myRoot;
-
+public class MiscPsiTest extends LightCodeInsightFixtureTestCase {
@Override
- protected void setUp() throws Exception {
- super.setUp();
-
- myRoot = PsiTestUtil.createTestProjectStructure(myProject, myModule, myFilesToDelete);
+ protected void invokeTestRunnable(final Runnable runnable) throws Exception {
+ new WriteCommandAction.Simple(getProject()) {
+ @Override
+ protected void run() throws Throwable {
+ runnable.run();
+ }
+ }.execute();
}
public void testCopyTextFile() throws Exception{
- VirtualFile vFile = myRoot.createChildData(null, "Test.txt");
- final String text = "1234567890";
- vFile.setBinaryContent(text.getBytes());
+ String text = "1234567890";
+ PsiFile file = myFixture.addFileToProject("Test.txt", text);
- VirtualFile vDir = myRoot.createChildDirectory(null, "dir");
+ VirtualFile vDir = myFixture.getTempDirFixture().findOrCreateDir("dir");
- PsiDocumentManager.getInstance(myProject).commitAllDocuments();
- PsiFile file = myPsiManager.findFile(vFile);
+ PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
assertTrue(file instanceof PsiPlainTextFile);
- PsiDirectory dir = myPsiManager.findDirectory(vDir);
+ PsiDirectory dir = getPsiManager().findDirectory(vDir);
PsiFile fileCopy = (PsiFile)file.copy();
fileCopy = (PsiFile) fileCopy.setName("NewTest.txt");
PsiFile newFile = (PsiFile)dir.add(fileCopy);
@@ -41,21 +38,21 @@
assertEquals(text, new String(newFile.getVirtualFile().contentsToByteArray()));
assertEquals(newFile.getVirtualFile().getModificationStamp(), newFile.getViewProvider().getModificationStamp());
- Document document = PsiDocumentManager.getInstance(myProject).getDocument(newFile);
+ Document document = PsiDocumentManager.getInstance(getProject()).getDocument(newFile);
assertEquals(newFile.getVirtualFile().getModificationStamp(), document.getModificationStamp());
}
public void testCopyBinaryFile() throws Exception{
- VirtualFile vFile = myRoot.createChildData(null, "Test.xxx");
+ VirtualFile vFile = myFixture.addFileToProject("Test.xxx", "").getVirtualFile();
final byte[] bytes = new byte[]{12,34,56,78,90,45,83,0x22,(byte)0xff, (byte)0xff, (byte)0xff, (byte)0xee};
vFile.setBinaryContent(bytes);
- VirtualFile vDir = myRoot.createChildDirectory(null, "dir");
+ VirtualFile vDir = myFixture.getTempDirFixture().findOrCreateDir("dir");
- PsiDocumentManager.getInstance(myProject).commitAllDocuments();
- PsiFile file = myPsiManager.findFile(vFile);
+ PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
+ PsiFile file = getPsiManager().findFile(vFile);
assertTrue(file instanceof PsiBinaryFile);
- PsiDirectory dir = myPsiManager.findDirectory(vDir);
+ PsiDirectory dir = getPsiManager().findDirectory(vDir);
PsiFile fileCopy = (PsiFile)file.copy();
fileCopy = (PsiFile) fileCopy.setName("NewTest.xxx");
PsiFile newFile = (PsiFile)dir.add(fileCopy);
@@ -65,15 +62,14 @@
}
public void testCopyBinaryToTextFile() throws Exception{
- VirtualFile vFile = myRoot.createChildData(null, "Test.xxx");
String text = "1234567890";
- vFile.setBinaryContent(text.getBytes());
+ VirtualFile vFile = myFixture.addFileToProject("Test.xxx", text).getVirtualFile();
- VirtualFile vDir = myRoot.createChildDirectory(null, "dir");
+ VirtualFile vDir = myFixture.getTempDirFixture().findOrCreateDir("dir");
- PsiDocumentManager.getInstance(myProject).commitAllDocuments();
- PsiFile file = myPsiManager.findFile(vFile);
- PsiDirectory dir = myPsiManager.findDirectory(vDir);
+ PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
+ PsiFile file = getPsiManager().findFile(vFile);
+ PsiDirectory dir = getPsiManager().findDirectory(vDir);
PsiFile fileCopy = (PsiFile)file.copy();
fileCopy = (PsiFile) fileCopy.setName("NewTest.txt");
PsiFile newFile = (PsiFile)dir.add(fileCopy);
@@ -85,12 +81,11 @@
}
public void testSCR4212() throws Exception{
- VirtualFile vFile = myRoot.createChildData(null, "Test.java");
String text = "class A{{ return(Object)new String(); }}";
- VfsUtil.saveText(vFile, text);
+ VirtualFile vFile = myFixture.addFileToProject("Test.java", text).getVirtualFile();
- PsiDocumentManager.getInstance(myProject).commitAllDocuments();
- PsiJavaFile file = (PsiJavaFile)myPsiManager.findFile(vFile);
+ PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
+ PsiJavaFile file = (PsiJavaFile)getPsiManager().findFile(vFile);
PsiClass aClass = file.getClasses()[0];
PsiClassInitializer initializer = aClass.getInitializers()[0];
PsiStatement statement = initializer.getBody().getStatements()[0];
@@ -116,17 +111,16 @@
}
public void testSCR5929() throws Exception {
- VirtualFile vFileA = myRoot.createChildData(null, "A.java");
String text = "class A{ /** @see a.B */ }";
- VfsUtil.saveText(vFileA, text);
+ VirtualFile vFileA = myFixture.addFileToProject("A.java", text).getVirtualFile();
- VirtualFile dir = myRoot.createChildDirectory(null, "a");
+ VirtualFile dir = myFixture.getTempDirFixture().findOrCreateDir("a");
VirtualFile vFileB = dir.createChildData(null, "B.java");
text = "class B{}";
VfsUtil.saveText(vFileB, text);
- PsiDocumentManager.getInstance(myProject).commitAllDocuments();
- PsiFile fileA = myPsiManager.findFile(vFileA);
+ PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
+ PsiFile fileA = getPsiManager().findFile(vFileA);
PsiJavaFile fileACopy = (PsiJavaFile)fileA.copy();
PsiClass aClass = fileACopy.getClasses()[0];
aClass.setName("A2");
@@ -134,26 +128,25 @@
}
public void testCopyClass() throws Exception {
- VirtualFile vFile = myRoot.createChildData(null, "A.java");
String text = "package aaa; class A{}";
- VfsUtil.saveText(vFile, text);
+ VirtualFile vFile = myFixture.addFileToProject("A.java", text).getVirtualFile();
- PsiDocumentManager.getInstance(myProject).commitAllDocuments();
- PsiFile file = myPsiManager.findFile(vFile);
+ PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
+ PsiFile file = getPsiManager().findFile(vFile);
PsiJavaFile fileACopy = (PsiJavaFile)file.copy();
PsiClass aClass = fileACopy.getClasses()[0];
aClass.setName("ANew");
PsiFile newFile = (PsiFile)file.getContainingDirectory().add(fileACopy);
- Document document = PsiDocumentManager.getInstance(myProject).getDocument(newFile);
+ Document document = PsiDocumentManager.getInstance(getProject()).getDocument(newFile);
FileDocumentManager.getInstance().saveDocument(document);
assertEquals(newFile.getVirtualFile().getModificationStamp(), newFile.getViewProvider().getModificationStamp());
assertFalse(FileDocumentManager.getInstance().isFileModified(newFile.getVirtualFile()));
}
public void testSCR15954() throws Exception {
- PsiJavaFile file = (PsiJavaFile)createFile("A.java", "class A{\nA(){}\n}");
+ PsiJavaFile file = (PsiJavaFile)myFixture.addFileToProject("A.java", "class A{\nA(){}\n}");
- PsiDocumentManager psiDocumentManager = PsiDocumentManager.getInstance(myProject);
+ PsiDocumentManager psiDocumentManager = PsiDocumentManager.getInstance(getProject());
Document document = psiDocumentManager.getDocument(file);
document.insertString(document.getTextLength(), " "); // insert a trailing space to strip
psiDocumentManager.commitAllDocuments();
@@ -188,6 +181,10 @@
assertEquals("@A({ c})", annotation.getText());
}
+ private JavaPsiFacade getJavaFacade() {
+ return JavaPsiFacade.getInstance(getProject());
+ }
+
public void testJavaLangObjectSuperMethod() throws Exception {
final PsiClass aClass =
getJavaFacade().getElementFactory().createClassFromText("public String toString() {return null;}", null);
@@ -231,7 +228,7 @@
}
public void testDoNotExpandNestedChameleons() throws Exception {
- PsiJavaFile file = (PsiJavaFile)createFile("a.java", "class A {{{}}}");
+ PsiJavaFile file = (PsiJavaFile)myFixture.addFileToProject("a.java", "class A {{{}}}");
file.getNode();
PsiCodeBlock initializer = file.getClasses()[0].getInitializers()[0].getBody();
@@ -242,4 +239,9 @@
assertFalse(assertInstanceOf(nestedBlock.getNode(), LazyParseableElement.class).isParsed());
}
+ public void testTypeCanonicalText() {
+ PsiType type = JavaPsiFacade.getElementFactory(getProject()).createTypeFromText("some .unknown. Foo<? extends String>", null);
+ assertEquals("some.unknown.Foo<? extends String>", type.getCanonicalText());
+ }
+
}
diff --git a/java/java-tests/testSrc/com/intellij/psi/PsiConcurrencyStressTest.java b/java/java-tests/testSrc/com/intellij/psi/PsiConcurrencyStressTest.java
index a9c2b5f..ee23c2d 100644
--- a/java/java-tests/testSrc/com/intellij/psi/PsiConcurrencyStressTest.java
+++ b/java/java-tests/testSrc/com/intellij/psi/PsiConcurrencyStressTest.java
@@ -182,7 +182,7 @@
public void visitElement(final PsiElement element) {
super.visitElement(element);
- final HighlightInfoHolder infoHolder = new HighlightInfoHolder(myFile, HighlightInfoFilter.EMPTY_ARRAY);
+ final HighlightInfoHolder infoHolder = new HighlightInfoHolder(myFile);
final HighlightVisitorImpl visitor = new HighlightVisitorImpl(PsiResolveHelper.SERVICE.getInstance(getProject()));
visitor.analyze(myFile, true, infoHolder, new Runnable() {
@Override
diff --git a/java/java-tests/testSrc/com/intellij/psi/StubAstSwitchTest.groovy b/java/java-tests/testSrc/com/intellij/psi/StubAstSwitchTest.groovy
index da446c7..b7b39fb 100644
--- a/java/java-tests/testSrc/com/intellij/psi/StubAstSwitchTest.groovy
+++ b/java/java-tests/testSrc/com/intellij/psi/StubAstSwitchTest.groovy
@@ -19,6 +19,7 @@
import com.intellij.openapi.vfs.VfsUtil
import com.intellij.psi.impl.source.PsiFileImpl
import com.intellij.psi.search.GlobalSearchScope
+import com.intellij.psi.search.searches.OverridingMethodsSearch
import com.intellij.psi.util.PsiTreeUtil
import com.intellij.reference.SoftReference
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase
@@ -97,4 +98,34 @@
assert pointer.element == oldClass
assert ((PsiFileImpl)file).treeElement
}
+
+ public void "test do not parse when resolving references inside an anonymous class"() {
+ PsiFileImpl file = (PsiFileImpl) myFixture.addFileToProject("A.java", """
+class A {
+ Object field = new B() {
+ void foo(Object o) {
+ }
+ };
+}
+
+class B {
+ void foo(Object o) {}
+}
+""")
+ assert !file.contentsLoaded
+ PsiClass bClass = ((PsiJavaFile) file).classes[1]
+ assert !file.contentsLoaded
+
+ def fooMethod = bClass.methods[0]
+ assert !file.contentsLoaded
+
+ def override = OverridingMethodsSearch.search(fooMethod).findAll().first()
+ assert override
+ assert !file.contentsLoaded
+
+ assert override.containingClass instanceof PsiAnonymousClass
+ assert !file.contentsLoaded
+
+ assert bClass == override.containingClass.superClass
+ }
}
diff --git a/java/java-tests/testSrc/com/intellij/psi/formatter/java/AbstractJavaFormatterTest.java b/java/java-tests/testSrc/com/intellij/psi/formatter/java/AbstractJavaFormatterTest.java
index bd2f80c..df73270 100644
--- a/java/java-tests/testSrc/com/intellij/psi/formatter/java/AbstractJavaFormatterTest.java
+++ b/java/java-tests/testSrc/com/intellij/psi/formatter/java/AbstractJavaFormatterTest.java
@@ -39,6 +39,7 @@
import com.intellij.util.text.LineReader;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import java.io.ByteArrayInputStream;
import java.io.File;
@@ -129,35 +130,47 @@
doTextTest(Action.REFORMAT, text, textAfter);
}
- public void doTextTest(final Action action, final String text, String textAfter) throws IncorrectOperationException {
+ public void doTextTest(@NotNull final Action action, @NotNull final String text, @NotNull String textAfter) throws IncorrectOperationException {
final PsiFile file = createFile("A.java", text);
-
- if (myLineRange != null) {
- final DocumentImpl document = new DocumentImpl(text);
- myTextRange =
- new TextRange(document.getLineStartOffset(myLineRange.getStartOffset()), document.getLineEndOffset(myLineRange.getEndOffset()));
- }
-
- /*
- CommandProcessor.getInstance().executeCommand(getProject(), new Runnable() {
- public void run() {
- ApplicationManager.getApplication().runWriteAction(new Runnable() {
- public void run() {
- performFormatting(file);
- }
- });
- }
- }, null, null);
-
- assertEquals(prepareText(textAfter), prepareText(file.getText()));
-
-
- */
-
final PsiDocumentManager manager = PsiDocumentManager.getInstance(getProject());
final Document document = manager.getDocument(file);
+ if (document == null) {
+ fail("Document is null");
+ return;
+ }
+ replaceAndProcessDocument(action, text, file, document);
+ assertEquals(textAfter, document.getText());
+ manager.commitDocument(document);
+ assertEquals(textAfter, file.getText());
+ }
+ public void formatEveryoneAndCheckIfResultEqual(@NotNull final String...before) {
+ assert before.length > 1;
+ final PsiFile file = createFile("A.java", "");
+ final PsiDocumentManager manager = PsiDocumentManager.getInstance(getProject());
+ final Document document = manager.getDocument(file);
+ String afterFirst = replaceAndProcessDocument(Action.REFORMAT, before[0], file, document);
+ for (String nextBefore: before) {
+ assertEquals(afterFirst, replaceAndProcessDocument(Action.REFORMAT, nextBefore, file, document));
+ }
+ }
+ @NotNull
+ private String replaceAndProcessDocument(@NotNull final Action action,
+ @NotNull final String text,
+ @NotNull final PsiFile file,
+ @Nullable final Document document) throws IncorrectOperationException
+ {
+ if (document == null) {
+ fail("Don't expect the document to be null");
+ return null;
+ }
+ if (myLineRange != null) {
+ final DocumentImpl doc = new DocumentImpl(text);
+ myTextRange =
+ new TextRange(doc.getLineStartOffset(myLineRange.getStartOffset()), doc.getLineEndOffset(myLineRange.getEndOffset()));
+ }
+ final PsiDocumentManager manager = PsiDocumentManager.getInstance(getProject());
CommandProcessor.getInstance().executeCommand(getProject(), new Runnable() {
@Override
public void run() {
@@ -181,15 +194,7 @@
}
}, action == Action.REFORMAT ? ReformatCodeProcessor.COMMAND_NAME : "", "");
-
- if (document == null) {
- fail("Don't expect the document to be null");
- return;
- }
- assertEquals(textAfter, document.getText());
- manager.commitDocument(document);
- assertEquals(textAfter, file.getText());
-
+ return document.getText();
}
public void doMethodTest(@NonNls final String before, @NonNls final String after) throws Exception {
diff --git a/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaFormatterTest.java b/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaFormatterTest.java
index c50436b..695ac71 100644
--- a/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaFormatterTest.java
+++ b/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaFormatterTest.java
@@ -320,18 +320,20 @@
}
public void testClassComment() throws Exception {
- doTextTest("/**\n" +
- "* @author smbd\n" +
- "* @param <T> some param\n" +
- "* @since 1.9\n" +
- "*/\n" +
- "class Test<T>{}",
- "/**\n" +
- " * @param <T> some param\n" +
- " * @author smbd\n" +
- " * @since 1.9\n" +
- " */\n" +
- "class Test<T> {\n}");
+ String before = "/**\n" +
+ "* @author smbd\n" +
+ "* @param <T> some param\n" +
+ "* @since 1.9\n" +
+ "*/\n" +
+ "class Test<T>{}";
+ String after = "/**\n" +
+ " * @param <T> some param\n" +
+ " * @author smbd\n" +
+ " * @since 1.9\n" +
+ " */\n" +
+ "class Test<T> {\n" +
+ "}";
+ doTextTest(before,after);
}
public void testStringBinaryOperation() throws Exception {
@@ -1166,23 +1168,27 @@
}
public void testNewLineAfterJavaDocs() throws Exception {
- doTextTest("/** @noinspection InstanceVariableNamingConvention*/class Foo{\n" +
- "/** @noinspection InstanceVariableNamingConvention*/int myFoo;\n" +
-"/** @noinspection InstanceVariableNamingConvention*/ void foo(){}}", "/**\n" +
- " * @noinspection InstanceVariableNamingConvention\n" +
- " */\n" +
- "class Foo {\n" +
- " /**\n" +
- " * @noinspection InstanceVariableNamingConvention\n" +
- " */\n" +
- " int myFoo;\n" +
- "\n" +
- " /**\n" +
- " * @noinspection InstanceVariableNamingConvention\n" +
- " */\n" +
- " void foo() {\n" +
- " }\n" +
- "}");
+ String before = "/** @noinspection InstanceVariableNamingConvention*/class Foo{\n" +
+ "/** @noinspection InstanceVariableNamingConvention*/int myFoo;\n" +
+ "/** @noinspection InstanceVariableNamingConvention*/ void foo(){}}";
+
+ String after = "/**\n" +
+ " * @noinspection InstanceVariableNamingConvention\n" +
+ " */\n" +
+ "class Foo {\n" +
+ " /**\n" +
+ " * @noinspection InstanceVariableNamingConvention\n" +
+ " */\n" +
+ " int myFoo;\n" +
+ "\n" +
+ " /**\n" +
+ " * @noinspection InstanceVariableNamingConvention\n" +
+ " */\n" +
+ " void foo() {\n" +
+ " }\n" +
+ "}";
+
+ doTextTest(before, after);
}
public void testArrayInitializerWrapping() throws Exception {
diff --git a/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaFormatterWrapTest.java b/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaFormatterWrapTest.java
index 96ec1fe..c867bf1 100644
--- a/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaFormatterWrapTest.java
+++ b/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaFormatterWrapTest.java
@@ -304,12 +304,12 @@
doMethodTest(
"test(1,\n" +
" 2,\n" +
- " Test.loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooongMethod());\n" +
+ " MyTestClass.loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooongMethod());\n" +
"int i = 1;\n" +
"int j = 2;",
"test(1,\n" +
" 2,\n" +
- " Test\n" +
+ " MyTestClass\n" +
" .loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooongMethod());\n" +
"int i = 1;\n" +
"int j = 2;"
diff --git a/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavadocFormatterTest.java b/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavadocFormatterTest.java
index 28e4de5..24adb29 100644
--- a/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavadocFormatterTest.java
+++ b/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavadocFormatterTest.java
@@ -41,6 +41,23 @@
}
+ public void testOneLineCommentWrappedByRightMarginIntoMultiLine() throws Exception {
+ getSettings().getRootSettings().WRAP_COMMENTS = true;
+ getSettings().getRootSettings().ENABLE_JAVADOC_FORMATTING = true;
+ getSettings().getRootSettings().JD_DO_NOT_WRAP_ONE_LINE_COMMENTS = true;
+ getSettings().getRootSettings().RIGHT_MARGIN = 35;
+ doTextTest(
+ "/** Here is one-line java-doc comment */" +
+ "class Foo {\n" +
+ "}",
+ "/**\n" +
+ " * Here is one-line java-doc\n" +
+ " * comment\n" +
+ " */\n" +
+ "class Foo {\n" +
+ "}");
+ }
+
public void testLineFeedsArePreservedDuringWrap() {
// Inspired by IDEA-61895
getSettings().getRootSettings().WRAP_COMMENTS = true;
@@ -217,6 +234,79 @@
doTextTest(before, after);
}
+ public void testDoNotWrapMultiLineCommentIntoOneLine() throws Exception {
+ getCurrentCodeStyleSettings().ENABLE_JAVADOC_FORMATTING = true;
+ getCurrentCodeStyleSettings().JD_DO_NOT_WRAP_ONE_LINE_COMMENTS = true;
+ String test = "/**\n" +
+ " * foo\n" +
+ " */\n" +
+ "public Object next() {\n" +
+ " return new Object();\n" +
+ "}";
+ doClassTest(test, test);
+ }
+
+ public void testLeaveOneLineComment() throws Exception {
+ getCurrentCodeStyleSettings().ENABLE_JAVADOC_FORMATTING = true;
+ getCurrentCodeStyleSettings().JD_DO_NOT_WRAP_ONE_LINE_COMMENTS = true;
+ String test = "/** foo */\n" +
+ "public Object next() {\n" +
+ " return new Object();\n" +
+ "}";
+ doClassTest(test, test);
+ }
+
+ public void testWrapOneLineComment() throws Exception {
+ getCurrentCodeStyleSettings().ENABLE_JAVADOC_FORMATTING = true;
+ getCurrentCodeStyleSettings().JD_DO_NOT_WRAP_ONE_LINE_COMMENTS = false;
+ String test = "/** foo */\n" +
+ "public Object next() {\n" +
+ " return new Object();\n" +
+ "}";
+ String after = "/**\n" +
+ " * foo\n" +
+ " */\n" +
+ "public Object next() {\n" +
+ " return new Object();\n" +
+ "}";
+ doClassTest(test, after);
+ }
+
+ public void testWrapStrangeComment() throws Exception {
+ getCurrentCodeStyleSettings().ENABLE_JAVADOC_FORMATTING = true;
+ getCurrentCodeStyleSettings().JD_DO_NOT_WRAP_ONE_LINE_COMMENTS = false;
+ String test = "/** foo" +
+ " */\n" +
+ "public Object next() {\n" +
+ " return new Object();\n" +
+ "}";
+ String after = "/**\n" +
+ " * foo\n" +
+ " */\n" +
+ "public Object next() {\n" +
+ " return new Object();\n" +
+ "}";
+ doClassTest(test, after);
+ }
+
+ public void testWrapStrangeCommentIfNotWrapOneLines() throws Exception {
+ getCurrentCodeStyleSettings().ENABLE_JAVADOC_FORMATTING = true;
+ getCurrentCodeStyleSettings().JD_DO_NOT_WRAP_ONE_LINE_COMMENTS = true;
+ String test = "/** foo\n" +
+ " */" +
+ "public Object next() {\n" +
+ " return new Object();\n" +
+ "}";
+ String after = "/**\n" +
+ " * foo\n" +
+ " */\n" +
+ "public Object next() {\n" +
+ " return new Object();\n" +
+ "}";
+ doClassTest(test, after);
+ }
+
+
public void testReturnTagAlignment() throws Exception {
getSettings().getRootSettings().ENABLE_JAVADOC_FORMATTING = true;
getSettings().getRootSettings().RIGHT_MARGIN = 80;
@@ -352,4 +442,180 @@
doClassTest(before, after);
}
-}
+
+ public void testJavadocFormattingIndependentOfMethodIndentation() {
+ getCurrentCodeStyleSettings().RIGHT_MARGIN = 50;
+ getCurrentCodeStyleSettings().ENABLE_JAVADOC_FORMATTING = true;
+ getCurrentCodeStyleSettings().WRAP_COMMENTS = true;
+ getCurrentCodeStyleSettings().JD_LEADING_ASTERISKS_ARE_ENABLED = true;
+ getCurrentCodeStyleSettings().JD_P_AT_EMPTY_LINES = false;
+ getCurrentCodeStyleSettings().JD_KEEP_EMPTY_LINES = false;
+ getCurrentCodeStyleSettings().JD_ADD_BLANK_AFTER_DESCRIPTION = false;
+ String before1 = "class A {\n" +
+ " /**\n" +
+ " * Some really great independent test approach purpose live fish\n" +
+ " * banana split string be accurate when writing tests and code\n" +
+ " * read write buffer.\n" +
+ " *\n" +
+ " * Some text after empty line\n" +
+ " *\n" +
+ " */\n" +
+ "void foo() {\n" +
+ "\n" +
+ "}\n" +
+ "}";
+
+ String before2 = "class A {\n" +
+ " /**\n" +
+ " * Some really great independent test approach purpose live fish\n" +
+ " * banana split string be accurate when writing tests and code\n" +
+ " * read write buffer.\n" +
+ " *\n" +
+ " * Some text after empty line\n" +
+ " *\n" +
+ " */\n" +
+ " void foo() {\n" +
+ "\n" +
+ " }\n" +
+ "}";
+
+ formatEveryoneAndCheckIfResultEqual(before1, before2);
+ }
+
+ public void testJavadocAlignmentForInnerClasses() {
+ getCurrentCodeStyleSettings().RIGHT_MARGIN = 40;
+ getCurrentCodeStyleSettings().ENABLE_JAVADOC_FORMATTING = true;
+ getCurrentCodeStyleSettings().WRAP_COMMENTS = true;
+ getCurrentCodeStyleSettings().JD_LEADING_ASTERISKS_ARE_ENABLED = true;
+
+ String code = "public class Outer {\n" +
+ " class Inner {\n" +
+ " /**\n" +
+ " * Password from wild forest big house\n" +
+ " */\n" +
+ " public int getMagic() {\n" +
+ " return 312;\n" +
+ " }\n" +
+ "\n" +
+ "class InnerInner {\n" +
+ "/**\n" +
+ " * Special magic needs special rules\n" +
+ " */\n" +
+ "public int innerMagic() {\n" +
+ " return 1;\n" +
+ "}\n" +
+ "}\n" +
+ " }\n" +
+ "}";
+
+ String result = "public class Outer {\n" +
+ " class Inner {\n" +
+ " /**\n" +
+ " * Password from wild forest big\n" +
+ " * house\n" +
+ " */\n" +
+ " public int getMagic() {\n" +
+ " return 312;\n" +
+ " }\n" +
+ "\n" +
+ " class InnerInner {\n" +
+ " /**\n" +
+ " * Special magic needs\n" +
+ " * special rules\n" +
+ " */\n" +
+ " public int innerMagic() {\n" +
+ " return 1;\n" +
+ " }\n" +
+ " }\n" +
+ " }\n" +
+ "}";
+ doTextTest(code, result);
+ }
+
+ public void testAlignmentWithNoTopClassMembersIndentation() {
+ getCurrentCodeStyleSettings().RIGHT_MARGIN = 40;
+ getCurrentCodeStyleSettings().WRAP_COMMENTS = true;
+ getCurrentCodeStyleSettings().JD_LEADING_ASTERISKS_ARE_ENABLED = true;
+ getCurrentCodeStyleSettings().getCommonSettings(JavaLanguage.INSTANCE).DO_NOT_INDENT_TOP_LEVEL_CLASS_MEMBERS = true;
+
+ String before = "public class Outer {\n" +
+ "class Inner {\n" +
+ "/**\n" +
+ " * Password from wild forest big\n" +
+ " * house\n" +
+ " */\n" +
+ "public int getMagic() {\n" +
+ " return 312;\n" +
+ "}\n" +
+ "\n" +
+ "class InnerInner {\n" +
+ "/**\n" +
+ " * Special magic needs special rules\n" +
+ " */\n" +
+ "public int innerMagic() {\n" +
+ " return 1;\n" +
+ "}\n" +
+ "\n" +
+ "class InnerInnerInner {\n" +
+ "int iii;\n" +
+ "class TripleInner {\n" +
+ "int ti;\n" +
+ "}\n" +
+ "}\n" +
+ "}\n" +
+ "}\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(\"AAA!\");\n" +
+ " }\n" +
+ "}";
+
+ String after = "public class Outer {\n" +
+ "class Inner {\n" +
+ " /**\n" +
+ " * Password from wild forest big\n" +
+ " * house\n" +
+ " */\n" +
+ " public int getMagic() {\n" +
+ " return 312;\n" +
+ " }\n" +
+ "\n" +
+ " class InnerInner {\n" +
+ " /**\n" +
+ " * Special magic needs special\n" +
+ " * rules\n" +
+ " */\n" +
+ " public int innerMagic() {\n" +
+ " return 1;\n" +
+ " }\n" +
+ "\n" +
+ " class InnerInnerInner {\n" +
+ " int iii;\n" +
+ "\n" +
+ " class TripleInner {\n" +
+ " int ti;\n" +
+ " }\n" +
+ " }\n" +
+ " }\n" +
+ "}\n" +
+ "\n" +
+ "public static void main(String[] args) {\n" +
+ " System.out.println(\"AAA!\");\n" +
+ "}\n" +
+ "}";
+
+ doTextTest(before, after);
+ }
+
+ public void testDoNotWrapLongLineCommentWithSpaceInStart() throws Exception {
+ getSettings().KEEP_FIRST_COLUMN_COMMENT = true;
+ getSettings().WRAP_LONG_LINES = true;
+ getSettings().getRootSettings().RIGHT_MARGIN = 200;
+ String before = "public class JiraIssue {\n" +
+ "\n" +
+ " public static void main(String[] args) {\n" +
+ "// AAAMIIGgIBADANBgkqhkiG9w0BAQEFAASCBugwgsdfssdflkldkflskdfsdkfjskdlfjdskjfksdjfksdjfkjsdkfjsdkfjgbkAgEAAoIBgQCZfKds4XjFWIU8D4OqCYJ0TkAkKPVV96v2l6PuMBNbON3ndHCVvwoJOJnopfbtFro9eCTCUC9MlAUZBAVdCbPVi3ioqaEN\n" +
+ " }\n" +
+ "}";
+ doTextTest(before, before);
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testSrc/com/intellij/psi/resolve/Resolve15TestCase.java b/java/java-tests/testSrc/com/intellij/psi/resolve/Resolve15TestCase.java
index 01d43d8..13978f2 100644
--- a/java/java-tests/testSrc/com/intellij/psi/resolve/Resolve15TestCase.java
+++ b/java/java-tests/testSrc/com/intellij/psi/resolve/Resolve15TestCase.java
@@ -4,10 +4,9 @@
package com.intellij.psi.resolve;
import com.intellij.openapi.projectRoots.JavaSdkVersion;
-import com.intellij.openapi.projectRoots.JavaVersionService;
-import com.intellij.openapi.projectRoots.JavaVersionServiceImpl;
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
import com.intellij.pom.java.LanguageLevel;
+import com.intellij.testFramework.IdeaTestUtil;
import com.intellij.testFramework.ResolveTestCase;
/**
@@ -21,7 +20,7 @@
super.setUp();
myOldLanguageLevel = LanguageLevelProjectExtension.getInstance(myJavaFacade.getProject()).getLanguageLevel();
LanguageLevelProjectExtension.getInstance(myJavaFacade.getProject()).setLanguageLevel(LanguageLevel.JDK_1_5);
- ((JavaVersionServiceImpl)JavaVersionService.getInstance()).setTestVersion(JavaSdkVersion.JDK_1_5, getTestRootDisposable());
+ IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_5, getModule(), getTestRootDisposable());
}
@Override
diff --git a/java/java-tests/testSrc/com/intellij/psi/resolve/ResolveInLibrariesTest.groovy b/java/java-tests/testSrc/com/intellij/psi/resolve/ResolveInLibrariesTest.groovy
index 36d6b53..df43e5b 100644
--- a/java/java-tests/testSrc/com/intellij/psi/resolve/ResolveInLibrariesTest.groovy
+++ b/java/java-tests/testSrc/com/intellij/psi/resolve/ResolveInLibrariesTest.groovy
@@ -149,9 +149,12 @@
Collection<VirtualFile> pkgDirs = pkg.directories.collect { it.virtualFile }
Collection<VirtualFile> pkgChildren = pkgDirs.collect { it.children as List }.flatten()
PsiFile javaSrc = psiManager.findFile(pkgChildren.find { it.name == 'LibraryClass.java' })
- assert !javaSrc.node.parsed
+ assert !javaSrc.contentsLoaded
+ assert !javaSrc.stub
assert pkg.containsClassNamed('LibraryClass')
+ assert !javaSrc.contentsLoaded
+ assert !javaSrc.stub
assert !javaSrc.node.parsed
}
diff --git a/java/java-tests/testSrc/com/intellij/psi/resolve/ResolveMethod15Test.java b/java/java-tests/testSrc/com/intellij/psi/resolve/ResolveMethod15Test.java
index d1b6fac..36b1c4c 100644
--- a/java/java-tests/testSrc/com/intellij/psi/resolve/ResolveMethod15Test.java
+++ b/java/java-tests/testSrc/com/intellij/psi/resolve/ResolveMethod15Test.java
@@ -7,6 +7,7 @@
import org.jetbrains.annotations.NonNls;
import static org.junit.Assert.assertThat;
import static org.hamcrest.core.IsInstanceOf.instanceOf;
+import static org.junit.Assert.assertTrue;
/**
* @author dsl
@@ -118,6 +119,16 @@
assertEquals("java.lang.Class<? extends java.lang.String>", type.getCanonicalText());
}
+ public void testToString() throws Exception {
+ final PsiReference ref = configureByFile();
+ assertThat(ref, instanceOf(PsiReferenceExpression.class));
+ final PsiReferenceExpression refExpr = (PsiReferenceExpression)ref;
+ final PsiElement resolve = refExpr.resolve();
+ assertTrue(resolve != null ? resolve.toString() : null, resolve instanceof PsiMethod);
+ final PsiClass containingClass = ((PsiMethod)resolve).getContainingClass();
+ assertTrue(containingClass != null ? containingClass.getName() : null, containingClass instanceof PsiAnonymousClass);
+ }
+
public void testFilterFixedVsVarargs1() throws Exception {
final PsiReference ref = configureByFile();
assertThat(ref, instanceOf(PsiReferenceExpression.class));
diff --git a/java/java-tests/testSrc/com/intellij/psi/resolve/TypeInferenceTest.java b/java/java-tests/testSrc/com/intellij/psi/resolve/TypeInferenceTest.java
index 57fd633..58e7159 100644
--- a/java/java-tests/testSrc/com/intellij/psi/resolve/TypeInferenceTest.java
+++ b/java/java-tests/testSrc/com/intellij/psi/resolve/TypeInferenceTest.java
@@ -40,7 +40,7 @@
assertTrue(type instanceof PsiClassType);
PsiType[] paramTypes = ((PsiClassType)type).getParameters();
assertEquals(1, paramTypes.length);
- assertEquals(CommonClassNames.JAVA_LANG_STRING, paramTypes[0].getCanonicalText());
+ assertEquals(CommonClassNames.JAVA_LANG_OBJECT, paramTypes[0].getCanonicalText());
}
public void testInferWithBounds () throws Exception {
diff --git a/java/java-tests/testSrc/com/intellij/refactoring/ChangeSignatureTest.java b/java/java-tests/testSrc/com/intellij/refactoring/ChangeSignatureTest.java
index 6519401..9157e43 100644
--- a/java/java-tests/testSrc/com/intellij/refactoring/ChangeSignatureTest.java
+++ b/java/java-tests/testSrc/com/intellij/refactoring/ChangeSignatureTest.java
@@ -155,6 +155,13 @@
}, false);
}
+ public void testParamJavadoc0() throws Exception {
+ doTest(null, new ParameterInfoImpl[] {
+ new ParameterInfoImpl(1, "z", PsiType.INT),
+ new ParameterInfoImpl(0, "y", PsiType.INT)
+ }, false);
+ }
+
public void testParamJavadoc1() throws Exception {
doTest(null, new ParameterInfoImpl[]{
new ParameterInfoImpl(0, "z", PsiType.BOOLEAN)
@@ -414,7 +421,7 @@
method.getName(),
CanonicalTypes.createTypeWrapper(PsiType.VOID), new ParameterInfoImpl[]{
new ParameterInfoImpl(0, parameters[0].getName(), parameters[0].getType()),
- new ParameterInfoImpl(-1, "b", PsiType.BOOLEAN, "true")}, null,
+ new ParameterInfoImpl(-1, "b", PsiType.BOOLEAN)}, null,
propagateParametersMethods, null).run();
@NonNls String after = basePath + "_after.java";
checkResultByFile(after);
diff --git a/java/java-tests/testSrc/com/intellij/refactoring/SafeDeleteTest.java b/java/java-tests/testSrc/com/intellij/refactoring/SafeDeleteTest.java
index 83dbbef..2e3da90 100644
--- a/java/java-tests/testSrc/com/intellij/refactoring/SafeDeleteTest.java
+++ b/java/java-tests/testSrc/com/intellij/refactoring/SafeDeleteTest.java
@@ -122,6 +122,24 @@
doTest("Super");
}
+ public void testOverrideAnnotation() throws Exception {
+ myDoCompare = false;
+ doTest("Super");
+ }
+
+ public void testSuperCall() throws Exception {
+ myDoCompare = false;
+ try {
+ doTest("Super");
+ fail("Conflict was not detected");
+ }
+ catch (BaseRefactoringProcessor.ConflictsInTestsException e) {
+ String message = e.getMessage();
+ assertTrue(message, message.equals("method <b><code>Super.foo()</code></b> has 1 usage that is not safe to delete.\n" +
+ "Of those 0 usages are in strings, comments, or non-code files."));
+ }
+ }
+
public void testMethodDeepHierarchy() throws Exception {
myDoCompare = false;
doTest("Super");