diff options
Diffstat (limited to 'java/java-tests/testSrc/com/intellij')
75 files changed, 1014 insertions, 358 deletions
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/GlobalMemberNameCompletionTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/completion/GlobalMemberNameCompletionTest.groovy index 1fc4145095c2..c70c166a19b0 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/GlobalMemberNameCompletionTest.groovy +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/GlobalMemberNameCompletionTest.groovy @@ -197,6 +197,44 @@ class A { ''' } + public void "test static import before an identifier"() { + myFixture.addClass ''' +package test.t1; + +public enum DemoEnum +{ + XXONE, + TWO +}''' + doTest """ +import test.t1.DemoEnum; + +public class Demo { + + public static void doStuff(DemoEnum enumValue, String value) {} + public static void main(String[] args) + { + String val = "anyValue"; + doStuff(XXON<caret>val); + } +} +""", true, """ +import test.t1.DemoEnum; + +import static test.t1.DemoEnum.XXONE; + +public class Demo { + + public static void doStuff(DemoEnum enumValue, String value) {} + public static void main(String[] args) + { + String val = "anyValue"; + doStuff(XXONE<caret>val); + } +} +""" + } + private void doTest(String input, boolean importStatic, String output) { myFixture.configureByText("a.java", input) diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/HippieCompletionTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/completion/HippieCompletionTest.groovy new file mode 100644 index 000000000000..d8a49bfd7cae --- /dev/null +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/HippieCompletionTest.groovy @@ -0,0 +1,36 @@ +/* + * Copyright 2000-2013 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.codeInsight.completion + +import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase +/** + * @author peter + */ +class HippieCompletionTest extends LightCodeInsightFixtureTestCase { + + public void testDollars() { + myFixture.configureByText "a.txt", ''' +$some_long_variable_name = Obj::instance(); +$some_lon<caret> +''' + myFixture.performEditorAction("HippieCompletion") + myFixture.checkResult ''' +$some_long_variable_name = Obj::instance(); +$some_long_variable_name<caret> +''' + } + +} 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 904e83c41fe9..bc2a12897497 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaAutoPopupTest.groovy +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaAutoPopupTest.groovy @@ -60,14 +60,14 @@ class JavaAutoPopupTest extends CompletionAutoPopupTestCase { } """) type('i') - assertContains("if", "iterable", "int") + assertContains("iterable", "if", "int") type('t') assertContains "iterable" assertEquals 'iterable', lookup.currentItem.lookupString type('er') - assertContains("iter", "iterable") + assertContains "iterable", "iter" assertEquals 'iterable', lookup.currentItem.lookupString assert lookup.focused @@ -76,7 +76,7 @@ class JavaAutoPopupTest extends CompletionAutoPopupTestCase { } def assertContains(String... items) { - assert myFixture.lookupElementStrings.containsAll(items as List) + myFixture.assertPreferredCompletionItems(0, items) } public void testRecalculateItemsOnBackspace() { @@ -89,7 +89,7 @@ class JavaAutoPopupTest extends CompletionAutoPopupTestCase { } """) type "r" - assertContains "iter", "iterable" + assertContains "iterable", "iter" type '\b' assertContains "iterable" @@ -104,7 +104,7 @@ class JavaAutoPopupTest extends CompletionAutoPopupTestCase { assertContains "iterable" type "r" - assertContains "iter", "iterable" + assertContains "iterable", "iter" } public void testExplicitSelectionShouldSurvive() { @@ -124,8 +124,7 @@ class JavaAutoPopupTest extends CompletionAutoPopupTestCase { assertEquals 'iterable2', lookup.currentItem.lookupString type "r" - assertContains "iter", "iterable", 'iterable2' - assertEquals 'iterable2', lookup.currentItem.lookupString + myFixture.assertPreferredCompletionItems 2, "iterable", "iter", 'iterable2' } @@ -146,8 +145,7 @@ class JavaAutoPopupTest extends CompletionAutoPopupTestCase { assertEquals 'iterable2', lookup.currentItem.lookupString type "r" - assertContains "iter", "iterable", 'iterable2' - assertEquals 'iterable2', lookup.currentItem.lookupString + myFixture.assertPreferredCompletionItems 2, "iterable", "iter", 'iterable2' } @@ -554,7 +552,7 @@ public interface Test { """) type('i') def offset = myFixture.editor.caretModel.offset - assertContains "if", "iterable", "int" + assertContains "iterable", "if", "int" edt { myFixture.performEditorAction(IdeActions.ACTION_EDITOR_MOVE_CARET_RIGHT) } assert myFixture.editor.caretModel.offset == offset + 1 @@ -569,7 +567,7 @@ public interface Test { joinAutopopup() joinCompletion() assert !lookup.calculating - assertContains "if", "iterable", "int" + assertContains "iterable", "if", "int" assertEquals 'iterable', lookup.currentItem.lookupString edt { myFixture.performEditorAction(IdeActions.ACTION_EDITOR_MOVE_CARET_LEFT) } @@ -656,26 +654,6 @@ public interface Test { } } - public void testTemplateSelectionByComma() { - myFixture.configureByText("a.java", """ -class Foo { - int itea = 2; - int itera = 2; - - { - it<caret> - } -} -""") - type 'e' - assertContains "itea", "itera" - type 'r' - assertContains "iter", "itera" - type ',' - assert !lookup - assert myFixture.editor.document.text.contains('itera,') - } - public void testTemplateSelectionBySpace() { myFixture.configureByText("a.java", """ class Foo { @@ -959,7 +937,7 @@ class Foo { } type('_') - assertContains 'x__foo', 'x__goo' + myFixture.assertPreferredCompletionItems 1, 'x__foo', 'x__goo' edt { assert goo == TargetElementUtil.instance.findTargetElement(myFixture.editor, TargetElementUtil.LOOKUP_ITEM_ACCEPTED) myFixture.performEditorAction(IdeActions.ACTION_EDITOR_MOVE_CARET_UP) @@ -1076,14 +1054,6 @@ public class UTest { return editor } - public void _testCharSelectionUndo() { - myFixture.configureByText "a.java", "class Foo {{ <caret> }}" - def editor = openEditorForUndo(); - type('ArrStoExce.') - edt { UndoManager.getInstance(project).undo(editor) } - assert myFixture.editor.document.text.contains('ArrStoExce.') - } - public void testAutopopupTypingUndo() { myFixture.configureByText "a.java", "class Foo {{ <caret> }}" def editor = openEditorForUndo(); @@ -1288,7 +1258,14 @@ class Foo { } @Override + protected void setUp() { + super.setUp() + CodeInsightSettings.instance.SELECT_AUTOPOPUP_SUGGESTIONS_BY_CHARS = true + } + + @Override protected void tearDown() { + CodeInsightSettings.instance.SELECT_AUTOPOPUP_SUGGESTIONS_BY_CHARS = false CodeInsightSettings.instance.COMPLETION_CASE_SENSITIVE = CodeInsightSettings.FIRST_LETTER super.tearDown() } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavadocCompletionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavadocCompletionTest.java index 1f16310242b1..3c17cc882e85 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavadocCompletionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavadocCompletionTest.java @@ -74,7 +74,7 @@ public class JavadocCompletionTest extends LightFixtureCompletionTestCase { public void testSee0() throws Exception { configureByFile("See0.java"); - assertStringItems("foo", "clone", "equals", "getClass", "hashCode", "notify", "notifyAll", "Object", "toString", "wait", "wait", "wait", "finalize", "registerNatives"); + myFixture.assertPreferredCompletionItems(0, "foo", "clone", "equals", "hashCode"); } public void testSee1() throws Exception { @@ -198,6 +198,12 @@ public class JavadocCompletionTest extends LightFixtureCompletionTestCase { assertTrue(getLookupElementStrings().containsAll(Arrays.asList("io", "lang", "util"))); } + public void testQualifyClassReferenceInPackageStatement() throws Exception { + configureByFile(getTestName(false) + ".java"); + myFixture.type('\n'); + checkResultByFile(getTestName(false) + "_after.java"); + } + public void testCustomReferenceProvider() throws Exception { PsiReferenceRegistrarImpl registrar = (PsiReferenceRegistrarImpl) ReferenceProvidersRegistry.getInstance().getRegistrar(StdLanguages.JAVA); diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/KeywordCompletionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/completion/KeywordCompletionTest.java index c50a4b5de7cc..55b27122e5f8 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/KeywordCompletionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/KeywordCompletionTest.java @@ -109,11 +109,13 @@ public class KeywordCompletionTest extends LightCompletionTestCase { public void testReturnInTernary() throws Exception { doTest(1, "return"); } public void testFinalAfterParameterAnno() throws Exception { doTest(2, "final", "float", "class"); } public void testFinalAfterParameterAnno2() throws Exception { doTest(2, "final", "float", "class"); } + public void testFinalAfterCase() throws Exception { doTest(3, "final", "float", "class"); } public void testFinalInTryWithResources() throws Exception { doTest(1, "final", "float", "class"); } public void testClassInMethod() throws Exception { doTest(2, "class", "char"); } public void testIntInClassArray() throws Throwable { doTest(2, "int", "char", "final"); } public void testIntInClassArray2() throws Throwable { doTest(2, "int", "char", "final"); } public void testIntInClassArray3() throws Throwable { doTest(2, "int", "char", "final"); } + public void testArrayClass() throws Throwable { doTest(1, "class", "interface"); } public void testIntInGenerics() throws Throwable { doTest(2, "int", "char", "final"); } public void testIntInGenerics2() throws Throwable { doTest(2, "int", "char", "final"); } 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 81466459ec26..6b5607b47cc1 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionOrderingTest.groovy +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionOrderingTest.groovy @@ -195,7 +195,7 @@ public class NormalCompletionOrderingTest extends CompletionSortingTestCase { public void testDeclaredMembersGoFirst() throws Exception { invokeCompletion(getTestName(false) + ".java"); - assertStringItems("fromThis", "overridden", "fromSuper", "equals", "getClass", "hashCode", "notify", "notifyAll", "toString", "wait", + assertStringItems("fromThis", "overridden", "fromSuper", "equals", "hashCode", "toString", "getClass", "notify", "notifyAll", "wait", "wait", "wait"); } @@ -314,6 +314,11 @@ public class NormalCompletionOrderingTest extends CompletionSortingTestCase { } } + public void testAlphaSortingStartMatchesFirst() { + UISettings.getInstance().SORT_LOOKUP_ELEMENTS_LEXICOGRAPHICALLY = true + checkPreferredItems 0, 'xxbar', 'xxfoo', 'xxgoo', 'barxx', 'fooxx', 'gooxx' + } + public void testSortSameNamedVariantsByProximity() { myFixture.addClass("public class Bar {}"); for (int i = 0; i < 10; i++) { @@ -465,7 +470,7 @@ import java.lang.annotation.Target; repeatCompletion 'b' myFixture.completeBasic(); - assertPreferredItems(0, '_boo2', '_foo2', 'return', '_boo1', '_foo1', '_goo1', '_goo2') + assertPreferredItems(0, 'return', '_boo2', '_foo2', '_boo1', '_foo1', '_goo1', '_goo2') myFixture.type('_'); assertPreferredItems(0, '_boo2', '_foo2', '_boo1', '_foo1', '_goo1', '_goo2') myFixture.type('g') @@ -544,4 +549,11 @@ import java.lang.annotation.Target; checkPreferredItems(0, 'vx') } + public void testLocalVarsOverStats() { + CodeInsightSettings.getInstance().COMPLETION_CASE_SENSITIVE = CodeInsightSettings.NONE; + checkPreferredItems 0, 'psiElement', 'PsiElement' + incUseCount lookup, 1 + assertPreferredItems 0, 'psiElement', 'PsiElement' + } + } 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 880e7b175c7a..0c7e3f1ce4bf 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy @@ -85,6 +85,20 @@ public class NormalCompletionTest extends LightFixtureCompletionTestCase { public void testSimpleVariable() throws Exception { doTest('\n') } + public void testTypeParameterItemPresentation() { + configure() + LookupElementPresentation presentation = renderElement(myItems[0]) + assert "Param" == presentation.itemText + assert presentation.tailText == " (type parameter of Foo)" + assert !presentation.typeText + assert !presentation.icon + assert !presentation.itemTextBold + + presentation = renderElement(myItems[1]) + assert "Param2" == presentation.itemText + assert presentation.tailText == " (type parameter of goo)" + } + public void testMethodItemPresentation() { configure() LookupElementPresentation presentation = renderElement(myItems[0]) @@ -839,7 +853,7 @@ public class ListUtils { final String path = getTestName(false) + ".java"; configureByFile(path); checkResultByFile(path); - assertStringItems("fai1", "fai2"); + assertStringItems("fai1", "fai2", "FunctionalInterface"); } public void testProtectedInaccessibleOnSecondInvocation() throws Throwable { @@ -1302,5 +1316,20 @@ class XInternalError {} assert lookup.items.size() == 1 } + public void testImplementViaCompletion() { + configure() + myFixture.assertPreferredCompletionItems 0, 'private', 'protected', 'public', 'public void run' + def item = lookup.items[3] + + def p = LookupElementPresentation.renderElement(item) + assert p.itemText == 'public void run' + assert p.tailText == '(s, myInt) {...}' + assert p.typeText == 'Foo' + + lookup.currentItem = item + myFixture.type('\n') + checkResult() + } + } 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 06beba331d5c..f8ea1ba949bc 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartType18CompletionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartType18CompletionTest.java @@ -17,7 +17,6 @@ package com.intellij.codeInsight.completion; import com.intellij.JavaTestUtil; import com.intellij.codeInsight.lookup.Lookup; -import com.intellij.codeInsight.lookup.LookupElementPresentation; import com.intellij.testFramework.LightProjectDescriptor; import org.jetbrains.annotations.NotNull; @@ -63,6 +62,10 @@ public class SmartType18CompletionTest extends LightFixtureCompletionTestCase { doTest(); } + public void testIgnoreDefaultMethods() { + doTest(); + } + private void doTest() { configureByFile("/" + getTestName(false) + ".java"); assertNotNull(myItems); diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartTypeCompletionOrderingTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartTypeCompletionOrderingTest.groovy index b14a645bc5ae..fa418ec9c5fb 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartTypeCompletionOrderingTest.groovy +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartTypeCompletionOrderingTest.groovy @@ -95,7 +95,7 @@ public class SmartTypeCompletionOrderingTest extends CompletionSortingTestCase { } public void testDontPreferKeywords() throws Throwable { - checkPreferredItems(0, "o1", "foo", "name", "this", "getClass"); + checkPreferredItems(0, "o1", "foo", "name", "this"); } public void testEnumValueOf() throws Throwable { @@ -129,11 +129,11 @@ public class SmartTypeCompletionOrderingTest extends CompletionSortingTestCase { } public void testSmartEquals2() throws Throwable { - checkPreferredItems(0, "foo", "this", "o", "s", "getClass"); + checkPreferredItems(0, "foo", "this", "o", "s"); } public void testSmartEquals3() throws Throwable { - checkPreferredItems(0, "b", "this", "a", "z", "getClass"); + checkPreferredItems(0, "b", "this", "a", "z"); } public void testSmartCollectionsNew() throws Throwable { @@ -222,7 +222,7 @@ public class SmartTypeCompletionOrderingTest extends CompletionSortingTestCase { } public void testFactoryMethodForDefaultType() throws Throwable { - checkPreferredItems(0, "create", "this", "getClass"); + checkPreferredItems(0, "create", "this"); } public void testLocalVarsBeforeClassLiterals() throws Throwable { 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 7741a09efe0a..a8fc06a8faad 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartTypeCompletionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartTypeCompletionTest.java @@ -348,6 +348,7 @@ public class SmartTypeCompletionTest extends LightFixtureCompletionTestCase { String path = "/generics"; configureByFile(path + "/before9.java"); + selectItem(myItems[1]); checkResultByFile(path + "/after9.java"); } @@ -421,7 +422,7 @@ public class SmartTypeCompletionTest extends LightFixtureCompletionTestCase { public void testArrayAccessIndex() throws Throwable { doTest(); } - public void testThrowExceptionConstructor() throws Throwable { doTest(); } + public void testThrowExceptionConstructor() throws Throwable { doTest('\n'); } public void testJavadocThrows() throws Throwable { doTest(); } @@ -470,7 +471,7 @@ public class SmartTypeCompletionTest extends LightFixtureCompletionTestCase { public void testVoidExpectedType() throws Throwable { configureByTestName(); - assertStringItems("notify", "notifyAll", "wait", "wait", "wait", "getClass", "equals", "hashCode", "toString"); + assertStringItems("notify", "notifyAll", "wait", "wait", "wait", "equals", "hashCode", "toString", "getClass"); type("eq"); assertEquals("equals", assertOneElement(getLookup().getItems()).getLookupString()); select(); @@ -594,16 +595,18 @@ public class SmartTypeCompletionTest extends LightFixtureCompletionTestCase { public void testNewVararg() throws Throwable { configureByTestName(); - assertStringItems("Foo", "Foo"); + assertStringItems("Foo", "Foo", "Foo"); assertEquals("{...} (default package)", LookupElementPresentation.renderElement(myItems[0]).getTailText()); assertEquals("[] (default package)", LookupElementPresentation.renderElement(myItems[1]).getTailText()); + assertEquals("[]{...} (default package)", LookupElementPresentation.renderElement(myItems[2]).getTailText()); } public void testNewVararg2() throws Throwable { configureByTestName(); - assertStringItems("String", "String"); + assertStringItems("String", "String", "String"); assertEquals(" (java.lang)", LookupElementPresentation.renderElement(myItems[0]).getTailText()); assertEquals("[] (java.lang)", LookupElementPresentation.renderElement(myItems[1]).getTailText()); + assertEquals("[]{...} (java.lang)", LookupElementPresentation.renderElement(myItems[2]).getTailText()); } public void testNewByteArray() { diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/AdvHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/AdvHighlightingTest.java index a5cdf9d20882..076773a62e34 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/AdvHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/AdvHighlightingTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,7 +27,6 @@ import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.openapi.module.Module; import com.intellij.openapi.module.ModuleManager; import com.intellij.openapi.projectRoots.Sdk; -import com.intellij.openapi.projectRoots.impl.JavaSdkImpl; import com.intellij.openapi.roots.LanguageLevelProjectExtension; import com.intellij.openapi.roots.ModuleRootModificationUtil; import com.intellij.openapi.vfs.LocalFileSystem; @@ -50,8 +49,8 @@ import java.io.File; import java.util.Collection; /** - * This class intended for "heavily-loaded" tests only, e.g. those need to setup separate project directory structure to run - * For "lightweight" tests use LightAdvHighlightingTest + * This class intended for "heavily-loaded" tests only, e.g. those need to setup separate project directory structure to run. + * For "lightweight" tests use LightAdvHighlightingTest. */ public class AdvHighlightingTest extends DaemonAnalyzerTestCase { @NonNls private static final String BASE_PATH = "/codeInsight/daemonCodeAnalyzer/advHighlighting"; @@ -158,7 +157,7 @@ public class AdvHighlightingTest extends DaemonAnalyzerTestCase { doTest(BASE_PATH + "/alreadyImportedClass/pack/AlreadyImportedClass.java", BASE_PATH + "/alreadyImportedClass", false, false); } - public void testImportDefaultPackage() throws Exception { + public void testImportDefaultPackage1() throws Exception { doTest(BASE_PATH + "/importDefaultPackage/x/Usage.java", BASE_PATH + "/importDefaultPackage", false, false); } @@ -166,6 +165,10 @@ public class AdvHighlightingTest extends DaemonAnalyzerTestCase { doTest(BASE_PATH + "/importDefaultPackage/x/ImportOnDemandUsage.java", BASE_PATH + "/importDefaultPackage", false, false); } + public void testImportDefaultPackage3() throws Exception { + doTest(BASE_PATH + "/importDefaultPackage/Test.java", BASE_PATH + "/importDefaultPackage", false, false); + } + public void testImportDefaultPackageInvalid() throws Exception { doTest(BASE_PATH + "/importDefaultPackage/x/InvalidUse.java", BASE_PATH + "/importDefaultPackage", false, false); } @@ -232,15 +235,16 @@ public class AdvHighlightingTest extends DaemonAnalyzerTestCase { public void testMultiJDKConflict() throws Exception { String path = PathManagerEx.getTestDataPath() + BASE_PATH + "/" + getTestName(true); VirtualFile root = LocalFileSystem.getInstance().findFileByIoFile(new File(path)); + assert root != null : path; loadAllModulesUnder(root); + ModuleManager moduleManager = ModuleManager.getInstance(getProject()); - final Module java4 = moduleManager.findModuleByName("java4"); + Module java4 = moduleManager.findModuleByName("java4"); Module java5 = moduleManager.findModuleByName("java5"); ModuleRootModificationUtil.setModuleSdk(java4, IdeaTestUtil.getMockJdk17("java 1.4")); ModuleRootModificationUtil.setModuleSdk(java5, IdeaTestUtil.getMockJdk17("java 1.5")); ModuleRootModificationUtil.addDependency(java5, java4); - assert root != null; configureByExistingFile(root.findFileByRelativePath("moduleJava5/com/Java5.java")); Collection<HighlightInfo> infos = highlightErrors(); assertEmpty(infos); @@ -249,9 +253,9 @@ public class AdvHighlightingTest extends DaemonAnalyzerTestCase { public void testSameFQNClasses() throws Exception { String path = PathManagerEx.getTestDataPath() + BASE_PATH + "/" + getTestName(true); VirtualFile root = LocalFileSystem.getInstance().findFileByIoFile(new File(path)); + assert root != null : path; loadAllModulesUnder(root); - assert root != null; configureByExistingFile(root.findFileByRelativePath("client/src/BugTest.java")); Collection<HighlightInfo> infos = highlightErrors(); assertEmpty(infos); @@ -260,9 +264,9 @@ public class AdvHighlightingTest extends DaemonAnalyzerTestCase { public void testSameClassesInSourceAndLib() throws Exception { String path = PathManagerEx.getTestDataPath() + BASE_PATH + "/" + getTestName(true); VirtualFile root = LocalFileSystem.getInstance().findFileByIoFile(new File(path)); + assert root != null : path; loadAllModulesUnder(root); - assert root != null; configureByExistingFile(root.findFileByRelativePath("src/ppp/SomeClass.java")); PsiField field = ((PsiJavaFile)myFile).getClasses()[0].findFieldByName("f", false); assert field != null; @@ -270,8 +274,8 @@ public class AdvHighlightingTest extends DaemonAnalyzerTestCase { assert aClass != null; assertEquals("ppp.BadClass", aClass.getQualifiedName()); //lies in source - final VirtualFile vFile1 = myFile.getVirtualFile(); - final VirtualFile vFile2 = aClass.getContainingFile().getVirtualFile(); + VirtualFile vFile1 = myFile.getVirtualFile(); + VirtualFile vFile2 = aClass.getContainingFile().getVirtualFile(); assert vFile1 != null; assert vFile2 != null; assertEquals(vFile1.getParent(), vFile2.getParent()); @@ -281,4 +285,28 @@ public class AdvHighlightingTest extends DaemonAnalyzerTestCase { LanguageLevelProjectExtension.getInstance(myProject).setLanguageLevel(LanguageLevel.JDK_1_4); doTest(BASE_PATH + "/notAKeywords/Test.java", BASE_PATH + "/notAKeywords", false, false); } + + public void testPackageAndClassConflict11() throws Exception { + doTest(BASE_PATH + "/packageClassClash1/pkg/sub/Test.java", BASE_PATH + "/packageClassClash1", false, false); + } + + public void testPackageAndClassConflict12() throws Exception { + doTest(BASE_PATH + "/packageClassClash1/pkg/sub.java", BASE_PATH + "/packageClassClash1", false, false); + } + + public void testPackageAndClassConflict21() throws Exception { + doTest(BASE_PATH + "/packageClassClash2/pkg/sub/Test.java", BASE_PATH + "/packageClassClash2", false, false); + } + + public void testPackageAndClassConflict22() throws Exception { + doTest(BASE_PATH + "/packageClassClash2/pkg/Sub.java", BASE_PATH + "/packageClassClash2", false, false); + } + + public void testDefaultPackageAndClassConflict() throws Exception { + doTest(BASE_PATH + "/lang.java", false, false); + } + + public void testPackageObscuring() throws Exception { + doTest(BASE_PATH + "/packageObscuring/main/Main.java", BASE_PATH + "/packageObscuring", false, false); + } } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/AmbiguousMethodCallTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/AmbiguousMethodCallTest.java index c716dbfab8c4..dfb7db246247 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/AmbiguousMethodCallTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/AmbiguousMethodCallTest.java @@ -22,6 +22,7 @@ import com.intellij.codeInspection.redundantCast.RedundantCastInspection; import com.intellij.codeInspection.uncheckedWarnings.UncheckedWarningLocalInspection; import com.intellij.codeInspection.unusedSymbol.UnusedSymbolLocalInspection; import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; /** * This class is for "lightweight" tests only, i.e. those which can run inside default light project set up @@ -40,6 +41,7 @@ public class AmbiguousMethodCallTest extends LightDaemonAnalyzerTestCase { doTest(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, checkWeakWarnings, checkInfos); } + @NotNull @Override protected LocalInspectionTool[] configureLocalInspectionTools() { return new LocalInspectionTool[]{ 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 b1b0fcb3b5b0..678bb665de9e 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java @@ -29,10 +29,12 @@ import com.intellij.psi.PsiClass; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.testFramework.IdeaTestUtil; import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase { @NonNls private static final String BASE_PATH = "/codeInsight/daemonCodeAnalyzer/genericsHighlighting"; + @NotNull @Override protected LocalInspectionTool[] configureLocalInspectionTools() { return new LocalInspectionTool[]{new UncheckedWarningLocalInspection(), new UnusedSymbolLocalInspection(), new UnusedImportLocalInspection()}; @@ -199,6 +201,9 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase { public void testIDEA67597() { doTest5(false); } public void testIDEA57539() { doTest5(false); } public void testIDEA67570() { doTest5(false); } + public void testIDEA99061() { doTest5(false); } + public void testIDEA99347() { doTest5(false); } + public void testIDEA86875() { doTest5(false); } public void testJavaUtilCollections_NoVerify() throws Exception { PsiClass collectionsClass = getJavaFacade().findClass("java.util.Collections", GlobalSearchScope.moduleWithLibrariesScope(getModule())); diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/JavadocHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/JavadocHighlightingTest.java index 1c63f947f882..0c561dfdace5 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/JavadocHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/JavadocHighlightingTest.java @@ -18,6 +18,7 @@ public class JavadocHighlightingTest extends LightDaemonAnalyzerTestCase { return JavaTestUtil.getJavaTestDataPath(); } + @NotNull @Override protected LocalInspectionTool[] configureLocalInspectionTools() { return new LocalInspectionTool[]{ diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingJdk6Test.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingJdk6Test.java new file mode 100644 index 000000000000..02de38b62f5e --- /dev/null +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingJdk6Test.java @@ -0,0 +1,61 @@ +/* + * Copyright 2000-2013 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.codeInsight.daemon; + +import com.intellij.codeInspection.LocalInspectionTool; +import com.intellij.codeInspection.compiler.JavacQuirksInspection; +import com.intellij.codeInspection.redundantCast.RedundantCastInspection; +import com.intellij.codeInspection.uncheckedWarnings.UncheckedWarningLocalInspection; +import com.intellij.codeInspection.unusedSymbol.UnusedSymbolLocalInspection; +import com.intellij.openapi.projectRoots.JavaSdkVersion; +import com.intellij.openapi.projectRoots.JavaVersionService; +import com.intellij.openapi.projectRoots.JavaVersionServiceImpl; +import com.intellij.pom.java.LanguageLevel; +import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; + +/** + * This class is for "lightweight" tests only, i.e. those which can run inside default light project set up + * For "heavyweight" tests use AdvHighlightingTest + */ +public class LightAdvHighlightingJdk6Test extends LightDaemonAnalyzerTestCase { + @NonNls static final String BASE_PATH = "/codeInsight/daemonCodeAnalyzer/advHighlighting6"; + + private void doTest(boolean checkWarnings, boolean checkInfos, Class<?>... classes) { + setLanguageLevel(LanguageLevel.JDK_1_6); + ((JavaVersionServiceImpl)JavaVersionService.getInstance()).setTestVersion(JavaSdkVersion.JDK_1_6, myTestRootDisposable); + enableInspectionTools(classes); + doTest(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, checkInfos); + } + + private void doTest(boolean checkWarnings, boolean checkWeakWarnings, boolean checkInfos, Class<?>... classes) { + enableInspectionTools(classes); + doTest(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, checkWeakWarnings, checkInfos); + } + + @NotNull + @Override + protected LocalInspectionTool[] configureLocalInspectionTools() { + return new LocalInspectionTool[]{ + new UnusedSymbolLocalInspection(), + new UncheckedWarningLocalInspection(), + new JavacQuirksInspection(), + new RedundantCastInspection() + }; + } + + public void testJavacQuirks() throws Exception { setLanguageLevel(LanguageLevel.JDK_1_6); doTest(true, false); } +} diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingJdk7Test.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingJdk7Test.java index 9b72a23757f7..53710582edd5 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingJdk7Test.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingJdk7Test.java @@ -21,7 +21,6 @@ import com.intellij.codeInspection.LocalInspectionTool; import com.intellij.codeInspection.compiler.JavacQuirksInspection; import com.intellij.codeInspection.deadCode.UnusedDeclarationInspection; import com.intellij.codeInspection.defUse.DefUseInspection; -import com.intellij.codeInspection.deprecation.DeprecatedDefenderSyntaxInspection; import com.intellij.codeInspection.redundantCast.RedundantCastInspection; import com.intellij.codeInspection.reference.EntryPoint; import com.intellij.codeInspection.reference.RefElement; @@ -30,6 +29,9 @@ import com.intellij.codeInspection.unusedSymbol.UnusedSymbolLocalInspection; import com.intellij.lang.annotation.HighlightSeverity; import com.intellij.openapi.extensions.ExtensionPoint; import com.intellij.openapi.extensions.Extensions; +import com.intellij.openapi.projectRoots.JavaSdkVersion; +import com.intellij.openapi.projectRoots.JavaVersionService; +import com.intellij.openapi.projectRoots.JavaVersionServiceImpl; import com.intellij.pom.java.LanguageLevel; import com.intellij.psi.PsiElement; import org.jdom.Element; @@ -46,6 +48,8 @@ public class LightAdvHighlightingJdk7Test extends LightDaemonAnalyzerTestCase { @NonNls static final String BASE_PATH = "/codeInsight/daemonCodeAnalyzer/advHighlighting7"; private void doTest(boolean checkWarnings, boolean checkInfos, Class<?>... classes) { + setLanguageLevel(LanguageLevel.JDK_1_7); + ((JavaVersionServiceImpl)JavaVersionService.getInstance()).setTestVersion(JavaSdkVersion.JDK_1_7, myTestRootDisposable); enableInspectionTools(classes); doTest(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, checkInfos); } @@ -55,6 +59,7 @@ public class LightAdvHighlightingJdk7Test extends LightDaemonAnalyzerTestCase { doTest(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, checkWeakWarnings, checkInfos); } + @NotNull @Override protected LocalInspectionTool[] configureLocalInspectionTools() { return new LocalInspectionTool[]{ @@ -93,7 +98,7 @@ public class LightAdvHighlightingJdk7Test extends LightDaemonAnalyzerTestCase { public void testDiamondNeg12() throws Exception { doTest(false, false); } public void testDiamondNeg13() throws Exception { doTest(false, false); } public void testDiamondNeg14() throws Exception { doTest(false, false); } - public void testDiamondMisc() throws Exception { setLanguageLevel(LanguageLevel.JDK_1_7); doTest(false, false); } + public void testDiamondMisc() throws Exception { doTest(false, false); } public void testHighlightInaccessibleFromClassModifierList() throws Exception { doTest(false, false); } public void testInnerInTypeArguments() throws Exception { doTest(false, false); } @@ -129,7 +134,6 @@ public class LightAdvHighlightingJdk7Test extends LightDaemonAnalyzerTestCase { } } - public void testJavacQuirks() throws Exception { setLanguageLevel(LanguageLevel.JDK_1_6); doTest(true, false); } public void testNumericLiterals() throws Exception { doTest(false, false); } public void testMultiCatch() throws Exception { doTest(false, false); } public void testTryWithResources() throws Exception { doTest(false, false); } @@ -146,8 +150,6 @@ public class LightAdvHighlightingJdk7Test extends LightDaemonAnalyzerTestCase { public void testExtendsBound() throws Exception { doTest(false, false); } public void testIDEA84533() throws Exception { doTest(false, false); } public void testClassLiteral() throws Exception { doTest(false, false); } - public void testExtensionMethods() throws Exception { doTest(false, false); } - public void testExtensionMethodSyntax() throws Exception { doTest(true, false, DeprecatedDefenderSyntaxInspection.class); } public void testMethodReferences() throws Exception { doTest(false, true, false); } public void testUsedMethodsByMethodReferences() throws Exception { doTest(true, true, false); } public void testLambdaExpressions() throws Exception { doTest(false, true, false); } @@ -157,9 +159,11 @@ public class LightAdvHighlightingJdk7Test extends LightDaemonAnalyzerTestCase { public void testUncheckedWarningIDEA70620() throws Exception { doTest(true, false); } public void testUncheckedWarningIDEA60166() throws Exception { doTest(true, false); } public void testUncheckedWarningIDEA21432() throws Exception { doTest(true, false); } + public void testUncheckedWarningIDEA99357() throws Exception { doTest(true, false); } public void testUncheckedWarningIDEA26738() throws Exception { doTest(true, false); } - public void testDefaultMethodVisibility() throws Exception { doTest(true, false); } + public void testUncheckedWarningIDEA99536() throws Exception { doTest(true, false); } public void testEnclosingInstance() throws Exception { doTest(false, false); } public void testWrongArgsAndUnknownTypeParams() throws Exception { doTest(false, false); } public void testAmbiguousMethodCallIDEA97983() throws Exception { doTest(false, false); } + public void testAmbiguousMethodCallIDEA100314() throws Exception { doTest(false, false); } } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingTest.java index 99b1ebcd6de2..3f4c1500c9fd 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingTest.java @@ -73,6 +73,7 @@ public class LightAdvHighlightingTest extends LightDaemonAnalyzerTestCase { setLanguageLevel(LanguageLevel.JDK_1_4); } + @NotNull @Override protected LocalInspectionTool[] configureLocalInspectionTools() { return new LocalInspectionTool[]{ @@ -360,4 +361,5 @@ public class LightAdvHighlightingTest extends LightDaemonAnalyzerTestCase { public void testThisBeforeSuper() throws Exception { doTest(false, false); } public void testExplicitConstructorInvocation() throws Exception { doTest(false, false); } public void testThisInInterface() throws Exception { doTest(false, false); } + public void testInnerClassConstantReference() throws Exception { doTest(false, false); } } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LossyEncodingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LossyEncodingTest.java index bac292138b6b..072726efe7fe 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LossyEncodingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LossyEncodingTest.java @@ -35,6 +35,7 @@ import com.intellij.openapi.vfs.encoding.EncodingManager; import com.intellij.openapi.vfs.encoding.EncodingProjectManager; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; import java.nio.charset.Charset; import java.util.Collection; @@ -43,6 +44,7 @@ import java.util.List; public class LossyEncodingTest extends LightDaemonAnalyzerTestCase { @NonNls private static final String BASE_PATH = "/codeInsight/daemonCodeAnalyzer/lossyEncoding"; + @NotNull @Override protected LocalInspectionTool[] configureLocalInspectionTools() { return new LocalInspectionTool[]{new LossyEncodingInspection()}; @@ -50,7 +52,9 @@ public class LossyEncodingTest extends LightDaemonAnalyzerTestCase { public void testText() throws Exception { doTest("Text.txt"); - EncodingManager.getInstance().setEncoding(myVFile, Charset.forName("US-ASCII")); + Charset ascii = CharsetToolkit.forName("US-ASCII"); + EncodingManager.getInstance().setEncoding(myVFile, ascii); + assertEquals(ascii, myVFile.getCharset()); int start = myEditor.getCaretModel().getOffset(); type((char)0x445); type((char)0x438); diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/SuppressWarningsTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/SuppressWarningsTest.java index 4bdee1a1897e..6e68611e77ff 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/SuppressWarningsTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/SuppressWarningsTest.java @@ -23,6 +23,7 @@ package com.intellij.codeInsight.daemon; import com.intellij.codeInspection.LocalInspectionTool; import com.intellij.codeInspection.unusedSymbol.UnusedSymbolLocalInspection; import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; public class SuppressWarningsTest extends LightDaemonAnalyzerTestCase { @NonNls private static final String BASE_PATH = "/codeInsight/daemonCodeAnalyzer/advHighlighting"; @@ -31,6 +32,7 @@ public class SuppressWarningsTest extends LightDaemonAnalyzerTestCase { doTest(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, false); } + @NotNull @Override protected LocalInspectionTool[] configureLocalInspectionTools() { return new LocalInspectionTool[]{new UnusedSymbolLocalInspection()}; 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 new file mode 100644 index 000000000000..762814e6049c --- /dev/null +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GraphInferenceHighlightingTest.java @@ -0,0 +1,59 @@ +/* + * Copyright 2000-2013 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.codeInsight.daemon.lambda; + +import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase; +import com.intellij.openapi.projectRoots.JavaSdkVersion; +import com.intellij.openapi.projectRoots.JavaVersionService; +import com.intellij.openapi.projectRoots.JavaVersionServiceImpl; +import org.jetbrains.annotations.NonNls; + +public class GraphInferenceHighlightingTest extends LightDaemonAnalyzerTestCase { + @NonNls static final String BASE_PATH = "/codeInsight/daemonCodeAnalyzer/lambda/graphInference"; + + public void testNestedCalls() throws Exception { + doTest(); + } + + public void testNestedCallsSameMethod() throws Exception { + doTest(); + } + + public void testChainedInference() throws Exception { + doTest(); + } + + public void testChainedInference1() throws Exception { + doTest(); + } + + public void testReturnStmt() throws Exception { + doTest(); + } + + public void testInferenceFromSiblings() throws Exception { + doTest(); + } + + private void doTest() throws Exception { + doTest(false); + } + + private void doTest(final boolean checkWarnings) throws Exception { + ((JavaVersionServiceImpl)JavaVersionService.getInstance()).setTestVersion(JavaSdkVersion.JDK_1_8, getTestRootDisposable()); + doTest(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, false); + } +} diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/Interface8MethodsHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/Interface8MethodsHighlightingTest.java new file mode 100644 index 000000000000..9778a6ae2886 --- /dev/null +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/Interface8MethodsHighlightingTest.java @@ -0,0 +1,45 @@ +/* + * Copyright 2000-2013 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.codeInsight.daemon.lambda; + +import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase; +import com.intellij.codeInspection.deprecation.DeprecatedDefenderSyntaxInspection; +import org.jetbrains.annotations.NonNls; + +public class Interface8MethodsHighlightingTest extends LightDaemonAnalyzerTestCase { + @NonNls static final String BASE_PATH = "/codeInsight/daemonCodeAnalyzer/lambda/interfaceMethods"; + + public void testStaticMethod() throws Exception { + doTest(); + } + + public void testNotInheritFromUnrelatedDefault() throws Exception { doTest(true, false); } + public void testDefaultMethodVisibility() throws Exception { doTest(true, false); } + public void testInheritUnrelatedDefaults() throws Exception { doTest(true, false); } + public void testExtensionMethods() throws Exception { doTest(false, false); } + public void testExtensionMethodSyntax() throws Exception { + enableInspectionTools(DeprecatedDefenderSyntaxInspection.class); + doTest(true, false); + } + + private void doTest() throws Exception { + doTest(false, false); + } + + private void doTest(final boolean checkWarnings, final boolean checkInfos) throws Exception { + doTest(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, checkInfos); + } +} 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 6b9e16ae63e0..a88f0c8f1dc2 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 @@ -16,11 +16,22 @@ package com.intellij.codeInsight.daemon.lambda; import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase; +import com.intellij.codeInspection.LocalInspectionTool; +import com.intellij.codeInspection.unusedSymbol.UnusedSymbolLocalInspection; import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; public class LambdaHighlightingTest extends LightDaemonAnalyzerTestCase { @NonNls static final String BASE_PATH = "/codeInsight/daemonCodeAnalyzer/lambda/highlighting"; + @NotNull + @Override + protected LocalInspectionTool[] configureLocalInspectionTools() { + return new LocalInspectionTool[]{ + new UnusedSymbolLocalInspection(), + }; + } + public void testStaticAccess() throws Exception { doTest(); } @@ -28,11 +39,11 @@ public class LambdaHighlightingTest extends LightDaemonAnalyzerTestCase { public void testEffectiveFinal() throws Exception { doTest(); } - + public void testReassignUsedVars() throws Exception { doTest(); } - + public void testLambdaContext() throws Exception { doTest(); } @@ -40,7 +51,7 @@ public class LambdaHighlightingTest extends LightDaemonAnalyzerTestCase { public void testReturnTypeCompatibility() throws Exception { doTest(); } - + public void testTypeArgsConsistency() throws Exception { doTest(); } @@ -55,7 +66,7 @@ public class LambdaHighlightingTest extends LightDaemonAnalyzerTestCase { public void testTypeArgsConsistencyWithoutParams() throws Exception { doTest(); - } + } public void testIncompatibleReturnTypes() throws Exception { doTest(); @@ -72,7 +83,7 @@ public class LambdaHighlightingTest extends LightDaemonAnalyzerTestCase { public void testInferFromTypeArgs() throws Exception { doTest(); } - + public void testAmbiguity1() throws Exception { doTest(); } @@ -80,7 +91,7 @@ public class LambdaHighlightingTest extends LightDaemonAnalyzerTestCase { public void _testAmbiguity2() throws Exception { doTest(); } - + public void testAmbiguityVarargs() throws Exception { doTest(); } @@ -88,7 +99,7 @@ public class LambdaHighlightingTest extends LightDaemonAnalyzerTestCase { public void testAmbiguityRawGenerics() throws Exception { doTest(); } - + public void testDefaultMethod() throws Exception { doTest(); } @@ -104,7 +115,7 @@ public class LambdaHighlightingTest extends LightDaemonAnalyzerTestCase { public void testReturnTypeCompatibility1() throws Exception { doTest(); } - + public void testNoInferenceResult() throws Exception { doTest(); } @@ -128,7 +139,7 @@ public class LambdaHighlightingTest extends LightDaemonAnalyzerTestCase { public void testConditionalExpr() throws Exception { doTest(); } - + public void testIncompleteSubst() throws Exception { doTest(); } @@ -141,10 +152,14 @@ public class LambdaHighlightingTest extends LightDaemonAnalyzerTestCase { doTest(); } + public void testUnhandledExceptions() throws Exception { + doTest(); + } + public void testReturnValue() throws Exception { doTest(); } - + public void testAlreadyUsedParamName() throws Exception { doTest(); } @@ -177,7 +192,27 @@ public class LambdaHighlightingTest extends LightDaemonAnalyzerTestCase { doTest(); } + public void testIntersectionTypeInCast() throws Exception { + doTest(); + } + + public void testAmbiguitySpecificReturn() throws Exception { + doTest(true); + } + + public void testFunctionalInterfaceAnnotation() throws Exception { + doTest(); + } + + public void testAmbiguityReturnValueResolution() throws Exception { + doTest(); + } + private void doTest() throws Exception { - doTest(BASE_PATH + "/" + getTestName(false) + ".java", false, false); + doTest(false); + } + + private void doTest(final boolean checkWarnings) throws Exception { + doTest(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, 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 ec1c083f372a..f93f7ac9025c 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 @@ -41,6 +41,10 @@ public class LambdaParamsTest extends LightDaemonAnalyzerTestCase { doTest(); } + public void testFormalParamsWithWildcards() throws Exception { + doTest(); + } + private void doTest() throws Exception { doTest(BASE_PATH + "/" + getTestName(false) + ".java", false, false); } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/MethodRefHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/MethodRefHighlightingTest.java index 5b38de1fb98e..997e0d563f1c 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 @@ -22,10 +22,12 @@ import com.intellij.openapi.projectRoots.JavaSdkVersion; import com.intellij.openapi.projectRoots.JavaVersionService; import com.intellij.openapi.projectRoots.JavaVersionServiceImpl; import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; public class MethodRefHighlightingTest extends LightDaemonAnalyzerTestCase { @NonNls static final String BASE_PATH = "/codeInsight/daemonCodeAnalyzer/lambda/methodRef"; + @NotNull @Override protected LocalInspectionTool[] configureLocalInspectionTools() { return new LocalInspectionTool[]{ @@ -153,6 +155,22 @@ public class MethodRefHighlightingTest extends LightDaemonAnalyzerTestCase { doTest(true); } + public void testIntersectionTypeInCast() throws Exception { + doTest(false); + } + + public void testUnhandledExceptions() throws Exception { + doTest(); + } + + public void testCapturedWildcards() throws Exception { + doTest(); + } + + public void testConstructorNonAbstractAbstractExpected() throws Exception { + doTest(); + } + private void doTest() throws Exception { doTest(false); } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/AnnotateMethodTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/AnnotateMethodTest.java index 59683ae56fcc..f285ee489727 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/AnnotateMethodTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/AnnotateMethodTest.java @@ -6,6 +6,7 @@ import com.intellij.codeInspection.nullable.NullableStuffInspection; import com.intellij.openapi.project.Project; import com.intellij.psi.PsiMethod; import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; public class AnnotateMethodTest extends LightQuickFix15TestCase { private boolean myMustBeAvailableAfterInvoke; @@ -15,6 +16,7 @@ public class AnnotateMethodTest extends LightQuickFix15TestCase { return "/codeInsight/daemonCodeAnalyzer/quickFix/annotateMethod"; } + @NotNull @Override protected LocalInspectionTool[] configureLocalInspectionTools() { return new LocalInspectionTool[]{new NullableStuffInspection(){ diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/Anonymous2LambdaInspectionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/Anonymous2LambdaInspectionTest.java index 892a92bc7569..c21eac60b308 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/Anonymous2LambdaInspectionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/Anonymous2LambdaInspectionTest.java @@ -17,9 +17,11 @@ package com.intellij.codeInsight.daemon.quickFix; import com.intellij.codeInspection.AnonymousCanBeLambdaInspection; import com.intellij.codeInspection.LocalInspectionTool; +import org.jetbrains.annotations.NotNull; public class Anonymous2LambdaInspectionTest extends LightQuickFixTestCase { + @NotNull @Override protected LocalInspectionTool[] configureLocalInspectionTools() { return new LocalInspectionTool[]{ diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/Anonymous2MethodReferenceInspectionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/Anonymous2MethodReferenceInspectionTest.java index e7fb3bedbf44..402409c6f6c4 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/Anonymous2MethodReferenceInspectionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/Anonymous2MethodReferenceInspectionTest.java @@ -17,9 +17,11 @@ package com.intellij.codeInsight.daemon.quickFix; import com.intellij.codeInspection.AnonymousCanBeMethodReferenceInspection; import com.intellij.codeInspection.LocalInspectionTool; +import org.jetbrains.annotations.NotNull; public class Anonymous2MethodReferenceInspectionTest extends LightQuickFixTestCase { + @NotNull @Override protected LocalInspectionTool[] configureLocalInspectionTools() { return new LocalInspectionTool[]{ diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/ChangeNewOperatorTypeTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/ChangeNewOperatorTypeTest.java index 98e438b71345..db262aa3696c 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/ChangeNewOperatorTypeTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/ChangeNewOperatorTypeTest.java @@ -1,8 +1,13 @@ package com.intellij.codeInsight.daemon.quickFix; -public class ChangeNewOperatorTypeTest extends LightQuickFix15TestCase { +import com.intellij.pom.java.LanguageLevel; - public void test() throws Exception { doAllTests(); } +public class ChangeNewOperatorTypeTest extends LightQuickFixTestCase { + + public void test() throws Exception { + setLanguageLevel(LanguageLevel.JDK_1_7); + doAllTests(); + } @Override protected String getBasePath() { diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/CreateClassFromNewTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/CreateClassFromNewTest.java index b90ee60adde4..82fcd0e2e466 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/CreateClassFromNewTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/CreateClassFromNewTest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2000-2013 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.intellij.codeInsight.daemon.quickFix; import com.intellij.psi.codeStyle.CodeStyleSettingsManager; @@ -6,10 +21,9 @@ import com.intellij.psi.codeStyle.CodeStyleSettingsManager; * @author ven */ public class CreateClassFromNewTest extends LightQuickFixTestCase { - public void test() throws Exception { CodeStyleSettingsManager.getSettings(getProject()).SPACE_BEFORE_CLASS_LBRACE = true; - doAllTests(); + doAllTests(); } @Override diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/CreateConstructorParameterFromFieldTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/CreateConstructorParameterFromFieldTest.java index 65c09a604bc5..94f8a9c65ce8 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/CreateConstructorParameterFromFieldTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/CreateConstructorParameterFromFieldTest.java @@ -2,11 +2,13 @@ package com.intellij.codeInsight.daemon.quickFix; import com.intellij.codeInspection.LocalInspectionTool; import com.intellij.codeInspection.unusedSymbol.UnusedSymbolLocalInspection; +import org.jetbrains.annotations.NotNull; /** * @author cdr */ public class CreateConstructorParameterFromFieldTest extends LightQuickFixTestCase { + @NotNull @Override protected LocalInspectionTool[] configureLocalInspectionTools() { return new LocalInspectionTool[]{ new UnusedSymbolLocalInspection()}; diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/CreateInnerClassFromNewTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/CreateInnerClassFromNewTest.java index 902f0ff881d9..7b53bd1505ae 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/CreateInnerClassFromNewTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/CreateInnerClassFromNewTest.java @@ -1,13 +1,30 @@ +/* + * Copyright 2000-2013 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.intellij.codeInsight.daemon.quickFix; /** * @author yole */ public class CreateInnerClassFromNewTest extends LightQuickFixTestCase { - public void test() throws Exception { doAllTests(); } + public void test() throws Exception { + doAllTests(); + } @Override protected String getBasePath() { return "/codeInsight/daemonCodeAnalyzer/quickFix/createInnerClassFromNew"; } -}
\ No newline at end of file +} diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/CreateMethodFromUsageTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/CreateMethodFromUsageTest.java index 3ad579bdf7e8..393f5208cbb9 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/CreateMethodFromUsageTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/CreateMethodFromUsageTest.java @@ -3,7 +3,7 @@ package com.intellij.codeInsight.daemon.quickFix; /** * @author ven */ -public class CreateMethodFromUsageTest extends LightQuickFix15TestCase { +public class CreateMethodFromUsageTest extends LightQuickFixTestCase { public void test() throws Exception { doAllTests(); } @Override diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/EmptyIntentionInspectionQuickFixTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/EmptyIntentionInspectionQuickFixTest.java index a2fea9938009..0895fd970d43 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/EmptyIntentionInspectionQuickFixTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/EmptyIntentionInspectionQuickFixTest.java @@ -24,6 +24,7 @@ public class EmptyIntentionInspectionQuickFixTest extends LightQuickFixTestCase{ return "/codeInsight/daemonCodeAnalyzer/quickFix/emptyIntention"; } + @NotNull @Override protected LocalInspectionTool[] configureLocalInspectionTools() { return new LocalInspectionTool[]{new DefUseInspection(), new LocalInspectionTool() { diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/EnableOptimizeImportsOnTheFlyTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/EnableOptimizeImportsOnTheFlyTest.java index e45590611ea0..3da506a90583 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/EnableOptimizeImportsOnTheFlyTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/EnableOptimizeImportsOnTheFlyTest.java @@ -4,9 +4,11 @@ import com.intellij.codeInsight.CodeInsightSettings; import com.intellij.codeInsight.intention.IntentionAction; import com.intellij.codeInspection.LocalInspectionTool; import com.intellij.codeInspection.unusedImport.UnusedImportLocalInspection; +import org.jetbrains.annotations.NotNull; public class EnableOptimizeImportsOnTheFlyTest extends LightQuickFixTestCase { + @NotNull @Override protected LocalInspectionTool[] configureLocalInspectionTools() { return new LocalInspectionTool[]{new UnusedImportLocalInspection()}; diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/FixAllQuickfixTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/FixAllQuickfixTest.java index 8da26aa6bb27..3cfb844aaaee 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/FixAllQuickfixTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/FixAllQuickfixTest.java @@ -7,8 +7,10 @@ package com.intellij.codeInsight.daemon.quickFix; import com.intellij.codeInspection.LocalInspectionTool; import com.intellij.codeInspection.dataFlow.DataFlowInspection; import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; public class FixAllQuickfixTest extends LightQuickFixTestCase { + @NotNull @Override protected LocalInspectionTool[] configureLocalInspectionTools() { return new LocalInspectionTool[] { diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/GenerifyFileTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/GenerifyFileTest.java index 1d0d11432ad4..9907b329e760 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/GenerifyFileTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/GenerifyFileTest.java @@ -2,10 +2,12 @@ package com.intellij.codeInsight.daemon.quickFix; import com.intellij.codeInspection.LocalInspectionTool; import com.intellij.codeInspection.uncheckedWarnings.UncheckedWarningLocalInspection; +import org.jetbrains.annotations.NotNull; public class GenerifyFileTest extends LightQuickFixAvailabilityTestCase { + @NotNull @Override protected LocalInspectionTool[] configureLocalInspectionTools() { return new LocalInspectionTool[] {new UncheckedWarningLocalInspection()}; diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/I18nQuickFixTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/I18nQuickFixTest.java index 2d6cb90a87bf..d55341d7af7e 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/I18nQuickFixTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/I18nQuickFixTest.java @@ -4,6 +4,7 @@ import com.intellij.codeInsight.daemon.quickFix.LightQuickFix15TestCase; import com.intellij.codeInspection.LocalInspectionTool; import com.intellij.codeInspection.i18n.I18nInspection; import com.intellij.openapi.util.Comparing; +import org.jetbrains.annotations.NotNull; /** * @author yole @@ -11,6 +12,7 @@ import com.intellij.openapi.util.Comparing; public class I18nQuickFixTest extends LightQuickFix15TestCase { private boolean myMustBeAvailableAfterInvoke; + @NotNull @Override protected LocalInspectionTool[] configureLocalInspectionTools() { return new LocalInspectionTool[]{new I18nInspection()}; diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/InitializeFinalFieldInConstructorFixTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/InitializeFinalFieldInConstructorFixTest.java index 4dadabcca79a..4b3c868eabce 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/InitializeFinalFieldInConstructorFixTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/InitializeFinalFieldInConstructorFixTest.java @@ -2,8 +2,10 @@ package com.intellij.codeInsight.daemon.quickFix; import com.intellij.codeInspection.LocalInspectionTool; import com.intellij.codeInspection.unusedSymbol.UnusedSymbolLocalInspection; +import org.jetbrains.annotations.NotNull; public class InitializeFinalFieldInConstructorFixTest extends LightQuickFixTestCase { + @NotNull @Override protected LocalInspectionTool[] configureLocalInspectionTools() { return new LocalInspectionTool[]{ new UnusedSymbolLocalInspection()}; diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/JavadocInspectionQuickFixTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/JavadocInspectionQuickFixTest.java index 6c40bf65b1db..17e729ebee42 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/JavadocInspectionQuickFixTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/JavadocInspectionQuickFixTest.java @@ -12,9 +12,11 @@ package com.intellij.codeInsight.daemon.quickFix; import com.intellij.codeInspection.LocalInspectionTool; import com.intellij.codeInspection.javaDoc.JavaDocLocalInspection; +import org.jetbrains.annotations.NotNull; public class JavadocInspectionQuickFixTest extends LightQuickFix15TestCase { + @NotNull @Override protected LocalInspectionTool[] configureLocalInspectionTools() { final JavaDocLocalInspection javaDocLocalInspection = new JavaDocLocalInspection(); diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/Lambda2MethodReferenceInspectionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/Lambda2MethodReferenceInspectionTest.java index dfed9a8c0fd9..af915d61836b 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/Lambda2MethodReferenceInspectionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/Lambda2MethodReferenceInspectionTest.java @@ -17,9 +17,11 @@ package com.intellij.codeInsight.daemon.quickFix; import com.intellij.codeInspection.LambdaCanBeMethReferenceInspection; import com.intellij.codeInspection.LocalInspectionTool; +import org.jetbrains.annotations.NotNull; public class Lambda2MethodReferenceInspectionTest extends LightQuickFixTestCase { + @NotNull @Override protected LocalInspectionTool[] configureLocalInspectionTools() { return new LocalInspectionTool[]{ diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/LightQuickFix15TestCase.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/LightQuickFix15TestCase.java index a97e7ae4bfb4..457d783a7bb4 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/LightQuickFix15TestCase.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/LightQuickFix15TestCase.java @@ -15,8 +15,15 @@ */ package com.intellij.codeInsight.daemon.quickFix; +import com.intellij.pom.java.LanguageLevel; + /** * @author ven */ public abstract class LightQuickFix15TestCase extends LightQuickFixTestCase { + @Override + protected void doAllTests() throws Exception { + setLanguageLevel(LanguageLevel.JDK_1_5); + super.doAllTests(); + } } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/ModifierTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/ModifierTest.java index c0eaeb8c1352..6c578808307a 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/ModifierTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/ModifierTest.java @@ -1,5 +1,7 @@ package com.intellij.codeInsight.daemon.quickFix; +import com.intellij.pom.java.LanguageLevel; + public class ModifierTest extends LightQuickFixTestCase { public void test() throws Exception { doAllTests(); } @@ -7,4 +9,9 @@ public class ModifierTest extends LightQuickFixTestCase { protected String getBasePath() { return "/codeInsight/daemonCodeAnalyzer/quickFix/modifier"; } + + @Override + protected LanguageLevel getLanguageLevel() { + return LanguageLevel.JDK_1_7; + } } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/RedundantLambdaCodeBlockInspectionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/RedundantLambdaCodeBlockInspectionTest.java index 9199e149583a..b5ed93893702 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/RedundantLambdaCodeBlockInspectionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/RedundantLambdaCodeBlockInspectionTest.java @@ -17,9 +17,11 @@ package com.intellij.codeInsight.daemon.quickFix; import com.intellij.codeInspection.LocalInspectionTool; import com.intellij.codeInspection.RedundantLambdaCodeBlockInspection; +import org.jetbrains.annotations.NotNull; public class RedundantLambdaCodeBlockInspectionTest extends LightQuickFixTestCase { + @NotNull @Override protected LocalInspectionTool[] configureLocalInspectionTools() { return new LocalInspectionTool[]{ diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/RemoveRedundantUncheckedSuppressionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/RemoveRedundantUncheckedSuppressionTest.java index 248fc1e0e32b..f341e1d6363c 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/RemoveRedundantUncheckedSuppressionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/RemoveRedundantUncheckedSuppressionTest.java @@ -25,6 +25,7 @@ import org.jetbrains.annotations.NotNull; public class RemoveRedundantUncheckedSuppressionTest extends LightQuickFixTestCase { + @NotNull @Override protected LocalInspectionTool[] configureLocalInspectionTools() { final PossibleHeapPollutionVarargsInspection varargsInspection = new PossibleHeapPollutionVarargsInspection(); diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/RemoveUnusedParameterTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/RemoveUnusedParameterTest.java index fade977647a2..fd6afa2fbadf 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/RemoveUnusedParameterTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/RemoveUnusedParameterTest.java @@ -3,11 +3,13 @@ package com.intellij.codeInsight.daemon.quickFix; import com.intellij.codeInspection.LocalInspectionTool; import com.intellij.codeInspection.unusedSymbol.UnusedSymbolLocalInspection; +import org.jetbrains.annotations.NotNull; public class RemoveUnusedParameterTest extends LightQuickFixTestCase { + @NotNull @Override protected LocalInspectionTool[] configureLocalInspectionTools() { return new LocalInspectionTool[]{ new UnusedSymbolLocalInspection()}; diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/RemoveUnusedVariableTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/RemoveUnusedVariableTest.java index f1821a6d5e3b..41b0863ac461 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/RemoveUnusedVariableTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/RemoveUnusedVariableTest.java @@ -3,8 +3,10 @@ package com.intellij.codeInsight.daemon.quickFix; import com.intellij.codeInspection.LocalInspectionTool; import com.intellij.codeInspection.unusedSymbol.UnusedSymbolLocalInspection; +import org.jetbrains.annotations.NotNull; public class RemoveUnusedVariableTest extends LightQuickFixTestCase { + @NotNull @Override protected LocalInspectionTool[] configureLocalInspectionTools() { return new LocalInspectionTool[]{ new UnusedSymbolLocalInspection()}; diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/ReplaceWithTernaryOperatorTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/ReplaceWithTernaryOperatorTest.java index 6419088e9583..3692eecbf886 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/ReplaceWithTernaryOperatorTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/ReplaceWithTernaryOperatorTest.java @@ -23,8 +23,10 @@ package com.intellij.codeInsight.daemon.quickFix; import com.intellij.codeInspection.LocalInspectionTool; import com.intellij.codeInspection.dataFlow.DataFlowInspection; import com.intellij.codeInspection.nullable.NullableStuffInspection; +import org.jetbrains.annotations.NotNull; public class ReplaceWithTernaryOperatorTest extends LightQuickFixTestCase { + @NotNull @Override protected LocalInspectionTool[] configureLocalInspectionTools() { return new LocalInspectionTool[]{new DataFlowInspection(), new NullableStuffInspection()}; diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/SafeVarargsCanBeUsedTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/SafeVarargsCanBeUsedTest.java index 8b7212e527d7..6b4605b2565e 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/SafeVarargsCanBeUsedTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/SafeVarargsCanBeUsedTest.java @@ -17,9 +17,11 @@ package com.intellij.codeInsight.daemon.quickFix; import com.intellij.codeInspection.LocalInspectionTool; import com.intellij.codeInspection.PossibleHeapPollutionVarargsInspection; +import org.jetbrains.annotations.NotNull; public class SafeVarargsCanBeUsedTest extends LightQuickFixTestCase { + @NotNull @Override protected LocalInspectionTool[] configureLocalInspectionTools() { return new LocalInspectionTool[]{ diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/Simplify2DiamondInspectionsTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/Simplify2DiamondInspectionsTest.java index 76136b5fb8ef..bd3f7a0c7731 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/Simplify2DiamondInspectionsTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/Simplify2DiamondInspectionsTest.java @@ -17,10 +17,12 @@ package com.intellij.codeInsight.daemon.quickFix; import com.intellij.codeInspection.ExplicitTypeCanBeDiamondInspection; import com.intellij.codeInspection.LocalInspectionTool; +import org.jetbrains.annotations.NotNull; //todo test3 should be checked if it compiles - as now javac infers Object instead of String?! public class Simplify2DiamondInspectionsTest extends LightQuickFixTestCase { + @NotNull @Override protected LocalInspectionTool[] configureLocalInspectionTools() { return new LocalInspectionTool[]{ diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/Suppress15InspectionsTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/Suppress15InspectionsTest.java index 9931d17a85bc..13ebabffecf8 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/Suppress15InspectionsTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/Suppress15InspectionsTest.java @@ -26,6 +26,7 @@ import com.intellij.codeInspection.uncheckedWarnings.UncheckedWarningLocalInspec import com.intellij.codeInspection.unneededThrows.RedundantThrowsDeclaration; import com.intellij.codeInspection.unusedParameters.UnusedParametersInspection; import com.intellij.codeInspection.unusedSymbol.UnusedSymbolLocalInspection; +import org.jetbrains.annotations.NotNull; public class Suppress15InspectionsTest extends LightQuickFixTestCase { @@ -35,6 +36,7 @@ public class Suppress15InspectionsTest extends LightQuickFixTestCase { enableInspectionTool(new GlobalInspectionToolWrapper(new UnusedParametersInspection())); } + @NotNull @Override protected LocalInspectionTool[] configureLocalInspectionTools() { return new LocalInspectionTool[]{ diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/SuppressLocalInspectionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/SuppressLocalInspectionTest.java index c096ff5a6ac0..4f3a1bbef42a 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/SuppressLocalInspectionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/SuppressLocalInspectionTest.java @@ -5,6 +5,7 @@ import com.intellij.codeInspection.LocalInspectionTool; import com.intellij.codeInspection.localCanBeFinal.LocalCanBeFinal; import com.intellij.openapi.roots.LanguageLevelProjectExtension; import com.intellij.pom.java.LanguageLevel; +import org.jetbrains.annotations.NotNull; public class SuppressLocalInspectionTest extends LightQuickFixTestCase { @@ -15,6 +16,7 @@ public class SuppressLocalInspectionTest extends LightQuickFixTestCase { LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(LanguageLevel.JDK_1_3); } + @NotNull @Override protected LocalInspectionTool[] configureLocalInspectionTools() { return new LocalInspectionTool[]{new LocalCanBeFinal()}; diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/SuppressNonInspectionsTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/SuppressNonInspectionsTest.java index 04a6a0567eb2..78ecf4f3113b 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/SuppressNonInspectionsTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/SuppressNonInspectionsTest.java @@ -11,6 +11,7 @@ import com.intellij.codeInspection.unneededThrows.RedundantThrowsDeclaration; import com.intellij.codeInspection.unusedSymbol.UnusedSymbolLocalInspection; import com.intellij.openapi.roots.LanguageLevelProjectExtension; import com.intellij.pom.java.LanguageLevel; +import org.jetbrains.annotations.NotNull; public class SuppressNonInspectionsTest extends LightQuickFixTestCase { @@ -21,6 +22,7 @@ public class SuppressNonInspectionsTest extends LightQuickFixTestCase { LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(LanguageLevel.JDK_1_3); } + @NotNull @Override protected LocalInspectionTool[] configureLocalInspectionTools() { return new LocalInspectionTool[]{ diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/SurroundWithIfFixTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/SurroundWithIfFixTest.java index 9a4a1699ccd5..19ed7fc148c4 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/SurroundWithIfFixTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/SurroundWithIfFixTest.java @@ -22,8 +22,10 @@ package com.intellij.codeInsight.daemon.quickFix; import com.intellij.codeInspection.LocalInspectionTool; import com.intellij.codeInspection.dataFlow.DataFlowInspection; +import org.jetbrains.annotations.NotNull; public class SurroundWithIfFixTest extends LightQuickFixTestCase { + @NotNull @Override protected LocalInspectionTool[] configureLocalInspectionTools() { return new LocalInspectionTool[]{new DataFlowInspection()}; diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/VariableTypeFromCallTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/VariableTypeFromCallTest.java index 2f940e97197a..6ee5908adc68 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/VariableTypeFromCallTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/VariableTypeFromCallTest.java @@ -16,7 +16,7 @@ package com.intellij.codeInsight.daemon.quickFix; -public class VariableTypeFromCallTest extends LightQuickFix15TestCase { +public class VariableTypeFromCallTest extends LightQuickFixTestCase { public void test() throws Exception { doAllTests(); } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/documentation/RefConvertorsTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/documentation/RefConvertorsTest.java new file mode 100644 index 000000000000..f5bd537a6788 --- /dev/null +++ b/java/java-tests/testSrc/com/intellij/codeInsight/documentation/RefConvertorsTest.java @@ -0,0 +1,100 @@ +/* + * Copyright 2000-2013 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.codeInsight.documentation; + +import com.intellij.JavaTestUtil; +import com.intellij.codeInsight.javadoc.JavaDocExternalFilter; +import com.intellij.openapi.util.io.FileUtil; +import com.intellij.openapi.util.io.FileUtilRt; +import com.intellij.openapi.vfs.JarFileSystem; +import com.intellij.openapi.vfs.LocalFileSystem; +import com.intellij.testFramework.LightCodeInsightTestCase; + +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.util.jar.JarEntry; +import java.util.jar.JarOutputStream; + +/** + * @author Denis Zhdanov + * @since 1/15/13 7:26 PM + */ +public class RefConvertorsTest extends LightCodeInsightTestCase { + + private File myExtractedImagesDir; + + @Override + protected void setUp() throws Exception { + super.setUp(); + String tempDirectory = FileUtilRt.getTempDirectory(); + myExtractedImagesDir = new File(tempDirectory, AbstractExternalFilter.QUICK_DOC_DIR_NAME); + } + + @Override + protected void tearDown() throws Exception { + FileUtilRt.delete(myExtractedImagesDir); + super.tearDown(); + } + + public void testImgInsideJar() throws Exception { + String imgJarName = "test-img"; + File imgJar = new File(myExtractedImagesDir, imgJarName + ".jar"); + boolean exist = FileUtil.createIfDoesntExist(imgJar); + assertTrue(exist); + + JarOutputStream out = new JarOutputStream(new BufferedOutputStream(new FileOutputStream(imgJar))); + try { + out.putNextEntry(new JarEntry("resources/inherit.gif")); + FileInputStream fIn = new FileInputStream(JavaTestUtil.getJavaTestDataPath() + "/codeInsight/documentation/inherit.gif"); + try { + FileUtil.copy(fIn, out); + } + finally { + fIn.close(); + } + } + finally { + out.close(); + } + + String textBefore = + "<HTML>" + + "java.lang.Object\n" + + " <IMG SRC=\"../../../resources/inherit.gif\" ALT=\"extended by \"><B>org.bouncycastle.asn1.BERSequenceParser</B>\n" + + "</HTML>"; + + File f = new File(myExtractedImagesDir, imgJarName); + f = new File(f, "resources"); + File extractedImgFile = new File(f, "inherit.gif"); + String expectedTextAfter = String.format( + "<HTML>" + + "java.lang.Object\n" + + " <IMG SRC=\"%s%s\" ALT=\"extended by \"><B>org.bouncycastle.asn1.BERSequenceParser</B>\n" + + "</HTML>", + LocalFileSystem.PROTOCOL_PREFIX, + extractedImgFile.getAbsolutePath()); + + JavaDocExternalFilter filter = new JavaDocExternalFilter(getProject()); + String textAfter = filter.correctRefs( + String.format("%s%s!/org/bouncycastle/asn1/BERSequenceParser.html", JarFileSystem.PROTOCOL_PREFIX, imgJar.getAbsolutePath()), + textBefore + ); + assertEquals(expectedTextAfter, textAfter); + assertTrue(extractedImgFile.isFile()); + } +} diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/intention/SplitIfActionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/intention/SplitIfActionTest.java index c6454a1e4ce0..c9653c3eabdb 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/intention/SplitIfActionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/intention/SplitIfActionTest.java @@ -10,51 +10,45 @@ import com.intellij.testFramework.LightCodeInsightTestCase; public class SplitIfActionTest extends LightCodeInsightTestCase { public void test1() throws Exception { CodeStyleSettingsManager.getSettings(getProject()).ELSE_ON_NEW_LINE= true; - configureByFile("/codeInsight/splitIfAction/before1.java"); - perform(); - checkResultByFile("/codeInsight/splitIfAction/after1.java"); + doTest(); } public void test2() throws Exception { - configureByFile("/codeInsight/splitIfAction/before2.java"); - perform(); - checkResultByFile("/codeInsight/splitIfAction/after2.java"); + doTest(); } public void test3() throws Exception { - configureByFile("/codeInsight/splitIfAction/before3.java"); - perform(); - checkResultByFile("/codeInsight/splitIfAction/after3.java"); + doTest(); } public void test4() throws Exception { - configureByFile("/codeInsight/splitIfAction/before4.java"); - perform(); - checkResultByFile("/codeInsight/splitIfAction/after4.java"); + doTest(); } public void test5() throws Exception { - configureByFile("/codeInsight/splitIfAction/before5.java"); - perform(); - checkResultByFile("/codeInsight/splitIfAction/after5.java"); + doTest(); } - public void test6() throws Exception { - configureByFile("/codeInsight/splitIfAction/beforeParenthesis.java"); - perform(); - checkResultByFile("/codeInsight/splitIfAction/afterParenthesis.java"); + public void testParenthesis() throws Exception { + doTest(); } - public void test7() throws Exception { - configureByFile("/codeInsight/splitIfAction/beforeOrParenthesis.java"); - perform(); - checkResultByFile("/codeInsight/splitIfAction/afterOrParenthesis.java"); + public void testOrParenthesis() throws Exception { + doTest(); } public void testComment() throws Exception { - configureByFile("/codeInsight/splitIfAction/beforeComment.java"); + doTest(); + } + + public void testWithoutSpaces() throws Exception { + doTest(); + } + + private void doTest() throws Exception { + configureByFile("/codeInsight/splitIfAction/before" + getTestName(false)+ ".java"); perform(); - checkResultByFile("/codeInsight/splitIfAction/afterComment.java"); + checkResultByFile("/codeInsight/splitIfAction/after" + getTestName(false) + ".java"); } public void test8() throws Exception { @@ -64,7 +58,6 @@ public class SplitIfActionTest extends LightCodeInsightTestCase { } - private void perform() throws Exception { SplitIfAction action = new SplitIfAction(); assertTrue(action.isAvailable(getProject(), getEditor(), getFile())); 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 666709af1083..e6595b98b11a 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/javadoc/JavaDocInfoGeneratorTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/javadoc/JavaDocInfoGeneratorTest.java @@ -58,6 +58,10 @@ public class JavaDocInfoGeneratorTest extends CodeInsightTestCase { public void testInitializerWithNew() throws Exception { doTestField(); } + + public void testInitializerWithReference() throws Exception { + doTestField(); + } private void doTestField() throws Exception { PsiClass psiClass = getTestClass(); @@ -80,6 +84,7 @@ public class JavaDocInfoGeneratorTest extends CodeInsightTestCase { 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())); } @@ -90,6 +95,7 @@ public class JavaDocInfoGeneratorTest extends CodeInsightTestCase { final String info = new JavaDocInfoGenerator(getProject(), JavaPsiFacade.getInstance(getProject()).findPackage(getTestName(true))).generateDocInfo(null); String htmlText = FileUtil.loadFile(new File(packageInfo + File.separator + "packageInfo.html")); + assertNotNull(info); assertEquals(StringUtil.convertLineSeparators(htmlText.trim()), StringUtil.convertLineSeparators(info.trim())); } 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 bd3eb0a5ac68..d739f69d91c8 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/template/LiveTemplateTest.groovy +++ b/java/java-tests/testSrc/com/intellij/codeInsight/template/LiveTemplateTest.groovy @@ -178,7 +178,7 @@ class Foo { assert !state } - public void "_test non-imported classes in className macro"() { + public void "test non-imported classes in className macro"() { myFixture.addClass('package bar; public class Bar {}') myFixture.configureByText 'a.java', ''' class Foo { diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionFixtureTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionFixtureTest.java deleted file mode 100644 index 600b822e2780..000000000000 --- a/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionFixtureTest.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Copyright 2000-2012 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.codeInspection; - -import com.intellij.JavaTestUtil; -import com.intellij.codeInsight.NullableNotNullManager; -import com.intellij.codeInspection.dataFlow.DataFlowInspection; -import com.intellij.openapi.Disposable; -import com.intellij.openapi.util.Disposer; -import com.intellij.pom.java.LanguageLevel; -import com.intellij.testFramework.builders.JavaModuleFixtureBuilder; -import com.intellij.testFramework.fixtures.JavaCodeInsightFixtureTestCase; - -/** - * @author peter - */ -public class DataFlowInspectionFixtureTest extends JavaCodeInsightFixtureTestCase { - @Override - protected void tuneFixture(JavaModuleFixtureBuilder moduleBuilder) { - moduleBuilder.setLanguageLevel(LanguageLevel.HIGHEST); - } - - @Override - protected String getTestDataPath() { - return JavaTestUtil.getJavaTestDataPath() + "/inspection/dataFlow/fixture/"; - } - - private void doTest() { - final DataFlowInspection inspection = new DataFlowInspection(); - inspection.SUGGEST_NULLABLE_ANNOTATIONS = true; - myFixture.enableInspections(inspection); - myFixture.testHighlighting(true, false, true, getTestName(false) + ".java"); - } - - public void testTryInAnonymous() throws Throwable { doTest(); } - public void testNullableAnonymousMethod() throws Throwable { doTest(); } - public void testNullableAnonymousParameter() throws Throwable { doTest(); } - public void testNullableAnonymousVolatile() throws Throwable { doTest(); } - public void testNullableAnonymousVolatileNotNull() throws Throwable { doTest(); } - public void testLocalClass() throws Throwable { doTest(); } - - public void testFieldInAnonymous() throws Throwable { doTest(); } - public void testFieldInitializerInAnonymous() throws Throwable { doTest(); } - public void testNullableField() throws Throwable { doTest(); } - public void testCanBeNullDoesntImplyIsNull() throws Throwable { doTest(); } - public void testAnnReport() throws Throwable { doTest(); } - - public void testBigMethodNotComplex() throws Throwable { doTest(); } - public void testBuildRegexpNotComplex() throws Throwable { doTest(); } - public void testTernaryInWhileNotComplex() throws Throwable { doTest(); } - public void testTryCatchInForNotComplex() throws Throwable { doTest(); } - public void testFieldChangedBetweenSynchronizedBlocks() throws Throwable { doTest(); } - - public void testGeneratedEquals() throws Throwable { doTest(); } - - public void testIDEA84489() throws Throwable { doTest(); } - public void testComparingToNotNullShouldNotAffectNullity() throws Throwable { doTest(); } - public void testStringTernaryAlwaysTrue() throws Throwable { doTest(); } - - public void testBoxing128() throws Throwable { doTest(); } - public void testFinalFieldsInitializedByAnnotatedParameters() throws Throwable { doTest(); } - public void testMultiCatch() throws Throwable { doTest(); } - public void testContinueFlushesLoopVariable() throws Throwable { doTest(); } - - public void testEqualsNotNull() throws Throwable { doTest(); } - public void testVisitFinallyOnce() throws Throwable { doTest(); } - public void testNotEqualsDoesntImplyNotNullity() throws Throwable { doTest(); } - public void testEqualsEnumConstant() throws Throwable { doTest(); } - public void testEqualsConstant() throws Throwable { doTest(); } - public void testFinalLoopVariableInstanceof() throws Throwable { doTest(); } - public void testGreaterIsNotEquals() throws Throwable { doTest(); } - public void testNotGreaterIsNotEquals() throws Throwable { doTest(); } - - public void testChainedFinalFieldsDfa() throws Throwable { doTest(); } - public void testFinalFieldsDifferentInstances() throws Throwable { doTest(); } - public void testThisFieldGetters() throws Throwable { doTest(); } - public void testChainedFinalFieldAccessorsDfa() throws Throwable { doTest(); } - - public void testAssigningUnknownToNullable() throws Throwable { doTest(); } - public void testAssigningClassLiteralToNullable() throws Throwable { doTest(); } - - public void testSynchronizingOnNullable() throws Throwable { doTest(); } - public void testReturningNullFromVoidMethod() throws Throwable { doTest(); } - - public void testCatchRuntimeException() throws Throwable { doTest(); } - - public void testAssertFailInCatch() throws Throwable { - myFixture.addClass("package org.junit; public class Assert { public static void fail() {}}"); - doTest(); - } - - public void testPreserveNullableOnUncheckedCast() throws Throwable { doTest(); } - - public void testPassingNullableIntoVararg() throws Throwable { doTest(); } - public void testEqualsImpliesNotNull() throws Throwable { doTest(); } - - public void testAnnotatedTypeParameters() throws Throwable { - setupCustomAnnotations(); - doTest(); - } - - private void setupCustomAnnotations() { - myFixture.addClass("package foo; public @interface Nullable {}"); - myFixture.addClass("package foo; public @interface NotNull {}"); - final NullableNotNullManager nnnManager = NullableNotNullManager.getInstance(getProject()); - nnnManager.setNotNulls("foo.NotNull"); - nnnManager.setNullables("foo.Nullable"); - Disposer.register(myTestRootDisposable, new Disposable() { - @Override - public void dispose() { - nnnManager.setNotNulls(); - nnnManager.setNullables(); - } - }); - } - - public void testSkipAssertions() { - final DataFlowInspection inspection = new DataFlowInspection(); - inspection.DONT_REPORT_TRUE_ASSERT_STATEMENTS = true; - myFixture.enableInspections(inspection); - myFixture.testHighlighting(true, false, true, getTestName(false) + ".java"); - } - - public void testCheckFieldInitializers() { - doTest(); - } - - public void testConstantDoubleComparisons() { doTest(); } - - public void _testMutableNullableFieldsTreatment() { doTest(); } - public void _testMutableVolatileNullableFieldsTreatment() { doTest(); } - public void testMutableNotAnnotatedFieldsTreatment() { doTest(); } - - public void testMethodCallFlushesField() { doTest(); } - public void testUnknownFloatMayBeNaN() { doTest(); } - public void testLastConstantConditionInAnd() { doTest(); } - - public void testTransientFinalField() { doTest(); } - public void _testSymmetricUncheckedCast() { doTest(); } - public void testNullCheckDoesntAffectUncheckedCast() { doTest(); } - - public void testNullableForeachVariable() { - setupCustomAnnotations(); - doTest(); - } - -} diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java index 480d955128bc..56fa8115d95f 100644 --- a/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java @@ -15,22 +15,147 @@ */ package com.intellij.codeInspection; -import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase; +import com.intellij.JavaTestUtil; +import com.intellij.codeInsight.NullableNotNullManager; import com.intellij.codeInspection.dataFlow.DataFlowInspection; -import org.jetbrains.annotations.NonNls; +import com.intellij.openapi.Disposable; +import com.intellij.openapi.util.Disposer; +import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase; -public class DataFlowInspectionTest extends LightDaemonAnalyzerTestCase { - @NonNls static final String BASE_PATH = "/inspection/dataFlow"; +/** + * @author peter + */ +public class DataFlowInspectionTest extends LightCodeInsightFixtureTestCase { + + @Override + protected String getTestDataPath() { + return JavaTestUtil.getJavaTestDataPath() + "/inspection/dataFlow/fixture/"; + } private void doTest() { - doTest(BASE_PATH + "/" + getTestName(false) + ".java", true, false); + final DataFlowInspection inspection = new DataFlowInspection(); + inspection.SUGGEST_NULLABLE_ANNOTATIONS = true; + myFixture.enableInspections(inspection); + myFixture.testHighlighting(true, false, true, getTestName(false) + ".java"); } - @Override - protected LocalInspectionTool[] configureLocalInspectionTools() { - return new LocalInspectionTool[]{new DataFlowInspection()}; + public void testTryInAnonymous() throws Throwable { doTest(); } + public void testNullableAnonymousMethod() throws Throwable { doTest(); } + public void testNullableAnonymousParameter() throws Throwable { doTest(); } + public void testNullableAnonymousVolatile() throws Throwable { doTest(); } + public void testNullableAnonymousVolatileNotNull() throws Throwable { doTest(); } + public void testLocalClass() throws Throwable { doTest(); } + + public void testFieldInAnonymous() throws Throwable { doTest(); } + public void testFieldInitializerInAnonymous() throws Throwable { doTest(); } + public void testNullableField() throws Throwable { doTest(); } + public void testCanBeNullDoesntImplyIsNull() throws Throwable { doTest(); } + public void testAnnReport() throws Throwable { doTest(); } + + public void testBigMethodNotComplex() throws Throwable { doTest(); } + public void testBuildRegexpNotComplex() throws Throwable { doTest(); } + public void testTernaryInWhileNotComplex() throws Throwable { doTest(); } + public void testTryCatchInForNotComplex() throws Throwable { doTest(); } + public void testFieldChangedBetweenSynchronizedBlocks() throws Throwable { doTest(); } + + public void testGeneratedEquals() throws Throwable { doTest(); } + + public void testIDEA84489() throws Throwable { doTest(); } + public void testComparingToNotNullShouldNotAffectNullity() throws Throwable { doTest(); } + public void testStringTernaryAlwaysTrue() throws Throwable { doTest(); } + + public void testBoxing128() throws Throwable { doTest(); } + public void testFinalFieldsInitializedByAnnotatedParameters() throws Throwable { doTest(); } + public void testMultiCatch() throws Throwable { doTest(); } + public void testContinueFlushesLoopVariable() throws Throwable { doTest(); } + + public void testEqualsNotNull() throws Throwable { doTest(); } + public void testVisitFinallyOnce() throws Throwable { doTest(); } + public void testNotEqualsDoesntImplyNotNullity() throws Throwable { doTest(); } + public void testEqualsEnumConstant() throws Throwable { doTest(); } + public void testEqualsConstant() throws Throwable { doTest(); } + public void testFinalLoopVariableInstanceof() throws Throwable { doTest(); } + public void testGreaterIsNotEquals() throws Throwable { doTest(); } + public void testNotGreaterIsNotEquals() throws Throwable { doTest(); } + + public void testChainedFinalFieldsDfa() throws Throwable { doTest(); } + public void testFinalFieldsDifferentInstances() throws Throwable { doTest(); } + public void testThisFieldGetters() throws Throwable { doTest(); } + public void testChainedFinalFieldAccessorsDfa() throws Throwable { doTest(); } + + public void testAssigningUnknownToNullable() throws Throwable { doTest(); } + public void testAssigningClassLiteralToNullable() throws Throwable { doTest(); } + + public void testSynchronizingOnNullable() throws Throwable { doTest(); } + public void testReturningNullFromVoidMethod() throws Throwable { doTest(); } + + public void testCatchRuntimeException() throws Throwable { doTest(); } + + public void testAssertFailInCatch() throws Throwable { + myFixture.addClass("package org.junit; public class Assert { public static void fail() {}}"); + doTest(); + } + + public void testPreserveNullableOnUncheckedCast() throws Throwable { doTest(); } + + public void testPassingNullableIntoVararg() throws Throwable { doTest(); } + public void testEqualsImpliesNotNull() throws Throwable { doTest(); } + public void testEffectivelyUnqualified() throws Throwable { doTest(); } + + public void testAnnotatedTypeParameters() throws Throwable { + setupCustomAnnotations(); + doTest(); + } + + private void setupCustomAnnotations() { + myFixture.addClass("package foo; public @interface Nullable {}"); + myFixture.addClass("package foo; public @interface NotNull {}"); + final NullableNotNullManager nnnManager = NullableNotNullManager.getInstance(getProject()); + nnnManager.setNotNulls("foo.NotNull"); + nnnManager.setNullables("foo.Nullable"); + Disposer.register(myTestRootDisposable, new Disposable() { + @Override + public void dispose() { + nnnManager.setNotNulls(); + nnnManager.setNullables(); + } + }); + } + + public void testSkipAssertions() { + final DataFlowInspection inspection = new DataFlowInspection(); + inspection.DONT_REPORT_TRUE_ASSERT_STATEMENTS = true; + myFixture.enableInspections(inspection); + myFixture.testHighlighting(true, false, true, getTestName(false) + ".java"); + } + + public void testCheckFieldInitializers() { + doTest(); + } + + public void testConstantDoubleComparisons() { doTest(); } + + public void testMutableNullableFieldsTreatment() { doTest(); } + public void testMutableVolatileNullableFieldsTreatment() { doTest(); } + public void testMutableNotAnnotatedFieldsTreatment() { doTest(); } + + public void testMethodCallFlushesField() { doTest(); } + public void testUnknownFloatMayBeNaN() { doTest(); } + public void testLastConstantConditionInAnd() { doTest(); } + + public void testTransientFinalField() { doTest(); } + public void _testSymmetricUncheckedCast() { doTest(); } + public void testNullCheckDoesntAffectUncheckedCast() { doTest(); } + + public void testNullableForeachVariable() { + setupCustomAnnotations(); + doTest(); } public void testTryWithResourcesNullability() { doTest(); } public void testTryWithResourcesInstanceOf() { doTest(); } + public void testOmnipresentExceptions() { doTest(); } + + public void testEqualsHasNoSideEffects() { doTest(); } + } diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTestSuite.java b/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTestSuite.java index 07d2bf4fc99e..480a910cc394 100644 --- a/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTestSuite.java +++ b/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTestSuite.java @@ -23,7 +23,6 @@ public class DataFlowInspectionTestSuite { public static Test suite() { TestSuite suite = new TestSuite(); suite.addTestSuite(DataFlowInspectionTest.class); - suite.addTestSuite(DataFlowInspectionFixtureTest.class); suite.addTestSuite(DataFlowInspectionAncientTest.class); suite.addTestSuite(SliceTreeTest.class); return suite; diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/GlobalInspectionContextTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/GlobalInspectionContextTest.java index dab2baf370b2..872ae1277119 100644 --- a/java/java-tests/testSrc/com/intellij/codeInspection/GlobalInspectionContextTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInspection/GlobalInspectionContextTest.java @@ -21,7 +21,6 @@ import com.intellij.codeInsight.CodeInsightTestCase; import com.intellij.codeInspection.actions.RunInspectionIntention; import com.intellij.codeInspection.ex.*; import com.intellij.codeInspection.visibility.VisibilityInspection; -import com.intellij.profile.codeInspection.InspectionProfileManager; import java.util.ArrayList; import java.util.Arrays; @@ -56,7 +55,7 @@ public class GlobalInspectionContextTest extends CodeInsightTestCase { } public void testRunInspectionContext() throws Exception { - InspectionProfile profile = (InspectionProfile)InspectionProfileManager.getInstance().getRootProfile(); + InspectionProfile profile = new InspectionProfileImpl("foo"); InspectionProfileEntry[] tools = profile.getInspectionTools(null); for (InspectionProfileEntry tool : tools) { if (!tool.isEnabledByDefault()) { diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/InspectionProfileTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/InspectionProfileTest.java index 409426b19c0b..b8ad3a04614d 100644 --- a/java/java-tests/testSrc/com/intellij/codeInspection/InspectionProfileTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInspection/InspectionProfileTest.java @@ -16,6 +16,7 @@ package com.intellij.codeInspection; import com.intellij.codeInsight.daemon.HighlightDisplayKey; +import com.intellij.codeInspection.dataFlow.DataFlowInspection; import com.intellij.codeInspection.deadCode.UnusedDeclarationInspection; import com.intellij.codeInspection.ex.*; import com.intellij.openapi.util.JDOMUtil; @@ -254,7 +255,8 @@ public class InspectionProfileTest extends LightIdeaTestCase { assertEquals(0, countInitializedTools(profile)); InspectionProfileEntry[] tools = profile.getInspectionTools(null); assertTrue(tools.length > 0); - InspectionProfileEntry tool = tools[0]; + InspectionProfileEntry tool = profile.getInspectionTool(new DataFlowInspection().getShortName()); + assertNotNull(tool); String id = tool.getShortName(); System.out.println(id); if (profile.isToolEnabled(HighlightDisplayKey.findById(id))) { @@ -263,9 +265,15 @@ public class InspectionProfileTest extends LightIdeaTestCase { else { profile.enableTool(id); } + assertEquals(0, countInitializedTools(profile)); profile.writeExternal(new Element("profile")); List<InspectionProfileEntry> initializedTools = getInitializedTools(profile); - assertEquals(initializedTools.toString(), 1, initializedTools.size()); + if (initializedTools.size() != 1) { + for (InspectionProfileEntry initializedTool : initializedTools) { + System.out.println(initializedTool.getShortName()); + } + fail(); + } } public void testInspectionInitializationForSerialization() throws Exception { diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/SingleInspectionProfilePanelTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/SingleInspectionProfilePanelTest.java index 01d2908f7c0c..ab3a853a96bb 100644 --- a/java/java-tests/testSrc/com/intellij/codeInspection/SingleInspectionProfilePanelTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInspection/SingleInspectionProfilePanelTest.java @@ -23,6 +23,7 @@ import com.intellij.openapi.project.ProjectManager; import com.intellij.profile.codeInspection.InspectionProjectProfileManager; import com.intellij.profile.codeInspection.ui.SingleInspectionProfilePanel; import com.intellij.testFramework.LightIdeaTestCase; +import org.jetbrains.annotations.NotNull; /** * @author Dmitry Avdeev @@ -46,19 +47,65 @@ public class SingleInspectionProfilePanelTest extends LightIdeaTestCase { panel.reset(); assertEquals(InspectionProfileTest.getInitializedTools(model).toString(), 0, InspectionProfileTest.countInitializedTools(model)); - LocalInspectionToolWrapper wrapper = (LocalInspectionToolWrapper)model.getInspectionTool(myInspection.getShortName()); - assert wrapper != null; - JavaDocLocalInspection tool = (JavaDocLocalInspection)wrapper.getTool(); + JavaDocLocalInspection tool = getInspection(model); assertEquals("", tool.myAdditionalJavadocTags); tool.myAdditionalJavadocTags = "foo"; model.setModified(true); panel.apply(); assertEquals(1, InspectionProfileTest.countInitializedTools(model)); - wrapper = (LocalInspectionToolWrapper)profile.getInspectionTool(myInspection.getShortName()); - assert wrapper != null; - tool = (JavaDocLocalInspection)wrapper.getTool(); - assertEquals("foo", tool.myAdditionalJavadocTags); + assertEquals("foo", getInspection(profile).myAdditionalJavadocTags); + } + + public void testModifyInstantiatedTool() throws Exception { + Project project = ProjectManager.getInstance().getDefaultProject(); + InspectionProjectProfileManager profileManager = InspectionProjectProfileManager.getInstance(project); + InspectionProfileImpl profile = (InspectionProfileImpl)profileManager.getProfile(PROFILE); + profile.initInspectionTools(project); + assertEquals(0, InspectionProfileTest.countInitializedTools(profile)); + + JavaDocLocalInspection originalTool = getInspection(profile); + originalTool.myAdditionalJavadocTags = "foo"; + + InspectionProfileImpl model = (InspectionProfileImpl)profile.getModifiableModel(); + + SingleInspectionProfilePanel panel = new SingleInspectionProfilePanel(profileManager, PROFILE, model); + panel.setVisible(true); + panel.reset(); + assertEquals(InspectionProfileTest.getInitializedTools(model).toString(), 1, InspectionProfileTest.countInitializedTools(model)); + + JavaDocLocalInspection copyTool = getInspection(model); + copyTool.myAdditionalJavadocTags = "bar"; + + model.setModified(true); + panel.apply(); + assertEquals(1, InspectionProfileTest.countInitializedTools(model)); + + assertEquals("bar", getInspection(profile).myAdditionalJavadocTags); + } + + public void testDoNotChangeSettingsOnCancel() throws Exception { + Project project = ProjectManager.getInstance().getDefaultProject(); + InspectionProjectProfileManager profileManager = InspectionProjectProfileManager.getInstance(project); + InspectionProfileImpl profile = (InspectionProfileImpl)profileManager.getProfile(PROFILE); + profile.initInspectionTools(project); + assertEquals(0, InspectionProfileTest.countInitializedTools(profile)); + + JavaDocLocalInspection originalTool = getInspection(profile); + assertEquals("", originalTool.myAdditionalJavadocTags); + + InspectionProfileImpl model = (InspectionProfileImpl)profile.getModifiableModel(); + JavaDocLocalInspection copyTool = getInspection(model); + copyTool.myAdditionalJavadocTags = "foo"; + // this change IS NOT COMMITTED + + assertEquals("", getInspection(profile).myAdditionalJavadocTags); + } + + private JavaDocLocalInspection getInspection(InspectionProfileImpl profile) { + LocalInspectionToolWrapper original = (LocalInspectionToolWrapper)profile.getInspectionTool(myInspection.getShortName()); + assert original != null; + return (JavaDocLocalInspection)original.getTool(); } @Override @@ -75,6 +122,7 @@ public class SingleInspectionProfilePanelTest extends LightIdeaTestCase { private final JavaDocLocalInspection myInspection = new JavaDocLocalInspection(); + @NotNull @Override protected LocalInspectionTool[] configureLocalInspectionTools() { return new LocalInspectionTool[] {myInspection}; diff --git a/java/java-tests/testSrc/com/intellij/lang/java/lexer/JavaLexerTest.java b/java/java-tests/testSrc/com/intellij/lang/java/lexer/JavaLexerTest.java index b1639bc4b4be..113211720e39 100644 --- a/java/java-tests/testSrc/com/intellij/lang/java/lexer/JavaLexerTest.java +++ b/java/java-tests/testSrc/com/intellij/lang/java/lexer/JavaLexerTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -52,6 +52,17 @@ public class JavaLexerTest extends LexerTestCase { "DOUBLE_LITERAL ('3.14')\nWHITE_SPACE (' ')\n" + "DOUBLE_LITERAL ('1e-9d')\nWHITE_SPACE (' ')\n" + "DOUBLE_LITERAL ('1e137')"); + + doTest(". e0 x1 ax .e .p 08 .0e .0f", + "DOT ('.')\nWHITE_SPACE (' ')\n" + + "IDENTIFIER ('e0')\nWHITE_SPACE (' ')\n" + + "IDENTIFIER ('x1')\nWHITE_SPACE (' ')\n" + + "IDENTIFIER ('ax')\nWHITE_SPACE (' ')\n" + + "DOT ('.')\nIDENTIFIER ('e')\nWHITE_SPACE (' ')\n" + + "DOT ('.')\nIDENTIFIER ('p')\nWHITE_SPACE (' ')\n" + + "INTEGER_LITERAL ('08')\nWHITE_SPACE (' ')\n" + + "DOUBLE_LITERAL ('.0e')\nWHITE_SPACE (' ')\n" + + "FLOAT_LITERAL ('.0f')"); } public void testTigerNumericLiterals() { @@ -66,6 +77,9 @@ public class JavaLexerTest extends LexerTestCase { "DOUBLE_LITERAL ('0xab.P12')\nWHITE_SPACE (' ')\n" + "DOUBLE_LITERAL ('0x.abcP123d')\nWHITE_SPACE (' ')\n" + "DOUBLE_LITERAL ('0xabc.defP1234D')"); + + doTest("p0", + "IDENTIFIER ('p0')"); } public void testCoinNumericLiterals() { @@ -116,15 +130,18 @@ public class JavaLexerTest extends LexerTestCase { } public void testMalformedCoinLiterals() { - doTest("0_ _1 0_8 0x_f 0b_1 0B2 0x1.0_p-1 1.0e_1022", - "INTEGER_LITERAL ('0')\nIDENTIFIER ('_')\nWHITE_SPACE (' ')\n" + + doTest("_1 _b ._ 0_ 0_8 0x_f 0b_1 0B2 0x1.0_p-1 1.0e_1022 0._1", "IDENTIFIER ('_1')\nWHITE_SPACE (' ')\n" + - "INTEGER_LITERAL ('0')\nIDENTIFIER ('_8')\nWHITE_SPACE (' ')\n" + - "INTEGER_LITERAL ('0x')\nIDENTIFIER ('_f')\nWHITE_SPACE (' ')\n" + - "INTEGER_LITERAL ('0b')\nIDENTIFIER ('_1')\nWHITE_SPACE (' ')\n" + - "INTEGER_LITERAL ('0B')\nINTEGER_LITERAL ('2')\nWHITE_SPACE (' ')\n" + - "INTEGER_LITERAL ('0x1')\nDOUBLE_LITERAL ('.0')\nIDENTIFIER ('_p')\nMINUS ('-')\nINTEGER_LITERAL ('1')\nWHITE_SPACE (' ')\n" + - "DOUBLE_LITERAL ('1.0e')\nIDENTIFIER ('_1022')"); + "IDENTIFIER ('_b')\nWHITE_SPACE (' ')\n" + + "DOT ('.')\nIDENTIFIER ('_')\nWHITE_SPACE (' ')\n" + + "INTEGER_LITERAL ('0_')\nWHITE_SPACE (' ')\n" + + "INTEGER_LITERAL ('0_8')\nWHITE_SPACE (' ')\n" + + "INTEGER_LITERAL ('0x_f')\nWHITE_SPACE (' ')\n" + + "INTEGER_LITERAL ('0b_1')\nWHITE_SPACE (' ')\n" + + "INTEGER_LITERAL ('0B2')\nWHITE_SPACE (' ')\n" + + "DOUBLE_LITERAL ('0x1.0_p-1')\nWHITE_SPACE (' ')\n" + + "DOUBLE_LITERAL ('1.0e_1022')\nWHITE_SPACE (' ')\n" + + "DOUBLE_LITERAL ('0._1')"); } public void testMalformedOperators() { diff --git a/java/java-tests/testSrc/com/intellij/openapi/roots/impl/DirectoryIndexTest.java b/java/java-tests/testSrc/com/intellij/openapi/roots/impl/DirectoryIndexTest.java index 88151e01c8fd..072e6b3ff52a 100644 --- a/java/java-tests/testSrc/com/intellij/openapi/roots/impl/DirectoryIndexTest.java +++ b/java/java-tests/testSrc/com/intellij/openapi/roots/impl/DirectoryIndexTest.java @@ -168,6 +168,8 @@ public class DirectoryIndexTest extends IdeaTestCase { }); myIndex = DirectoryIndex.getInstance(myProject); + // to not interfere with previous test firing vfs events + VirtualFileManager.getInstance().syncRefresh(); } private CompilerProjectExtension getCompilerProjectExtension() { diff --git a/java/java-tests/testSrc/com/intellij/psi/CoreJavaFileManagerTest.java b/java/java-tests/testSrc/com/intellij/psi/CoreJavaFileManagerTest.java new file mode 100644 index 000000000000..1cd630ccc2db --- /dev/null +++ b/java/java-tests/testSrc/com/intellij/psi/CoreJavaFileManagerTest.java @@ -0,0 +1,68 @@ +/* + * Copyright 2000-2013 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.psi; + +import com.intellij.core.CoreJavaFileManager; +import com.intellij.ide.highlighter.JavaFileType; +import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.psi.search.GlobalSearchScope; +import com.intellij.testFramework.PsiTestCase; +import com.intellij.testFramework.PsiTestUtil; + + +public class CoreJavaFileManagerTest extends PsiTestCase { + + public void testNotNullInnerClass() throws Exception { + VirtualFile root = PsiTestUtil.createTestProjectStructure(myProject, myModule, myFilesToDelete); + VirtualFile pkg = root.createChildDirectory(this, "foo"); + PsiDirectory dir = myPsiManager.findDirectory(pkg); + assertNotNull(dir); + String text = "package foo;\n\n" + + "public class Nested {\n" + + "public class InnerGeneral {}\n" + + "public class Inner$ {}\n" + + "\n" + + "public Inner$ inner() {\n" + + " return new Inner$();\n" + + "}\n" + + "\n" + + "}"; + PsiElement created = dir.add(PsiFileFactory.getInstance(getProject()).createFileFromText("Nested.java", JavaFileType.INSTANCE, text)); + + GlobalSearchScope scope = GlobalSearchScope.allScope(getProject()); + CoreJavaFileManager manager = new CoreJavaFileManager(myPsiManager); + manager.addToClasspath(root); + + PsiClass clazz = manager.findClass("foo.Nested", scope); + assertNotNull(clazz); + + PsiClass clazzInnerGeneral = manager.findClass("foo.Nested.InnerGeneral", scope); + assertNotNull(clazzInnerGeneral); + + PsiClass clazzInner$ = manager.findClass("foo.Nested.Inner$", scope); + assertNotNull(clazzInner$); + + PsiClass clazzInner$Wrong1 = manager.findClass("foo.Nested.Inner$X", scope); + assertNull(clazzInner$Wrong1); + + PsiClass clazzInner$Wrong2 = manager.findClass("foo.Nested.Inner$$X", scope); + assertNull(clazzInner$Wrong2); + + PsiClass clazzInner$Wrong3 = manager.findClass("foo.Nested.Inner$$", scope); + assertNull(clazzInner$Wrong3); + } + +} diff --git a/java/java-tests/testSrc/com/intellij/psi/PsiConcurrencyStressTest.java b/java/java-tests/testSrc/com/intellij/psi/PsiConcurrencyStressTest.java index 49fcdd73f39e..c1d20b4481c5 100644 --- a/java/java-tests/testSrc/com/intellij/psi/PsiConcurrencyStressTest.java +++ b/java/java-tests/testSrc/com/intellij/psi/PsiConcurrencyStressTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,6 +41,14 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; public class PsiConcurrencyStressTest extends PsiTestCase { + private static final boolean SKIP = "true".equalsIgnoreCase(System.getProperty("skip.psi.concurrency.test")); + + @Override + public void runBare() throws Throwable { + if (!SKIP) { + super.runBare(); + } + } @Override protected void setUp() throws Exception { diff --git a/java/java-tests/testSrc/com/intellij/psi/StubAstSwitchTest.groovy b/java/java-tests/testSrc/com/intellij/psi/StubAstSwitchTest.groovy index 2d0830edcbd5..b9a5732b83c6 100644 --- a/java/java-tests/testSrc/com/intellij/psi/StubAstSwitchTest.groovy +++ b/java/java-tests/testSrc/com/intellij/psi/StubAstSwitchTest.groovy @@ -61,10 +61,10 @@ class StubAstSwitchTest extends LightCodeInsightFixtureTestCase { } public void "test traversing PSI and switching concurrently"() { - int count = 1000 + int count = 100 List<PsiClass> classList = (0..<count).collect { myFixture.addClass("class Foo$it { " + - (0..<10).collect { "void foo$it(int i, boolean b, Object o) {}" }.join("\n") + + (0..<100).collect { "void foo$it(int i, boolean b, Object o) {}" }.join("\n") + " }") } CountDownLatch latch = new CountDownLatch(count) diff --git a/java/java-tests/testSrc/com/intellij/psi/TypesTest.java b/java/java-tests/testSrc/com/intellij/psi/TypesTest.java index 1ae10fadaeb1..1613f6344e08 100644 --- a/java/java-tests/testSrc/com/intellij/psi/TypesTest.java +++ b/java/java-tests/testSrc/com/intellij/psi/TypesTest.java @@ -454,6 +454,6 @@ public class TypesTest extends GenericsTestCase { assertEquals(PsiType.INT, plusBytePrefix.getType()); final PsiStatement declaration = factory.createStatementFromText("Byte b = 1;", null); final PsiExpression plusPlusPostfix = factory.createExpressionFromText("b++", declaration); - assertEquals(PsiType.BYTE, plusPlusPostfix.getType()); + assertEquals(PsiType.BYTE.getBoxedType(declaration), plusPlusPostfix.getType()); } } 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 2c24ba632bb7..36d6b534c67d 100644 --- a/java/java-tests/testSrc/com/intellij/psi/resolve/ResolveInLibrariesTest.groovy +++ b/java/java-tests/testSrc/com/intellij/psi/resolve/ResolveInLibrariesTest.groovy @@ -131,8 +131,8 @@ class ResolveInLibrariesTest extends JavaCodeInsightFixtureTestCase { assert fooInheritors(m1) == [fooMethod(other0), fooMethod(b1)] as Set } - private PsiMethod fooMethod(PsiClass c) { c.findMethodsByName('foo', false)[0] } - private Set<PsiMethod> fooInheritors(PsiClass c) { OverridingMethodsSearch.search(fooMethod(c)).findAll() as Set } + private static PsiMethod fooMethod(PsiClass c) { c.findMethodsByName('foo', false)[0] } + private static Set<PsiMethod> fooInheritors(PsiClass c) { OverridingMethodsSearch.search(fooMethod(c)).findAll() as Set } public void "test do not parse not stubbed sources in class jars"() { def lib = LocalFileSystem.getInstance().refreshAndFindFileByPath(PathManagerEx.getTestDataPath() + "/libResolve/classesAndSources") @@ -150,6 +150,9 @@ class ResolveInLibrariesTest extends JavaCodeInsightFixtureTestCase { Collection<VirtualFile> pkgChildren = pkgDirs.collect { it.children as List }.flatten() PsiFile javaSrc = psiManager.findFile(pkgChildren.find { it.name == 'LibraryClass.java' }) assert !javaSrc.node.parsed + + assert pkg.containsClassNamed('LibraryClass') + assert !javaSrc.node.parsed } } diff --git a/java/java-tests/testSrc/com/intellij/psi/search/UpdateCacheTest.java b/java/java-tests/testSrc/com/intellij/psi/search/UpdateCacheTest.java index 01fb2d1e512e..fe43ca04330e 100644 --- a/java/java-tests/testSrc/com/intellij/psi/search/UpdateCacheTest.java +++ b/java/java-tests/testSrc/com/intellij/psi/search/UpdateCacheTest.java @@ -19,13 +19,13 @@ import com.intellij.JavaTestUtil; import com.intellij.ide.highlighter.JavaFileType; import com.intellij.ide.impl.ProjectUtil; import com.intellij.ide.todo.TodoConfiguration; -import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.command.WriteCommandAction; import com.intellij.openapi.project.Project; import com.intellij.openapi.project.ProjectManager; import com.intellij.openapi.project.ex.ProjectManagerEx; import com.intellij.openapi.projectRoots.impl.ProjectRootUtil; -import com.intellij.openapi.roots.*; +import com.intellij.openapi.roots.ModuleRootManager; +import com.intellij.openapi.roots.ProjectRootManager; import com.intellij.openapi.roots.ex.ProjectRootManagerEx; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.vfs.LocalFileSystem; @@ -284,26 +284,7 @@ public class UpdateCacheTest extends PsiTestCase{ PsiTodoSearchHelper.SERVICE.getInstance(myProject).findFilesWithTodoItems(); // to update caches - ApplicationManager.getApplication().runWriteAction(new Runnable() { - public void run() { - final ModifiableRootModel rootModel1 = ModuleRootManager.getInstance(myModule).getModifiableModel(); - final ContentEntry[] content1 = rootModel1.getContentEntries(); - contentLoop: - for (ContentEntry contentEntry : content1) { - if (root.equals(contentEntry.getFile())) { - final ExcludeFolder[] excludeFolders = contentEntry.getExcludeFolders(); - for (ExcludeFolder excludeFolder : excludeFolders) { - if (dir.equals(excludeFolder.getFile())) { - contentEntry.removeExcludeFolder(excludeFolder); - break contentLoop; - } - } - } - } - rootModel1.commit(); - } - }); - + PsiTestUtil.removeExcludedRoot(myModule, dir); PsiClass exceptionClass = myJavaFacade.findClass("java.lang.Exception", GlobalSearchScope.allScope(getProject())); assertNotNull(exceptionClass); @@ -338,9 +319,8 @@ public class UpdateCacheTest extends PsiTestCase{ checkTodos(new String[]{"2.java", "New.java"}); } - public void testRemoveSourceRoot() throws Exception{ - final ModuleRootManager rootManager = ModuleRootManager.getInstance(myModule); - final VirtualFile root = rootManager.getContentRoots()[0]; + public void testRemoveSourceRoot() { + final VirtualFile root = ModuleRootManager.getInstance(myModule).getContentRoots()[0]; PsiTodoSearchHelper.SERVICE.getInstance(myProject).findFilesWithTodoItems(); // to initialize caches @@ -356,27 +336,9 @@ public class UpdateCacheTest extends PsiTestCase{ PsiTodoSearchHelper.SERVICE.getInstance(myProject).findFilesWithTodoItems(); // to update caches - ApplicationManager.getApplication().runWriteAction(new Runnable() { - public void run() { - VirtualFile[] sourceRoots = rootManager.getSourceRoots(); - LOG.assertTrue(sourceRoots.length == 1); - final ModifiableRootModel rootModel = ModuleRootManager.getInstance(myModule).getModifiableModel(); - final ContentEntry[] content1 = rootModel.getContentEntries(); - contentLoop: - for (ContentEntry contentEntry : content1) { - if (root.equals(contentEntry.getFile())) { - final SourceFolder[] sourceFolders = contentEntry.getSourceFolders(); - for (SourceFolder sourceFolder : sourceFolders) { - if (sourceRoots[0].equals(sourceFolder.getFile())) { - contentEntry.removeSourceFolder(sourceFolder); - break contentLoop; - } - } - } - } - rootModel.commit(); - } - }); + VirtualFile[] sourceRoots = ModuleRootManager.getInstance(myModule).getSourceRoots(); + LOG.assertTrue(sourceRoots.length == 1); + PsiTestUtil.removeSourceRoot(myModule, sourceRoots[0]); PsiClass exceptionClass = myJavaFacade.findClass("java.lang.Exception", GlobalSearchScope.allScope(getProject())); diff --git a/java/java-tests/testSrc/com/intellij/refactoring/RenameLocalTest.java b/java/java-tests/testSrc/com/intellij/refactoring/RenameLocalTest.java index a57526b3e9ba..c254828e4d36 100644 --- a/java/java-tests/testSrc/com/intellij/refactoring/RenameLocalTest.java +++ b/java/java-tests/testSrc/com/intellij/refactoring/RenameLocalTest.java @@ -109,6 +109,10 @@ public class RenameLocalTest extends LightRefactoringTestCase { doTestInplaceRename("r1"); } + public void testRenameToFieldNameInStaticContext() throws Exception { + doTestInplaceRename("myFoo"); + } + public void testRenameInPlaceInStaticContextWithConflictingField() throws Exception { doTestInplaceRename("s"); } diff --git a/java/java-tests/testSrc/com/intellij/refactoring/inline/InlineLocalTest.java b/java/java-tests/testSrc/com/intellij/refactoring/inline/InlineLocalTest.java index 0fff5440c057..a157129cbe4e 100644 --- a/java/java-tests/testSrc/com/intellij/refactoring/inline/InlineLocalTest.java +++ b/java/java-tests/testSrc/com/intellij/refactoring/inline/InlineLocalTest.java @@ -4,6 +4,7 @@ import com.intellij.JavaTestUtil; import com.intellij.codeInsight.TargetElementUtilBase; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.Project; +import com.intellij.pom.java.LanguageLevel; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiLocalVariable; import com.intellij.psi.PsiReference; @@ -221,6 +222,7 @@ public class InlineLocalTest extends LightCodeInsightTestCase { private void doTest(final boolean inlineDef) throws Exception { + setLanguageLevel(LanguageLevel.JDK_1_7); String name = getTestName(false); String fileName = "/refactoring/inlineLocal/" + name + ".java"; configureByFile(fileName); 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 98a2685d5575..b29fe84bc2c4 100644 --- a/java/java-tests/testSrc/com/intellij/refactoring/inline/InlineMethodTest.java +++ b/java/java-tests/testSrc/com/intellij/refactoring/inline/InlineMethodTest.java @@ -17,6 +17,7 @@ package com.intellij.refactoring.inline; import com.intellij.JavaTestUtil; import com.intellij.codeInsight.TargetElementUtilBase; +import com.intellij.pom.java.LanguageLevel; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiMethod; import com.intellij.psi.PsiReference; @@ -158,6 +159,7 @@ public class InlineMethodTest extends LightRefactoringTestCase { } public void testInferredType() throws Exception { + setLanguageLevel(LanguageLevel.JDK_1_7); doTest(); } |