summaryrefslogtreecommitdiff
path: root/java/java-tests/testSrc/com/intellij
diff options
context:
space:
mode:
authorTor Norbye <tnorbye@google.com>2014-07-16 18:07:37 -0700
committerTor Norbye <tnorbye@google.com>2014-07-16 18:09:03 -0700
commit65f60eb9011bb2c549a6d83ae31257480368ddc5 (patch)
treede0dca03bec460e8797332e5f460400f5cf6485f /java/java-tests/testSrc/com/intellij
parent9ea67227e8fdcf8ed37e65bb96e32767291d0f4f (diff)
downloadidea-65f60eb9011bb2c549a6d83ae31257480368ddc5.tar.gz
Snapshot idea/138.1029 from git://git.jetbrains.org/idea/community.git
Update from idea/138.538 to idea/138.1029 Change-Id: I828f829a968439a99ec67640990c18ff7c9b58ce
Diffstat (limited to 'java/java-tests/testSrc/com/intellij')
-rw-r--r--java/java-tests/testSrc/com/intellij/codeInsight/completion/HeavyNormalCompletionTest.groovy4
-rw-r--r--java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaAutoPopupTest.groovy13
-rw-r--r--java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaReflectionCompletionTest.java1
-rw-r--r--java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionOrderingTest.groovy13
-rw-r--r--java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy17
-rw-r--r--java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java3
-rw-r--r--java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GraphInferenceHighlightingTest.java4
-rw-r--r--java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewLambdaHighlightingTest.java16
-rw-r--r--java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewMethodRefHighlightingTest.java12
-rw-r--r--java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/AddMethodQualifierTest.java104
-rw-r--r--java/java-tests/testSrc/com/intellij/codeInsight/folding/JavaFoldingTest.groovy220
-rw-r--r--java/java-tests/testSrc/com/intellij/codeInsight/intention/SwapIfStatementsTest.java34
-rw-r--r--java/java-tests/testSrc/com/intellij/codeInsight/javadoc/JavaDocInfoGeneratorTest.java4
-rw-r--r--java/java-tests/testSrc/com/intellij/codeInsight/template/LiveTemplateTest.groovy2
-rw-r--r--java/java-tests/testSrc/com/intellij/codeInspection/ContractInferenceFromSourceTest.groovy49
-rw-r--r--java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java4
-rw-r--r--java/java-tests/testSrc/com/intellij/codeInspection/OfflineIRVTest.java194
-rw-r--r--java/java-tests/testSrc/com/intellij/codeInspection/RedundantCast15Test.java1
-rw-r--r--java/java-tests/testSrc/com/intellij/codeInspection/RedundantCast18Test.java2
-rw-r--r--java/java-tests/testSrc/com/intellij/codeInspection/SuspiciousCollectionMethodCalls14Test.java44
-rw-r--r--java/java-tests/testSrc/com/intellij/compiler/notNullVerification/NotNullVerifyingInstrumenterTest.java4
-rw-r--r--java/java-tests/testSrc/com/intellij/find/FindManagerTest.java22
-rw-r--r--java/java-tests/testSrc/com/intellij/navigation/ChooseByNameTest.groovy60
-rw-r--r--java/java-tests/testSrc/com/intellij/openapi/editor/impl/FoldingExceptionTest.java14
-rw-r--r--java/java-tests/testSrc/com/intellij/psi/ClsDuplicatesTest.java103
-rw-r--r--java/java-tests/testSrc/com/intellij/psi/ClsMirrorBuildingTest.java46
-rw-r--r--java/java-tests/testSrc/com/intellij/psi/ClsRepositoryUseTest.java26
-rw-r--r--java/java-tests/testSrc/com/intellij/psi/MiscPsiTest.java3
-rw-r--r--java/java-tests/testSrc/com/intellij/psi/StubAstSwitchTest.groovy8
-rw-r--r--java/java-tests/testSrc/com/intellij/psi/codeStyle/arrangement/JavaRearrangerFieldReferenceTest.groovy52
-rw-r--r--java/java-tests/testSrc/com/intellij/psi/impl/file/impl/PsiEventsTest.java101
-rw-r--r--java/java-tests/testSrc/com/intellij/psi/resolve/ResolveInLibrariesTest.groovy26
-rw-r--r--java/java-tests/testSrc/com/intellij/refactoring/MoveMembersTest.java12
-rw-r--r--java/java-tests/testSrc/com/intellij/refactoring/inline/InlineMethodTest.java4
-rw-r--r--java/java-tests/testSrc/com/intellij/roots/ModuleScopesTest.java41
-rw-r--r--java/java-tests/testSrc/com/intellij/slicer/SliceBackwardTest.java4
36 files changed, 1086 insertions, 181 deletions
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/HeavyNormalCompletionTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/completion/HeavyNormalCompletionTest.groovy
index 45a3f818df3f..5d0bcd4eaa8c 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/HeavyNormalCompletionTest.groovy
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/HeavyNormalCompletionTest.groovy
@@ -26,6 +26,8 @@ import com.intellij.psi.search.GlobalSearchScope
import com.intellij.psi.util.PsiTreeUtil
import com.intellij.testFramework.PsiTestUtil
import com.intellij.testFramework.fixtures.JavaCodeInsightFixtureTestCase
+import org.jetbrains.annotations.NotNull
+
/**
* @author peter
*/
@@ -94,7 +96,7 @@ public class HeavyNormalCompletionTest extends JavaCodeInsightFixtureTestCase {
static class CacheVerifyingContributor extends CompletionContributor {
@Override
- void fillCompletionVariants(CompletionParameters parameters, CompletionResultSet result) {
+ void fillCompletionVariants(@NotNull CompletionParameters parameters, @NotNull CompletionResultSet result) {
PsiClass psiClass = PsiTreeUtil.getParentOfType(parameters.position, PsiClass)
for (ci in OverrideImplementExploreUtil.getMethodsToOverrideImplement(psiClass, true)) {
assert ci.element.valid
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 a5397a2de68b..8a54c9594144 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaAutoPopupTest.groovy
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaAutoPopupTest.groovy
@@ -47,7 +47,9 @@ import com.intellij.openapi.extensions.LoadingOrder
import com.intellij.openapi.fileEditor.FileEditor
import com.intellij.openapi.fileEditor.FileEditorManager
import com.intellij.openapi.progress.ProgressManager
+import com.intellij.openapi.util.Computable
import com.intellij.openapi.util.Disposer
+import com.intellij.psi.PsiClass
import com.intellij.psi.PsiFile
import com.intellij.psi.PsiJavaFile
import com.intellij.psi.statistics.StatisticsManager
@@ -559,7 +561,7 @@ public interface Test {
static class LongContributor extends CompletionContributor {
@Override
- void fillCompletionVariants(CompletionParameters parameters, CompletionResultSet result) {
+ void fillCompletionVariants(@NotNull CompletionParameters parameters, @NotNull CompletionResultSet result) {
result.runRemainingContributors(parameters, true)
Thread.sleep 500
}
@@ -892,9 +894,7 @@ class Foo {
void bar(int aaa, int aaaaa) { foo(<caret>) }
} """)
type 'a'
- println myFixture.lookupElementStrings
type 'a'
- println myFixture.lookupElementStrings
type ','
assert myFixture.editor.document.text.contains('foo(aaa, )')
}
@@ -967,7 +967,12 @@ class Foo {
void x__goo() {}
}
'''
- def cls = ((PsiJavaFile)myFixture.file).getClasses()[0]
+ PsiClass cls = ApplicationManager.getApplication().runReadAction(new Computable<PsiClass>() {
+ @Override
+ public PsiClass compute() {
+ return ((PsiJavaFile)myFixture.file).getClasses()[0];
+ }
+ });
def foo = cls.methods[0]
def goo = cls.methods[2]
type('x')
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaReflectionCompletionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaReflectionCompletionTest.java
index 8aa780abbaa2..6eb495d27c26 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaReflectionCompletionTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaReflectionCompletionTest.java
@@ -64,6 +64,7 @@ public class JavaReflectionCompletionTest extends LightFixtureCompletionTestCase
}
public void testGenerics() throws Exception {
+ myFixture.addFileToProject("a.properties", "foo=bar"); // check that property variants don't override reflection ones
doTest(0, "foo");
}
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 c1e6d4182aa5..900555d21ab9 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionOrderingTest.groovy
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionOrderingTest.groovy
@@ -633,6 +633,19 @@ interface TxANotAnno {}
checkPreferredItems 0, 'fact'
}
+ public void testPreferAnnotationsToInterfaceKeyword() {
+ checkPreferredItems 0, 'Deprecated', 'Override'
+ }
+
+ public void testPreferThrownExceptionsInCatch() {
+ checkPreferredItems 0, 'FileNotFoundException', 'File'
+ }
+
+ public void testHonorFirstLetterCase() {
+ CodeInsightSettings.getInstance().COMPLETION_CASE_SENSITIVE = CodeInsightSettings.NONE;
+ checkPreferredItems 0, 'posIdMap', 'PImageDecoder', 'PNGImageDecoder'
+ }
+
public void testGlobalStaticMemberStats() {
configureNoCompletion(getTestName(false) + ".java")
myFixture.complete(CompletionType.BASIC, 2)
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 ba38fd1a45ad..79a94aaa8148 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy
@@ -792,7 +792,7 @@ public class ListUtils {
public void testDoubleFalse() throws Throwable {
configureByFile(getTestName(false) + ".java");
- assertFirstStringItems("false", "fefefef", "float", "finalize");
+ assertFirstStringItems("fefefef", "false", "float", "finalize");
}
public void testSameNamedVariableInNestedClasses() throws Throwable {
@@ -938,6 +938,13 @@ public class ListUtils {
public void testQualifyInnerMembers() throws Throwable { doTest('\n') }
+ public void testDeepInner() throws Throwable {
+ configure()
+ assert myFixture.lookupElementStrings == ['ClassInner1', 'ClassInner1.ClassInner2']
+ selectItem(lookup.items[1])
+ checkResult()
+ }
+
public void testSuggestExpectedTypeMembers() throws Throwable { doTest('\n') }
public void testSuggestExpectedTypeMembersInCall() throws Throwable { doTest('\n') }
public void testSuggestExpectedTypeMembersInAnno() throws Throwable { doTest('\n') }
@@ -1209,6 +1216,12 @@ class XInternalError {}
public void testConstantInAnno() { doTest() }
+ public void testCharsetName() {
+ myFixture.addClass("package java.nio.charset; public class Charset { public static Charset forName(String s) {} }")
+ configureByTestName()
+ assert myFixture.lookupElementStrings.contains('UTF-8')
+ }
+
public void testInnerClassInExtendsGenerics() {
def text = "package bar; class Foo extends List<Inne<caret>> { public static class Inner {} }"
myFixture.configureFromExistingVirtualFile(myFixture.addClass(text).containingFile.virtualFile)
@@ -1240,7 +1253,7 @@ class XInternalError {}
configure()
def items = myFixture.lookupElements.findAll { it.lookupString == 'String' }
assert items.size() == 1
- assert LookupElementPresentation.renderElement(items[0]).tailText?.contains('java.lang')
+ assert LookupElementPresentation.renderElement(items[0]).tailText == ' (java.lang)'
}
public void testSameSignature() {
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 74d2465f43a5..f6be0686d239 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java
@@ -368,6 +368,9 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
public void testIDEA125816() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); }
public void testIDEA57338() { doTest(LanguageLevel.JDK_1_6, JavaSdkVersion.JDK_1_6, false); }
public void testIDEA67600() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); }
+ public void testIDEA126697() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, true); }
+ public void testIDEA126633() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); }
+ public void testIDEA124363() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); }
//jdk should propagate LL 1.4 but actually it provides LL 1.7?!
public void testCastObjectToIntJdk14() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_4, false); }
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 20a5d5139d99..79506280a778 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
@@ -184,6 +184,10 @@ public class GraphInferenceHighlightingTest extends LightDaemonAnalyzerTestCase
doTest();
}
+ public void testRawTypeFromParentArrayType() throws Exception {
+ doTest();
+ }
+
private void doTest() throws Exception {
doTest(false);
}
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewLambdaHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewLambdaHighlightingTest.java
index f5e6a651f167..6bd7654b72af 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewLambdaHighlightingTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewLambdaHighlightingTest.java
@@ -226,6 +226,22 @@ public class NewLambdaHighlightingTest extends LightDaemonAnalyzerTestCase {
doTest();
}
+ public void testIDEA125254() throws Exception {
+ doTest();
+ }
+
+ public void testIDEA124961() throws Exception {
+ doTest();
+ }
+
+ public void testIDEA126109() throws Exception {
+ doTest();
+ }
+
+ public void testIDEA126809() throws Exception {
+ doTest();
+ }
+
private void doTest() {
doTest(false);
}
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewMethodRefHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewMethodRefHighlightingTest.java
index 16af9001cf43..6860bc0c88fa 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewMethodRefHighlightingTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewMethodRefHighlightingTest.java
@@ -261,6 +261,18 @@ public class NewMethodRefHighlightingTest extends LightDaemonAnalyzerTestCase {
doTest();
}
+ public void testRejectReceiverTypesForConstructorRefs() {
+ doTest();
+ }
+
+ public void testEnumValuesMethod() throws Exception {
+ doTest();
+ }
+
+ public void testMissedApplicableMemberContainingClassSubstitution() throws Exception {
+ doTest();
+ }
+
private void doTest() {
doTest(false);
}
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/AddMethodQualifierTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/AddMethodQualifierTest.java
new file mode 100644
index 000000000000..48572b2c8068
--- /dev/null
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/AddMethodQualifierTest.java
@@ -0,0 +1,104 @@
+/*
+ * Copyright 2000-2014 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.daemon.quickFix;
+
+import com.intellij.JavaTestUtil;
+import com.intellij.codeInsight.daemon.impl.quickfix.AddMethodQualifierFix;
+import com.intellij.codeInsight.intention.IntentionAction;
+import com.intellij.psi.PsiNamedElement;
+import com.intellij.testFramework.fixtures.JavaCodeInsightFixtureTestCase;
+import com.intellij.util.Function;
+import com.intellij.util.containers.ContainerUtil;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.*;
+
+/**
+ * @author Dmitry Batkovich
+ */
+public class AddMethodQualifierTest extends JavaCodeInsightFixtureTestCase {
+
+ @Override
+ protected String getTestDataPath() {
+ return JavaTestUtil.getJavaTestDataPath() + "/codeInsight/daemonCodeAnalyzer/quickFix/addMethodCallQualifier/";
+ }
+
+ public void testNonStaticMethod() {
+ doTest("fieldElement", "staticElement", "localElement1", "paramElement");
+ }
+
+ public void testStaticMethod() {
+ doTest("staticElement", "localElement1", "paramElement");
+ }
+
+ public void testNestedMethod() {
+ doTest("fieldElement", "localElement1", "nestedField", "nestedParamElement", "staticElement", "paramElement");
+ }
+
+ public void testConstructor() {
+ doTest("fieldElement", "staticElement", "localElement1");
+ }
+
+ public void testStaticInitializer() {
+ doTest("staticElement", "localElement1");
+ }
+
+ public void testFix() {
+ doTestFix();
+ }
+
+ private void doTestFix() {
+ myFixture.configureByFile(getTestName(false) + "Before.java");
+ final AddMethodQualifierFix quickFix = getQuickFix();
+ assertNotNull(quickFix);
+ myFixture.launchAction(quickFix);
+ myFixture.checkResultByFile(getTestName(false) + "After.java");
+ }
+
+ private void doTest(final String... candidatesNames) {
+ myFixture.configureByFile(getTestName(false) + ".java");
+ final AddMethodQualifierFix addMethodQualifierFix = getQuickFix();
+ if (candidatesNames.length == 0) {
+ assertNull(addMethodQualifierFix);
+ return;
+ }
+ assertNotNull(addMethodQualifierFix);
+ final Set<String> actualCandidatesNames = new TreeSet<String>(ContainerUtil.map(addMethodQualifierFix.getCandidates(), new Function<PsiNamedElement, String>() {
+ @Override
+ public String fun(final PsiNamedElement psiNamedElement) {
+ final String name = psiNamedElement.getName();
+ assertNotNull(name);
+ return name;
+ }
+ }));
+ final Set<String> expectedCandidatesNames = new TreeSet<String>(ContainerUtil.list(candidatesNames));
+ assertEquals(expectedCandidatesNames, actualCandidatesNames);
+ }
+
+ @Nullable
+ private AddMethodQualifierFix getQuickFix() {
+ final List<IntentionAction> availableIntentions = myFixture.getAvailableIntentions();
+ AddMethodQualifierFix addMethodQualifierFix = null;
+ for (final IntentionAction availableIntention : availableIntentions) {
+ if (availableIntention instanceof AddMethodQualifierFix) {
+ addMethodQualifierFix = (AddMethodQualifierFix)availableIntention;
+ break;
+ }
+ }
+ return addMethodQualifierFix;
+ }
+
+}
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 41d72f7e9a0e..2047f13b795d 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/folding/JavaFoldingTest.groovy
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/folding/JavaFoldingTest.groovy
@@ -27,6 +27,7 @@ import com.intellij.openapi.editor.impl.FoldingModelImpl
import com.intellij.openapi.fileEditor.impl.text.TextEditorProvider
import com.intellij.psi.JavaPsiFacade
import com.intellij.psi.PsiClass
+import com.intellij.psi.PsiLiteralExpression
import com.intellij.psi.PsiMethod
import com.intellij.psi.search.GlobalSearchScope
import com.intellij.testFramework.LightProjectDescriptor
@@ -592,6 +593,225 @@ class Test {
assert regions[0].placeholderText == '{...}'
}
+ public void "test insert boolean literal argument name"() {
+ def text = """class Groo {
+
+ public void test() {
+ boolean testNow = System.currentTimeMillis() > 34000;
+ int times = 1;
+ float pi = 4;
+ String title = "Testing..."
+ char ch = 'q'
+ File file;
+
+ configure(true, false, 555, 3.141f, "Huge Title", 'c', null);
+ configure(testNow, shouldIgnoreRoots(), fourteen, pi, title, c, file);
+ }
+
+ pubic void configure(boolean testNow, boolean shouldIgnoreRoots, int times, float pi, String title, char terminate, File file) {
+ System.out.println();
+ System.out.println();
+ }
+
+}"""
+ configure text
+ PsiClass fooClass = JavaPsiFacade.getInstance(project).findClass('Groo', GlobalSearchScope.allScope(project))
+
+ def regions = myFixture.editor.foldingModel.allFoldRegions.sort { it.startOffset }
+ assert regions.size() == 9
+
+ def literals = fooClass.methods[0].body.statements[6].children[0].children[1].children.findAll { it instanceof PsiLiteralExpression }
+ def parameters = fooClass.methods[1].parameterList.parameters
+
+ for (int i = 0; i < literals.size(); i++) {
+ def currentElement = literals[i]
+ def correspondingFolding = regions[i + 1]
+ assert correspondingFolding.startOffset == currentElement.textRange.startOffset && correspondingFolding.endOffset == currentElement.textRange.endOffset
+ assert correspondingFolding.placeholderText == parameters[i].name + ": " + currentElement.text
+ }
+ }
+
+ public void "test do not inline name if setter"() {
+ def text = """class Groo {
+
+ public void test() {
+ setTestNow(false);
+ System.out.println("");
+ }
+
+ pubic void setTestNow(boolean testNow) {
+ System.out.println("");
+ System.out.println("");
+ }
+
+}"""
+ configure text
+ def regions = myFixture.editor.foldingModel.allFoldRegions
+ assert regions.size() == 2
+ }
+
+ public void "test do not collapse varargs"() {
+ def text = """
+public class VarArgTest {
+
+ public void main() {
+ System.out.println("AAA");
+ testBooleanVarargs(13, false);
+ }
+
+ public boolean testBooleanVarargs(int test, boolean... booleans) {
+ int temp = test;
+ return false;
+ }
+}
+"""
+ configure text
+ def regions = myFixture.editor.foldingModel.allFoldRegions.sort { it.startOffset }
+ assert regions.size() == 3
+ checkRangeOffsetByPositionInText(regions[1], text, "13")
+ assert regions[1].placeholderText == "test: 13"
+ }
+
+ public void "test inline if argument length is one (EA-57555)"() {
+ def text = """
+public class CharSymbol {
+
+ public void main() {
+ System.out.println("AAA");
+ count(1, false);
+ }
+
+ public void count(int test, boolean fast) {
+ int temp = test;
+ boolean isFast = fast;
+ }
+}
+"""
+ configure text
+ def regions = myFixture.editor.foldingModel.allFoldRegions.sort { it.startOffset }
+ assert regions.size() == 4
+
+ checkRangeOffsetByPositionInText(regions[1], text, "1")
+ assert regions[1].placeholderText == "test: 1"
+
+ checkRangeOffsetByPositionInText(regions[2], text, "false")
+ assert regions[2].placeholderText == "fast: false"
+ }
+
+ public void "test inline names if literal expression can be assigned to method parameter"() {
+ def text = """
+public class CharSymbol {
+
+ public void main() {
+ Object obj = new Object();
+ count(100, false, "Hi!");
+ }
+
+ public void count(Integer test, Boolean boo, CharSequence seq) {
+ int a = test;
+ Object obj = new Object();
+ }
+}
+"""
+ configure text
+ def regions = myFixture.editor.foldingModel.allFoldRegions.sort { it.startOffset }
+ assert regions.size() == 5
+
+ checkRangeOffsetByPositionInText(regions[1], text, "100")
+ assert regions[1].placeholderText == "test: 100"
+
+ checkRangeOffsetByPositionInText(regions[2], text, "false")
+ assert regions[2].placeholderText == "boo: false"
+
+ checkRangeOffsetByPositionInText(regions[3], text, '"Hi!"')
+ assert regions[3].placeholderText == 'seq: "Hi!"'
+ }
+
+ public void "test inline negative numbers (IDEA-126753)"() {
+ def text = """
+public class CharSymbol {
+
+ public void main() {
+ Object obj = new Object();
+ count(-1, obj);
+ }
+
+ public void count(int test, Object obj) {
+ Object tmp = obj;
+ boolean isFast = false;
+ }
+}
+"""
+ configure text
+ def regions = myFixture.editor.foldingModel.allFoldRegions.sort { it.startOffset }
+ assert regions.size() == 3
+
+ checkRangeOffsetByPositionInText(regions[1], text, "-1")
+ assert regions[1].placeholderText == "test: -1"
+ }
+
+ public void "test inline constructor literal arguments names"() {
+ def text = """
+public class Test {
+
+ public void main() {
+ System.out.println("AAA");
+ Checker r = new Checker(true, false) {
+ @Override
+ void test() {
+ }
+ };
+ }
+
+ abstract class Checker {
+ Checker(boolean applyToFirst, boolean applyToSecond) {}
+ abstract void test();
+ }
+}
+"""
+ configure text
+ def regions = myFixture.editor.foldingModel.allFoldRegions.sort { it.startOffset }
+ assert regions.length == 6
+
+ assert regions[1].placeholderText == "applyToFirst: true"
+ assert regions[2].placeholderText == "applyToSecond: false"
+
+ checkRangeOffsetByPositionInText(regions[1], text, "true")
+ checkRangeOffsetByPositionInText(regions[2], text, "false")
+ }
+
+ public void "test inline anonymous class constructor literal arguments names"() {
+ def text = """
+public class Test {
+
+ Test(int counter, boolean shouldTest) {
+ System.out.println();
+ System.out.println();
+ }
+
+ public static void main() {
+ System.out.println();
+ Test t = new Test(10, false);
+ }
+
+}
+"""
+ configure text
+ def regions = myFixture.editor.foldingModel.allFoldRegions.sort { it.startOffset }
+ assert regions.length == 4
+
+ assert regions[2].placeholderText == "counter: 10"
+ assert regions[3].placeholderText == "shouldTest: false"
+
+ checkRangeOffsetByPositionInText(regions[2], text, "10")
+ checkRangeOffsetByPositionInText(regions[3], text, "false")
+ }
+
+ private static def checkRangeOffsetByPositionInText(FoldRegion region, String text, String foldElement) {
+ assert region.startOffset == text.indexOf(foldElement) && region.endOffset == text.indexOf(foldElement) + foldElement.length()
+ }
+
+
private def changeFoldRegions(Closure op) {
myFixture.editor.foldingModel.runBatchFoldingOperationDoNotCollapseCaret(op)
}
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/intention/SwapIfStatementsTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/intention/SwapIfStatementsTest.java
new file mode 100644
index 000000000000..a973a9775be0
--- /dev/null
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/intention/SwapIfStatementsTest.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2000-2014 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.intention;
+
+import com.intellij.codeInsight.daemon.quickFix.LightQuickFixParameterizedTestCase;
+
+/**
+ * @author Dmitry Batkovich
+ */
+public class SwapIfStatementsTest extends LightQuickFixParameterizedTestCase {
+
+ @Override
+ protected String getBasePath() {
+ return "/codeInsight/daemonCodeAnalyzer/quickFix/swapIfStatements";
+ }
+
+ @Override
+ protected boolean shouldBeAvailableAfterExecution() {
+ return true;
+ }
+}
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/javadoc/JavaDocInfoGeneratorTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/javadoc/JavaDocInfoGeneratorTest.java
index 6df51f02df15..454bb7f97a58 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/javadoc/JavaDocInfoGeneratorTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/javadoc/JavaDocInfoGeneratorTest.java
@@ -76,6 +76,10 @@ public class JavaDocInfoGeneratorTest extends CodeInsightTestCase {
doTestField();
}
+ public void testAnnotations() throws Exception {
+ doTestField();
+ }
+
public void testLiteral() throws Exception {
doTestField();
}
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 cc50869bc886..3acb9845df66 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/template/LiveTemplateTest.groovy
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/template/LiveTemplateTest.groovy
@@ -461,7 +461,7 @@ class Foo {
}
@Override
- protected void invokeTestRunnable(final Runnable runnable) throws Exception {
+ protected void invokeTestRunnable(@NotNull final Runnable runnable) throws Exception {
if (name in ["testNavigationActionsDontTerminateTemplate", "testTemplateWithEnd", "testDisappearingVar", "test escape string characters in soutv"]) {
runnable.run();
return;
diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/ContractInferenceFromSourceTest.groovy b/java/java-tests/testSrc/com/intellij/codeInspection/ContractInferenceFromSourceTest.groovy
index ab9a5660b8ad..32982f3687df 100644
--- a/java/java-tests/testSrc/com/intellij/codeInspection/ContractInferenceFromSourceTest.groovy
+++ b/java/java-tests/testSrc/com/intellij/codeInspection/ContractInferenceFromSourceTest.groovy
@@ -171,6 +171,55 @@ class ContractInferenceFromSourceTest extends LightCodeInsightFixtureTestCase {
assert c == []
}
+ public void "test plain delegation"() {
+ def c = inferContracts("""
+ boolean delegating(Object o) {
+ return smth(o);
+ }
+ boolean smth(Object o) {
+ assert o instanceof String;
+ return true;
+ }
+""")
+ assert c == ['null -> fail']
+ }
+
+ public void "test arg swapping delegation"() {
+ def c = inferContracts("""
+ boolean delegating(Object o, Object o1) {
+ return smth(o1, o);
+ }
+ boolean smth(Object o, Object o1) {
+ return o == null && o1 != null;
+ }
+""")
+ assert c == ['_, !null -> false', 'null, null -> false', '!null, null -> true']
+ }
+
+ public void "test negating delegation"() {
+ def c = inferContracts("""
+ boolean delegating(Object o) {
+ return !smth(o);
+ }
+ boolean smth(Object o) {
+ return o == null;
+ }
+""")
+ assert c == ['null -> false', '!null -> true']
+ }
+
+ public void "test delegation with constant"() {
+ def c = inferContracts("""
+ boolean delegating(Object o) {
+ return smth(null);
+ }
+ boolean smth(Object o) {
+ return o == null;
+ }
+""")
+ assert c == ['_ -> true']
+ }
+
private String inferContract(String method) {
return assertOneElement(inferContracts(method))
}
diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java
index 67987b3ab8eb..833b5196d74a 100644
--- a/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java
@@ -71,6 +71,9 @@ public class DataFlowInspectionTest extends LightCodeInsightFixtureTestCase {
public void testGeneratedEquals() throws Throwable { doTest(); }
public void testIDEA84489() throws Throwable { doTest(); }
+ public void testComparingNullToNotNull() { doTest(); }
+ public void testComparingNullableToNullable() { doTest(); }
+ public void testComparingNullableToUnknown() { doTest(); }
public void testComparingToNotNullShouldNotAffectNullity() throws Throwable { doTest(); }
public void testComparingToNullableShouldNotAffectNullity() throws Throwable { doTest(); }
public void testStringTernaryAlwaysTrue() throws Throwable { doTest(); }
@@ -235,6 +238,7 @@ public class DataFlowInspectionTest extends LightCodeInsightFixtureTestCase {
public void testManySequentialInstanceofsNotComplex() { doTest(); }
public void testLongDisjunctionsNotComplex() { doTest(); }
public void testWhileNotComplex() { doTest(); }
+ public void testAssertTrueNotComplex() { doTest(); }
public void testManyDisjunctiveFieldAssignmentsInLoopNotComplex() { doTest(); }
public void testManyContinuesNotComplex() { doTest(); }
public void testFinallyNotComplex() { doTest(); }
diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/OfflineIRVTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/OfflineIRVTest.java
new file mode 100644
index 000000000000..a1f81da5773b
--- /dev/null
+++ b/java/java-tests/testSrc/com/intellij/codeInspection/OfflineIRVTest.java
@@ -0,0 +1,194 @@
+/*
+ * Copyright (c) 2000-2007 JetBrains s.r.o. All Rights Reserved.
+ */
+
+/*
+ * User: anna
+ * Date: 14-Jan-2007
+ */
+package com.intellij.codeInspection;
+
+import com.intellij.codeInsight.daemon.HighlightDisplayKey;
+import com.intellij.codeInspection.actions.ViewOfflineResultsAction;
+import com.intellij.codeInspection.defUse.DefUseInspection;
+import com.intellij.codeInspection.defUse.DefUseInspectionBase;
+import com.intellij.codeInspection.ex.InspectionProfileImpl;
+import com.intellij.codeInspection.ex.InspectionToolWrapper;
+import com.intellij.codeInspection.ex.LocalInspectionToolWrapper;
+import com.intellij.codeInspection.ex.ToolsImpl;
+import com.intellij.codeInspection.offline.OfflineProblemDescriptor;
+import com.intellij.codeInspection.offlineViewer.OfflineViewParseUtil;
+import com.intellij.codeInspection.ui.InspectionResultsView;
+import com.intellij.codeInspection.ui.InspectionTree;
+import com.intellij.codeInspection.ui.InspectionTreeNode;
+import com.intellij.openapi.application.ex.PathManagerEx;
+import com.intellij.openapi.util.Comparing;
+import com.intellij.openapi.util.Disposer;
+import com.intellij.openapi.util.io.FileUtil;
+import com.intellij.psi.PsiElement;
+import com.intellij.testFramework.PlatformTestUtil;
+import com.intellij.testFramework.TestSourceBasedTestCase;
+import com.intellij.util.ui.tree.TreeUtil;
+import org.jetbrains.annotations.NotNull;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+public class OfflineIRVTest extends TestSourceBasedTestCase {
+ private InspectionResultsView myView;
+ private LocalInspectionToolWrapper myToolWrapper;
+
+ private static String varMessage(String name) {
+ return InspectionsBundle.message("inspection.unused.assignment.problem.descriptor1", "'"+name+"'");
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ HighlightDisplayKey.register(DefUseInspectionBase.SHORT_NAME);
+ myToolWrapper = new LocalInspectionToolWrapper(new DefUseInspection());
+ myView = ViewOfflineResultsAction.showOfflineView(getProject(), parse(), new InspectionProfileImpl("test") {
+ @Override
+ public boolean isToolEnabled(final HighlightDisplayKey key, PsiElement element) {
+ return Comparing.strEqual(key.toString(), DefUseInspectionBase.SHORT_NAME);
+ }
+
+ @Override
+ @NotNull
+ public InspectionToolWrapper[] getInspectionTools(PsiElement element) {
+ return new InspectionToolWrapper[]{myToolWrapper};
+ }
+
+ @Override
+ @NotNull
+ public ModifiableModel getModifiableModel() {
+ return new InspectionProfileImpl("test") {
+ @Override
+ @NotNull
+ public InspectionToolWrapper[] getInspectionTools(PsiElement element) {
+ return new InspectionToolWrapper[]{myToolWrapper};
+ }
+
+ @Override
+ public boolean isToolEnabled(final HighlightDisplayKey key, PsiElement element) {
+ return Comparing.strEqual(key.toString(), DefUseInspectionBase.SHORT_NAME);
+ }
+ };
+ }
+ }, null);
+ myView.getGlobalInspectionContext().getTools().put(
+ myToolWrapper.getShortName(), new ToolsImpl(myToolWrapper, myToolWrapper.getDefaultLevel(), true));
+ myToolWrapper.initialize(myView.getGlobalInspectionContext());
+ }
+
+ private Map<String, Map<String, Set<OfflineProblemDescriptor>>> parse() throws IOException {
+ final String moduleName = getModule().getName();
+ final Map<String, Map<String, Set<OfflineProblemDescriptor>>> map = new HashMap<String, Map<String, Set<OfflineProblemDescriptor>>>();
+ final File res = new File(PathManagerEx.getTestDataPath(), getTestPath() + File.separator + "res");
+ final File[] files = res.listFiles();
+ assert files != null;
+ for (File file : files) {
+ final String name = file.getName();
+ final String problems = FileUtil.loadFile(file);
+ final Map<String, Set<OfflineProblemDescriptor>> descriptors = OfflineViewParseUtil.parse(problems);
+ for (Set<OfflineProblemDescriptor> problemDescriptors : descriptors.values()) {
+ for (OfflineProblemDescriptor descriptor : problemDescriptors) {
+ descriptor.setModule(moduleName);
+ }
+ }
+ map.put(name.substring(0, name.lastIndexOf('.')), descriptors);
+ }
+ return map;
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ Disposer.dispose(myView);
+ myView = null;
+ myToolWrapper = null;
+ super.tearDown();
+ }
+
+ public void testOfflineView() throws Exception {
+ myView.getGlobalInspectionContext().getUIOptions().SHOW_STRUCTURE = true;
+ InspectionTree tree = updateTree();
+ TreeUtil.expandAll(tree);
+ PlatformTestUtil.assertTreeEqual(tree, "-" + getProject() + "\n"
+ + " -Probable bugs\n"
+ + " -" + myToolWrapper + "\n"
+ + " -" + getModule().toString() + "\n"
+ + " -<default>\n"
+ + " -Test\n"
+ + " -foo()\n"
+ + " " + varMessage("j") + "\n"
+ + " -main(String[])\n"
+ + " " + varMessage("test") + "\n"
+ + " -f()\n"
+ + " -D\n"
+ + " -b()\n"
+ + " " + varMessage("r") + "\n"
+ + " -anonymous (java.lang.Runnable)\n"
+ + " -run()\n"
+ + " " + varMessage("i") + "\n"
+ + " -ff()\n"
+ + " " + varMessage("d") + "\n"
+ + " " + varMessage("a") + "\n");
+ myView.getGlobalInspectionContext().getUIOptions().SHOW_STRUCTURE = false;
+ tree = updateTree();
+ PlatformTestUtil.assertTreeEqual(tree, "-" + getProject() + "\n"
+ + " -Probable bugs\n"
+ + " -" + myToolWrapper + "\n"
+ + " -Test\n"
+ + " " + varMessage("j") + "\n"
+ + " " + varMessage("test") + "\n"
+ + " " + varMessage("r") + "\n"
+ + " " + varMessage("i") + "\n"
+ + " " + varMessage("d") + "\n"
+ + " " + varMessage("a") + "\n");
+ TreeUtil.selectFirstNode(tree);
+ final InspectionTreeNode root = (InspectionTreeNode)tree.getLastSelectedPathComponent();
+ root.ignoreElement();
+ TreeUtil.traverse(root, new TreeUtil.Traverse() {
+ @Override
+ public boolean accept(final Object node) {
+ assertTrue(((InspectionTreeNode)node).isResolved());
+ return true;
+ }
+ });
+ myView.getGlobalInspectionContext().getUIOptions().FILTER_RESOLVED_ITEMS = true;
+ tree = updateTree();
+ PlatformTestUtil.assertTreeEqual(tree, getProject() + "\n");
+ myView.getGlobalInspectionContext().getUIOptions().FILTER_RESOLVED_ITEMS = false;
+ tree = updateTree();
+ PlatformTestUtil.assertTreeEqual(tree, "-" + getProject() + "\n"
+ + " -Probable bugs\n"
+ + " -" + myToolWrapper + "\n"
+ + " -Test\n"
+ + " " + varMessage("j") + "\n"
+ + " " + varMessage("test") + "\n"
+ + " " + varMessage("r") + "\n"
+ + " " + varMessage("i") + "\n"
+ + " " + varMessage("d") + "\n"
+ + " " + varMessage("a") + "\n");
+ }
+
+ private InspectionTree updateTree() {
+ myView.update();
+ final InspectionTree tree = myView.getTree();
+ TreeUtil.expandAll(tree);
+ return tree;
+ }
+
+ @Override
+ protected String getTestPath() {
+ return "inspection/offline";
+ }
+
+ @Override
+ protected String getTestDirectoryName() {
+ return "project";
+ }
+}
diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/RedundantCast15Test.java b/java/java-tests/testSrc/com/intellij/codeInspection/RedundantCast15Test.java
index 4dd29648e055..a8b27ab21089 100644
--- a/java/java-tests/testSrc/com/intellij/codeInspection/RedundantCast15Test.java
+++ b/java/java-tests/testSrc/com/intellij/codeInspection/RedundantCast15Test.java
@@ -49,6 +49,7 @@ public class RedundantCast15Test extends InspectionTestCase {
public void testGetClassProcessing() throws Exception { doTest();}
public void testInstanceOfChecks() throws Exception { doTest();}
public void testForEachValue() throws Exception { doTest();}
+ public void testForEachValueIDEA126166() throws Exception { doTest();}
public void testCaseThrowable() throws Exception { doTest();}
public void testSafeTempVarName() throws Exception { doTest();}
diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/RedundantCast18Test.java b/java/java-tests/testSrc/com/intellij/codeInspection/RedundantCast18Test.java
index 0a0c5396c6c9..6cb52914fe84 100644
--- a/java/java-tests/testSrc/com/intellij/codeInspection/RedundantCast18Test.java
+++ b/java/java-tests/testSrc/com/intellij/codeInspection/RedundantCast18Test.java
@@ -18,7 +18,6 @@ package com.intellij.codeInspection;
import com.intellij.codeInspection.ex.LocalInspectionToolWrapper;
import com.intellij.codeInspection.redundantCast.RedundantCastInspection;
import com.intellij.openapi.projectRoots.Sdk;
-import com.intellij.openapi.projectRoots.impl.JavaSdkImpl;
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.testFramework.IdeaTestUtil;
@@ -33,6 +32,7 @@ public class RedundantCast18Test extends InspectionTestCase {
public void testLambdaContext() throws Exception { doTest(); }
public void testMethodRefContext() throws Exception { doTest(); }
public void testExpectedSupertype() throws Exception { doTest(); }
+ public void testForeachValue() throws Exception { doTest(); }
@Override
protected Sdk getTestProjectSdk() {
diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/SuspiciousCollectionMethodCalls14Test.java b/java/java-tests/testSrc/com/intellij/codeInspection/SuspiciousCollectionMethodCalls14Test.java
new file mode 100644
index 000000000000..2d30216395ac
--- /dev/null
+++ b/java/java-tests/testSrc/com/intellij/codeInspection/SuspiciousCollectionMethodCalls14Test.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2000-2014 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.codeInspection;
+
+import com.intellij.JavaTestUtil;
+import com.intellij.codeInspection.miscGenerics.SuspiciousCollectionsMethodCallsInspection;
+import com.intellij.testFramework.LightProjectDescriptor;
+import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase;
+import org.jetbrains.annotations.NotNull;
+
+public class SuspiciousCollectionMethodCalls14Test extends LightCodeInsightFixtureTestCase {
+ private final SuspiciousCollectionsMethodCallsInspection myTool = new SuspiciousCollectionsMethodCallsInspection();
+
+ @Override
+ protected String getBasePath() {
+ return JavaTestUtil.getRelativeJavaTestDataPath() + "/inspection/suspiciousCalls";
+ }
+
+ private void doTest() throws Exception {
+ myFixture.enableInspections(myTool);
+ myFixture.testHighlighting(getTestName(false) + ".java");
+ }
+
+ public void testRemoveAll14() throws Exception { doTest(); }
+
+ @NotNull
+ @Override
+ protected LightProjectDescriptor getProjectDescriptor() {
+ return JAVA_1_4;
+ }
+}
diff --git a/java/java-tests/testSrc/com/intellij/compiler/notNullVerification/NotNullVerifyingInstrumenterTest.java b/java/java-tests/testSrc/com/intellij/compiler/notNullVerification/NotNullVerifyingInstrumenterTest.java
index ef4b5ea42d8c..498a1172fa9a 100644
--- a/java/java-tests/testSrc/com/intellij/compiler/notNullVerification/NotNullVerifyingInstrumenterTest.java
+++ b/java/java-tests/testSrc/com/intellij/compiler/notNullVerification/NotNullVerifyingInstrumenterTest.java
@@ -27,8 +27,8 @@ import com.intellij.testFramework.fixtures.TestFixtureBuilder;
import com.intellij.util.ArrayUtil;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.Nullable;
-import org.jetbrains.asm4.ClassReader;
-import org.jetbrains.asm4.ClassWriter;
+import org.jetbrains.org.objectweb.asm.ClassReader;
+import org.jetbrains.org.objectweb.asm.ClassWriter;
import java.io.File;
import java.io.IOException;
diff --git a/java/java-tests/testSrc/com/intellij/find/FindManagerTest.java b/java/java-tests/testSrc/com/intellij/find/FindManagerTest.java
index 86d79fb41e10..92caad03d8ef 100644
--- a/java/java-tests/testSrc/com/intellij/find/FindManagerTest.java
+++ b/java/java-tests/testSrc/com/intellij/find/FindManagerTest.java
@@ -53,9 +53,11 @@ import com.intellij.util.ArrayUtil;
import com.intellij.util.CommonProcessors;
import com.intellij.util.ThrowableRunnable;
import com.intellij.util.WaitFor;
+import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import java.io.File;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -284,6 +286,26 @@ public class FindManagerTest extends DaemonAnalyzerTestCase {
assertSize(2, findUsages(findModel));
}
+ public void testFindInOpenedFilesIncludesNoneProjectButOpenedFile() throws IOException {
+ File dir = createTempDirectory();
+ File file = new File(dir.getPath(), "A.test1234");
+ file.createNewFile();
+ FileUtil.writeToFile(file, "foo fo foo");
+ VirtualFile nonProjectFile = VfsUtil.findFileByIoFile(file, true);
+ assertNotNull(nonProjectFile);
+
+ FindModel findModel = new FindModel();
+ findModel.setStringToFind("fo");
+ findModel.setWholeWordsOnly(true);
+ findModel.setFromCursor(false);
+ findModel.setGlobal(true);
+ findModel.setMultipleFiles(true);
+ findModel.setCustomScope(true);
+ findModel.setCustomScope(new GlobalSearchScope.FilesScope(myProject, ContainerUtil.list(nonProjectFile)));
+
+ assertSize(1, findUsages(findModel));
+ }
+
public void testWholeWordsInNonIndexedFiles() throws Exception {
createFile(myModule, "A.test123", "foo fo foo");
diff --git a/java/java-tests/testSrc/com/intellij/navigation/ChooseByNameTest.groovy b/java/java-tests/testSrc/com/intellij/navigation/ChooseByNameTest.groovy
index fad8e4fd94e9..dabe06ba79fa 100644
--- a/java/java-tests/testSrc/com/intellij/navigation/ChooseByNameTest.groovy
+++ b/java/java-tests/testSrc/com/intellij/navigation/ChooseByNameTest.groovy
@@ -1,17 +1,30 @@
+/*
+ * Copyright 2000-2014 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.navigation
-import com.intellij.ide.util.gotoByName.ChooseByNameBase
-import com.intellij.ide.util.gotoByName.ChooseByNameModel
-import com.intellij.ide.util.gotoByName.ChooseByNamePopup
-import com.intellij.ide.util.gotoByName.GotoClassModel2
-import com.intellij.ide.util.gotoByName.GotoFileModel
-import com.intellij.ide.util.gotoByName.GotoSymbolModel2
+import com.intellij.ide.util.gotoByName.*
import com.intellij.openapi.Disposable
import com.intellij.openapi.application.ModalityState
import com.intellij.openapi.util.Disposer
import com.intellij.psi.PsiElement
+import com.intellij.psi.PsiFile
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase
import com.intellij.util.Consumer
import com.intellij.util.concurrency.Semaphore
+import org.jetbrains.annotations.NotNull
+
/**
* @author peter
*/
@@ -135,24 +148,32 @@ class Intf {
}
public void "test goto file can go to dir"() {
- def fooIndex = myFixture.addFileToProject("foo/index.html", "foo")
- def barIndex = myFixture.addFileToProject("bar.txt/bar.txt", "foo")
+ PsiFile fooIndex = myFixture.addFileToProject("foo/index.html", "foo")
+ PsiFile barIndex = myFixture.addFileToProject("bar.txt/bar.txt", "foo")
def popup = createPopup(new GotoFileModel(project), fooIndex)
- assert calcPopupElements(popup, "foo/") == [fooIndex.containingDirectory]
- assert calcPopupElements(popup, "foo\\") == [fooIndex.containingDirectory]
- assert calcPopupElements(popup, "/foo") == [fooIndex.containingDirectory]
- assert calcPopupElements(popup, "\\foo") == [fooIndex.containingDirectory]
+
+ def fooDir
+ def barDir
+ edt {
+ fooDir = fooIndex.containingDirectory
+ barDir = barIndex.containingDirectory
+ }
+
+ assert calcPopupElements(popup, "foo/") == [fooDir]
+ assert calcPopupElements(popup, "foo\\") == [fooDir]
+ assert calcPopupElements(popup, "/foo") == [fooDir]
+ assert calcPopupElements(popup, "\\foo") == [fooDir]
assert calcPopupElements(popup, "foo") == []
assert calcPopupElements(popup, "/index.html") == [fooIndex]
assert calcPopupElements(popup, "\\index.html") == [fooIndex]
assert calcPopupElements(popup, "index.html/") == [fooIndex]
assert calcPopupElements(popup, "index.html\\") == [fooIndex]
- assert calcPopupElements(popup, "bar.txt/") == [barIndex.containingDirectory]
- assert calcPopupElements(popup, "bar.txt\\") == [barIndex.containingDirectory]
- assert calcPopupElements(popup, "/bar.txt") == [barIndex.containingDirectory]
- assert calcPopupElements(popup, "\\bar.txt") == [barIndex.containingDirectory]
+ assert calcPopupElements(popup, "bar.txt/") == [barDir]
+ assert calcPopupElements(popup, "bar.txt\\") == [barDir]
+ assert calcPopupElements(popup, "/bar.txt") == [barDir]
+ assert calcPopupElements(popup, "\\bar.txt") == [barDir]
assert calcPopupElements(popup, "bar.txt") == [barIndex]
popup.close(false)
}
@@ -178,7 +199,10 @@ class Intf {
public void "test super method in jdk"() {
def ourRun = myFixture.addClass("package foo.bar; class Goo implements Runnable { public void run() {} }").methods[0]
- def sdkRun = ourRun.containingClass.interfaces[0].methods[0]
+ def sdkRun
+ edt {
+ sdkRun = ourRun.containingClass.interfaces[0].methods[0]
+ }
assert getPopupElements(new GotoSymbolModel2(project), 'run ', true) == [sdkRun]
assert getPopupElements(new GotoSymbolModel2(project), 'run ', false) == [ourRun]
}
@@ -218,7 +242,7 @@ class Intf {
}
@Override
- protected void invokeTestRunnable(Runnable runnable) throws Exception {
+ protected void invokeTestRunnable(@NotNull Runnable runnable) throws Exception {
runnable.run()
}
}
diff --git a/java/java-tests/testSrc/com/intellij/openapi/editor/impl/FoldingExceptionTest.java b/java/java-tests/testSrc/com/intellij/openapi/editor/impl/FoldingExceptionTest.java
index f40a58b16788..b168bc214014 100644
--- a/java/java-tests/testSrc/com/intellij/openapi/editor/impl/FoldingExceptionTest.java
+++ b/java/java-tests/testSrc/com/intellij/openapi/editor/impl/FoldingExceptionTest.java
@@ -15,11 +15,8 @@
*/
package com.intellij.openapi.editor.impl;
-import com.intellij.codeHighlighting.TextEditorHighlightingPass;
import com.intellij.codeInsight.daemon.impl.CodeFoldingPassFactory;
-import com.intellij.mock.MockProgressIndicator;
import com.intellij.psi.PsiDocumentManager;
-import com.intellij.psi.PsiFile;
import com.intellij.testFramework.EditorTestUtil;
import com.intellij.testFramework.LightCodeInsightTestCase;
@@ -43,14 +40,7 @@ public class FoldingExceptionTest extends LightCodeInsightTestCase {
}
private static void runFoldingPass() {
- PsiDocumentManager psiDocumentManager = PsiDocumentManager.getInstance(getProject());
- psiDocumentManager.commitAllDocuments();
- PsiFile psiFile = psiDocumentManager.getPsiFile(myEditor.getDocument());
- assertNotNull(psiFile);
-
- CodeFoldingPassFactory factory = getProject().getComponent(CodeFoldingPassFactory.class);
- TextEditorHighlightingPass highlightingPass = factory.createHighlightingPass(psiFile, myEditor);
- highlightingPass.collectInformation(new MockProgressIndicator());
- highlightingPass.doApplyInformationToEditor();
+ PsiDocumentManager.getInstance(ourProject).commitAllDocuments();
+ EditorTestUtil.runTextEditorHighlightingPass(myEditor, CodeFoldingPassFactory.class);
}
}
diff --git a/java/java-tests/testSrc/com/intellij/psi/ClsDuplicatesTest.java b/java/java-tests/testSrc/com/intellij/psi/ClsDuplicatesTest.java
deleted file mode 100644
index dd32222cc7a8..000000000000
--- a/java/java-tests/testSrc/com/intellij/psi/ClsDuplicatesTest.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright 2000-2014 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.psi;
-
-import com.intellij.JavaTestUtil;
-import com.intellij.openapi.projectRoots.Sdk;
-import com.intellij.openapi.util.text.StringUtil;
-import com.intellij.psi.search.GlobalSearchScope;
-import com.intellij.testFramework.PsiTestCase;
-import com.intellij.testFramework.SkipSlowTestLocally;
-import com.intellij.usageView.UsageViewLongNameLocation;
-import gnu.trove.THashSet;
-import gnu.trove.TObjectHashingStrategy;
-
-import java.util.Set;
-
-@SkipSlowTestLocally
-public class ClsDuplicatesTest extends PsiTestCase {
- private Set<PsiNamedElement> myUnique = new THashSet<PsiNamedElement>(new TObjectHashingStrategy<PsiNamedElement>() {
- @Override
- public int computeHashCode(PsiNamedElement object) {
- String name = object.getName();
- return name == null ? 0 : name.hashCode();
- }
-
- @Override
- public boolean equals(PsiNamedElement o1, PsiNamedElement o2) {
- return o1.getParent() == o2.getParent() &&
- o1.getClass() == o2.getClass() &&
- StringUtil.equals(o1.getName(), o2.getName()) &&
- StringUtil.equals(o1.getText(), o2.getText());
- }
- });
-
- @Override
- protected void tearDown() throws Exception {
- myUnique = null;
- super.tearDown();
- }
-
- @Override
- protected Sdk getTestProjectJdk() {
- return JavaTestUtil.getTestJdk();
- }
-
- public void testDuplicates() throws Exception {
- final PsiPackage rootPackage = JavaPsiFacade.getInstance(getProject()).findPackage("");
- assert rootPackage != null;
-
- final GlobalSearchScope scope = GlobalSearchScope.allScope(getProject());
- JavaRecursiveElementVisitor visitor = new JavaRecursiveElementVisitor() {
- @Override
- public void visitPackage(PsiPackage aPackage) {
- visit(aPackage);
- for (PsiPackage subPackage : aPackage.getSubPackages(scope)) {
- visitPackage(subPackage);
- }
- for (PsiClass aClass : aPackage.getClasses(scope)) {
- visitClass(aClass);
- }
- }
-
- @Override
- public void visitElement(PsiElement element) {
- if (element instanceof PsiNamedElement) {
- visit((PsiNamedElement)element);
- }
- super.visitElement(element);
- }
-
- @Override
- public void visitClass(PsiClass aClass) {
- super.visitClass(aClass);
- PsiElement parent = aClass.getParent();
- if (parent instanceof PsiFile) {
- myUnique.clear();
- }
- }
- };
-
- rootPackage.accept(visitor);
- }
-
- private void visit(PsiNamedElement element) {
- if (!myUnique.add(element)) {
- String description = ElementDescriptionUtil.getElementDescription(element, UsageViewLongNameLocation.INSTANCE);
- fail("Duplicate Element: " + description + ": " + element.getText());
- }
- }
-}
diff --git a/java/java-tests/testSrc/com/intellij/psi/ClsMirrorBuildingTest.java b/java/java-tests/testSrc/com/intellij/psi/ClsMirrorBuildingTest.java
index b832e65c7675..c88c8c28c102 100644
--- a/java/java-tests/testSrc/com/intellij/psi/ClsMirrorBuildingTest.java
+++ b/java/java-tests/testSrc/com/intellij/psi/ClsMirrorBuildingTest.java
@@ -18,15 +18,18 @@ package com.intellij.psi;
import com.intellij.JavaTestUtil;
import com.intellij.ide.highlighter.JavaFileType;
import com.intellij.openapi.util.text.StringUtil;
-import com.intellij.openapi.vfs.JarFileSystem;
-import com.intellij.openapi.vfs.LocalFileSystem;
+import com.intellij.openapi.vfs.StandardFileSystems;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileSystem;
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
import com.intellij.psi.impl.compiled.ClsFileImpl;
+import com.intellij.psi.impl.compiled.InnerClassSourceStrategy;
+import com.intellij.psi.impl.compiled.StubBuildingVisitor;
+import com.intellij.psi.impl.java.stubs.impl.PsiJavaFileStubImpl;
import com.intellij.testFramework.LightIdeaTestCase;
import com.intellij.testFramework.PlatformTestUtil;
+import org.jetbrains.org.objectweb.asm.ClassReader;
import java.io.IOException;
@@ -75,6 +78,35 @@ public class ClsMirrorBuildingTest extends LightIdeaTestCase {
doTest(clsPath, txtPath);
}
+ public void testStrayInnersFiltering() throws IOException {
+ String path = JavaTestUtil.getJavaTestDataPath() + "/../../mockJDK-1.8/jre/lib/rt.jar!/java/lang/Class.class";
+ VirtualFile file = StandardFileSystems.jar().findFileByPath(path);
+ assertNotNull(path, file);
+
+ InnerClassSourceStrategy<VirtualFile> strategy = new InnerClassSourceStrategy<VirtualFile>() {
+ @Override
+ public VirtualFile findInnerClass(String innerName, VirtualFile outerClass) {
+ String baseName = outerClass.getNameWithoutExtension();
+ VirtualFile child = outerClass.getParent().findChild(baseName + "$" + innerName + ".class");
+ // stray inner classes should be filtered out
+ assert child != null : innerName + " is not an inner class of " + outerClass;
+ return child;
+ }
+
+ @Override
+ public void accept(VirtualFile innerClass, StubBuildingVisitor<VirtualFile> visitor) {
+ try {
+ byte[] bytes = innerClass.contentsToByteArray();
+ new ClassReader(bytes).accept(visitor, ClassReader.SKIP_FRAMES);
+ }
+ catch (IOException ignored) { }
+ }
+ };
+ PsiJavaFileStubImpl stub = new PsiJavaFileStubImpl("do.not.know.yet", true);
+ StubBuildingVisitor<VirtualFile> visitor = new StubBuildingVisitor<VirtualFile>(file, strategy, stub, 0, null);
+ new ClassReader(file.contentsToByteArray()).accept(visitor, ClassReader.SKIP_FRAMES);
+ }
+
private void doTest() {
doTest(getTestName(false));
}
@@ -85,11 +117,9 @@ public class ClsMirrorBuildingTest extends LightIdeaTestCase {
}
private static void doTest(String clsPath, String txtPath) {
- VirtualFileSystem fs = clsPath.contains("!/") ? JarFileSystem.getInstance() : LocalFileSystem.getInstance();
- VirtualFile vFile = fs.findFileByPath(clsPath);
- assertNotNull(clsPath, vFile);
- PsiFile clsFile = getPsiManager().findFile(vFile);
- assertNotNull(vFile.getPath(), clsFile);
+ VirtualFileSystem fs = clsPath.contains("!/") ? StandardFileSystems.jar() : StandardFileSystems.local();
+ VirtualFile file = fs.findFileByPath(clsPath);
+ assertNotNull(clsPath, file);
String expected;
try {
@@ -100,6 +130,6 @@ public class ClsMirrorBuildingTest extends LightIdeaTestCase {
return;
}
- assertEquals(expected, ((ClsFileImpl)clsFile).getMirror().getText());
+ assertEquals(expected, ClsFileImpl.decompile(file).toString());
}
}
diff --git a/java/java-tests/testSrc/com/intellij/psi/ClsRepositoryUseTest.java b/java/java-tests/testSrc/com/intellij/psi/ClsRepositoryUseTest.java
index 16392eb601d5..e8317415d8b3 100644
--- a/java/java-tests/testSrc/com/intellij/psi/ClsRepositoryUseTest.java
+++ b/java/java-tests/testSrc/com/intellij/psi/ClsRepositoryUseTest.java
@@ -690,7 +690,6 @@ public class ClsRepositoryUseTest extends PsiTestCase {
final PsiType returnType = methodsWithReturnType.getReturnType();
assert returnType != null : methodsWithReturnType;
assertEquals("pack.Parametrized<? extends T>", returnType.getCanonicalText());
- assertEquals("public pack.Parametrized<? extends T> method() { /* compiled code */ }", methodsWithReturnType.getText());
}
private static void checkEnumConstant(String name, PsiField field, PsiClassType type) {
@@ -740,19 +739,20 @@ public class ClsRepositoryUseTest extends PsiTestCase {
assertEquals(PsiWildcardType.createUnbounded(myPsiManager), substitution);
}
+ @SuppressWarnings("ConstantConditions")
public void testModifiers() throws Exception {
- final PsiClass psiClass = myJavaFacade.findClass("pack.Modifiers", RESOLVE_SCOPE);
+ PsiClass psiClass = myJavaFacade.findClass("pack.Modifiers", RESOLVE_SCOPE);
assertNotNull(psiClass);
- assertEquals("public class Modifiers {\n" +
- " private transient int f1;\n" +
- " private volatile int f2;\n" +
- "\n" +
- " public Modifiers() { /* compiled code */ }\n" +
- "\n" +
- " private void m1(int... i) { /* compiled code */ }\n" +
- "\n" +
- " private synchronized void m2() { /* compiled code */ }\n" +
- "}",
- psiClass.getText().trim());
+
+ PsiField f1 = psiClass.findFieldByName("f1", false);
+ assertEquals("private transient", f1.getModifierList().getText());
+ PsiField f2 = psiClass.findFieldByName("f2", false);
+ assertEquals("private volatile", f2.getModifierList().getText());
+ PsiMethod init = psiClass.findMethodsByName("Modifiers", false)[0];
+ assertEquals("public", init.getModifierList().getText());
+ PsiMethod m1 = psiClass.findMethodsByName("m1", false)[0];
+ assertEquals("private", m1.getModifierList().getText());
+ PsiMethod m2 = psiClass.findMethodsByName("m2", false)[0];
+ assertEquals("private synchronized", m2.getModifierList().getText());
}
}
diff --git a/java/java-tests/testSrc/com/intellij/psi/MiscPsiTest.java b/java/java-tests/testSrc/com/intellij/psi/MiscPsiTest.java
index 301a99319cbb..096547c4f4db 100644
--- a/java/java-tests/testSrc/com/intellij/psi/MiscPsiTest.java
+++ b/java/java-tests/testSrc/com/intellij/psi/MiscPsiTest.java
@@ -25,10 +25,11 @@ import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.psi.impl.source.tree.LazyParseableElement;
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase;
+import org.jetbrains.annotations.NotNull;
public class MiscPsiTest extends LightCodeInsightFixtureTestCase {
@Override
- protected void invokeTestRunnable(final Runnable runnable) throws Exception {
+ protected void invokeTestRunnable(@NotNull final Runnable runnable) throws Exception {
new WriteCommandAction.Simple(getProject()) {
@Override
protected void run() throws Throwable {
diff --git a/java/java-tests/testSrc/com/intellij/psi/StubAstSwitchTest.groovy b/java/java-tests/testSrc/com/intellij/psi/StubAstSwitchTest.groovy
index c9153983344a..021f7f95c480 100644
--- a/java/java-tests/testSrc/com/intellij/psi/StubAstSwitchTest.groovy
+++ b/java/java-tests/testSrc/com/intellij/psi/StubAstSwitchTest.groovy
@@ -73,7 +73,13 @@ class StubAstSwitchTest extends LightCodeInsightFixtureTestCase {
}
CountDownLatch latch = new CountDownLatch(count)
for (c in classList) {
- ApplicationManager.application.executeOnPooledThread { Thread.yield(); c.text; latch.countDown() }
+ ApplicationManager.application.executeOnPooledThread {
+ Thread.yield();
+ ApplicationManager.application.runReadAction {
+ c.text;
+ }
+ latch.countDown()
+ }
for (m in c.methods) {
def parameters = m.parameterList.parameters
for (i in 0..<parameters.size()) {
diff --git a/java/java-tests/testSrc/com/intellij/psi/codeStyle/arrangement/JavaRearrangerFieldReferenceTest.groovy b/java/java-tests/testSrc/com/intellij/psi/codeStyle/arrangement/JavaRearrangerFieldReferenceTest.groovy
index 302f1b331530..d11a34f6e376 100644
--- a/java/java-tests/testSrc/com/intellij/psi/codeStyle/arrangement/JavaRearrangerFieldReferenceTest.groovy
+++ b/java/java-tests/testSrc/com/intellij/psi/codeStyle/arrangement/JavaRearrangerFieldReferenceTest.groovy
@@ -328,9 +328,61 @@ class Second extends First {
)
}
+ void "test IDEA-123875"() {
+ doTest(
+ initial: '''\
+public class RearrangeFail {
+
+ public static final byte[] ENTITIES_END = "</entities>".getBytes();
+ private final Element entitiesEndElement = new Element(ENTITIES_END);
+ public static final byte[] ENTITIES_START = "<entities>".getBytes();
+ private final Element entitiesStartElement = new Element(ENTITIES_START);
+
+}
+''',
+ expected: '''\
+public class RearrangeFail {
+
+ public static final byte[] ENTITIES_END = "</entities>".getBytes();
+ public static final byte[] ENTITIES_START = "<entities>".getBytes();
+ private final Element entitiesEndElement = new Element(ENTITIES_END);
+ private final Element entitiesStartElement = new Element(ENTITIES_START);
+
+}
+''',
+ rules: [
+ rule(PUBLIC, STATIC, FINAL),
+ rule(PRIVATE),
+ ]
+ )
+ }
+ void "test IDEA-125099"() {
+ doTest(
+ initial: '''\
+public class test {
+ private int a = 2;
+ public static final String TEST = "1";
+ public static final String SHOULD_BE_IN_BETWEEN = "2";
+ public static final String USERS_ROLE_ID_COLUMN = TEST;
+}
+''',
+ expected: '''\
+public class test {
+ public static final String TEST = "1";
+ public static final String SHOULD_BE_IN_BETWEEN = "2";
+ public static final String USERS_ROLE_ID_COLUMN = TEST;
+ private int a = 2;
+}
+''',
+ rules: [
+ rule(PUBLIC, STATIC, FINAL),
+ rule(PRIVATE)
+ ]
+ )
+ }
}
diff --git a/java/java-tests/testSrc/com/intellij/psi/impl/file/impl/PsiEventsTest.java b/java/java-tests/testSrc/com/intellij/psi/impl/file/impl/PsiEventsTest.java
index 8ea8d3a77112..2461a4601eba 100644
--- a/java/java-tests/testSrc/com/intellij/psi/impl/file/impl/PsiEventsTest.java
+++ b/java/java-tests/testSrc/com/intellij/psi/impl/file/impl/PsiEventsTest.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2000-2014 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.psi.impl.file.impl;
@@ -640,4 +655,90 @@ public class PsiEventsTest extends PsiTestCase {
getPsiManager().removePsiTreeChangeListener(listener);
}
}
+
+ public void testPsiEventsComeWhenDocumentAlreadyCommitted() throws Exception {
+ myFile = createFile("A.java", "class A { int i; }");
+ getPsiManager().addPsiTreeChangeListener(new PsiTreeChangeListener() {
+ @Override
+ public void beforeChildAddition(@NotNull PsiTreeChangeEvent event) {
+ // did not decide whether the doc should be committed at this point
+ //checkCommitted(false, event);
+ }
+
+ @Override
+ public void beforeChildRemoval(@NotNull PsiTreeChangeEvent event) {
+ // did not decide whether the doc should be committed at this point
+ //checkCommitted(false, event);
+ }
+
+ @Override
+ public void beforeChildReplacement(@NotNull PsiTreeChangeEvent event) {
+ // did not decide whether the doc should be committed at this point
+ //checkCommitted(false, event);
+ }
+
+ @Override
+ public void beforeChildMovement(@NotNull PsiTreeChangeEvent event) {
+ // did not decide whether the doc should be committed at this point
+ //checkCommitted(false, event);
+ }
+
+ @Override
+ public void beforeChildrenChange(@NotNull PsiTreeChangeEvent event) {
+ // did not decide whether the doc should be committed at this point
+ //checkCommitted(false, event);
+ }
+
+ @Override
+ public void beforePropertyChange(@NotNull PsiTreeChangeEvent event) {
+ // did not decide whether the doc should be committed at this point
+ //checkCommitted(false, event);
+ }
+
+ @Override
+ public void childAdded(@NotNull PsiTreeChangeEvent event) {
+ checkCommitted(true, event);
+ }
+
+ @Override
+ public void childRemoved(@NotNull PsiTreeChangeEvent event) {
+ checkCommitted(true, event);
+ }
+
+ @Override
+ public void childReplaced(@NotNull PsiTreeChangeEvent event) {
+ checkCommitted(true, event);
+ }
+
+ @Override
+ public void childrenChanged(@NotNull PsiTreeChangeEvent event) {
+ checkCommitted(true, event);
+ }
+
+ @Override
+ public void childMoved(@NotNull PsiTreeChangeEvent event) {
+ checkCommitted(true, event);
+ }
+
+ @Override
+ public void propertyChanged(@NotNull PsiTreeChangeEvent event) {
+ checkCommitted(true, event);
+ }
+ }, myTestRootDisposable);
+
+ PsiDocumentManager documentManager = PsiDocumentManager.getInstance(getProject());
+ Document document = documentManager.getDocument(getFile());
+ assertTrue(documentManager.isCommitted(document));
+
+ document.setText("");
+ documentManager.commitAllDocuments();
+ assertTrue(documentManager.isCommitted(document));
+ }
+
+ private void checkCommitted(boolean shouldBeCommitted, PsiTreeChangeEvent event) {
+ PsiFile file = event.getFile();
+ PsiDocumentManager documentManager = PsiDocumentManager.getInstance(file.getProject());
+ Document document = documentManager.getDocument(file);
+ assertEquals(shouldBeCommitted, documentManager.isCommitted(document));
+ }
}
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 5e6adfdb4f55..ce04dd0ba20c 100644
--- a/java/java-tests/testSrc/com/intellij/psi/resolve/ResolveInLibrariesTest.groovy
+++ b/java/java-tests/testSrc/com/intellij/psi/resolve/ResolveInLibrariesTest.groovy
@@ -20,12 +20,12 @@ 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.PsiFile
-import com.intellij.psi.PsiManager
import com.intellij.psi.PsiMethod
+import com.intellij.psi.impl.source.PsiFileImpl
import com.intellij.psi.search.GlobalSearchScope
import com.intellij.psi.search.searches.ClassInheritorsSearch
import com.intellij.psi.search.searches.OverridingMethodsSearch
+import com.intellij.psi.stubs.StubTreeLoader
import com.intellij.testFramework.PsiTestUtil
import com.intellij.testFramework.fixtures.JavaCodeInsightFixtureTestCase
/**
@@ -150,14 +150,12 @@ class ResolveInLibrariesTest extends JavaCodeInsightFixtureTestCase {
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.contentsLoaded
- assert !javaSrc.stub
+ VirtualFile javaSrc = pkgChildren.find { it.name == 'LibraryClass.java' }
+ checkFileIsNotLoadedAndHasNoIndexedStub(javaSrc)
assert pkg.containsClassNamed('LibraryClass')
- assert !javaSrc.contentsLoaded
- assert !javaSrc.stub
- assert !javaSrc.node.parsed
+ checkFileIsNotLoadedAndHasNoIndexedStub(javaSrc)
+ assert !((PsiFileImpl)psiManager.findFile(javaSrc)).treeElement
}
@Override
@@ -174,7 +172,7 @@ class ResolveInLibrariesTest extends JavaCodeInsightFixtureTestCase {
def localFile = myFixture.copyFileToProject(testDataPathForTest + File.separator + "Foo.java", 'Foo.java')
assert localFile != null
- checkFileIsNotLoadedAndHasNoStub(localFile)
+ checkFileIsNotLoadedAndHasNoIndexedStub(localFile)
assert facade.findClasses('Foo', scope).size() == 0
PsiTestUtil.addLibrary(myModule, 'cas', lib.path, [] as String[], ["/classesAndSources.jar!/"] as String[])
@@ -187,14 +185,16 @@ class ResolveInLibrariesTest extends JavaCodeInsightFixtureTestCase {
assert facade.findClasses('LibraryClass', scope).size() == 0
- checkFileIsNotLoadedAndHasNoStub(vfile)
+ checkFileIsNotLoadedAndHasNoIndexedStub(vfile)
}
- private void checkFileIsNotLoadedAndHasNoStub(VirtualFile vfile) {
- def file = PsiManager.getInstance(project).findFile(vfile);
+ private void checkFileIsNotLoadedAndHasNoIndexedStub(VirtualFile vfile) {
+ PsiFileImpl file = psiManager.findFile(vfile);
assert file != null
assert !file.contentsLoaded
- assert !file.stub
+ assert !StubTreeLoader.instance.readFromVFile(project, vfile)
+ assert !StubTreeLoader.instance.canHaveStub(vfile)
+ assert file.stub // from text
}
}
diff --git a/java/java-tests/testSrc/com/intellij/refactoring/MoveMembersTest.java b/java/java-tests/testSrc/com/intellij/refactoring/MoveMembersTest.java
index 83e8fa10aed9..b34486fcf110 100644
--- a/java/java-tests/testSrc/com/intellij/refactoring/MoveMembersTest.java
+++ b/java/java-tests/testSrc/com/intellij/refactoring/MoveMembersTest.java
@@ -187,6 +187,18 @@ public class MoveMembersTest extends MultiFileTestCase {
doTest("Outer.Inner", "Outer", true, VisibilityUtil.ESCALATE_VISIBILITY, 0);
}
+ public void testFromNestedToOuterMethodRef() throws Exception {
+ final LanguageLevelProjectExtension projectExtension = LanguageLevelProjectExtension.getInstance(getProject());
+ final LanguageLevel oldLevel = projectExtension.getLanguageLevel();
+ try {
+ projectExtension.setLanguageLevel(LanguageLevel.HIGHEST);
+ doTest("Outer.Inner", "Outer", true, VisibilityUtil.ESCALATE_VISIBILITY, 0);
+ }
+ finally {
+ projectExtension.setLanguageLevel(oldLevel);
+ }
+ }
+
@NotNull
@Override
protected String getTestRoot() {
diff --git a/java/java-tests/testSrc/com/intellij/refactoring/inline/InlineMethodTest.java b/java/java-tests/testSrc/com/intellij/refactoring/inline/InlineMethodTest.java
index c77b344f6722..99de5eb68dc4 100644
--- a/java/java-tests/testSrc/com/intellij/refactoring/inline/InlineMethodTest.java
+++ b/java/java-tests/testSrc/com/intellij/refactoring/inline/InlineMethodTest.java
@@ -264,6 +264,10 @@ public class InlineMethodTest extends LightRefactoringTestCase {
doTest();
}
+ public void testSameVarMethodNames() throws Exception {
+ doTest();
+ }
+
private void doTestInlineThisOnly() {
@NonNls String fileName = "/refactoring/inlineMethod/" + getTestName(false) + ".java";
configureByFile(fileName);
diff --git a/java/java-tests/testSrc/com/intellij/roots/ModuleScopesTest.java b/java/java-tests/testSrc/com/intellij/roots/ModuleScopesTest.java
index 180a8ee3c66a..514348e5913b 100644
--- a/java/java-tests/testSrc/com/intellij/roots/ModuleScopesTest.java
+++ b/java/java-tests/testSrc/com/intellij/roots/ModuleScopesTest.java
@@ -1,12 +1,29 @@
+/*
+ * Copyright 2000-2014 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.roots;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.StdModuleTypes;
+import com.intellij.openapi.module.impl.ModuleEx;
import com.intellij.openapi.module.impl.scopes.LibraryScope;
import com.intellij.openapi.roots.*;
import com.intellij.openapi.roots.libraries.Library;
import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.testFramework.ModuleTestCase;
import com.intellij.testFramework.PsiTestUtil;
import com.intellij.testFramework.fixtures.impl.LightTempDirTestFixtureImpl;
@@ -207,4 +224,28 @@ public class ModuleScopesTest extends ModuleTestCase {
addLibrary(myModule, DependencyScope.COMPILE);
assertTrue(myModule.getModuleWithDependenciesAndLibrariesScope(false).contains(file));
}
+
+ public void testScopeEquality() {
+ Module module = createModule("a.iml", StdModuleTypes.JAVA);
+ addDependentModule(module, DependencyScope.COMPILE);
+ addLibrary(module, DependencyScope.COMPILE);
+
+ GlobalSearchScope deps = module.getModuleWithDependentsScope();
+ GlobalSearchScope depsTests = module.getModuleTestsWithDependentsScope();
+
+ assertFalse(deps.equals(depsTests));
+ assertFalse(depsTests.equals(deps));
+
+ ((ModuleEx)module).clearScopesCache();
+
+ GlobalSearchScope deps2 = module.getModuleWithDependentsScope();
+ GlobalSearchScope depsTests2 = module.getModuleTestsWithDependentsScope();
+
+ assertFalse(deps2.equals(depsTests2));
+ assertFalse(depsTests2.equals(deps2));
+ assertNotSame(deps, deps2);
+ assertNotSame(depsTests, depsTests2);
+ assertEquals(deps, deps2);
+ assertEquals(depsTests, depsTests2);
+ }
}
diff --git a/java/java-tests/testSrc/com/intellij/slicer/SliceBackwardTest.java b/java/java-tests/testSrc/com/intellij/slicer/SliceBackwardTest.java
index 513fcec9d347..2f6ea959a1a6 100644
--- a/java/java-tests/testSrc/com/intellij/slicer/SliceBackwardTest.java
+++ b/java/java-tests/testSrc/com/intellij/slicer/SliceBackwardTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -179,6 +179,8 @@ public class SliceBackwardTest extends SliceTestCase {
public void testArrayElements() throws Exception { doTest();}
public void testAnonArray() throws Exception { doTest();}
public void testVarArgs() throws Exception { doTest();}
+ public void testVarArgsAsAWhole() throws Exception { doTest();}
+ public void testVarArgsPartial() throws Exception { doTest();}
public void testListTrackToArray() throws Exception { doTest();}
}