summaryrefslogtreecommitdiff
path: root/java/java-tests/testSrc/com
diff options
context:
space:
mode:
Diffstat (limited to 'java/java-tests/testSrc/com')
-rw-r--r--java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartType18CompletionTest.java18
-rw-r--r--java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartTypeCompletionTest.java2
-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/ConstraintsInferenceMiscTest.java6
-rw-r--r--java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/Diamond8HighlightingTest.java4
-rw-r--r--java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/ExceptionVariablesInferenceTest.java4
-rw-r--r--java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/FunctionalExpressionIncompleteHighlightingTest.java2
-rw-r--r--java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/FunctionalTypeWildcardParameterizationTest.java2
-rw-r--r--java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GenericsHighlighting8Test.java16
-rw-r--r--java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GraphInferenceHighlightingTest.java12
-rw-r--r--java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/LambdaHighlightingTest.java2
-rw-r--r--java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/LambdaInferenceTest.java4
-rw-r--r--java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/LambdaParamsTest.java4
-rw-r--r--java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/LambdaRedundantCastTest.java4
-rw-r--r--java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/LightAdvHighlightingJdk8Test.java3
-rw-r--r--java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/MethodRefHighlightingTest.java4
-rw-r--r--java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/MostSpecificResolutionTest.java2
-rw-r--r--java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewLambdaHighlightingTest.java32
-rw-r--r--java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewMethodRefHighlightingTest.java6
-rw-r--r--java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/OverloadResolutionTest.java63
-rw-r--r--java/java-tests/testSrc/com/intellij/codeInsight/folding/JavaFoldingTest.groovy6
-rw-r--r--java/java-tests/testSrc/com/intellij/codeInsight/generation/surroundWith/JavaSurroundWithTest.java14
-rw-r--r--java/java-tests/testSrc/com/intellij/codeInsight/javadoc/JavaDocInfoGeneratorTest.java32
-rw-r--r--java/java-tests/testSrc/com/intellij/codeInsight/template/LiveTemplateTest.groovy44
-rw-r--r--java/java-tests/testSrc/com/intellij/codeInspection/ContractInferenceFromSourceTest.groovy39
-rw-r--r--java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java3
-rw-r--r--java/java-tests/testSrc/com/intellij/codeInspection/bytecodeAnalysis/BytecodeAnalysisIntegrationTest.java34
-rw-r--r--java/java-tests/testSrc/com/intellij/codeInspection/bytecodeAnalysis/BytecodeAnalysisTest.java5
-rw-r--r--java/java-tests/testSrc/com/intellij/execution/configurations/JavaCommandLineTest.java11
-rw-r--r--java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaFormatterWrapTest.java31
-rw-r--r--java/java-tests/testSrc/com/intellij/refactoring/ExtractMethodObject4DebuggerTest.java179
-rw-r--r--java/java-tests/testSrc/com/intellij/refactoring/IntroduceVariableTest.java18
32 files changed, 498 insertions, 111 deletions
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartType18CompletionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartType18CompletionTest.java
index eb3c4c4577b6..68aba5eca978 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartType18CompletionTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartType18CompletionTest.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.
@@ -17,9 +17,6 @@ package com.intellij.codeInsight.completion;
import com.intellij.JavaTestUtil;
import com.intellij.codeInsight.lookup.Lookup;
-import com.intellij.psi.JavaPsiFacade;
-import com.intellij.psi.impl.source.resolve.PsiResolveHelperImpl;
-import com.intellij.psi.impl.source.resolve.graphInference.PsiGraphInferenceHelper;
import com.intellij.testFramework.LightProjectDescriptor;
import org.jetbrains.annotations.NotNull;
@@ -117,16 +114,9 @@ public class SmartType18CompletionTest extends LightFixtureCompletionTestCase {
}
public void testInferFromRawType() throws Exception {
- final PsiResolveHelperImpl helper = (PsiResolveHelperImpl)JavaPsiFacade.getInstance(getProject()).getResolveHelper();
- helper.setTestHelper(new PsiGraphInferenceHelper(getPsiManager()));
- try {
- configureByFile("/" + getTestName(false) + ".java");
- assertNotNull(myItems);
- assertTrue(myItems.length == 0);
- }
- finally {
- helper.setTestHelper(null);
- }
+ configureByFile("/" + getTestName(false) + ".java");
+ assertNotNull(myItems);
+ assertTrue(myItems.length == 0);
}
public void testDiamondsInsideMethodCall() throws Exception {
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartTypeCompletionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartTypeCompletionTest.java
index 967de28820e8..2db5b7fbbfea 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartTypeCompletionTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartTypeCompletionTest.java
@@ -701,6 +701,8 @@ public class SmartTypeCompletionTest extends LightFixtureCompletionTestCase {
doTest();
}
+ public void testNoSemicolonInsideParentheses() { doTest(); }
+
public void testAssignFromTheSameFieldOfAnotherObject() throws Throwable {
doTest();
}
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 09225b64bc1d..ac57a71e9c9f 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java
@@ -372,6 +372,9 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
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); }
public void testIDEA78402() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); }
+ public void testIDEA106985() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); }
+ public void testIDEA114797() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); }
+ public void testCaptureWildcardFromUnboundCaptureWildcard() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); }
public void testSuperCaptureSubstitutionWhenTypeParameterHasUpperBounds() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); }
public void testParameterBoundsWithCapturedWildcard() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); }
//jdk should propagate LL 1.4 but actually it provides LL 1.7?!
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/ConstraintsInferenceMiscTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/ConstraintsInferenceMiscTest.java
index 42433d327e2d..08857080b060 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/ConstraintsInferenceMiscTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/ConstraintsInferenceMiscTest.java
@@ -54,8 +54,12 @@ public class ConstraintsInferenceMiscTest extends LightDaemonAnalyzerTestCase {
doTest(false);
}
+ public void testIntersectionTypeStrictSubtypingConstraint() throws Exception {
+ doTest(false);
+ }
+
private void doTest(final boolean checkWarnings) {
- doTestNewInference(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, false);
+ doTest(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, false);
}
@Override
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/Diamond8HighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/Diamond8HighlightingTest.java
index eb73906a5f15..62c96e148ea1 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/Diamond8HighlightingTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/Diamond8HighlightingTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 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.
@@ -36,7 +36,7 @@ public class Diamond8HighlightingTest extends LightDaemonAnalyzerTestCase {
}
private void doTest() throws Exception {
- doTestNewInference(BASE_PATH + "/" + getTestName(false) + ".java", false, false);
+ doTest(BASE_PATH + "/" + getTestName(false) + ".java", false, false);
}
@Override
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/ExceptionVariablesInferenceTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/ExceptionVariablesInferenceTest.java
index 0384c0f074db..c55c6ae2e775 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/ExceptionVariablesInferenceTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/ExceptionVariablesInferenceTest.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.
@@ -54,6 +54,6 @@ public class ExceptionVariablesInferenceTest extends LightDaemonAnalyzerTestCase
}
private void doTest(final boolean checkWarnings) throws Exception {
- doTestNewInference(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, false);
+ doTest(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, false);
}
}
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/FunctionalExpressionIncompleteHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/FunctionalExpressionIncompleteHighlightingTest.java
index e47f6acc9afc..5e34b963e321 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/FunctionalExpressionIncompleteHighlightingTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/FunctionalExpressionIncompleteHighlightingTest.java
@@ -47,7 +47,7 @@ public class FunctionalExpressionIncompleteHighlightingTest extends LightDaemonA
}
private void doTest(final boolean checkWarnings) {
- doTestNewInference(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, false);
+ doTest(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, false);
}
@Override
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/FunctionalTypeWildcardParameterizationTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/FunctionalTypeWildcardParameterizationTest.java
index 599ae74cd00d..72f709a48697 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/FunctionalTypeWildcardParameterizationTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/FunctionalTypeWildcardParameterizationTest.java
@@ -38,7 +38,7 @@ public class FunctionalTypeWildcardParameterizationTest extends LightDaemonAnaly
private void doTest() {
IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_8, getModule(), getTestRootDisposable());
- doTestNewInference(BASE_PATH + "/" + getTestName(false) + ".java", false, false);
+ doTest(BASE_PATH + "/" + getTestName(false) + ".java", false, false);
}
@Override
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GenericsHighlighting8Test.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GenericsHighlighting8Test.java
index a66d999b283c..a919843a3164 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GenericsHighlighting8Test.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GenericsHighlighting8Test.java
@@ -1,11 +1,11 @@
/*
- * 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.
* You may obtain a copy of the License at
*
- * http:www.apache.org/licenses/LICENSE-2.0
+ * 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,
@@ -24,9 +24,6 @@ import com.intellij.openapi.projectRoots.JavaSdkVersion;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
import com.intellij.pom.java.LanguageLevel;
-import com.intellij.psi.JavaPsiFacade;
-import com.intellij.psi.impl.source.resolve.PsiResolveHelperImpl;
-import com.intellij.psi.impl.source.resolve.graphInference.PsiGraphInferenceHelper;
import com.intellij.testFramework.IdeaTestUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -772,14 +769,7 @@ public class GenericsHighlighting8Test extends LightDaemonAnalyzerTestCase {
private void doTest(boolean warnings) {
LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).setLanguageLevel(LanguageLevel.JDK_1_8);
IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_8, getModule(), myTestRootDisposable);
- final PsiResolveHelperImpl helper = (PsiResolveHelperImpl)JavaPsiFacade.getInstance(getProject()).getResolveHelper();
- helper.setTestHelper(new PsiGraphInferenceHelper(getPsiManager()));
- try {
- doTest(BASE_PATH + "/" + getTestName(false) + ".java", warnings, false);
- }
- finally {
- helper.setTestHelper(null);
- }
+ doTest(BASE_PATH + "/" + getTestName(false) + ".java", warnings, 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 7585d661b289..69afb0db23bb 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
@@ -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.
@@ -236,13 +236,21 @@ public class GraphInferenceHighlightingTest extends LightDaemonAnalyzerTestCase
doTest();
}
+ public void testIncompatibleBoundsFromAssignment() throws Exception {
+ doTest();
+ }
+
+ public void testFreshVariablesCreatedDuringResolveDependingOnAlreadyResolvedVariables() throws Exception {
+ doTest();
+ }
+
private void doTest() throws Exception {
doTest(false);
}
private void doTest(final boolean checkWarnings) throws Exception {
IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_8, getModule(), getTestRootDisposable());
- doTestNewInference(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, false);
+ doTest(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, false);
}
@Override
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 a3a326cfcf81..5ecab96d8926 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
@@ -112,7 +112,7 @@ public class LambdaHighlightingTest extends LightDaemonAnalyzerTestCase {
}
private void doTest(final boolean checkWarnings) {
- doTestNewInference(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, false);
+ doTest(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, false);
}
@Override
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/LambdaInferenceTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/LambdaInferenceTest.java
index 96e60587a225..b13cfbc22e02 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/LambdaInferenceTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/LambdaInferenceTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 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.
@@ -30,6 +30,6 @@ public class LambdaInferenceTest extends LightDaemonAnalyzerTestCase {
}
private void doTest() throws Exception {
- doTestNewInference(BASE_PATH + "/" + getTestName(false) + ".java", false, false);
+ doTest(BASE_PATH + "/" + getTestName(false) + ".java", false, false);
}
}
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/LambdaParamsTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/LambdaParamsTest.java
index 94ca90df2d02..faf1608c1cf0 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/LambdaParamsTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/LambdaParamsTest.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.
@@ -30,6 +30,6 @@ public class LambdaParamsTest extends LightDaemonAnalyzerTestCase {
public void testInferFromFormal() { doTest(); }
private void doTest() {
- doTestNewInference(BASE_PATH + "/" + getTestName(false) + ".java", false, false);
+ doTest(BASE_PATH + "/" + getTestName(false) + ".java", false, false);
}
}
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/LambdaRedundantCastTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/LambdaRedundantCastTest.java
index 36f98aa91cc6..ae5a97933ca8 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/LambdaRedundantCastTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/LambdaRedundantCastTest.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.
@@ -35,6 +35,6 @@ public class LambdaRedundantCastTest extends LightDaemonAnalyzerTestCase {
public void testIntersection() { doTest(); }
public void testSer() { doTest(); }
private void doTest() {
- doTestNewInference(BASE_PATH + "/" + getTestName(false) + ".java", true, false);
+ doTest(BASE_PATH + "/" + getTestName(false) + ".java", true, false);
}
}
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/LightAdvHighlightingJdk8Test.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/LightAdvHighlightingJdk8Test.java
index 630acb0404b7..08a2b63550ff 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/LightAdvHighlightingJdk8Test.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/LightAdvHighlightingJdk8Test.java
@@ -18,7 +18,6 @@ package com.intellij.codeInsight.daemon.lambda;
import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase;
import com.intellij.codeInspection.LocalInspectionTool;
import com.intellij.codeInspection.compiler.JavacQuirksInspection;
-import com.intellij.codeInspection.unusedSymbol.UnusedSymbolLocalInspection;
import com.intellij.openapi.projectRoots.JavaSdkVersion;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.testFramework.IdeaTestUtil;
@@ -42,7 +41,7 @@ public class LightAdvHighlightingJdk8Test extends LightDaemonAnalyzerTestCase {
private void doTest() {
IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_8, getModule(), getTestRootDisposable());
- doTestNewInference(BASE_PATH + "/" + getTestName(false) + ".java", true, false);
+ doTest(BASE_PATH + "/" + getTestName(false) + ".java", true, false);
}
@Override
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 156aac5613c1..d0bed5e9d5df 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
@@ -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.
@@ -116,7 +116,7 @@ public class MethodRefHighlightingTest extends LightDaemonAnalyzerTestCase {
private void doTest(boolean warnings) {
IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_8, getModule(), getTestRootDisposable());
- doTestNewInference(BASE_PATH + "/" + getTestName(false) + ".java", warnings, false);
+ doTest(BASE_PATH + "/" + getTestName(false) + ".java", warnings, false);
}
@Override
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/MostSpecificResolutionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/MostSpecificResolutionTest.java
index 9bb7d4801944..294a3cc8a4f6 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/MostSpecificResolutionTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/MostSpecificResolutionTest.java
@@ -121,7 +121,7 @@ public class MostSpecificResolutionTest extends LightDaemonAnalyzerTestCase {
private void doTest(boolean warnings) {
IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_8, getModule(), getTestRootDisposable());
- doTestNewInference(BASE_PATH + "/" + getTestName(false) + ".java", warnings, false);
+ doTest(BASE_PATH + "/" + getTestName(false) + ".java", warnings, false);
}
@Override
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 1da75f51ba6f..712df26e356f 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
@@ -22,6 +22,8 @@ import com.intellij.idea.Bombed;
import com.intellij.openapi.projectRoots.JavaSdkVersion;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.testFramework.IdeaTestUtil;
+import junit.framework.Test;
+import junit.framework.TestSuite;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -71,21 +73,23 @@ public class NewLambdaHighlightingTest extends LightDaemonAnalyzerTestCase {
public void testIDEA121315() { doTest(); }
public void testIDEA118965comment() { doTest(); }
public void testIDEA122074() { doTest(); }
+ @Bombed(day = 30, month = Calendar.SEPTEMBER)
public void testIDEA122084() { doTest(); }
public void testAdditionalConstraintDependsOnNonMentionedVars() { doTest(); }
public void testIDEA122616() { doTest(); }
public void testIDEA122700() { doTest(); }
public void testIDEA122406() { doTest(); }
- @Bombed(day = 30, month = Calendar.SEPTEMBER)
public void testNestedCallsInsideLambdaReturnExpression() { doTest(); }
@Bombed(day = 30, month = Calendar.SEPTEMBER)
public void testIDEA123731() { doTest(); }
public void testIDEA123869() { doTest(); }
+ @Bombed(day = 30, month = Calendar.SEPTEMBER)
public void testIDEA123848() { doTest(); }
public void testOnlyLambdaAtTypeParameterPlace() { doTest(); }
public void testLiftedIntersectionType() { doTest(); }
public void testInferenceFromReturnStatements() { doTest(); }
public void testDownUpThroughLambdaReturnStatements() { doTest(); }
+ @Bombed(day = 30, month = Calendar.SEPTEMBER)
public void testIDEA124547() { doTest(); }
public void testIDEA118362() { doTest(); }
public void testIDEA126056() { doTest(); }
@@ -94,12 +98,17 @@ public class NewLambdaHighlightingTest extends LightDaemonAnalyzerTestCase {
public void testIDEA126109() { doTest(); }
public void testIDEA126809() { doTest(); }
public void testIDEA124424() { doTest(); }
+ public void testNestedLambdaExpressions1() { doTest(); }
+ public void testNestedLambdaExpressionsNoFormalParams() { doTest(); }
+ @Bombed(day = 30, month = Calendar.SEPTEMBER)
+ public void testNestedLambdaExpressionsNoFormalParams1() { doTest(); }
+ public void testDeepNestedLambdaExpressionsNoFormalParams() { doTest(); }
+ public void testNestedLambdaExpressionsNoFormalParamsStopAtStandalone() { doTest(); }
public void testIDEA127596() throws Exception {
doTest();
}
- @Bombed(day = 30, month = Calendar.SEPTEMBER)
public void testIDEA124983() throws Exception {
doTest();
}
@@ -115,17 +124,34 @@ public class NewLambdaHighlightingTest extends LightDaemonAnalyzerTestCase {
doTest();
}
+ public void testParenthesizedExpressionsDuringConstrainsCollection() throws Exception {
+ doTest();
+ }
+
+ @Bombed(day = 30, month = Calendar.SEPTEMBER)
+ public void testIDEA126778() throws Exception {
+ doTest();
+ }
+
private void doTest() {
doTest(false);
}
private void doTest(boolean warnings) {
IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_8, getModule(), getTestRootDisposable());
- doTestNewInference(BASE_PATH + "/" + getTestName(false) + ".java", warnings, false);
+ doTest(BASE_PATH + "/" + getTestName(false) + ".java", warnings, false);
}
@Override
protected Sdk getProjectJDK() {
return IdeaTestUtil.getMockJdk18();
}
+/*
+ public static Test suite() {
+ final TestSuite suite = new TestSuite();
+ for (int i = 0; i < 100; i++) {
+ suite.addTestSuite(NewLambdaHighlightingTest.class);
+ }
+ return suite;
+ }*/
}
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 c981137d0253..0b8a66fe5b39 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
@@ -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.
@@ -288,7 +288,6 @@ public class NewMethodRefHighlightingTest extends LightDaemonAnalyzerTestCase {
doTest();
}
- @Bombed(day = 30, month = Calendar.SEPTEMBER)
public void testIDEA127275_() throws Exception {
doTest();
}
@@ -305,7 +304,6 @@ public class NewMethodRefHighlightingTest extends LightDaemonAnalyzerTestCase {
doTest();
}
- @Bombed(day = 30, month = Calendar.SEPTEMBER)
public void testAdditionalConstraints3Level() throws Exception {
doTest();
}
@@ -320,7 +318,7 @@ public class NewMethodRefHighlightingTest extends LightDaemonAnalyzerTestCase {
private void doTest(boolean warnings) {
IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_8, getModule(), getTestRootDisposable());
- doTestNewInference(BASE_PATH + "/" + getTestName(false) + ".java", warnings, false);
+ doTest(BASE_PATH + "/" + getTestName(false) + ".java", warnings, false);
}
@Override
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/OverloadResolutionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/OverloadResolutionTest.java
new file mode 100644
index 000000000000..0e5c5a2f3d78
--- /dev/null
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/OverloadResolutionTest.java
@@ -0,0 +1,63 @@
+/*
+ * 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.lambda;
+
+import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase;
+import com.intellij.codeInspection.LocalInspectionTool;
+import com.intellij.codeInspection.unusedSymbol.UnusedSymbolLocalInspection;
+import com.intellij.openapi.projectRoots.JavaSdkVersion;
+import com.intellij.openapi.projectRoots.Sdk;
+import com.intellij.testFramework.IdeaTestUtil;
+import org.jetbrains.annotations.NonNls;
+import org.jetbrains.annotations.NotNull;
+
+public class OverloadResolutionTest extends LightDaemonAnalyzerTestCase {
+ @NonNls static final String BASE_PATH = "/codeInsight/daemonCodeAnalyzer/lambda/overloadResolution";
+
+ @NotNull
+ @Override
+ protected LocalInspectionTool[] configureLocalInspectionTools() {
+ return new LocalInspectionTool[]{
+ new UnusedSymbolLocalInspection(),
+ };
+ }
+
+ public void testPertinentToApplicabilityOfExplicitlyTypedLambda() throws Exception {
+ doTest();
+ }
+
+ public void testVoidValueCompatibilityOfImplicitlyTypedLambda() throws Exception {
+ doTest();
+ }
+
+ public void testIDEA102800() throws Exception {
+ doTest();
+ }
+
+ private void doTest() {
+ doTest(true);
+ }
+
+ private void doTest(boolean warnings) {
+ IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_8, getModule(), getTestRootDisposable());
+ doTest(BASE_PATH + "/" + getTestName(false) + ".java", warnings, false);
+ }
+
+ @Override
+ protected Sdk getProjectJDK() {
+ return IdeaTestUtil.getMockJdk18();
+ }
+}
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 095de51543af..3907b9828888 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/folding/JavaFoldingTest.groovy
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/folding/JavaFoldingTest.groovy
@@ -578,10 +578,14 @@ class Test {
return 0;
}
+ int arrayMethod(int param)[] {
+ return new int[];
+ }
+
}"""
PsiClass fooClass = JavaPsiFacade.getInstance(project).findClass('Foo', GlobalSearchScope.allScope(project))
def regions = myFixture.editor.foldingModel.allFoldRegions.sort { it.startOffset }
- assert regions.size() == 3
+ assert regions.size() == 4
checkAccessorFolding(regions[0], regions[1], fooClass.methods[0])
}
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/generation/surroundWith/JavaSurroundWithTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/generation/surroundWith/JavaSurroundWithTest.java
index 60be917bde7c..8bd53fdabfbf 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/generation/surroundWith/JavaSurroundWithTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/generation/surroundWith/JavaSurroundWithTest.java
@@ -17,6 +17,7 @@ package com.intellij.codeInsight.generation.surroundWith;
import com.intellij.codeInsight.template.impl.TemplateManagerImpl;
import com.intellij.codeInsight.template.impl.TemplateState;
+import com.intellij.ide.highlighter.JavaFileType;
import com.intellij.lang.LanguageSurrounders;
import com.intellij.lang.java.JavaLanguage;
import com.intellij.lang.surroundWith.SurroundDescriptor;
@@ -24,6 +25,7 @@ import com.intellij.lang.surroundWith.Surrounder;
import com.intellij.openapi.editor.SelectionModel;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.PsiElement;
+import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
import com.intellij.testFramework.LightCodeInsightTestCase;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
@@ -156,6 +158,18 @@ public class JavaSurroundWithTest extends LightCodeInsightTestCase {
doTest(getTestName(false), new JavaWithIfElseExpressionSurrounder());
}
+ public void testSurroundWithTryFinallyUsingIndents() {
+ CommonCodeStyleSettings.IndentOptions indentOptions = getCurrentCodeStyleSettings().getIndentOptions(JavaFileType.INSTANCE);
+ boolean oldUseTabs = indentOptions.USE_TAB_CHARACTER;
+ try {
+ indentOptions.USE_TAB_CHARACTER = true;
+ doTest(getTestName(false), new JavaWithTryFinallySurrounder());
+ }
+ finally {
+ indentOptions.USE_TAB_CHARACTER = oldUseTabs;
+ }
+ }
+
private void doTest(@NotNull String fileName, final Surrounder surrounder) {
configureByFile(BASE_PATH + fileName + ".java");
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 8bac921916d3..409ebcc681c1 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/javadoc/JavaDocInfoGeneratorTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/javadoc/JavaDocInfoGeneratorTest.java
@@ -99,11 +99,26 @@ public class JavaDocInfoGeneratorTest extends CodeInsightTestCase {
public void testEnumConstantOrdinal() throws Exception {
PsiClass psiClass = getTestClass();
PsiField field = psiClass.getFields() [0];
- final File htmlPath = new File(JavaTestUtil.getJavaTestDataPath() + "/codeInsight/javadocIG/" + getTestName(true) + ".html");
- String htmlText = FileUtil.loadFile(htmlPath);
- String docInfo = new JavaDocumentationProvider().getQuickNavigateInfo(field, field);
+ String docInfo = new JavaDocumentationProvider().generateDoc(field, field);
assertNotNull(docInfo);
- assertEquals(StringUtil.convertLineSeparators(htmlText.trim()), StringUtil.convertLineSeparators(docInfo.trim()));
+ assertEquals(exampleHtmlFileText(getTestName(true)), StringUtil.convertLineSeparators(docInfo.trim()));
+
+ docInfo = new JavaDocumentationProvider().getQuickNavigateInfo(field, field);
+ assertNotNull(docInfo);
+ assertEquals(exampleHtmlFileText(getTestName(true) + "_quick"), StringUtil.convertLineSeparators(docInfo.trim()));
+ }
+
+ public void testClickableFieldReference() throws Exception {
+ PsiClass aClass = getTestClass();
+ PsiTypeElement element = aClass.getFields()[0].getTypeElement();
+ String docInfo = new JavaDocumentationProvider().generateDoc(element.getInnermostComponentReferenceElement().resolve(), element);
+ assertNotNull(docInfo);
+ assertEquals(exampleHtmlFileText(getTestName(true)), StringUtil.convertLineSeparators(docInfo.trim()));
+ }
+
+ private static String exampleHtmlFileText(String name) throws IOException {
+ final File htmlPath = new File(JavaTestUtil.getJavaTestDataPath() + "/codeInsight/javadocIG/" + name + ".html");
+ return StringUtil.convertLineSeparators(FileUtil.loadFile(htmlPath).trim());
}
public void testClassTypeParamsPresentation() throws Exception {
@@ -111,11 +126,10 @@ public class JavaDocInfoGeneratorTest extends CodeInsightTestCase {
final PsiReferenceList extendsList = psiClass.getExtendsList();
final PsiJavaCodeReferenceElement referenceElement = extendsList.getReferenceElements()[0];
final PsiClass superClass = extendsList.getReferencedTypes()[0].resolve();
- final File htmlPath = new File(JavaTestUtil.getJavaTestDataPath() + "/codeInsight/javadocIG/" + getTestName(true) + ".html");
- String htmlText = FileUtil.loadFile(htmlPath);
+
String docInfo = new JavaDocumentationProvider().getQuickNavigateInfo(superClass, referenceElement);
assertNotNull(docInfo);
- assertEquals(StringUtil.convertLineSeparators(htmlText.trim()), StringUtil.convertLineSeparators(docInfo.trim()));
+ assertEquals(exampleHtmlFileText(getTestName(true)), StringUtil.convertLineSeparators(docInfo.trim()));
}
private void doTestField() throws Exception {
@@ -136,11 +150,9 @@ public class JavaDocInfoGeneratorTest extends CodeInsightTestCase {
}
private void verifyJavaDoc(final PsiElement field) throws IOException {
- final File htmlPath = new File(JavaTestUtil.getJavaTestDataPath() + "/codeInsight/javadocIG/" + getTestName(true) + ".html");
- String htmlText = FileUtil.loadFile(htmlPath);
String docInfo = new JavaDocInfoGenerator(getProject(), field).generateDocInfo(null);
assertNotNull(docInfo);
- assertEquals(StringUtil.convertLineSeparators(htmlText.trim()), StringUtil.convertLineSeparators(docInfo.trim()));
+ assertEquals(exampleHtmlFileText(getTestName(true)), StringUtil.convertLineSeparators(docInfo.trim()));
}
public void testPackageInfo() throws Exception {
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 d866ddd783cf..6abd2e809cdd 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/template/LiveTemplateTest.groovy
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/template/LiveTemplateTest.groovy
@@ -14,16 +14,14 @@
* limitations under the License.
*/
package com.intellij.codeInsight.template
+
import com.intellij.JavaTestUtil
import com.intellij.codeInsight.CodeInsightSettings
import com.intellij.codeInsight.lookup.LookupManager
import com.intellij.codeInsight.lookup.impl.LookupImpl
import com.intellij.codeInsight.lookup.impl.LookupManagerImpl
import com.intellij.codeInsight.template.impl.*
-import com.intellij.codeInsight.template.macro.ClassNameCompleteMacro
-import com.intellij.codeInsight.template.macro.CompleteMacro
-import com.intellij.codeInsight.template.macro.MethodReturnTypeMacro
-import com.intellij.codeInsight.template.macro.SnakeCaseMacro
+import com.intellij.codeInsight.template.macro.*
import com.intellij.openapi.Disposable
import com.intellij.openapi.command.WriteCommandAction
import com.intellij.openapi.editor.Editor
@@ -39,6 +37,7 @@ import com.intellij.util.ui.UIUtil
import org.jetbrains.annotations.NotNull
import static com.intellij.codeInsight.template.Template.Property.USE_STATIC_IMPORT_IF_POSSIBLE
+
/**
* @author spleaner
*/
@@ -462,7 +461,8 @@ class Foo {
@Override
protected void invokeTestRunnable(@NotNull final Runnable runnable) throws Exception {
- if (name in ["testNavigationActionsDontTerminateTemplate", "testTemplateWithEnd", "testDisappearingVar", "test escape string characters in soutv"]) {
+ if (name in ["testNavigationActionsDontTerminateTemplate", "testTemplateWithEnd", "testDisappearingVar",
+ "test escape string characters in soutv", "test do not replace macro value with empty result"]) {
runnable.run();
return;
}
@@ -823,4 +823,38 @@ class Foo {
}
"""
}
+
+ public void "test do not replace macro value with empty result"() {
+ myFixture.configureByText "a.java", """\
+class Foo {
+ {
+ <caret>
+ }
+}
+"""
+ final TemplateManager manager = TemplateManager.getInstance(getProject());
+ final Template template = manager.createTemplate("xxx", "user", '$VAR1$ $VAR2$ $VAR1$');
+ template.addVariable("VAR1", "", "", true)
+ template.addVariable("VAR2", new MacroCallNode(new FileNameMacro()), new ConstantNode("default"), true)
+ ((TemplateImpl)template).templateContext.setEnabled(contextType(JavaCodeContextType.class), true)
+ addTemplate(template, testRootDisposable)
+
+ startTemplate(template);
+ myFixture.checkResult """\
+class Foo {
+ {
+ <caret> a.java
+ }
+}
+"""
+ myFixture.type 'test'
+
+ myFixture.checkResult """\
+class Foo {
+ {
+ test<caret> a.java test
+ }
+}
+"""
+ }
}
diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/ContractInferenceFromSourceTest.groovy b/java/java-tests/testSrc/com/intellij/codeInspection/ContractInferenceFromSourceTest.groovy
index c3bb014d8342..d8b6fb2c53df 100644
--- a/java/java-tests/testSrc/com/intellij/codeInspection/ContractInferenceFromSourceTest.groovy
+++ b/java/java-tests/testSrc/com/intellij/codeInspection/ContractInferenceFromSourceTest.groovy
@@ -161,11 +161,10 @@ class ContractInferenceFromSourceTest extends LightCodeInsightFixtureTestCase {
assert c == ['null -> fail']
}
- void "_test no NotNull duplication"() {
+ void "test no return value NotNull duplication"() {
def c = inferContracts("""
- boolean smth(@org.jetbrains.annotations.NotNull Object o) {
- if (o == null) throw new RuntimeException();
- return o.hashCode() == 1;
+ @org.jetbrains.annotations.NotNull String smth(Object o) {
+ return "abc";
}
""")
assert c == []
@@ -334,29 +333,41 @@ class ContractInferenceFromSourceTest extends LightCodeInsightFixtureTestCase {
assert c == ['null -> null']
}
- public void "test go inside try"() {
+ public void "test use invoked method notnull"() {
def c = inferContracts("""
final Object foo(Object bar) {
- try {
- if (bar == null) return null;
- bar = smth(bar);
- } finally {}
- return new String("abc");
+ if (bar == null) return null;
+ return doo();
}
+
+ @org.jetbrains.annotations.NotNull Object doo() {}
""")
- assert c == ['null -> null']
+ assert c == ['null -> null', '!null -> !null']
}
- public void "test use invoked method notnull"() {
+ public void "test use delegated method notnull"() {
def c = inferContracts("""
final Object foo(Object bar) {
- if (bar == null) return null;
return doo();
}
@org.jetbrains.annotations.NotNull Object doo() {}
""")
- assert c == ['null -> null', '!null -> !null']
+ assert c == ['_ -> !null']
+ }
+
+ public void "test use delegated method notnull with contracts"() {
+ def c = inferContracts("""
+ final Object foo(Object bar, Object o2) {
+ return doo(o2);
+ }
+
+ @org.jetbrains.annotations.NotNull Object doo(Object o) {
+ if (o == null) throw new RuntimeException();
+ return smth();
+ }
+ """)
+ assert c == ['_, null -> fail', '_, _ -> !null']
}
private String inferContract(String method) {
diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java
index a10d02d31fca..0acf071bbf4a 100644
--- a/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java
@@ -113,7 +113,8 @@ public class DataFlowInspectionTest extends LightCodeInsightFixtureTestCase {
public void testReturningNullFromVoidMethod() throws Throwable { doTest(); }
public void testCatchRuntimeException() throws Throwable { doTest(); }
- public void testCatchThrowable() throws Throwable { doTest(); }
+ // IDEA-129331
+ //public void testCatchThrowable() throws Throwable { doTest(); }
public void testNotNullCatchParameter() { doTest(); }
public void testAssertFailInCatch() throws Throwable {
diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/bytecodeAnalysis/BytecodeAnalysisIntegrationTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/bytecodeAnalysis/BytecodeAnalysisIntegrationTest.java
index ab6d92263162..8cde2d7f1bc2 100644
--- a/java/java-tests/testSrc/com/intellij/codeInspection/bytecodeAnalysis/BytecodeAnalysisIntegrationTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInspection/bytecodeAnalysis/BytecodeAnalysisIntegrationTest.java
@@ -133,22 +133,37 @@ public class BytecodeAnalysisIntegrationTest extends JavaCodeInsightFixtureTestC
return;
}
- // not null-result
- String externalOutAnnotation =
- myExternalAnnotationsManager.findExternalAnnotation(method, AnnotationUtil.NOT_NULL) == null ? "null" : "@NotNull";
- String inferredOutAnnotation =
- myInferredAnnotationsManager.findInferredAnnotation(method, AnnotationUtil.NOT_NULL) == null ? "null" : "@NotNull";
String methodKey = PsiFormatUtil.getExternalName(method, false, Integer.MAX_VALUE);
- if (!externalOutAnnotation.equals(inferredOutAnnotation)) {
- diffs.add(methodKey + ": " + externalOutAnnotation + " != " + inferredOutAnnotation);
+ {
+ // @NotNull method
+ String externalNotNullMethodAnnotation =
+ myExternalAnnotationsManager.findExternalAnnotation(method, AnnotationUtil.NOT_NULL) == null ? "null" : "@NotNull";
+ String inferredNotNullMethodAnnotation =
+ myInferredAnnotationsManager.findInferredAnnotation(method, AnnotationUtil.NOT_NULL) == null ? "null" : "@NotNull";
+
+ if (!externalNotNullMethodAnnotation.equals(inferredNotNullMethodAnnotation)) {
+ diffs.add(methodKey + ": " + externalNotNullMethodAnnotation + " != " + inferredNotNullMethodAnnotation);
+ }
+ }
+
+ {
+ // @Nullable method
+ String externalNullableMethodAnnotation =
+ myExternalAnnotationsManager.findExternalAnnotation(method, AnnotationUtil.NULLABLE) == null ? "null" : "@Nullable";
+ String inferredNullableMethodAnnotation =
+ myInferredAnnotationsManager.findInferredAnnotation(method, AnnotationUtil.NULLABLE) == null ? "null" : "@Nullable";
+
+ if (!externalNullableMethodAnnotation.equals(inferredNullableMethodAnnotation)) {
+ diffs.add(methodKey + ": " + externalNullableMethodAnnotation + " != " + inferredNullableMethodAnnotation);
+ }
}
for (PsiParameter parameter : method.getParameterList().getParameters()) {
String parameterKey = PsiFormatUtil.getExternalName(parameter, false, Integer.MAX_VALUE);
{
- // @NotNull
+ // @NotNull parameter
String externalNotNull =
myExternalAnnotationsManager.findExternalAnnotation(parameter, AnnotationUtil.NOT_NULL) == null ? "null" : "@NotNull";
String inferredNotNull =
@@ -159,7 +174,7 @@ public class BytecodeAnalysisIntegrationTest extends JavaCodeInsightFixtureTestC
}
{
- // @Nullable
+ // @Nullable parameter
String externalNullable =
myExternalAnnotationsManager.findExternalAnnotation(parameter, AnnotationUtil.NULLABLE) == null ? "null" : "@Nullable";
String inferredNullable =
@@ -170,6 +185,7 @@ public class BytecodeAnalysisIntegrationTest extends JavaCodeInsightFixtureTestC
}
}
+ // @Contract
PsiAnnotation externalContractAnnotation =
myExternalAnnotationsManager.findExternalAnnotation(method, ORG_JETBRAINS_ANNOTATIONS_CONTRACT);
PsiAnnotation inferredContractAnnotation =
diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/bytecodeAnalysis/BytecodeAnalysisTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/bytecodeAnalysis/BytecodeAnalysisTest.java
index 2cbf3fbdfd6c..abae78e2a8e5 100644
--- a/java/java-tests/testSrc/com/intellij/codeInspection/bytecodeAnalysis/BytecodeAnalysisTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInspection/bytecodeAnalysis/BytecodeAnalysisTest.java
@@ -184,14 +184,13 @@ public class BytecodeAnalysisTest extends JavaCodeInsightFixtureTestCase {
}
private void checkCompoundId(Method method, PsiMethod psiMethod, boolean noKey) throws IOException {
- Direction direction = new Out();
System.out.println();
System.out.println(method.internalClassName);
System.out.println(method.methodName);
System.out.println(method.methodDesc);
- HKey psiKey = BytecodeAnalysisConverter.psiKey(psiMethod, direction, myMessageDigest);
+ HKey psiKey = BytecodeAnalysisConverter.psiKey(psiMethod, Direction.Out, myMessageDigest);
if (noKey) {
assertTrue(null == psiKey);
return;
@@ -199,7 +198,7 @@ public class BytecodeAnalysisTest extends JavaCodeInsightFixtureTestCase {
else {
assertFalse(null == psiKey);
}
- HKey asmKey = BytecodeAnalysisConverter.asmKey(new Key(method, direction, true), myMessageDigest);
+ HKey asmKey = BytecodeAnalysisConverter.asmKey(new Key(method, Direction.Out, true), myMessageDigest);
Assert.assertEquals(asmKey, psiKey);
}
diff --git a/java/java-tests/testSrc/com/intellij/execution/configurations/JavaCommandLineTest.java b/java/java-tests/testSrc/com/intellij/execution/configurations/JavaCommandLineTest.java
index 2708ac91181c..e4d0bc039c5d 100644
--- a/java/java-tests/testSrc/com/intellij/execution/configurations/JavaCommandLineTest.java
+++ b/java/java-tests/testSrc/com/intellij/execution/configurations/JavaCommandLineTest.java
@@ -48,6 +48,14 @@ public class JavaCommandLineTest extends LightIdeaTestCase {
}
}
+ public void testJarParameter() throws CantRunException {
+ JavaParameters javaParameters = new JavaParameters();
+ javaParameters.setJdk(getProjectJDK());
+ javaParameters.setJarPath("my-jar-file.jar");
+ String commandLineString = CommandLineBuilder.createFromJavaParameters(javaParameters).getCommandLineString();
+ assertTrue(commandLineString, commandLineString.contains("-jar my-jar-file.jar"));
+ }
+
public void testClasspath() throws CantRunException {
JavaParameters javaParameters;
String commandLineString;
@@ -55,12 +63,14 @@ public class JavaCommandLineTest extends LightIdeaTestCase {
javaParameters = new JavaParameters();
final Sdk internalJdk = JavaAwareProjectJdkTableImpl.getInstanceEx().getInternalJdk();
javaParameters.setJdk(internalJdk);
+ javaParameters.getClassPath().add("my-jar-file.jar");
javaParameters.setMainClass("Main");
commandLineString = CommandLineBuilder.createFromJavaParameters(javaParameters).getCommandLineString();
assertTrue(containsClassPath(commandLineString));
javaParameters = new JavaParameters();
javaParameters.setJdk(internalJdk);
+ javaParameters.getClassPath().add("my-jar-file.jar");
javaParameters.setMainClass("Main");
javaParameters.getVMParametersList().add("-cp");
javaParameters.getVMParametersList().add("..");
@@ -70,6 +80,7 @@ public class JavaCommandLineTest extends LightIdeaTestCase {
javaParameters = new JavaParameters();
javaParameters.setJdk(internalJdk);
+ javaParameters.getClassPath().add("my-jar-file.jar");
javaParameters.setMainClass("Main");
javaParameters.getVMParametersList().add("-classpath");
javaParameters.getVMParametersList().add("..");
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 c06370b06743..b16e23e83e37 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
@@ -16,7 +16,6 @@
package com.intellij.psi.formatter.java;
import com.intellij.idea.Bombed;
-import com.intellij.lang.java.JavaLanguage;
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
@@ -448,4 +447,34 @@ public class JavaFormatterWrapTest extends AbstractJavaFormatterTest {
" public @TA String m();\n" +
"}");
}
+
+ public void testKeepSingleFieldAnnotationOnSameLine() {
+ getJavaSettings().DO_NOT_WRAP_AFTER_SINGLE_ANNOTATION = true;
+ doClassTest(
+ "@NotNull public String result = \"OK\"\n" +
+ "@NotNull String newResult = \"OK\"\n" +
+ "@NotNull\n" +
+ "@Deprecated public String bad = \"bad\"",
+
+ "@NotNull public String result = \"OK\"\n" +
+ "@NotNull String newResult = \"OK\"\n" +
+ "@NotNull\n" +
+ "@Deprecated\n" +
+ "public String bad = \"bad\""
+ );
+ }
+
+ public void testMoveSingleAnnotationOnSameLine() {
+ getJavaSettings().DO_NOT_WRAP_AFTER_SINGLE_ANNOTATION = true;
+ getSettings().KEEP_LINE_BREAKS = false;
+ doClassTest(
+ "@NotNull\n" +
+ "public String test = \"tst\";\n" +
+ "String ok = \"ok\";\n",
+ "@NotNull public String test = \"tst\";\n" +
+ "String ok = \"ok\";\n"
+ );
+ }
+
+
}
diff --git a/java/java-tests/testSrc/com/intellij/refactoring/ExtractMethodObject4DebuggerTest.java b/java/java-tests/testSrc/com/intellij/refactoring/ExtractMethodObject4DebuggerTest.java
new file mode 100644
index 000000000000..9321cf9a6695
--- /dev/null
+++ b/java/java-tests/testSrc/com/intellij/refactoring/ExtractMethodObject4DebuggerTest.java
@@ -0,0 +1,179 @@
+/*
+ * 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.
+ */
+
+/*
+ * User: anna
+ * Date: 06-May-2008
+ */
+package com.intellij.refactoring;
+
+import com.intellij.JavaTestUtil;
+import com.intellij.idea.Bombed;
+import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.projectRoots.Sdk;
+import com.intellij.psi.*;
+import com.intellij.refactoring.extractMethodObject.ExtractLightMethodObjectHandler;
+import com.intellij.testFramework.IdeaTestUtil;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.Calendar;
+
+public class ExtractMethodObject4DebuggerTest extends LightRefactoringTestCase {
+ @NotNull
+ @Override
+ protected String getTestDataPath() {
+ return JavaTestUtil.getJavaTestDataPath();
+ }
+
+ private void doTest(String evaluatedText, String expectedCallSite, String expectedClass) throws Exception {
+ final String testName = getTestName(false);
+ configureByFile("/refactoring/extractMethodObject4Debugger/" + testName + ".java");
+ final int offset = getEditor().getCaretModel().getOffset();
+ final PsiElement context = getFile().findElementAt(offset);
+ final JavaCodeFragment fragment = JavaCodeFragmentFactory.getInstance(getProject()).createCodeBlockCodeFragment(evaluatedText, context, false);
+ final ExtractLightMethodObjectHandler.ExtractedData extractedData =
+ ExtractLightMethodObjectHandler.extractLightMethodObject(getProject(), getFile(), fragment, "test");
+ assertNotNull(extractedData);
+ assertEquals(expectedCallSite, extractedData.getGeneratedCallText());
+ final PsiClass innerClass = extractedData.getGeneratedInnerClass();
+ assertEquals(expectedClass, innerClass.getText());
+ }
+
+ public void testSimpleGeneration() throws Exception {
+ doTest("int i = 0; int j = 0;", "Test test = new Test().invoke();int i = test.getI();int j = test.getJ();",
+
+ "public class Test {\n" +
+ " private int i;\n" +
+ " private int j;\n" +
+ "\n" +
+ " public int getI() {\n" +
+ " return i;\n" +
+ " }\n" +
+ "\n" +
+ " public int getJ() {\n" +
+ " return j;\n" +
+ " }\n" +
+ "\n" +
+ " public Test invoke() {\n" +
+ " i = 0;\n" +
+ " j = 0;\n" +
+ " return this;\n" +
+ " }\n" +
+ " }");
+ }
+
+ public void testInvokeReturnType() throws Exception {
+ doTest("x = 6; y = 6;", "Test test = new Test().invoke();x = test.getX();y = test.getY();",
+
+ "public static class Test {\n" +
+ " private int x;\n" +
+ " private int y;\n" +
+ "\n" +
+ " public int getX() {\n" +
+ " return x;\n" +
+ " }\n" +
+ "\n" +
+ " public int getY() {\n" +
+ " return y;\n" +
+ " }\n" +
+ "\n" +
+ " public Test invoke() {\n" +
+ " x = 6;\n" +
+ " y = 6;\n" +
+ " return this;\n" +
+ " }\n" +
+ " }");
+ }
+
+ public void testAnonymousClassParams() throws Exception {
+ doTest("new I() {public void foo(int i) {i++;}};", "I result = new Test().invoke();",
+
+ "public class Test {\n" +
+ " public I invoke() {\n" +
+ " return new I() {\n" +
+ " public void foo(int i) {\n" +
+ " i++;\n" +
+ " }\n" +
+ " };\n" +
+ " }\n" +
+ " }");
+ }
+
+ public void testInnerClass() throws Exception {
+ doTest(" new I(2).foo()", "new Test().invoke();",
+
+ "public class Test {\n" +
+ " public void invoke() {\n" +
+ " new Sample.I(2).foo();\n" +
+ " }\n" +
+ " }");
+ }
+
+ public void testResultExpr() throws Exception {
+ doTest(" foo()", "int result = new Test().invoke();",
+
+ "public class Test {\n" +
+ " public int invoke() {\n" +
+ " return foo();\n" +
+ " }\n" +
+ " }");
+ }
+
+ public void testResultStatements() throws Exception {
+ doTest("int i = 0;\nfoo()", "Test test = new Test().invoke();int i = test.getI();int result = test.getResult();",
+
+ "public class Test {\n" +
+ " private int i;\n" +
+ " private int result;\n" +
+ "\n" +
+ " public int getI() {\n" +
+ " return i;\n" +
+ " }\n" +
+ "\n" +
+ " public int getResult() {\n" +
+ " return result;\n" +
+ " }\n" +
+ "\n" +
+ " public Test invoke() {\n" +
+ " i = 0;\n" +
+ " result = foo();\n" +
+ " return this;\n" +
+ " }\n" +
+ " }");
+ }
+
+
+ public void testOffsetsAtCallSite() throws Exception {
+ doTest("map.entrySet().stream().filter((a) -> (a.getKey()>0));",
+ "java.util.stream.Stream<Map.Entry<Integer,Integer>> result = new Test(map).invoke();",
+ "public class Test {\n" +
+ " private Map<Integer, Integer> map;\n" +
+ "\n" +
+ " public Test(Map<Integer, Integer> map) {\n" +
+ " this.map = map;\n" +
+ " }\n" +
+ "\n" +
+ " public Stream<Map.Entry<Integer, Integer>> invoke() {\n" +
+ " return map.entrySet().stream().filter((a) -> (a.getKey() > 0));\n" +
+ " }\n" +
+ " }");
+ }
+
+ @Override
+ protected Sdk getProjectJDK() {
+ return IdeaTestUtil.getMockJdk18();
+ }
+}
diff --git a/java/java-tests/testSrc/com/intellij/refactoring/IntroduceVariableTest.java b/java/java-tests/testSrc/com/intellij/refactoring/IntroduceVariableTest.java
index 34745372977e..6ef80d01903e 100644
--- a/java/java-tests/testSrc/com/intellij/refactoring/IntroduceVariableTest.java
+++ b/java/java-tests/testSrc/com/intellij/refactoring/IntroduceVariableTest.java
@@ -18,9 +18,10 @@ package com.intellij.refactoring;
import com.intellij.JavaTestUtil;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
-import com.intellij.psi.*;
-import com.intellij.psi.impl.source.resolve.PsiResolveHelperImpl;
-import com.intellij.psi.impl.source.resolve.graphInference.PsiGraphInferenceHelper;
+import com.intellij.psi.CommonClassNames;
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiExpression;
+import com.intellij.psi.PsiType;
import com.intellij.refactoring.introduce.inplace.OccurrencesChooser;
import com.intellij.refactoring.introduceVariable.InputValidator;
import com.intellij.refactoring.introduceVariable.IntroduceVariableBase;
@@ -95,15 +96,8 @@ public class IntroduceVariableTest extends LightCodeInsightTestCase {
}
public void testExpectedType8Inference() {
- final PsiResolveHelperImpl helper = (PsiResolveHelperImpl)JavaPsiFacade.getInstance(getProject()).getResolveHelper();
- helper.setTestHelper(new PsiGraphInferenceHelper(getPsiManager()));
- try {
- doTest(new MockIntroduceVariableHandler("temp", true, false, false,
- "java.util.Map<java.lang.String,java.util.List<java.lang.String>>"));
- }
- finally {
- helper.setTestHelper(null);
- }
+ doTest(new MockIntroduceVariableHandler("temp", true, false, false,
+ "java.util.Map<java.lang.String,java.util.List<java.lang.String>>"));
}
public void testMethodCall() {