From e647d9a6309f0ff55dec0906226f370cb23917bc Mon Sep 17 00:00:00 2001 From: anna Date: Thu, 3 Feb 2011 16:04:40 +0100 Subject: [PATCH 01/11] coverage: do not clone coverage data - it should be reread from xml (IDEA-65045) --- .../com/intellij/execution/RunConfigurationExtension.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/java/execution/impl/src/com/intellij/execution/RunConfigurationExtension.java b/java/execution/impl/src/com/intellij/execution/RunConfigurationExtension.java index e34390e6f645..3eb9d7e9f2d0 100644 --- a/java/execution/impl/src/com/intellij/execution/RunConfigurationExtension.java +++ b/java/execution/impl/src/com/intellij/execution/RunConfigurationExtension.java @@ -60,6 +60,14 @@ public abstract class RunConfigurationExtension { public abstract void patchConfiguration(RunConfigurationBase runJavaConfiguration); public abstract void checkConfiguration(RunConfigurationBase runJavaConfiguration) throws RuntimeConfigurationException; + public void cleanUserData(RunConfigurationBase runConfigurationBase) {} + + public static void cleanExtensionsUserData(RunConfigurationBase runConfigurationBase) { + for (RunConfigurationExtension extension : Extensions.getExtensions(EP_NAME)) { + extension.cleanUserData(runConfigurationBase); + } + } + public RefactoringElementListener wrapElementListener(PsiElement element, RunConfigurationBase runJavaConfiguration, RefactoringElementListener listener) { From f578b7c7df6472f68b7c748e60797408135223e5 Mon Sep 17 00:00:00 2001 From: anna Date: Mon, 7 Feb 2011 18:24:13 +0100 Subject: [PATCH 02/11] n mnemonic should not trigger no action without further checks (IDEA-65106) --- .../src/com/intellij/openapi/ui/DialogWrapper.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/platform/platform-api/src/com/intellij/openapi/ui/DialogWrapper.java b/platform/platform-api/src/com/intellij/openapi/ui/DialogWrapper.java index 105ef385b1dc..df1eef72205b 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/DialogWrapper.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/DialogWrapper.java @@ -439,10 +439,11 @@ public abstract class DialogWrapper { final Object value = action.getValue(Action.MNEMONIC_KEY); if (value instanceof Integer) { final int mnemonic = ((Integer)value).intValue(); - if (mnemonic == 'Y') { + final Object name = action.getValue(Action.NAME); + if (mnemonic == 'Y' && "Yes".equals(name)) { myYesAction = action; } - else if (mnemonic == 'N') { + else if (mnemonic == 'N' && "No".equals(name)) { myNoAction = action; } button.setMnemonic(mnemonic); @@ -496,11 +497,11 @@ public abstract class DialogWrapper { plainText.append(ch); } button.setText(plainText.toString()); - - if (mnemonic == KeyEvent.VK_Y) { + final Object name = action.getValue(Action.NAME); + if (mnemonic == KeyEvent.VK_Y && "Yes".equals(name)) { myYesAction = action; } - else if (mnemonic == KeyEvent.VK_N) { + else if (mnemonic == KeyEvent.VK_N && "No".equals(name)) { myNoAction = action; } From ee862ce037653687f087ac42656b5e03bfa1831b Mon Sep 17 00:00:00 2001 From: nik Date: Tue, 8 Feb 2011 10:23:36 +0300 Subject: [PATCH 03/11] unused JSF library removed --- lib/required_for_dist.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/required_for_dist.txt b/lib/required_for_dist.txt index 24d54ee64caa..25f054b5ccd7 100644 --- a/lib/required_for_dist.txt +++ b/lib/required_for_dist.txt @@ -21,7 +21,6 @@ looks-2.2.2.jar jcip-annotations.jar jh.jar JNIWrap.jar -jsf-api.jar jsp-api.jar junit.jar junit-4.8.jar From 8c84b14788e78a122eca6ba76584ebc9beda7a42 Mon Sep 17 00:00:00 2001 From: nik Date: Tue, 8 Feb 2011 10:24:10 +0300 Subject: [PATCH 04/11] more licenses added --- build/scripts/libLicenses.gant | 1 + 1 file changed, 1 insertion(+) diff --git a/build/scripts/libLicenses.gant b/build/scripts/libLicenses.gant index 1b47080e930f..f8f36c627ef9 100644 --- a/build/scripts/libLicenses.gant +++ b/build/scripts/libLicenses.gant @@ -148,6 +148,7 @@ libraryLicense(name: "Jakarta ORO", libraryName: "OroMatcher", version: "2.0.8", libraryLicense(name: "PicoContainer", libraryName: "picocontainer", version: "1.2", license: "BSD", url: "http://www.picocontainer.org/", licenseUrl: "http://docs.codehaus.org/display/PICO/License") libraryLicense(name: "Plexus Utils", libraryName: "plexus-utils-1.5.5.jar", version: "1.5.5", license: "Apache 2.0", url: "http://plexus.codehaus.org/plexus-utils") libraryLicense(name: "Relax NG Object Model", libraryName: "rngom-20051226-patched.jar", license: "MIT", url: "http://java.net/projects/rngom/", licenseUrl: "http://www.opensource.org/licenses/mit-license.php") +libraryLicense(name: "Sonatype Nexus: Indexer", libraryName: "nexus-indexer-1.2.3.jar", version: "1.2.3", license: "Eclipse Public License", url: "http://nexus.sonatype.org/", licenseUrl: "http://www.eclipse.org/org/documents/epl-v10.html") libraryLicense(name: "SVNKit", libraryName: "svnkit.jar", version: "SVN version, 1.1 branch as of 1 Oct 2007", license: "link (commercial license)", url: "http://www.svnkit.com/", licenseUrl: "http://svnkit.com/license.html") libraryLicense(name: "TestNG", version: "5.7 snapshot", license: "Apache 2.0", url: "http://testng.org/doc/", licenseUrl: "http://code.google.com/p/testng/") libraryLicense(name: "Trilead SSH", libraryName: "trilead-ssh2", version: "build 213", license: "BSD style (see LICENSE.txt in trilead.jar)", url: "http://www.trilead.com/SSH_Library/") From a798c2d55893541af14636bfefc5bcd3acd38c7c Mon Sep 17 00:00:00 2001 From: nik Date: Tue, 8 Feb 2011 10:51:04 +0300 Subject: [PATCH 05/11] unused dependency removed --- plugins/svn4idea/svn4idea.iml | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/svn4idea/svn4idea.iml b/plugins/svn4idea/svn4idea.iml index f67dd2fc60b3..ebf1588a452a 100644 --- a/plugins/svn4idea/svn4idea.iml +++ b/plugins/svn4idea/svn4idea.iml @@ -10,7 +10,6 @@ - From 8198ef22128576f0603126ba9b6be1178427e99d Mon Sep 17 00:00:00 2001 From: nik Date: Tue, 8 Feb 2011 11:38:44 +0300 Subject: [PATCH 06/11] use 'test' scope for junit and testng libraries --- plugins/git4idea/git4idea.iml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/git4idea/git4idea.iml b/plugins/git4idea/git4idea.iml index c923afcd21fc..100a53b37a3e 100644 --- a/plugins/git4idea/git4idea.iml +++ b/plugins/git4idea/git4idea.iml @@ -26,10 +26,10 @@ - + - + From a0a96d97a915bce4fc9b7592293729b9c10afc82 Mon Sep 17 00:00:00 2001 From: nik Date: Tue, 8 Feb 2011 12:31:25 +0300 Subject: [PATCH 07/11] message fixed --- .../configuration/projectRoot/BaseLibrariesConfigurable.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/BaseLibrariesConfigurable.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/BaseLibrariesConfigurable.java index 45a518e17f23..d7f4b443bfac 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/BaseLibrariesConfigurable.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/BaseLibrariesConfigurable.java @@ -238,9 +238,9 @@ public abstract class BaseLibrariesConfigurable extends BaseStructureConfigurabl } if (artifacts.size() > 0) { - sb.append(modules.size() > 0 ? " and in " : "."); + sb.append(modules.size() > 0 ? " and in " : ""); - if (modules.size() == 1) { + if (artifacts.size() == 1) { sb.append("artifact ").append("\"").append(artifacts.get(0)).append("\"."); } else { sb.append(artifacts.size()).append(" artifacts."); From dc07ec9460f8889824e81a5a057b9c3ad02845d9 Mon Sep 17 00:00:00 2001 From: nik Date: Tue, 8 Feb 2011 12:59:07 +0300 Subject: [PATCH 08/11] added libraries implicitly attached to modules --- build/scripts/libLicenses.gant | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/build/scripts/libLicenses.gant b/build/scripts/libLicenses.gant index f8f36c627ef9..f1f9071cdda6 100644 --- a/build/scripts/libLicenses.gant +++ b/build/scripts/libLicenses.gant @@ -3,6 +3,7 @@ import org.jetbrains.jps.* class LibraryLicense { String name, libraryName, url, version String license, licenseUrl + String attachedTo } List licensesList = [] @@ -72,7 +73,7 @@ binding.setVariable("checkLibLicensesAndGenerateTable", {String filePath -> }) binding.setVariable("generateLicensesTable", {String filePath -> - Set usedModules = project.modules.values().findAll {it["used"] != null} + Set usedModules = project.modules.values()//.findAll {it["used"] != null} Map usedLibraries = [:] usedModules.each {Module module -> module.getClasspath(ClasspathKind.PRODUCTION_RUNTIME).each {item -> @@ -82,11 +83,12 @@ binding.setVariable("generateLicensesTable", {String filePath -> } } - def licenses = licensesList.findAll {usedLibraries.containsKey(it.libraryName) } + def usedModuleNames = usedModules.collect {it.name} as Set + def licenses = licensesList.findAll {usedLibraries.containsKey(it.libraryName) || usedModuleNames.contains(it.attachedTo)} project.info("Generating licenses table") project.info("Used libraries:") List lines = [] - licenses.each { LibraryLicense lib -> + licenses.each {LibraryLicense lib -> def name = lib.url != null ? "[$lib.name|$lib.url]" : lib.name def license = lib.licenseUrl != null ? "[$lib.license|$lib.licenseUrl]" : lib.license project.info(" $lib.libraryName (in module ${usedLibraries[lib.libraryName]})") @@ -128,13 +130,14 @@ libraryLicense(name: "Gradle API", libraryName: "gradle-open-api-0.8.jar", versi libraryLicense(name: "Groovy", version: "1.7.3", license: "Apache 2.0", url: "http://groovy.codehaus.org/") libraryLicense(name: "Gson", libraryName: "gson-1.3.jar", license: "Apache 2.0", url: "http://code.google.com/p/google-gson/") libraryLicense(name: "ISO RELAX", libraryName: "isorelax.jar", license: "MIT License", url: "http://sourceforge.net/projects/iso-relax/", licenseUrl: "http://www.opensource.org/licenses/mit-license.html") -libraryLicense(name: "JavaCVS", version: "no version number available (with patches by JetBrains)", license: "Sun Public License", url: "http://javacvs.netbeans.org/library/", licenseUrl: "http://www.netbeans.org/about/legal/spl.html") +libraryLicense(name: "JavaCVS", attachedTo: "javacvs-src", version: "no version number available (with patches by JetBrains)", license: "Sun Public License", url: "http://javacvs.netbeans.org/library/", licenseUrl: "http://www.netbeans.org/about/legal/spl.html") libraryLicense(name: "JAXB", libraryName: "JAXB", version: "2.1.10", license: "CDDL 1.1 & GPL 2", url: "http://jaxb.java.net/", licenseUrl: "http://glassfish.java.net/public/CDDL+GPL_1_1.html") libraryLicense(name: "Jaxen", version: "", license: "modified Apache", url: "http://www.jaxen.org/", licenseUrl: "http://www.jaxen.org/license.html") libraryLicense(name: "JavaHelp", version: "2.0_02", license: "included as license/javahelp_license.html in IntelliJ IDEA distribution", url: "http://java.sun.com/products/javahelp/") libraryLicense(name: "JCIP Annotations", libraryName: "jcip", license: "Creative Commons Attribution License", url: "http://www.jcip.net", licenseUrl: "http://creativecommons.org/licenses/by/2.5") libraryLicense(name: "JDOM", version: "1.1 (with patches by JetBrains)", license: "modified Apache", url: "http://www.jdom.org/", licenseUrl: "http://www.jdom.org/docs/faq.html#a0030") libraryLicense(name: "JGoodies Forms", libraryName: "jgoodies-forms", version: "CVS snapshot as of 5 May 2006", license: "BSD ", url: "http://www.jgoodies.com/freeware/forms/", licenseUrl: "http://www.jgoodies.com/downloads/libraries.html") +libraryLicense(name: "JGoodies Looks", attachedTo: "platform-impl", version: "2.2.2", license: "BSD ", url: "http://www.jgoodies.com/freeware/looks/", licenseUrl: "http://www.jgoodies.com/downloads/libraries.html") libraryLicense(name: "JNA", libraryName: "jna", version: "3.2.4", license: "LGPL 2.1", url: "https://jna.dev.java.net/", licenseUrl: "http://www.opensource.org/licenses/lgpl-2.1.php") libraryLicense(name: "JNA", libraryName: "jna.jar", version: "3.2.7", license: "LGPL 2.1", url: "https://jna.dev.java.net/", licenseUrl: "http://www.opensource.org/licenses/lgpl-2.1.php") libraryLicense(name: "JUnit", libraryName: "JUnit3", version: "3.8.1", license: "CPL 1.0", url: "http://junit.org/") @@ -147,6 +150,7 @@ libraryLicense(name: "Eclipse JDT Core", libraryName: "Eclipse", version: "3.3", libraryLicense(name: "Jakarta ORO", libraryName: "OroMatcher", version: "2.0.8", license: "Apache", url: "http://jakarta.apache.org/oro/", licenseUrl: "http://svn.apache.org/repos/asf/jakarta/oro/trunk/LICENSE") libraryLicense(name: "PicoContainer", libraryName: "picocontainer", version: "1.2", license: "BSD", url: "http://www.picocontainer.org/", licenseUrl: "http://docs.codehaus.org/display/PICO/License") libraryLicense(name: "Plexus Utils", libraryName: "plexus-utils-1.5.5.jar", version: "1.5.5", license: "Apache 2.0", url: "http://plexus.codehaus.org/plexus-utils") +libraryLicense(name: "Quaqua L&F", attachedTo: "platform-impl", version: "6.2", license: "BSD", url: "http://www.randelshofer.ch/quaqua/", licenseUrl: "http://www.randelshofer.ch/quaqua/license.html") libraryLicense(name: "Relax NG Object Model", libraryName: "rngom-20051226-patched.jar", license: "MIT", url: "http://java.net/projects/rngom/", licenseUrl: "http://www.opensource.org/licenses/mit-license.php") libraryLicense(name: "Sonatype Nexus: Indexer", libraryName: "nexus-indexer-1.2.3.jar", version: "1.2.3", license: "Eclipse Public License", url: "http://nexus.sonatype.org/", licenseUrl: "http://www.eclipse.org/org/documents/epl-v10.html") libraryLicense(name: "SVNKit", libraryName: "svnkit.jar", version: "SVN version, 1.1 branch as of 1 Oct 2007", license: "link (commercial license)", url: "http://www.svnkit.com/", licenseUrl: "http://svnkit.com/license.html") From e2ca615b102f3e3f14b3a59ecb9ef238fd850a5a Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Mon, 7 Feb 2011 15:34:42 +0300 Subject: [PATCH 09/11] exception --- .../com/intellij/openapi/editor/impl/RangeHighlighterData.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/RangeHighlighterData.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/RangeHighlighterData.java index cb0fa21f512a..f8bd2a489ba2 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/RangeHighlighterData.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/RangeHighlighterData.java @@ -207,7 +207,8 @@ abstract class RangeHighlighterData { public int getAffectedAreaStartOffset() { int startOffset = getRangeHighlighter().getStartOffset(); if (getTargetArea() == HighlighterTargetArea.EXACT_RANGE) return startOffset; - if (startOffset == myModel.getDocument().getTextLength()) return startOffset; + int textLength = myModel.getDocument().getTextLength(); + if (startOffset >= textLength) return textLength; return myModel.getDocument().getLineStartOffset(myModel.getDocument().getLineNumber(startOffset)); } From be9220e9d096bbb44532645e1bb800fe9a8a4e25 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Tue, 8 Feb 2011 12:53:56 +0300 Subject: [PATCH 10/11] moved java resolve tests to community --- .../resolve/class/ClassExtendsItsInner.java | 7 + .../resolve/class/ClassExtendsItsInner1.java | 7 + .../resolve/class/ClassExtendsItsInner2.java | 3 + .../testData/psi/resolve/class/FQName.java | 3 + .../psi/resolve/class/ImportConflict1.java | 8 + .../psi/resolve/class/ImportConflict2.java | 8 + .../resolve/class/InnerPrivateMember1.java | 8 + .../testData/psi/resolve/class/Locals1.java | 7 + .../testData/psi/resolve/class/Locals2.java | 9 + .../psi/resolve/class/PrivateInExtends.java | 5 + .../testData/psi/resolve/class/QNew1.java | 10 + .../testData/psi/resolve/class/QNew2.java | 10 + .../testData/psi/resolve/class/SCR40332.java | 4 + .../testData/psi/resolve/class/Shadowing.java | 13 + .../resolve/class/StaticImportVsImplicit.java | 12 + .../psi/resolve/class/TwoModules.java | 4 + .../psi/resolve/class/TwoModules2.java | 4 + .../testData/psi/resolve/class/VarInNew.java | 5 + .../testData/psi/resolve/class/VarInNew1.java | 5 + .../class/dependentModule/src/Src.java | 1 + .../class/dependentModule/test/Test.java | 1 + .../resolve/codeFragment/LocalVariable.java | 6 + .../testData/psi/resolve/filePath/C.java | 3 + .../testData/psi/resolve/filePath/C2.java | 3 + .../psi/resolve/filePath/x/MyFile.txt | 1 + .../psi/resolve/filePath/x/y/MyClass.java | 1 + .../resolve/inference/BoundComposition.java | 7 + .../psi/resolve/inference/InferAutoboxed.java | 9 + .../psi/resolve/inference/InferInAssign1.java | 18 + .../psi/resolve/inference/InferInAssign2.java | 18 + .../psi/resolve/inference/InferInCall1.java | 20 + .../psi/resolve/inference/InferInCast.java | 18 + .../resolve/inference/InferInParamsOnly.java | 11 + .../psi/resolve/inference/InferInReturn.java | 9 + .../inference/InferInSuperAssignment.java | 10 + .../psi/resolve/inference/InferNotNull.java | 13 + .../inference/InferPrimitiveArray.java | 12 + .../psi/resolve/inference/InferRawType.java | 10 + .../psi/resolve/inference/InferUnchecked.java | 14 + .../resolve/inference/InferWithBounds.java | 8 + .../resolve/inference/InferWithBounds1.java | 9 + .../resolve/inference/InferWithVarargs1.java | 10 + .../resolve/inference/InferWithVarargs2.java | 10 + .../resolve/inference/InferWithVarargs3.java | 10 + .../resolve/inference/InferWithVarargs4.java | 10 + .../resolve/inference/InferWithVarargs5.java | 10 + .../resolve/inference/InferWithVarargs6.java | 10 + .../resolve/inference/InferWithWildcards.java | 17 + .../inference/InferWithWildcards1.java | 7 + .../inference/InferWithWildcards2.java | 25 + .../inference/InferWithWildcards3.java | 15 + .../inference/InferWithWildcards4.java | 15 + .../inference/InferWithWildcards5.java | 15 + .../psi/resolve/inference/SCR41031.java | 15 + .../psi/resolve/method/AnonymousSuper1.java | 20 + .../testData/psi/resolve/method/Array1.java | 6 + .../testData/psi/resolve/method/Bug7968.java | 21 + .../testData/psi/resolve/method/Clone.java | 17 + .../testData/psi/resolve/method/Cycle1.java | 23 + .../psi/resolve/method/EmptyConstructor.java | 5 + .../psi/resolve/method/ImplementOrder.java | 11 + .../testData/psi/resolve/method/IndexOf.java | 5 + .../method/InheranceWithExtendsConflict.java | 24 + .../testData/psi/resolve/method/Inherit1.java | 17 + .../psi/resolve/method/InnerClass.java | 12 + .../psi/resolve/method/MethodConflict1.java | 12 + .../resolve/method/MethodFromAnonBase.java | 9 + .../psi/resolve/method/NextMethod.java | 11 + .../method/NotAccessibleAccessClass.java | 17 + .../psi/resolve/method/ObjectVsInterface.java | 11 + .../psi/resolve/method/PartlyImplement1.java | 13 + .../psi/resolve/method/PreferPublic.java | 10 + .../resolve/method/PrivateInSuperInner.java | 10 + .../resolve/method/PrivateInSuperInner1.java | 10 + .../psi/resolve/method/ProtectedM.java | 10 + .../testData/psi/resolve/method/Remove1.java | 14 + .../testData/psi/resolve/method/Remove2.java | 7 + .../testData/psi/resolve/method/Remove3.java | 18 + .../testData/psi/resolve/method/Remove4.java | 11 + .../testData/psi/resolve/method/SCR5134.java | 11 + .../testData/psi/resolve/method/SCR5859.java | 27 + .../psi/resolve/method/ShortVsInt.java | 8 + .../testData/psi/resolve/method/Simple.java | 9 + .../testData/psi/resolve/method/Sout.java | 5 + .../psi/resolve/method/StaticVSNonStatic.java | 11 + .../testData/psi/resolve/method/Super1.java | 10 + .../psi/resolve/method/SuperOfObject.java | 15 + .../psi/resolve/method/TestOverloading1.java | 20 + .../psi/resolve/method/ThrowWithoutNew.java | 5 + .../psi/resolve/method/ThrowWithoutNew2.java | 5 + .../testData/psi/resolve/method/ValueOf.java | 5 + .../method/generics/AmbiguousBoxing.java | 9 + .../generics/AutoboxingAndWidening.java | 11 + .../generics/ConstructorExplicitParams.java | 9 + .../method/generics/CovariantReturnTypes.java | 13 + .../method/generics/DependingParams1.java | 6 + .../method/generics/DependingParams2.java | 14 + .../method/generics/ExplicitParams1.java | 8 + .../method/generics/ExplicitParams2.java | 8 + .../psi/resolve/method/generics/Extends1.java | 14 + .../method/generics/FilterBoxing1.java | 14 + .../generics/FilterFixedVsVarargs1.java | 14 + .../generics/FilterFixedVsVarargs2.java | 14 + .../generics/FilterFixedVsVarargs3.java | 16 + .../generics/FilterFixedVsVarargs4.java | 16 + .../generics/FilterFixedVsVarargs5.java | 18 + .../generics/FilterFixedVsVarargs6.java | 19 + .../generics/FilterFixedVsVarargs7.java | 19 + .../generics/FilterFixedVsVarargs8.java | 8 + .../generics/FilterFixedVsVarargs9.java | 14 + .../generics/FilterVarargsVsVarargs1.java | 15 + .../generics/FilterVarargsVsVarargs2.java | 9 + .../method/generics/GenericClass1.java | 9 + .../method/generics/GenericClass2.java | 12 + .../method/generics/GenericMethods1.java | 13 + .../method/generics/GenericMethods2.java | 13 + .../method/generics/GenericMethods3.java | 11 + .../method/generics/GenericMethods4.java | 11 + .../method/generics/GenericMethods5.java | 19 + .../method/generics/GenericMethods6.java | 18 + .../GenericsAndVarargsNoConflict.java | 12 + .../psi/resolve/method/generics/GetClass.java | 5 + .../method/generics/HidingSuperPrivate.java | 18 + .../resolve/method/generics/Inheritance1.java | 16 + .../resolve/method/generics/Inheritance2.java | 16 + .../resolve/method/generics/Inheritance3.java | 16 + .../resolve/method/generics/Inheritance4.java | 18 + .../psi/resolve/method/generics/Merge1.java | 14 + .../generics/MoreSpecificSameErasure.java | 20 + .../method/generics/NestedTypeParams.java | 22 + .../generics/PreferArrayTypeToObject.java | 21 + .../resolve/method/generics/RawMethod1.java | 8 + .../method/generics/RawVsGenericConflict.java | 16 + .../psi/resolve/method/generics/SOE.java | 6 + .../method/generics/StaticImportConflict.java | 9 + .../generics/StaticImportConflict1.java | 21 + .../method/generics/StaticImportDirect.java | 8 + .../method/generics/StaticImportHidden.java | 11 + .../method/generics/StaticImportOnDemand.java | 8 + .../generics/StaticMethodInSubclass.java | 23 + .../TestGenericMethodOverloading1.java | 20 + .../TestGenericMethodOverloading2.java | 17 + .../TestGenericMethodOverloading3.java | 17 + .../TestGenericMethodOverloading4.java | 17 + .../method/generics/TestReturnType1.java | 17 + .../method/generics/TestReturnType2.java | 17 + .../method/generics/TestThisExpression.java | 12 + .../method/generics/TypeInference1.java | 25 + .../generics/TypeParamBoundConflict.java | 22 + .../resolve/var/AnonymousConstructorArg.java | 10 + .../testData/psi/resolve/var/Array1.java | 6 + .../testData/psi/resolve/var/Bug7869.java | 12 + .../psi/resolve/var/FieldConflict.java | 16 + .../psi/resolve/var/FieldFromInterface.java | 12 + .../psi/resolve/var/FieldsAndLocals.java | 23 + .../psi/resolve/var/ForeachParameter.java | 7 + .../psi/resolve/var/InheritedOuter.java | 9 + .../testData/psi/resolve/var/Inner1.java | 20 + .../psi/resolve/var/InnerPrivates1.java | 9 + .../psi/resolve/var/InterfaceConflict1.java | 16 + .../psi/resolve/var/InterfaceConflict10.java | 20 + .../psi/resolve/var/InterfaceConflict11.java | 15 + .../psi/resolve/var/InterfaceConflict2.java | 19 + .../psi/resolve/var/InterfaceConflict3.java | 19 + .../psi/resolve/var/InterfaceConflict4.java | 17 + .../psi/resolve/var/InterfaceConflict5.java | 17 + .../psi/resolve/var/InterfaceConflict6.java | 17 + .../psi/resolve/var/InterfaceConflict7.java | 16 + .../psi/resolve/var/InterfaceConflict8.java | 16 + .../psi/resolve/var/InterfaceConflict9.java | 20 + .../psi/resolve/var/LocalVariable1.java | 6 + .../psi/resolve/var/PrivateOverloading.java | 20 + .../testData/psi/resolve/var/Qualified1.java | 10 + .../testData/psi/resolve/var/Qualified2.java | 7 + .../testData/psi/resolve/var/Qualified3.java | 7 + .../testData/psi/resolve/var/Qualified4.java | 9 + .../testData/psi/resolve/var/RefInOuter.java | 8 + .../testData/psi/resolve/var/RefInSuper.java | 8 + .../resolve/var/ShadowFieldsInHierarchy.java | 20 + .../resolve/var/ShadowFieldsInHierarchy2.java | 18 + .../testData/psi/resolve/var/Unresolved1.java | 5 + .../testData/psi/resolve/var/Visibility1.java | 9 + .../testData/psi/resolve/var/Visibility2.java | 3 + .../testData/psi/resolve/var/Visibility3.java | 12 + .../testData/psi/resolve/var/Visibility4.java | 5 + .../testData/psi/resolve/var/Visibility5.java | 5 + .../testData/psi/resolve/var/Visibility6.java | 11 + .../resolve/var15/DuplicateStaticImport.java | 8 + .../psi/resolve/var15/RhombExtending.java | 15 + .../psi/resolve/FilePathResolveTest.java | 43 ++ .../psi/resolve/Resolve15TestCase.java | 30 + .../psi/resolve/ResolveClassTest.java | 184 ++++++ .../resolve/ResolveInCodeFragmentTest.java | 48 ++ .../psi/resolve/ResolveMethod15Test.java | 532 ++++++++++++++++++ .../psi/resolve/ResolveMethodTest.java | 265 +++++++++ .../psi/resolve/ResolveVariable15Test.java | 36 ++ .../psi/resolve/ResolveVariableTest.java | 255 +++++++++ .../psi/resolve/TypeInferenceTest.java | 157 ++++++ 198 files changed, 3836 insertions(+) create mode 100644 java/java-tests/testData/psi/resolve/class/ClassExtendsItsInner.java create mode 100644 java/java-tests/testData/psi/resolve/class/ClassExtendsItsInner1.java create mode 100644 java/java-tests/testData/psi/resolve/class/ClassExtendsItsInner2.java create mode 100644 java/java-tests/testData/psi/resolve/class/FQName.java create mode 100644 java/java-tests/testData/psi/resolve/class/ImportConflict1.java create mode 100644 java/java-tests/testData/psi/resolve/class/ImportConflict2.java create mode 100644 java/java-tests/testData/psi/resolve/class/InnerPrivateMember1.java create mode 100644 java/java-tests/testData/psi/resolve/class/Locals1.java create mode 100644 java/java-tests/testData/psi/resolve/class/Locals2.java create mode 100644 java/java-tests/testData/psi/resolve/class/PrivateInExtends.java create mode 100644 java/java-tests/testData/psi/resolve/class/QNew1.java create mode 100644 java/java-tests/testData/psi/resolve/class/QNew2.java create mode 100644 java/java-tests/testData/psi/resolve/class/SCR40332.java create mode 100644 java/java-tests/testData/psi/resolve/class/Shadowing.java create mode 100644 java/java-tests/testData/psi/resolve/class/StaticImportVsImplicit.java create mode 100644 java/java-tests/testData/psi/resolve/class/TwoModules.java create mode 100644 java/java-tests/testData/psi/resolve/class/TwoModules2.java create mode 100644 java/java-tests/testData/psi/resolve/class/VarInNew.java create mode 100644 java/java-tests/testData/psi/resolve/class/VarInNew1.java create mode 100644 java/java-tests/testData/psi/resolve/class/dependentModule/src/Src.java create mode 100644 java/java-tests/testData/psi/resolve/class/dependentModule/test/Test.java create mode 100644 java/java-tests/testData/psi/resolve/codeFragment/LocalVariable.java create mode 100644 java/java-tests/testData/psi/resolve/filePath/C.java create mode 100644 java/java-tests/testData/psi/resolve/filePath/C2.java create mode 100644 java/java-tests/testData/psi/resolve/filePath/x/MyFile.txt create mode 100644 java/java-tests/testData/psi/resolve/filePath/x/y/MyClass.java create mode 100644 java/java-tests/testData/psi/resolve/inference/BoundComposition.java create mode 100644 java/java-tests/testData/psi/resolve/inference/InferAutoboxed.java create mode 100644 java/java-tests/testData/psi/resolve/inference/InferInAssign1.java create mode 100644 java/java-tests/testData/psi/resolve/inference/InferInAssign2.java create mode 100644 java/java-tests/testData/psi/resolve/inference/InferInCall1.java create mode 100644 java/java-tests/testData/psi/resolve/inference/InferInCast.java create mode 100644 java/java-tests/testData/psi/resolve/inference/InferInParamsOnly.java create mode 100644 java/java-tests/testData/psi/resolve/inference/InferInReturn.java create mode 100644 java/java-tests/testData/psi/resolve/inference/InferInSuperAssignment.java create mode 100644 java/java-tests/testData/psi/resolve/inference/InferNotNull.java create mode 100644 java/java-tests/testData/psi/resolve/inference/InferPrimitiveArray.java create mode 100644 java/java-tests/testData/psi/resolve/inference/InferRawType.java create mode 100644 java/java-tests/testData/psi/resolve/inference/InferUnchecked.java create mode 100644 java/java-tests/testData/psi/resolve/inference/InferWithBounds.java create mode 100644 java/java-tests/testData/psi/resolve/inference/InferWithBounds1.java create mode 100644 java/java-tests/testData/psi/resolve/inference/InferWithVarargs1.java create mode 100644 java/java-tests/testData/psi/resolve/inference/InferWithVarargs2.java create mode 100644 java/java-tests/testData/psi/resolve/inference/InferWithVarargs3.java create mode 100644 java/java-tests/testData/psi/resolve/inference/InferWithVarargs4.java create mode 100644 java/java-tests/testData/psi/resolve/inference/InferWithVarargs5.java create mode 100644 java/java-tests/testData/psi/resolve/inference/InferWithVarargs6.java create mode 100644 java/java-tests/testData/psi/resolve/inference/InferWithWildcards.java create mode 100644 java/java-tests/testData/psi/resolve/inference/InferWithWildcards1.java create mode 100644 java/java-tests/testData/psi/resolve/inference/InferWithWildcards2.java create mode 100644 java/java-tests/testData/psi/resolve/inference/InferWithWildcards3.java create mode 100644 java/java-tests/testData/psi/resolve/inference/InferWithWildcards4.java create mode 100644 java/java-tests/testData/psi/resolve/inference/InferWithWildcards5.java create mode 100644 java/java-tests/testData/psi/resolve/inference/SCR41031.java create mode 100644 java/java-tests/testData/psi/resolve/method/AnonymousSuper1.java create mode 100644 java/java-tests/testData/psi/resolve/method/Array1.java create mode 100644 java/java-tests/testData/psi/resolve/method/Bug7968.java create mode 100644 java/java-tests/testData/psi/resolve/method/Clone.java create mode 100644 java/java-tests/testData/psi/resolve/method/Cycle1.java create mode 100644 java/java-tests/testData/psi/resolve/method/EmptyConstructor.java create mode 100644 java/java-tests/testData/psi/resolve/method/ImplementOrder.java create mode 100644 java/java-tests/testData/psi/resolve/method/IndexOf.java create mode 100644 java/java-tests/testData/psi/resolve/method/InheranceWithExtendsConflict.java create mode 100644 java/java-tests/testData/psi/resolve/method/Inherit1.java create mode 100644 java/java-tests/testData/psi/resolve/method/InnerClass.java create mode 100644 java/java-tests/testData/psi/resolve/method/MethodConflict1.java create mode 100644 java/java-tests/testData/psi/resolve/method/MethodFromAnonBase.java create mode 100644 java/java-tests/testData/psi/resolve/method/NextMethod.java create mode 100644 java/java-tests/testData/psi/resolve/method/NotAccessibleAccessClass.java create mode 100644 java/java-tests/testData/psi/resolve/method/ObjectVsInterface.java create mode 100644 java/java-tests/testData/psi/resolve/method/PartlyImplement1.java create mode 100644 java/java-tests/testData/psi/resolve/method/PreferPublic.java create mode 100644 java/java-tests/testData/psi/resolve/method/PrivateInSuperInner.java create mode 100644 java/java-tests/testData/psi/resolve/method/PrivateInSuperInner1.java create mode 100644 java/java-tests/testData/psi/resolve/method/ProtectedM.java create mode 100644 java/java-tests/testData/psi/resolve/method/Remove1.java create mode 100644 java/java-tests/testData/psi/resolve/method/Remove2.java create mode 100644 java/java-tests/testData/psi/resolve/method/Remove3.java create mode 100644 java/java-tests/testData/psi/resolve/method/Remove4.java create mode 100644 java/java-tests/testData/psi/resolve/method/SCR5134.java create mode 100644 java/java-tests/testData/psi/resolve/method/SCR5859.java create mode 100644 java/java-tests/testData/psi/resolve/method/ShortVsInt.java create mode 100644 java/java-tests/testData/psi/resolve/method/Simple.java create mode 100644 java/java-tests/testData/psi/resolve/method/Sout.java create mode 100644 java/java-tests/testData/psi/resolve/method/StaticVSNonStatic.java create mode 100644 java/java-tests/testData/psi/resolve/method/Super1.java create mode 100644 java/java-tests/testData/psi/resolve/method/SuperOfObject.java create mode 100644 java/java-tests/testData/psi/resolve/method/TestOverloading1.java create mode 100644 java/java-tests/testData/psi/resolve/method/ThrowWithoutNew.java create mode 100644 java/java-tests/testData/psi/resolve/method/ThrowWithoutNew2.java create mode 100644 java/java-tests/testData/psi/resolve/method/ValueOf.java create mode 100644 java/java-tests/testData/psi/resolve/method/generics/AmbiguousBoxing.java create mode 100644 java/java-tests/testData/psi/resolve/method/generics/AutoboxingAndWidening.java create mode 100644 java/java-tests/testData/psi/resolve/method/generics/ConstructorExplicitParams.java create mode 100644 java/java-tests/testData/psi/resolve/method/generics/CovariantReturnTypes.java create mode 100644 java/java-tests/testData/psi/resolve/method/generics/DependingParams1.java create mode 100644 java/java-tests/testData/psi/resolve/method/generics/DependingParams2.java create mode 100644 java/java-tests/testData/psi/resolve/method/generics/ExplicitParams1.java create mode 100644 java/java-tests/testData/psi/resolve/method/generics/ExplicitParams2.java create mode 100644 java/java-tests/testData/psi/resolve/method/generics/Extends1.java create mode 100644 java/java-tests/testData/psi/resolve/method/generics/FilterBoxing1.java create mode 100644 java/java-tests/testData/psi/resolve/method/generics/FilterFixedVsVarargs1.java create mode 100644 java/java-tests/testData/psi/resolve/method/generics/FilterFixedVsVarargs2.java create mode 100644 java/java-tests/testData/psi/resolve/method/generics/FilterFixedVsVarargs3.java create mode 100644 java/java-tests/testData/psi/resolve/method/generics/FilterFixedVsVarargs4.java create mode 100644 java/java-tests/testData/psi/resolve/method/generics/FilterFixedVsVarargs5.java create mode 100644 java/java-tests/testData/psi/resolve/method/generics/FilterFixedVsVarargs6.java create mode 100644 java/java-tests/testData/psi/resolve/method/generics/FilterFixedVsVarargs7.java create mode 100644 java/java-tests/testData/psi/resolve/method/generics/FilterFixedVsVarargs8.java create mode 100644 java/java-tests/testData/psi/resolve/method/generics/FilterFixedVsVarargs9.java create mode 100644 java/java-tests/testData/psi/resolve/method/generics/FilterVarargsVsVarargs1.java create mode 100644 java/java-tests/testData/psi/resolve/method/generics/FilterVarargsVsVarargs2.java create mode 100644 java/java-tests/testData/psi/resolve/method/generics/GenericClass1.java create mode 100644 java/java-tests/testData/psi/resolve/method/generics/GenericClass2.java create mode 100644 java/java-tests/testData/psi/resolve/method/generics/GenericMethods1.java create mode 100644 java/java-tests/testData/psi/resolve/method/generics/GenericMethods2.java create mode 100644 java/java-tests/testData/psi/resolve/method/generics/GenericMethods3.java create mode 100644 java/java-tests/testData/psi/resolve/method/generics/GenericMethods4.java create mode 100644 java/java-tests/testData/psi/resolve/method/generics/GenericMethods5.java create mode 100644 java/java-tests/testData/psi/resolve/method/generics/GenericMethods6.java create mode 100644 java/java-tests/testData/psi/resolve/method/generics/GenericsAndVarargsNoConflict.java create mode 100644 java/java-tests/testData/psi/resolve/method/generics/GetClass.java create mode 100644 java/java-tests/testData/psi/resolve/method/generics/HidingSuperPrivate.java create mode 100644 java/java-tests/testData/psi/resolve/method/generics/Inheritance1.java create mode 100644 java/java-tests/testData/psi/resolve/method/generics/Inheritance2.java create mode 100644 java/java-tests/testData/psi/resolve/method/generics/Inheritance3.java create mode 100644 java/java-tests/testData/psi/resolve/method/generics/Inheritance4.java create mode 100644 java/java-tests/testData/psi/resolve/method/generics/Merge1.java create mode 100644 java/java-tests/testData/psi/resolve/method/generics/MoreSpecificSameErasure.java create mode 100644 java/java-tests/testData/psi/resolve/method/generics/NestedTypeParams.java create mode 100644 java/java-tests/testData/psi/resolve/method/generics/PreferArrayTypeToObject.java create mode 100644 java/java-tests/testData/psi/resolve/method/generics/RawMethod1.java create mode 100644 java/java-tests/testData/psi/resolve/method/generics/RawVsGenericConflict.java create mode 100644 java/java-tests/testData/psi/resolve/method/generics/SOE.java create mode 100644 java/java-tests/testData/psi/resolve/method/generics/StaticImportConflict.java create mode 100644 java/java-tests/testData/psi/resolve/method/generics/StaticImportConflict1.java create mode 100644 java/java-tests/testData/psi/resolve/method/generics/StaticImportDirect.java create mode 100644 java/java-tests/testData/psi/resolve/method/generics/StaticImportHidden.java create mode 100644 java/java-tests/testData/psi/resolve/method/generics/StaticImportOnDemand.java create mode 100644 java/java-tests/testData/psi/resolve/method/generics/StaticMethodInSubclass.java create mode 100644 java/java-tests/testData/psi/resolve/method/generics/TestGenericMethodOverloading1.java create mode 100644 java/java-tests/testData/psi/resolve/method/generics/TestGenericMethodOverloading2.java create mode 100644 java/java-tests/testData/psi/resolve/method/generics/TestGenericMethodOverloading3.java create mode 100644 java/java-tests/testData/psi/resolve/method/generics/TestGenericMethodOverloading4.java create mode 100644 java/java-tests/testData/psi/resolve/method/generics/TestReturnType1.java create mode 100644 java/java-tests/testData/psi/resolve/method/generics/TestReturnType2.java create mode 100644 java/java-tests/testData/psi/resolve/method/generics/TestThisExpression.java create mode 100644 java/java-tests/testData/psi/resolve/method/generics/TypeInference1.java create mode 100644 java/java-tests/testData/psi/resolve/method/generics/TypeParamBoundConflict.java create mode 100644 java/java-tests/testData/psi/resolve/var/AnonymousConstructorArg.java create mode 100644 java/java-tests/testData/psi/resolve/var/Array1.java create mode 100644 java/java-tests/testData/psi/resolve/var/Bug7869.java create mode 100644 java/java-tests/testData/psi/resolve/var/FieldConflict.java create mode 100644 java/java-tests/testData/psi/resolve/var/FieldFromInterface.java create mode 100644 java/java-tests/testData/psi/resolve/var/FieldsAndLocals.java create mode 100644 java/java-tests/testData/psi/resolve/var/ForeachParameter.java create mode 100644 java/java-tests/testData/psi/resolve/var/InheritedOuter.java create mode 100644 java/java-tests/testData/psi/resolve/var/Inner1.java create mode 100644 java/java-tests/testData/psi/resolve/var/InnerPrivates1.java create mode 100644 java/java-tests/testData/psi/resolve/var/InterfaceConflict1.java create mode 100644 java/java-tests/testData/psi/resolve/var/InterfaceConflict10.java create mode 100644 java/java-tests/testData/psi/resolve/var/InterfaceConflict11.java create mode 100644 java/java-tests/testData/psi/resolve/var/InterfaceConflict2.java create mode 100644 java/java-tests/testData/psi/resolve/var/InterfaceConflict3.java create mode 100644 java/java-tests/testData/psi/resolve/var/InterfaceConflict4.java create mode 100644 java/java-tests/testData/psi/resolve/var/InterfaceConflict5.java create mode 100644 java/java-tests/testData/psi/resolve/var/InterfaceConflict6.java create mode 100644 java/java-tests/testData/psi/resolve/var/InterfaceConflict7.java create mode 100644 java/java-tests/testData/psi/resolve/var/InterfaceConflict8.java create mode 100644 java/java-tests/testData/psi/resolve/var/InterfaceConflict9.java create mode 100644 java/java-tests/testData/psi/resolve/var/LocalVariable1.java create mode 100644 java/java-tests/testData/psi/resolve/var/PrivateOverloading.java create mode 100644 java/java-tests/testData/psi/resolve/var/Qualified1.java create mode 100644 java/java-tests/testData/psi/resolve/var/Qualified2.java create mode 100644 java/java-tests/testData/psi/resolve/var/Qualified3.java create mode 100644 java/java-tests/testData/psi/resolve/var/Qualified4.java create mode 100644 java/java-tests/testData/psi/resolve/var/RefInOuter.java create mode 100644 java/java-tests/testData/psi/resolve/var/RefInSuper.java create mode 100644 java/java-tests/testData/psi/resolve/var/ShadowFieldsInHierarchy.java create mode 100644 java/java-tests/testData/psi/resolve/var/ShadowFieldsInHierarchy2.java create mode 100644 java/java-tests/testData/psi/resolve/var/Unresolved1.java create mode 100644 java/java-tests/testData/psi/resolve/var/Visibility1.java create mode 100644 java/java-tests/testData/psi/resolve/var/Visibility2.java create mode 100644 java/java-tests/testData/psi/resolve/var/Visibility3.java create mode 100644 java/java-tests/testData/psi/resolve/var/Visibility4.java create mode 100644 java/java-tests/testData/psi/resolve/var/Visibility5.java create mode 100644 java/java-tests/testData/psi/resolve/var/Visibility6.java create mode 100644 java/java-tests/testData/psi/resolve/var15/DuplicateStaticImport.java create mode 100644 java/java-tests/testData/psi/resolve/var15/RhombExtending.java create mode 100644 java/java-tests/testSrc/com/intellij/psi/resolve/FilePathResolveTest.java create mode 100644 java/java-tests/testSrc/com/intellij/psi/resolve/Resolve15TestCase.java create mode 100644 java/java-tests/testSrc/com/intellij/psi/resolve/ResolveClassTest.java create mode 100644 java/java-tests/testSrc/com/intellij/psi/resolve/ResolveInCodeFragmentTest.java create mode 100644 java/java-tests/testSrc/com/intellij/psi/resolve/ResolveMethod15Test.java create mode 100644 java/java-tests/testSrc/com/intellij/psi/resolve/ResolveMethodTest.java create mode 100644 java/java-tests/testSrc/com/intellij/psi/resolve/ResolveVariable15Test.java create mode 100644 java/java-tests/testSrc/com/intellij/psi/resolve/ResolveVariableTest.java create mode 100644 java/java-tests/testSrc/com/intellij/psi/resolve/TypeInferenceTest.java diff --git a/java/java-tests/testData/psi/resolve/class/ClassExtendsItsInner.java b/java/java-tests/testData/psi/resolve/class/ClassExtendsItsInner.java new file mode 100644 index 000000000000..439c5594258c --- /dev/null +++ b/java/java-tests/testData/psi/resolve/class/ClassExtendsItsInner.java @@ -0,0 +1,7 @@ +class A extends A.Foo, B{ +} + +interface B{ + static class Foo{ + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/class/ClassExtendsItsInner1.java b/java/java-tests/testData/psi/resolve/class/ClassExtendsItsInner1.java new file mode 100644 index 000000000000..c5e0f4f9391e --- /dev/null +++ b/java/java-tests/testData/psi/resolve/class/ClassExtendsItsInner1.java @@ -0,0 +1,7 @@ +class A extends B.Foo implements B{ +} + +interface B{ + static class Foo{ + } +} diff --git a/java/java-tests/testData/psi/resolve/class/ClassExtendsItsInner2.java b/java/java-tests/testData/psi/resolve/class/ClassExtendsItsInner2.java new file mode 100644 index 000000000000..025240313ab4 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/class/ClassExtendsItsInner2.java @@ -0,0 +1,3 @@ +public class TTT implements Bar{ + static interface Bar{} +} diff --git a/java/java-tests/testData/psi/resolve/class/FQName.java b/java/java-tests/testData/psi/resolve/class/FQName.java new file mode 100644 index 000000000000..ba3bc1da9440 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/class/FQName.java @@ -0,0 +1,3 @@ +class Test{ + void foo() throws java.io.IOException{} +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/class/ImportConflict1.java b/java/java-tests/testData/psi/resolve/class/ImportConflict1.java new file mode 100644 index 000000000000..73ea67d423bf --- /dev/null +++ b/java/java-tests/testData/psi/resolve/class/ImportConflict1.java @@ -0,0 +1,8 @@ +import java.sql.*; +import java.util.*; + +public class ImpmortConflict1{ + public static void main(String[] args){ + Date d = new Date(); + } +} diff --git a/java/java-tests/testData/psi/resolve/class/ImportConflict2.java b/java/java-tests/testData/psi/resolve/class/ImportConflict2.java new file mode 100644 index 000000000000..653cf13eb838 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/class/ImportConflict2.java @@ -0,0 +1,8 @@ +import java.sql.*; +import java.util.Date; + +public class ImportConflict2{ + public static void main(String[] args){ + Date d = new Date(); + } +} diff --git a/java/java-tests/testData/psi/resolve/class/InnerPrivateMember1.java b/java/java-tests/testData/psi/resolve/class/InnerPrivateMember1.java new file mode 100644 index 000000000000..8d8728153b07 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/class/InnerPrivateMember1.java @@ -0,0 +1,8 @@ +class C{ + void foo(){ + class A{ + B b = null; + private class B{}; + } + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/class/Locals1.java b/java/java-tests/testData/psi/resolve/class/Locals1.java new file mode 100644 index 000000000000..53f53d580261 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/class/Locals1.java @@ -0,0 +1,7 @@ +class A{ + { + class B{} + + new B(); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/class/Locals2.java b/java/java-tests/testData/psi/resolve/class/Locals2.java new file mode 100644 index 000000000000..e300f31e14d8 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/class/Locals2.java @@ -0,0 +1,9 @@ +class A{ + { + class B{ + B b; + } + + new B(); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/class/PrivateInExtends.java b/java/java-tests/testData/psi/resolve/class/PrivateInExtends.java new file mode 100644 index 000000000000..1a9e8680db9f --- /dev/null +++ b/java/java-tests/testData/psi/resolve/class/PrivateInExtends.java @@ -0,0 +1,5 @@ +class A{ +private static class B{} +} + +class C extends A.B{} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/class/QNew1.java b/java/java-tests/testData/psi/resolve/class/QNew1.java new file mode 100644 index 000000000000..c79784a8b7dc --- /dev/null +++ b/java/java-tests/testData/psi/resolve/class/QNew1.java @@ -0,0 +1,10 @@ +class A { + { + Outer outer; + outer.new Inner(); + } +} + +class Outer{ + class Inner{} +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/class/QNew2.java b/java/java-tests/testData/psi/resolve/class/QNew2.java new file mode 100644 index 000000000000..537bc12407f7 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/class/QNew2.java @@ -0,0 +1,10 @@ +class A { + { + Outer outer; + outer.new Inner(){}; + } +} + +class Outer{ + class Inner{} +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/class/SCR40332.java b/java/java-tests/testData/psi/resolve/class/SCR40332.java new file mode 100644 index 000000000000..034275bc29d2 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/class/SCR40332.java @@ -0,0 +1,4 @@ +class C {} +class CC extends C<Inner> { + static class Inner { } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/class/Shadowing.java b/java/java-tests/testData/psi/resolve/class/Shadowing.java new file mode 100644 index 000000000000..831de207eeae --- /dev/null +++ b/java/java-tests/testData/psi/resolve/class/Shadowing.java @@ -0,0 +1,13 @@ +interface A { + class Entry {} +} + +class B implements A { + private class Entry {} +} + + +class C extends B { + static void foo(Entry e){ + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/class/StaticImportVsImplicit.java b/java/java-tests/testData/psi/resolve/class/StaticImportVsImplicit.java new file mode 100644 index 000000000000..52aacf19183c --- /dev/null +++ b/java/java-tests/testData/psi/resolve/class/StaticImportVsImplicit.java @@ -0,0 +1,12 @@ +import static Outer.Double; + +class Outer { + static class Double { + } +} + +class StaticImportTest { + public static void main(String[] args) { + Double d; + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/class/TwoModules.java b/java/java-tests/testData/psi/resolve/class/TwoModules.java new file mode 100644 index 000000000000..774251233b52 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/class/TwoModules.java @@ -0,0 +1,4 @@ +class TwoModules { + + Src src; +} diff --git a/java/java-tests/testData/psi/resolve/class/TwoModules2.java b/java/java-tests/testData/psi/resolve/class/TwoModules2.java new file mode 100644 index 000000000000..a1d2ed11f005 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/class/TwoModules2.java @@ -0,0 +1,4 @@ +class TwoModules2 { + + Test test; +} diff --git a/java/java-tests/testData/psi/resolve/class/VarInNew.java b/java/java-tests/testData/psi/resolve/class/VarInNew.java new file mode 100644 index 000000000000..97e57a47b059 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/class/VarInNew.java @@ -0,0 +1,5 @@ +class s { + public static final repeat REPEAT = new repeat(); + boolean repeat = false; + static class repeat {} +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/class/VarInNew1.java b/java/java-tests/testData/psi/resolve/class/VarInNew1.java new file mode 100644 index 000000000000..03d4582c1462 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/class/VarInNew1.java @@ -0,0 +1,5 @@ +class s { + public static final repeat REPEAT = new repeat(){}; + boolean repeat = false; + static class repeat {} +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/class/dependentModule/src/Src.java b/java/java-tests/testData/psi/resolve/class/dependentModule/src/Src.java new file mode 100644 index 000000000000..8e0b48eab908 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/class/dependentModule/src/Src.java @@ -0,0 +1 @@ +class Src {} diff --git a/java/java-tests/testData/psi/resolve/class/dependentModule/test/Test.java b/java/java-tests/testData/psi/resolve/class/dependentModule/test/Test.java new file mode 100644 index 000000000000..ef22a69f1931 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/class/dependentModule/test/Test.java @@ -0,0 +1 @@ +class Test {} diff --git a/java/java-tests/testData/psi/resolve/codeFragment/LocalVariable.java b/java/java-tests/testData/psi/resolve/codeFragment/LocalVariable.java new file mode 100644 index 000000000000..12ee72b66e8f --- /dev/null +++ b/java/java-tests/testData/psi/resolve/codeFragment/LocalVariable.java @@ -0,0 +1,6 @@ +public class Test { + public void foo() { + int i = 0; + System.out.println(i); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/filePath/C.java b/java/java-tests/testData/psi/resolve/filePath/C.java new file mode 100644 index 000000000000..f92974d1ab3d --- /dev/null +++ b/java/java-tests/testData/psi/resolve/filePath/C.java @@ -0,0 +1,3 @@ +class C { + String s = "/x/y/MyClass.java"; +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/filePath/C2.java b/java/java-tests/testData/psi/resolve/filePath/C2.java new file mode 100644 index 000000000000..6840ddc505f4 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/filePath/C2.java @@ -0,0 +1,3 @@ +class C { + String s = "x/MyFile.txt"; +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/filePath/x/MyFile.txt b/java/java-tests/testData/psi/resolve/filePath/x/MyFile.txt new file mode 100644 index 000000000000..fdd2f73c2132 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/filePath/x/MyFile.txt @@ -0,0 +1 @@ +xxxxxxxxxxxxx \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/filePath/x/y/MyClass.java b/java/java-tests/testData/psi/resolve/filePath/x/y/MyClass.java new file mode 100644 index 000000000000..a2d3a618439d --- /dev/null +++ b/java/java-tests/testData/psi/resolve/filePath/x/y/MyClass.java @@ -0,0 +1 @@ +//xxxxxxxxx \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/inference/BoundComposition.java b/java/java-tests/testData/psi/resolve/inference/BoundComposition.java new file mode 100644 index 000000000000..ab504e5f3626 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/inference/BoundComposition.java @@ -0,0 +1,7 @@ + +class Test { + private static void p( Class cl ) + { + cl.getSuperclass(); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/inference/InferAutoboxed.java b/java/java-tests/testData/psi/resolve/inference/InferAutoboxed.java new file mode 100644 index 000000000000..9ec0914bd9b7 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/inference/InferAutoboxed.java @@ -0,0 +1,9 @@ +class C { + V m(V v) { + return null; + } + + void n () { + m(10); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/inference/InferInAssign1.java b/java/java-tests/testData/psi/resolve/inference/InferInAssign1.java new file mode 100644 index 000000000000..31da41a0f0cc --- /dev/null +++ b/java/java-tests/testData/psi/resolve/inference/InferInAssign1.java @@ -0,0 +1,18 @@ +public class Seq { + public Seq() {} + + public Seq(T x, Seq xs) { + } + + static Seq nil () { + return new Seq (); + } + + static Seq cons (V x, Seq xs) { + return new Seq (x, xs); + } + + static void foo() { + Seq n = nil(); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/inference/InferInAssign2.java b/java/java-tests/testData/psi/resolve/inference/InferInAssign2.java new file mode 100644 index 000000000000..c4bc740dc1a2 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/inference/InferInAssign2.java @@ -0,0 +1,18 @@ +public class Seq { + public Seq() {} + + public Seq(T x, Seq xs) { + } + + static Seq nil () { + return new Seq (); + } + + static Seq cons (V x, Seq xs) { + return new Seq (x, xs); + } + + static void foo() { + Seq s = cons("abc", nil()); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/inference/InferInCall1.java b/java/java-tests/testData/psi/resolve/inference/InferInCall1.java new file mode 100644 index 000000000000..8ee070f3ef92 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/inference/InferInCall1.java @@ -0,0 +1,20 @@ +public class Seq { + public Seq() {} + + public Seq(T x, Seq xs) { + } + + static Seq nil () { + return new Seq (); + } + + static Seq cons (V x, Seq xs) { + return new Seq (x, xs); + } + + static void foo (Seq seq) {} + + static void foo() { + foo(nil()); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/inference/InferInCast.java b/java/java-tests/testData/psi/resolve/inference/InferInCast.java new file mode 100644 index 000000000000..50f770c79d40 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/inference/InferInCast.java @@ -0,0 +1,18 @@ +public class Seq { + public Seq() {} + + public Seq(T x, Seq xs) { + } + + static Seq nil () { + return new Seq (); + } + + static Seq cons (V x, Seq xs) { + return new Seq (x, xs); + } + + static void foo() { + (Seq)nil(); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/inference/InferInParamsOnly.java b/java/java-tests/testData/psi/resolve/inference/InferInParamsOnly.java new file mode 100644 index 000000000000..dc2dda377419 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/inference/InferInParamsOnly.java @@ -0,0 +1,11 @@ +class C { + class I {} + class A extends I {} + class B extends I {} + + T f(T t1, T t2) {return null;} + + void foo () { + Object o = f (new A(), new B ()); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/inference/InferInReturn.java b/java/java-tests/testData/psi/resolve/inference/InferInReturn.java new file mode 100644 index 000000000000..da9098d5ffb6 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/inference/InferInReturn.java @@ -0,0 +1,9 @@ +public class C { + T foo () {return null;} + + class Sub { + T foo () { + return C.this.foo(); + } + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/inference/InferInSuperAssignment.java b/java/java-tests/testData/psi/resolve/inference/InferInSuperAssignment.java new file mode 100644 index 000000000000..c79bc77a205c --- /dev/null +++ b/java/java-tests/testData/psi/resolve/inference/InferInSuperAssignment.java @@ -0,0 +1,10 @@ +class A {} +class B extends A {} + +class C { + B f() {return null;} + + void bar () { + A a = f(); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/inference/InferNotNull.java b/java/java-tests/testData/psi/resolve/inference/InferNotNull.java new file mode 100644 index 000000000000..4e4cbae20035 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/inference/InferNotNull.java @@ -0,0 +1,13 @@ +import java.util.*; + + +class SortedList extends ArrayList +{ + public static T binarySearch(List> list, T key) { + return null; + } + + public boolean add(E e){ + binarySearch(this,e); //infer E + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/inference/InferPrimitiveArray.java b/java/java-tests/testData/psi/resolve/inference/InferPrimitiveArray.java new file mode 100644 index 000000000000..2c2fc6645d02 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/inference/InferPrimitiveArray.java @@ -0,0 +1,12 @@ +class List {} + +class Test { + T extract(List l) { + return null; + } + + void foo (List l) { + extract(l); + } +} + diff --git a/java/java-tests/testData/psi/resolve/inference/InferRawType.java b/java/java-tests/testData/psi/resolve/inference/InferRawType.java new file mode 100644 index 000000000000..3252e813a9cb --- /dev/null +++ b/java/java-tests/testData/psi/resolve/inference/InferRawType.java @@ -0,0 +1,10 @@ +class G {} + +public class C { + + T f (G l) { return null;} + + void foo (G l) { + String s = f(l); + } +} diff --git a/java/java-tests/testData/psi/resolve/inference/InferUnchecked.java b/java/java-tests/testData/psi/resolve/inference/InferUnchecked.java new file mode 100644 index 000000000000..613fba51310a --- /dev/null +++ b/java/java-tests/testData/psi/resolve/inference/InferUnchecked.java @@ -0,0 +1,14 @@ +class List {} +class ArrayList extends List {} +class Comparator {} + +public class TokenStreamRewriteEngine { + public static T binarySearch(List list, T key, Comparator c) { + return null; + } + + protected void addToSortedRewriteList(String programName, String op, Comparator comparator) { + List rewrites = new ArrayList(); + binarySearch(rewrites, op, comparator); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/inference/InferWithBounds.java b/java/java-tests/testData/psi/resolve/inference/InferWithBounds.java new file mode 100644 index 000000000000..86c70b4437a4 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/inference/InferWithBounds.java @@ -0,0 +1,8 @@ +class C { + class Inner {} + T f() {return null;} + + void bar () { + Object o = f(); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/inference/InferWithBounds1.java b/java/java-tests/testData/psi/resolve/inference/InferWithBounds1.java new file mode 100644 index 000000000000..8a18221840a6 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/inference/InferWithBounds1.java @@ -0,0 +1,9 @@ +class Test { + int getValue() { + return 3; + } + + void cc() { + getValue(); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/inference/InferWithVarargs1.java b/java/java-tests/testData/psi/resolve/inference/InferWithVarargs1.java new file mode 100644 index 000000000000..f6a45fc879a8 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/inference/InferWithVarargs1.java @@ -0,0 +1,10 @@ +class C1 {} +class C2 extends C1 {} + +class C { + T foo (T... ts) { return null; } + + void bar () { + foo(new C2()); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/inference/InferWithVarargs2.java b/java/java-tests/testData/psi/resolve/inference/InferWithVarargs2.java new file mode 100644 index 000000000000..04fb22e30ac0 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/inference/InferWithVarargs2.java @@ -0,0 +1,10 @@ +class C1 {} +class C2 extends C1 {} + +class C { + T foo (T... ts) { return null; } + + void bar () { + foo(new C2(), new C1()); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/inference/InferWithVarargs3.java b/java/java-tests/testData/psi/resolve/inference/InferWithVarargs3.java new file mode 100644 index 000000000000..1e77a7dc3944 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/inference/InferWithVarargs3.java @@ -0,0 +1,10 @@ +class List {} + +class Test { + List asList(T... ts) { + return null; + } + void foo () { + asList(new int[0]); + } +} diff --git a/java/java-tests/testData/psi/resolve/inference/InferWithVarargs4.java b/java/java-tests/testData/psi/resolve/inference/InferWithVarargs4.java new file mode 100644 index 000000000000..fb144b66b191 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/inference/InferWithVarargs4.java @@ -0,0 +1,10 @@ +class List {} + +class Test { + List asList(T... ts) { + return null; + } + void foo () { + asList(new int[0], new int[0]); + } +} diff --git a/java/java-tests/testData/psi/resolve/inference/InferWithVarargs5.java b/java/java-tests/testData/psi/resolve/inference/InferWithVarargs5.java new file mode 100644 index 000000000000..2a801d7c8258 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/inference/InferWithVarargs5.java @@ -0,0 +1,10 @@ +class List {} + +class Test { + List asList(T... ts) { + return null; + } + void foo () { + asList(new Integer[0]); + } +} diff --git a/java/java-tests/testData/psi/resolve/inference/InferWithVarargs6.java b/java/java-tests/testData/psi/resolve/inference/InferWithVarargs6.java new file mode 100644 index 000000000000..8eed10afdadf --- /dev/null +++ b/java/java-tests/testData/psi/resolve/inference/InferWithVarargs6.java @@ -0,0 +1,10 @@ +class List {} + +class Test { + List asList(T... ts) { + return null; + } + void foo () { + asList(new Integer[0], new Integer[0]); + } +} diff --git a/java/java-tests/testData/psi/resolve/inference/InferWithWildcards.java b/java/java-tests/testData/psi/resolve/inference/InferWithWildcards.java new file mode 100644 index 000000000000..bbc8f8f9c359 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/inference/InferWithWildcards.java @@ -0,0 +1,17 @@ +class Collection {} +class Comparator {} + +public class Collections { + public static T min(Collection coll, Comparator comp) { + if (comp==null) + return (T)min((Collection) (Collection) coll); + + return null; + } + + public static > T min(Collection coll) { + return null; + } + + private interface SelfComparable extends Comparable {} +} diff --git a/java/java-tests/testData/psi/resolve/inference/InferWithWildcards1.java b/java/java-tests/testData/psi/resolve/inference/InferWithWildcards1.java new file mode 100644 index 000000000000..e13f6ca53cd2 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/inference/InferWithWildcards1.java @@ -0,0 +1,7 @@ +class C { + T foo (C c) {return null;} + + void bar (C c) { + foo(c); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/inference/InferWithWildcards2.java b/java/java-tests/testData/psi/resolve/inference/InferWithWildcards2.java new file mode 100644 index 000000000000..8e316f01d75c --- /dev/null +++ b/java/java-tests/testData/psi/resolve/inference/InferWithWildcards2.java @@ -0,0 +1,25 @@ +class Collection {} + +interface Bar {} + +class BarImpl implements Bar {} + +interface Foo { + Collection getElements(); +} + +class FooImpl implements Foo { + public Collection getElements() { + return null; + } +} + +public class Bazz { + public static Collection getElements(Collection> foos) { + return null; + } + + public static void failure(final Collection foos) { + getElements(foos); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/inference/InferWithWildcards3.java b/java/java-tests/testData/psi/resolve/inference/InferWithWildcards3.java new file mode 100644 index 000000000000..b163814708f1 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/inference/InferWithWildcards3.java @@ -0,0 +1,15 @@ +class X { + static class Y { + } + + static Y x(Y y) { + return null; + } + + + { + Y y1 = null; + X.x(y1); + } +} +} diff --git a/java/java-tests/testData/psi/resolve/inference/InferWithWildcards4.java b/java/java-tests/testData/psi/resolve/inference/InferWithWildcards4.java new file mode 100644 index 000000000000..9691d67adc38 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/inference/InferWithWildcards4.java @@ -0,0 +1,15 @@ +class X { + static class Y { + } + + static Y x(Y y) { + return null; + } + + + { + Y y1 = null; + X.x(y1); + } +} +} diff --git a/java/java-tests/testData/psi/resolve/inference/InferWithWildcards5.java b/java/java-tests/testData/psi/resolve/inference/InferWithWildcards5.java new file mode 100644 index 000000000000..c4b6760e5854 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/inference/InferWithWildcards5.java @@ -0,0 +1,15 @@ +class X { + static class Y { + } + + static Y x(Y> y) { + return null; + } + + + { + Y> y1 = null; + X.x(y1); + } +} +} diff --git a/java/java-tests/testData/psi/resolve/inference/SCR41031.java b/java/java-tests/testData/psi/resolve/inference/SCR41031.java new file mode 100644 index 000000000000..13ec923c993c --- /dev/null +++ b/java/java-tests/testData/psi/resolve/inference/SCR41031.java @@ -0,0 +1,15 @@ +class List{ + T get () {return null;} +} + +class CaptureTest { + private List> listOfSets; + + private void foo() { + doGenericThing(listOfSets.get(0)); + } + + public List doGenericThing(List set) { + return null; + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/method/AnonymousSuper1.java b/java/java-tests/testData/psi/resolve/method/AnonymousSuper1.java new file mode 100644 index 000000000000..4daef9f9ac6d --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/AnonymousSuper1.java @@ -0,0 +1,20 @@ +/** + * Created by IntelliJ IDEA. + * User: ik + * Date: 22.01.2003 + * Time: 11:15:19 + * To change this template use Options | File Templates. + */ +public class Test1 { + public static class A{ + protected void foo(){} + } + + public static void main(String[] args){ + new A(){ + protected void foo(){ + super.foo(); + } + }; + } +} diff --git a/java/java-tests/testData/psi/resolve/method/Array1.java b/java/java-tests/testData/psi/resolve/method/Array1.java new file mode 100644 index 000000000000..a7e828947be4 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/Array1.java @@ -0,0 +1,6 @@ +class Array{ + void foo(){ + int[] array; + array.clone(); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/method/Bug7968.java b/java/java-tests/testData/psi/resolve/method/Bug7968.java new file mode 100644 index 000000000000..ce2af8aafd5b --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/Bug7968.java @@ -0,0 +1,21 @@ + +/** + * Created by IntelliJ IDEA. + * User: ik + * Date: 22.01.2003 + * Time: 14:46:09 + * To change this template use Options | File Templates. + */ +public class Bug7968 { + public static void foo (String s, String s1, String s2, Object[] oa) + { + Bar.bar (s, s1, s2, oa); + } + class Bar + { + public static void bar (Object o, String s1, String s2, Object[] ao) {} + public static void bar (String s, String s1, String s2, Object o) {} + public static void bar (String s, String s1, String s2, Object[] ao) {} + } + +} diff --git a/java/java-tests/testData/psi/resolve/method/Clone.java b/java/java-tests/testData/psi/resolve/method/Clone.java new file mode 100644 index 000000000000..6f77c23d7da8 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/Clone.java @@ -0,0 +1,17 @@ +class Z{ + public interface A { Object clone(); } + + interface B extends A { } + + + + + class C implements B { + Object clone() { + C c = new C(); + ((A) c).clone(); + ((B) c).clone(); + return c.clone(); + } + } +} diff --git a/java/java-tests/testData/psi/resolve/method/Cycle1.java b/java/java-tests/testData/psi/resolve/method/Cycle1.java new file mode 100644 index 000000000000..aaa54e1d0163 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/Cycle1.java @@ -0,0 +1,23 @@ +public class Cycle1{ + public interface A{ + void foo(); + } + + public interface B{ + void foo(); + } + + public static class C + implements A{ + void foo(){} + } + + public static class D extends C + implements B{ + void foo(int ggg){} + + void foo1(){ + foo(); + } + } +} diff --git a/java/java-tests/testData/psi/resolve/method/EmptyConstructor.java b/java/java-tests/testData/psi/resolve/method/EmptyConstructor.java new file mode 100644 index 000000000000..652070ee8eda --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/EmptyConstructor.java @@ -0,0 +1,5 @@ +class A{ + A(){ + super(); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/method/ImplementOrder.java b/java/java-tests/testData/psi/resolve/method/ImplementOrder.java new file mode 100644 index 000000000000..5d61f06a8867 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/ImplementOrder.java @@ -0,0 +1,11 @@ +abstract public class YYY implements I,II{ + private void f(YYY y) { + II i = y.foo(); + } +} +interface I { + I foo(); +} +interface II extends I { + II foo(); +} diff --git a/java/java-tests/testData/psi/resolve/method/IndexOf.java b/java/java-tests/testData/psi/resolve/method/IndexOf.java new file mode 100644 index 000000000000..7b095dfc5030 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/IndexOf.java @@ -0,0 +1,5 @@ +class A{ + { + "aaa".indexOf('a'); + } +} diff --git a/java/java-tests/testData/psi/resolve/method/InheranceWithExtendsConflict.java b/java/java-tests/testData/psi/resolve/method/InheranceWithExtendsConflict.java new file mode 100644 index 000000000000..d3bd0d4010cc --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/InheranceWithExtendsConflict.java @@ -0,0 +1,24 @@ +/** + * Created by IntelliJ IDEA. + * User: ik + * Date: 23.01.2003 + * Time: 18:44:34 + * To change this template use Options | File Templates. + */ +public class Inner1 { + private int a(){ + return 0; + } + + private class A extends B{ + { + int j = a(); + } + } +} + +class B { + public int a(){ + return 0; + } +} diff --git a/java/java-tests/testData/psi/resolve/method/Inherit1.java b/java/java-tests/testData/psi/resolve/method/Inherit1.java new file mode 100644 index 000000000000..168db98c4f0f --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/Inherit1.java @@ -0,0 +1,17 @@ +class A{ + public int askdh(){ + return 1; + } +} + +class B extends A{ + public void askdh(){ + return 2; + } +} + +class Super1 extends B{ + { + super.askdh(); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/method/InnerClass.java b/java/java-tests/testData/psi/resolve/method/InnerClass.java new file mode 100644 index 000000000000..5846ded7141a --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/InnerClass.java @@ -0,0 +1,12 @@ +public class InnerClass { + void foo() {} + + class Inner { + void foo(int i) {} + + void bar() { + foo(); + } + } + +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/method/MethodConflict1.java b/java/java-tests/testData/psi/resolve/method/MethodConflict1.java new file mode 100644 index 000000000000..07eaeca3e58d --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/MethodConflict1.java @@ -0,0 +1,12 @@ +class A{ + interface A{} + interface B{} + + class C implements A, B{ + void foo(A a){} + void foo(B b){} + } + { + new C().foo(new C()) + } +} diff --git a/java/java-tests/testData/psi/resolve/method/MethodFromAnonBase.java b/java/java-tests/testData/psi/resolve/method/MethodFromAnonBase.java new file mode 100644 index 000000000000..9ab99d5e6a03 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/MethodFromAnonBase.java @@ -0,0 +1,9 @@ +class Test{ + { + new Runnable(){ + { + run(); + } + } + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/method/NextMethod.java b/java/java-tests/testData/psi/resolve/method/NextMethod.java new file mode 100644 index 000000000000..65711f26769a --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/NextMethod.java @@ -0,0 +1,11 @@ +class A{ + void foo(Object a, String b){ + } + + void foo(){ + foo("aaa", true); + } + + void foo(String a, boolean b){ + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/method/NotAccessibleAccessClass.java b/java/java-tests/testData/psi/resolve/method/NotAccessibleAccessClass.java new file mode 100644 index 000000000000..c47e519a1074 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/NotAccessibleAccessClass.java @@ -0,0 +1,17 @@ +class A { + B b1; + static B b2; + public class Z extends B{ + public void akshdkjasdh(){} + } + private class B{ + public void f() {} + } +} + + +class C extends A { + { + b1.f(); + } + } \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/method/ObjectVsInterface.java b/java/java-tests/testData/psi/resolve/method/ObjectVsInterface.java new file mode 100644 index 000000000000..da5d26b12155 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/ObjectVsInterface.java @@ -0,0 +1,11 @@ +import java.io.Serializable; + +interface PublicCloneable { + Object clone(); +} +interface Extension extends Serializable, PublicCloneable {} +class Test { + void foo(Extension bar) { + bar.clone(); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/method/PartlyImplement1.java b/java/java-tests/testData/psi/resolve/method/PartlyImplement1.java new file mode 100644 index 000000000000..4dc62090273d --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/PartlyImplement1.java @@ -0,0 +1,13 @@ +class A{ +public abstract class IntegerPredicateBase implements Predicate{ + public boolean applies(Object obj){ + return applies((Integer)obj); + } +} +public interface Predicate{ + boolean applies(Object obj); + boolean applies(Integer myObj); +} + +} + diff --git a/java/java-tests/testData/psi/resolve/method/PreferPublic.java b/java/java-tests/testData/psi/resolve/method/PreferPublic.java new file mode 100644 index 000000000000..3408dcf20ab5 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/PreferPublic.java @@ -0,0 +1,10 @@ +class A{ + private void foo(String s){} + public void foo(Object o){} +} + +class B{ + { + new A().foo("a"); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/method/PrivateInSuperInner.java b/java/java-tests/testData/psi/resolve/method/PrivateInSuperInner.java new file mode 100644 index 000000000000..839af0ca8536 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/PrivateInSuperInner.java @@ -0,0 +1,10 @@ +class Outer { + private void foo() {} + + static class Inner extends Outer { + void bar() { + foo(); + } + } + +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/method/PrivateInSuperInner1.java b/java/java-tests/testData/psi/resolve/method/PrivateInSuperInner1.java new file mode 100644 index 000000000000..6c0fd5e11dbf --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/PrivateInSuperInner1.java @@ -0,0 +1,10 @@ +class Outer { + private void foo() {} + + class Inner extends Outer { + void bar() { + foo(); + } + } + +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/method/ProtectedM.java b/java/java-tests/testData/psi/resolve/method/ProtectedM.java new file mode 100644 index 000000000000..b95f2ac9aeda --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/ProtectedM.java @@ -0,0 +1,10 @@ +import javax.swing.*; +import java.awt.*; + +class Xc extends JComponent { + JComponent component; + + protected void paintComponent(final Graphics g) { + component.paintComponent(g); + } +} diff --git a/java/java-tests/testData/psi/resolve/method/Remove1.java b/java/java-tests/testData/psi/resolve/method/Remove1.java new file mode 100644 index 000000000000..246ae13516f4 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/Remove1.java @@ -0,0 +1,14 @@ +public class Remove1{ + void foo(Object o){} + void foo(String o){} + public static class A extends Remove{ + void foo(Object o){ + } + void foo(String o){ + } + } + + public static void main(){ + new A().foo("aaa"); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/method/Remove2.java b/java/java-tests/testData/psi/resolve/method/Remove2.java new file mode 100644 index 000000000000..4aca68e5a1a6 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/Remove2.java @@ -0,0 +1,7 @@ +import java.util.ArrayList; +public class Remove2{ + private static ArrayList lst = new ArrayList(); + public static void main(){ + lst.remove("aaa"); + } +} diff --git a/java/java-tests/testData/psi/resolve/method/Remove3.java b/java/java-tests/testData/psi/resolve/method/Remove3.java new file mode 100644 index 000000000000..442bcf7c35d6 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/Remove3.java @@ -0,0 +1,18 @@ +package psi.resolve.method; + +import com.intellij.util.containers.trove.THashMap; + +/** + * Created by IntelliJ IDEA. + * User: ik + * Date: 17.01.2003 + * Time: 15:08:26 + * To change this template use Options | File Templates. + */ +public class Remove3{ + THashMap map = new THashMap(); + + void foo(){ + map.size(); + } +} diff --git a/java/java-tests/testData/psi/resolve/method/Remove4.java b/java/java-tests/testData/psi/resolve/method/Remove4.java new file mode 100644 index 000000000000..6981c7f2804d --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/Remove4.java @@ -0,0 +1,11 @@ +package ; + +/** + * Created by IntelliJ IDEA. + * User: ik + * Date: 17.01.2003 + * Time: 19:11:56 + * To change this template use Options | File Templates. + */ +public class Remove4 { +} diff --git a/java/java-tests/testData/psi/resolve/method/SCR5134.java b/java/java-tests/testData/psi/resolve/method/SCR5134.java new file mode 100644 index 000000000000..b180b6eb62c4 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/SCR5134.java @@ -0,0 +1,11 @@ +interface I { + boolean foo(Object obj); + + boolean foo(Integer myObj); +} + +abstract class C implements I { + public boolean foo(Object obj) { + return foo((Integer)obj); + } +} diff --git a/java/java-tests/testData/psi/resolve/method/SCR5859.java b/java/java-tests/testData/psi/resolve/method/SCR5859.java new file mode 100644 index 000000000000..3fe506e51da9 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/SCR5859.java @@ -0,0 +1,27 @@ + +class Base { +} + +class Derived extends Base { +} + +class Server { + static Base sub(Base p1, Base p2) { + } + + static Derived sub(Derived p1, Base p2) { + } + + static Derived sub(Base p1, Derived p2) { + } + + static Derived sub(Derived p1, Derived p2) { + } +} + +class Client { + { + Derived arg = null; + Server.sub(arg, arg); + } +} diff --git a/java/java-tests/testData/psi/resolve/method/ShortVsInt.java b/java/java-tests/testData/psi/resolve/method/ShortVsInt.java new file mode 100644 index 000000000000..1abf64b0c6d9 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/ShortVsInt.java @@ -0,0 +1,8 @@ +class A{ + String toHex(int i) {} + String toHex(short i) {} + + void f(){ + toHex('i'); + } +} diff --git a/java/java-tests/testData/psi/resolve/method/Simple.java b/java/java-tests/testData/psi/resolve/method/Simple.java new file mode 100644 index 000000000000..8109ff99e9c7 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/Simple.java @@ -0,0 +1,9 @@ +public class Simple { + public void method(String s) { + } + + static { + Simple a = new Simple(); + a.method("blah"); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/method/Sout.java b/java/java-tests/testData/psi/resolve/method/Sout.java new file mode 100644 index 000000000000..e9f8799fc6b2 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/Sout.java @@ -0,0 +1,5 @@ +class Sout { + static { + System.out.println(); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/method/StaticVSNonStatic.java b/java/java-tests/testData/psi/resolve/method/StaticVSNonStatic.java new file mode 100644 index 000000000000..55c966d88083 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/StaticVSNonStatic.java @@ -0,0 +1,11 @@ + public class Foo { + public void foo() {} + + public static void foo(char c){} +} + +class A{ + { + Foo.foo(); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/method/Super1.java b/java/java-tests/testData/psi/resolve/method/Super1.java new file mode 100644 index 000000000000..9ea317a40945 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/Super1.java @@ -0,0 +1,10 @@ +class A{ + public void askdh(){ + } +} + +class Super1 extends A{ + { + super.askdh(); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/method/SuperOfObject.java b/java/java-tests/testData/psi/resolve/method/SuperOfObject.java new file mode 100644 index 000000000000..3793a9b1d275 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/SuperOfObject.java @@ -0,0 +1,15 @@ +interface I { + Object clone(); +} + +interface J extends I { +} + +class CBase implements I { +} + +class C extends CBase implements J { + { + super.clone(); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/method/TestOverloading1.java b/java/java-tests/testData/psi/resolve/method/TestOverloading1.java new file mode 100644 index 000000000000..859040799d83 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/TestOverloading1.java @@ -0,0 +1,20 @@ + +/** + * Created by IntelliJ IDEA. + * User: ik + * Date: 28.05.2003 + * Time: 16:24:03 + * To change this template use Options | File Templates. + */ +public class TestOverloading1 { + class A{ + void foo(){} + } + class B extends A{ + void foo(){} + } + + { + new B().foo(1); + } +} diff --git a/java/java-tests/testData/psi/resolve/method/ThrowWithoutNew.java b/java/java-tests/testData/psi/resolve/method/ThrowWithoutNew.java new file mode 100644 index 000000000000..71baf795c785 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/ThrowWithoutNew.java @@ -0,0 +1,5 @@ +class A{ + void foo() throws Exception{ + throw Exception(); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/method/ThrowWithoutNew2.java b/java/java-tests/testData/psi/resolve/method/ThrowWithoutNew2.java new file mode 100644 index 000000000000..71baf795c785 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/ThrowWithoutNew2.java @@ -0,0 +1,5 @@ +class A{ + void foo() throws Exception{ + throw Exception(); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/method/ValueOf.java b/java/java-tests/testData/psi/resolve/method/ValueOf.java new file mode 100644 index 000000000000..0292b5871408 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/ValueOf.java @@ -0,0 +1,5 @@ +class A{ + void foo(){ + String.valueOf(1); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/method/generics/AmbiguousBoxing.java b/java/java-tests/testData/psi/resolve/method/generics/AmbiguousBoxing.java new file mode 100644 index 000000000000..2b565f7dbfba --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/generics/AmbiguousBoxing.java @@ -0,0 +1,9 @@ +public class Ambiguous { + void f(Object o1, Object o2) {} + void f(int o1, int o2) {} + + void g(Integer i) + { + f(1, i); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/method/generics/AutoboxingAndWidening.java b/java/java-tests/testData/psi/resolve/method/generics/AutoboxingAndWidening.java new file mode 100644 index 000000000000..bd0fd5ee0a56 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/generics/AutoboxingAndWidening.java @@ -0,0 +1,11 @@ +public class Foo { + + public void foo(Comparable c) { + } + + + { + foo(1L); + } + +} diff --git a/java/java-tests/testData/psi/resolve/method/generics/ConstructorExplicitParams.java b/java/java-tests/testData/psi/resolve/method/generics/ConstructorExplicitParams.java new file mode 100644 index 000000000000..6de818552a09 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/generics/ConstructorExplicitParams.java @@ -0,0 +1,9 @@ +class Foo { + Foo(T t) { + + } + + static { + Foo f = new Foo(); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/method/generics/CovariantReturnTypes.java b/java/java-tests/testData/psi/resolve/method/generics/CovariantReturnTypes.java new file mode 100644 index 000000000000..095f908e21c7 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/generics/CovariantReturnTypes.java @@ -0,0 +1,13 @@ +interface F { + Object o(); +} +interface E extends F { + String o(); +} +interface B extends E,F { } + +class User { + void x(B a) { + String o = a.o(); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/method/generics/DependingParams1.java b/java/java-tests/testData/psi/resolve/method/generics/DependingParams1.java new file mode 100644 index 000000000000..df0475cdb3c0 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/generics/DependingParams1.java @@ -0,0 +1,6 @@ + class X { + class XX extends X {} + void f(X x, T t) { + f(new XX(), new X()); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/method/generics/DependingParams2.java b/java/java-tests/testData/psi/resolve/method/generics/DependingParams2.java new file mode 100644 index 000000000000..ccff1ff4e762 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/generics/DependingParams2.java @@ -0,0 +1,14 @@ +interface Runnable{} +interface Class{} + +public class Foo implements Runnable{ + static void foo(Class aClass, T t) { } + + Class getC(){ return new Class(){};} + public void run() { + } + + { + foo(new Class(){}, this); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/method/generics/ExplicitParams1.java b/java/java-tests/testData/psi/resolve/method/generics/ExplicitParams1.java new file mode 100644 index 000000000000..f9c022ebd47b --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/generics/ExplicitParams1.java @@ -0,0 +1,8 @@ +class Foo { + T f() { + } + + { + this.f(); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/method/generics/ExplicitParams2.java b/java/java-tests/testData/psi/resolve/method/generics/ExplicitParams2.java new file mode 100644 index 000000000000..33a9cf6bc406 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/generics/ExplicitParams2.java @@ -0,0 +1,8 @@ +class Foo { + Foo f() { + } + + static { + new Foo().f(); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/method/generics/Extends1.java b/java/java-tests/testData/psi/resolve/method/generics/Extends1.java new file mode 100644 index 000000000000..ddf45a8a857f --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/generics/Extends1.java @@ -0,0 +1,14 @@ + +class Test{ + interface Map{ + K put(K k, V v); + } + + class HashMap implements Map{ + } + + { + HashMap map = new HashMap(); + map.put(new Integer(1), new Integer(1)).byteValue(); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/method/generics/FilterBoxing1.java b/java/java-tests/testData/psi/resolve/method/generics/FilterBoxing1.java new file mode 100644 index 000000000000..cb4517f9c828 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/generics/FilterBoxing1.java @@ -0,0 +1,14 @@ +class Test1 { + public static void method(Object o, boolean b) { + System.out.println("Object"); + } + + public static void method(String s, Object o) { + System.out.println("String"); + } + + public static void main(String[] args) { + method("Hello, World", false); + } + +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/method/generics/FilterFixedVsVarargs1.java b/java/java-tests/testData/psi/resolve/method/generics/FilterFixedVsVarargs1.java new file mode 100644 index 000000000000..e875b2ee5616 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/generics/FilterFixedVsVarargs1.java @@ -0,0 +1,14 @@ + class Cast { + public void f(Object o1, String ... o) { + + } + + public void f(String s, Integer o) { + + } + + public void g() { +// Code is green - but we need a cast here + f(null, null); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/method/generics/FilterFixedVsVarargs2.java b/java/java-tests/testData/psi/resolve/method/generics/FilterFixedVsVarargs2.java new file mode 100644 index 000000000000..eb38a09fc109 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/generics/FilterFixedVsVarargs2.java @@ -0,0 +1,14 @@ + class Cast { + public void f(String ... o) { + + } + + public void f(Integer o) { + + } + + public void g() { +// Code is green - but we need a cast here + f(null); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/method/generics/FilterFixedVsVarargs3.java b/java/java-tests/testData/psi/resolve/method/generics/FilterFixedVsVarargs3.java new file mode 100644 index 000000000000..5156f69a043e --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/generics/FilterFixedVsVarargs3.java @@ -0,0 +1,16 @@ +class A {} +class B extends A{} +class Cast { + public void f(A... o) { + + } + + public void f(A o) { + + } + + public void g() { +// Code is green - but we need a cast here + f(null); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/method/generics/FilterFixedVsVarargs4.java b/java/java-tests/testData/psi/resolve/method/generics/FilterFixedVsVarargs4.java new file mode 100644 index 000000000000..87d51f04fefe --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/generics/FilterFixedVsVarargs4.java @@ -0,0 +1,16 @@ +class A {} +class B extends A{} +class Cast { + public void f(A... o) { + + } + + public void f(A o) { + + } + + public void g() { +// Casts ensures correct candidates filtering + f((A) null); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/method/generics/FilterFixedVsVarargs5.java b/java/java-tests/testData/psi/resolve/method/generics/FilterFixedVsVarargs5.java new file mode 100644 index 000000000000..ccb839da3346 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/generics/FilterFixedVsVarargs5.java @@ -0,0 +1,18 @@ +import java.util.List; + +class A { + static List listOf(String... elements) { + System.out.println("in varargs"); + return null; + } + + static List listOf(Object elements) { + System.out.println("in nonvarargs"); + return null; + } + + public static void main(String[] args) { + //resolves to nonvarargs method + List uhoh = listOf(""); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/method/generics/FilterFixedVsVarargs6.java b/java/java-tests/testData/psi/resolve/method/generics/FilterFixedVsVarargs6.java new file mode 100644 index 000000000000..8d0eb4fb8e6b --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/generics/FilterFixedVsVarargs6.java @@ -0,0 +1,19 @@ +import java.util.List; + +class A { + static List listOf(T... elements) { + System.out.println("in varargs"); + return null; + } + + static List listOf(T elements) { + System.out.println("in nonvarargs"); + return null; + } + + public static void main(String[] args) { + String[] array = {"foo", "bar"}; + //resolves to varargs method + List uhoh = listOf(array); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/method/generics/FilterFixedVsVarargs7.java b/java/java-tests/testData/psi/resolve/method/generics/FilterFixedVsVarargs7.java new file mode 100644 index 000000000000..3492c46470aa --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/generics/FilterFixedVsVarargs7.java @@ -0,0 +1,19 @@ +import java.util.List; + + class A { + static List listOf(T[]... elements) { + System.out.println("in multiple"); + return Arrays.asList(elements); + } + + static List listOf(T[] elements) { + System.out.println("in single"); + return Collections.singletonList(elements); + } + + public static void main(String[] args) { + String[] array = {"foo", "bar"}; + //resolves to nonvarargs method + List listOfString = listOf(array); + } + } diff --git a/java/java-tests/testData/psi/resolve/method/generics/FilterFixedVsVarargs8.java b/java/java-tests/testData/psi/resolve/method/generics/FilterFixedVsVarargs8.java new file mode 100644 index 000000000000..509e6fd0d39b --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/generics/FilterFixedVsVarargs8.java @@ -0,0 +1,8 @@ +class HH { + HH(Object o1, Object o2) { + this(o1, o2); + } + + + HH(Object... os) {} +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/method/generics/FilterFixedVsVarargs9.java b/java/java-tests/testData/psi/resolve/method/generics/FilterFixedVsVarargs9.java new file mode 100644 index 000000000000..90d83fac4196 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/generics/FilterFixedVsVarargs9.java @@ -0,0 +1,14 @@ + class ParentOf { + public static T getParentOfType(PsiElement element, Class aClass, boolean strict) { + return null; + } + public static T getParentOfType(PsiElement element, Class... classes) { + return null; + } + + void f(PsiElement e) { + getParentOfType(e, PsiElement.class, PsiElement.class); + } + + static class PsiElement {} + } diff --git a/java/java-tests/testData/psi/resolve/method/generics/FilterVarargsVsVarargs1.java b/java/java-tests/testData/psi/resolve/method/generics/FilterVarargsVsVarargs1.java new file mode 100644 index 000000000000..67c854ba4654 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/generics/FilterVarargsVsVarargs1.java @@ -0,0 +1,15 @@ +class XY { + public static Object getLocalizedObject(Object... objects) { + System.out.println("in first"); + return null; + } + + public static Object getLocalizedObject(Integer i, String string, Object... objects) { + System.out.println("in second"); + return null; + } + + public static void main(String[] args) { + getLocalizedObject(null, ""); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/method/generics/FilterVarargsVsVarargs2.java b/java/java-tests/testData/psi/resolve/method/generics/FilterVarargsVsVarargs2.java new file mode 100644 index 000000000000..0c19a2a3e4ae --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/generics/FilterVarargsVsVarargs2.java @@ -0,0 +1,9 @@ +class XY { + private void f(byte... bs) {} + + private void f(int... is) {} + + public static void main(String[] args) { + f((byte)0, (byte)1); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/method/generics/GenericClass1.java b/java/java-tests/testData/psi/resolve/method/generics/GenericClass1.java new file mode 100644 index 000000000000..d21803b47af9 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/generics/GenericClass1.java @@ -0,0 +1,9 @@ +interface Foo extends Comparable { + void compareTo(Foo foo); +} + +class User { + void foo (Foo foo) { + foo.compareTo(foo); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/method/generics/GenericClass2.java b/java/java-tests/testData/psi/resolve/method/generics/GenericClass2.java new file mode 100644 index 000000000000..229778721f30 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/generics/GenericClass2.java @@ -0,0 +1,12 @@ +import java.util.*; + +class Foo { + void f(ArrayList t) {} + void f(List t) {} +} + +class User { + void foo (Foo foo) { + foo.f(new ArrayList()); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/method/generics/GenericMethods1.java b/java/java-tests/testData/psi/resolve/method/generics/GenericMethods1.java new file mode 100644 index 000000000000..232c243fb358 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/generics/GenericMethods1.java @@ -0,0 +1,13 @@ +import java.util.*; + +public class AAA { + void f(java.util.List t) { + } + + void f(Collection s) { + } + + void y(List strings) { + f(strings); + } +} diff --git a/java/java-tests/testData/psi/resolve/method/generics/GenericMethods2.java b/java/java-tests/testData/psi/resolve/method/generics/GenericMethods2.java new file mode 100644 index 000000000000..8393aa1ebbb1 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/generics/GenericMethods2.java @@ -0,0 +1,13 @@ +import java.util.*; + +public class AAA { + void f(Collection t) { + } + + void f(java.util.List s) { + } + + void y(List strings) { + f(strings); + } +} diff --git a/java/java-tests/testData/psi/resolve/method/generics/GenericMethods3.java b/java/java-tests/testData/psi/resolve/method/generics/GenericMethods3.java new file mode 100644 index 000000000000..fef01026b6de --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/generics/GenericMethods3.java @@ -0,0 +1,11 @@ +public class AAA { + void g(T t) { + } + + void g(String s) { + } + + { + g(""); + } +} diff --git a/java/java-tests/testData/psi/resolve/method/generics/GenericMethods4.java b/java/java-tests/testData/psi/resolve/method/generics/GenericMethods4.java new file mode 100644 index 000000000000..4ee6cbf62129 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/generics/GenericMethods4.java @@ -0,0 +1,11 @@ +public class AAA { + void g(T... t) { + } + + void g(String... s) { + } + + { + g(""); + } +} diff --git a/java/java-tests/testData/psi/resolve/method/generics/GenericMethods5.java b/java/java-tests/testData/psi/resolve/method/generics/GenericMethods5.java new file mode 100644 index 000000000000..bec86bed5860 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/generics/GenericMethods5.java @@ -0,0 +1,19 @@ +class Key { T t; } + +class WKey extends Key { W w; } + +class Items { + void addItem(Key key, T value) {} + + void addItem(WKey key, T value) {} +} + +class IBug { + public IBug() { + Items items = new Items(); + + WKey sk = new WKey(); + + items.addItem(sk, ""); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/method/generics/GenericMethods6.java b/java/java-tests/testData/psi/resolve/method/generics/GenericMethods6.java new file mode 100644 index 000000000000..cb97bc81c2fc --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/generics/GenericMethods6.java @@ -0,0 +1,18 @@ +class ContainerUtil { + interface Condition { + boolean value(T object); + } + + public static T find(Iterable iterable, final T equalTo) { + return find(iterable, new Condition() { + public boolean value(final T object) { + return equalTo == object || equalTo.equals(object); + } + }); + } + + public static T find(Iterable iterable, Condition condition) { + return null; + } + +} diff --git a/java/java-tests/testData/psi/resolve/method/generics/GenericsAndVarargsNoConflict.java b/java/java-tests/testData/psi/resolve/method/generics/GenericsAndVarargsNoConflict.java new file mode 100644 index 000000000000..9513d380cdbd --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/generics/GenericsAndVarargsNoConflict.java @@ -0,0 +1,12 @@ +class Test { + + public static void main(String[] args) { + method("a", "b", "c"); + } + + public static T method(T... a) { + return null; + } + + public static void method(String... a) {} +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/method/generics/GetClass.java b/java/java-tests/testData/psi/resolve/method/generics/GetClass.java new file mode 100644 index 000000000000..301849469213 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/generics/GetClass.java @@ -0,0 +1,5 @@ +class Test { + public static void main(String[] args) { + "sss".getClass(); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/method/generics/HidingSuperPrivate.java b/java/java-tests/testData/psi/resolve/method/generics/HidingSuperPrivate.java new file mode 100644 index 000000000000..9e3aa1f6091b --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/generics/HidingSuperPrivate.java @@ -0,0 +1,18 @@ + public abstract class BaseTest + { + private Object f() { + return null; + } + + } + class S { + private Object f() { + new BaseTest() { + { + f(); + } + }; + + return null; + } + } diff --git a/java/java-tests/testData/psi/resolve/method/generics/Inheritance1.java b/java/java-tests/testData/psi/resolve/method/generics/Inheritance1.java new file mode 100644 index 000000000000..35b4e4b48417 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/generics/Inheritance1.java @@ -0,0 +1,16 @@ + +class Test{ + + class A { + B x; + class B { + public void put(T x, Z y){} + public Z getZ(){} + public T getT(){} + } + } + + { + new A().x.getT().byteValue(); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/method/generics/Inheritance2.java b/java/java-tests/testData/psi/resolve/method/generics/Inheritance2.java new file mode 100644 index 000000000000..574b1fd16a01 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/generics/Inheritance2.java @@ -0,0 +1,16 @@ + +class Test{ + + class A { + B x; + class B { + public void put(T x, Z y){} + public Z getZ(){} + public T getT(){} + } + } + + { + new A().new B().getZ().booleanValue(); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/method/generics/Inheritance3.java b/java/java-tests/testData/psi/resolve/method/generics/Inheritance3.java new file mode 100644 index 000000000000..08ac65fa9b3b --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/generics/Inheritance3.java @@ -0,0 +1,16 @@ + +class Test{ + + class A { + B x; + class B { + public void put(T x, Z y){} + public Z getZ(){} + public T getT(){} + } + } + + { + new A().new B().getT().byteValue(); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/method/generics/Inheritance4.java b/java/java-tests/testData/psi/resolve/method/generics/Inheritance4.java new file mode 100644 index 000000000000..0b81ca901d7a --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/generics/Inheritance4.java @@ -0,0 +1,18 @@ + +class Test{ + + class A { + B x; + class B { + public void put(T x, Z y){} + public Z getZ(){} + public T getT(){} + } + } + + class C extends A{} + + { + new C().new B().getT().byteValue(); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/method/generics/Merge1.java b/java/java-tests/testData/psi/resolve/method/generics/Merge1.java new file mode 100644 index 000000000000..5029c30a7ba8 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/generics/Merge1.java @@ -0,0 +1,14 @@ +class Test { + { + Test> test = new Test(); + { + test.put(""); + { + test.get().get().get().get(); + } + } + } + + T get(){ return null; } + void put(T x){} +} diff --git a/java/java-tests/testData/psi/resolve/method/generics/MoreSpecificSameErasure.java b/java/java-tests/testData/psi/resolve/method/generics/MoreSpecificSameErasure.java new file mode 100644 index 000000000000..71694b126e40 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/generics/MoreSpecificSameErasure.java @@ -0,0 +1,20 @@ +import java.util.*; + +class SSS { + public void x(List matcher) { + System.out.println(""); + } + + public int x(List matcher) { + System.out.println("long"); + return 0; + } + + public static List any(Class type) { + return null; + } + void f() { + x(any(Long.class)); + } + +} diff --git a/java/java-tests/testData/psi/resolve/method/generics/NestedTypeParams.java b/java/java-tests/testData/psi/resolve/method/generics/NestedTypeParams.java new file mode 100644 index 000000000000..27ec7bde066d --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/generics/NestedTypeParams.java @@ -0,0 +1,22 @@ +interface TestInterface { + + > void doStuff(E thing); +} + +class TestImpl implements TestInterface { + @Override + public > void doStuff(I thing){ + + } +} + +enum TestEnum { + THING +} + +class Testx { + public void doTest(){ + TestImpl impl = new TestImpl(); + impl.doStuff(TestEnum.THING); + } +} diff --git a/java/java-tests/testData/psi/resolve/method/generics/PreferArrayTypeToObject.java b/java/java-tests/testData/psi/resolve/method/generics/PreferArrayTypeToObject.java new file mode 100644 index 000000000000..74a844f4411a --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/generics/PreferArrayTypeToObject.java @@ -0,0 +1,21 @@ +import java.util.Arrays; + +public class MyClass +{ + public static void process(T obj) + { + System.out.println("Processing object: " + obj); + } + + public static void process(T[] arr) + { + System.out.println("Processing array: " + Arrays.toString(arr)); + } + + public static void main(String[] args) + { + String[] myArray = new String[] { "a", "b", "c" }; + + process(myArray); // Ctr-Left-Click on "process" takes me to the wrong method!!! + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/method/generics/RawMethod1.java b/java/java-tests/testData/psi/resolve/method/generics/RawMethod1.java new file mode 100644 index 000000000000..621b5377f5e8 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/generics/RawMethod1.java @@ -0,0 +1,8 @@ +class A{ + class B{} + void foo(T a, B b){} + + { + foo("", new B()); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/method/generics/RawVsGenericConflict.java b/java/java-tests/testData/psi/resolve/method/generics/RawVsGenericConflict.java new file mode 100644 index 000000000000..c39659e0144f --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/generics/RawVsGenericConflict.java @@ -0,0 +1,16 @@ +class TestClassT { + static { + B.foo(TestClassT.class); + } + + public static class A { + public static A foo(Class type) { + return new A(); + } + } + public static class B extends A { + public static B foo(Class type) { + return new B(); + } + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/method/generics/SOE.java b/java/java-tests/testData/psi/resolve/method/generics/SOE.java new file mode 100644 index 000000000000..ed304ff7d71f --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/generics/SOE.java @@ -0,0 +1,6 @@ +import java.util.Comparator; + +abstract class Z implements Comparator { + static abstract class NameRef implements java.lang.ComparableNameRef> { + } +} diff --git a/java/java-tests/testData/psi/resolve/method/generics/StaticImportConflict.java b/java/java-tests/testData/psi/resolve/method/generics/StaticImportConflict.java new file mode 100644 index 000000000000..d3d87cb499d9 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/generics/StaticImportConflict.java @@ -0,0 +1,9 @@ +import static java.util.Arrays.*; +import static java.util.Collections.sort; + +class C { + { + int[] array = null; + sort(array); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/method/generics/StaticImportConflict1.java b/java/java-tests/testData/psi/resolve/method/generics/StaticImportConflict1.java new file mode 100644 index 000000000000..e76994e684e8 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/generics/StaticImportConflict1.java @@ -0,0 +1,21 @@ +import static java.lang.Integer.parseInt; + +public class X { + + private String str; + + public X(String str) { + this.str = str; + } + + public int parseInt(){ + //The following line is rejected by the compiler but not by IntelliJ. + return parseInt(str); + } + + public static void main(String[] args) { + X x=new X("123"); + int i=x.parseInt(); + System.out.println(i); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/method/generics/StaticImportDirect.java b/java/java-tests/testData/psi/resolve/method/generics/StaticImportDirect.java new file mode 100644 index 000000000000..8c7db21ba5e9 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/generics/StaticImportDirect.java @@ -0,0 +1,8 @@ +import static java.util.Arrays.asList; +import java.util.*; + +class C { + { + List s = asList(new String[0]); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/method/generics/StaticImportHidden.java b/java/java-tests/testData/psi/resolve/method/generics/StaticImportHidden.java new file mode 100644 index 000000000000..bb88280c2fad --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/generics/StaticImportHidden.java @@ -0,0 +1,11 @@ +import static java.util.Arrays.toString; + +class ImportDuty { + public static void main(String[] args) { + new ImportDuty().printArgs(1, 2, 3, 4, 5); + } + + void printArgs(Object... args) { + System.out.println(toString(args)); + } +} diff --git a/java/java-tests/testData/psi/resolve/method/generics/StaticImportOnDemand.java b/java/java-tests/testData/psi/resolve/method/generics/StaticImportOnDemand.java new file mode 100644 index 000000000000..2dcc100d4c2d --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/generics/StaticImportOnDemand.java @@ -0,0 +1,8 @@ +import static java.util.Arrays.*; +import java.util.*; + +class C { + { + List s = asList(new String[0]); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/method/generics/StaticMethodInSubclass.java b/java/java-tests/testData/psi/resolve/method/generics/StaticMethodInSubclass.java new file mode 100644 index 000000000000..125295077743 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/generics/StaticMethodInSubclass.java @@ -0,0 +1,23 @@ +import java.util.Collection; + +public class SomeClass { + public static Object find(Collection collection, Object criteria) { + return criteria; + } + static class SomeSubClass extends SomeClass { + public static T find(Collection collection, Object criteria) { + return null; + } + } + + + void f() + { + Collection c = null; + Object criteria = null; + +// IntelliJ finds the find(Collection, Object) method, and reports a non-existent compile error. + T someInstance = SomeSubClass.find(c, criteria); + } + +} diff --git a/java/java-tests/testData/psi/resolve/method/generics/TestGenericMethodOverloading1.java b/java/java-tests/testData/psi/resolve/method/generics/TestGenericMethodOverloading1.java new file mode 100644 index 000000000000..e93c67761c8e --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/generics/TestGenericMethodOverloading1.java @@ -0,0 +1,20 @@ + +import java.util.List; + +/** + * Created by IntelliJ IDEA. + * User: ik + * Date: 28.05.2003 + * Time: 16:50:51 + * To change this template use Options | File Templates. + */ +public class TestGenericMethodOverloading1 { + class A{ + public boolean equals(T t){ + return false; + } + } + { + new A().equals(new Object()); + } +} diff --git a/java/java-tests/testData/psi/resolve/method/generics/TestGenericMethodOverloading2.java b/java/java-tests/testData/psi/resolve/method/generics/TestGenericMethodOverloading2.java new file mode 100644 index 000000000000..8978b817ab59 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/generics/TestGenericMethodOverloading2.java @@ -0,0 +1,17 @@ +/** + * Created by IntelliJ IDEA. + * User: ik + * Date: 28.05.2003 + * Time: 16:50:51 + * To change this template use Options | File Templates. + */ +public class TestGenericMethodOverloading2 { + class A{ + public boolean equals(T t){ + return false; + } + } + { + new A().equals(new Object()); + } +} diff --git a/java/java-tests/testData/psi/resolve/method/generics/TestGenericMethodOverloading3.java b/java/java-tests/testData/psi/resolve/method/generics/TestGenericMethodOverloading3.java new file mode 100644 index 000000000000..3b0180625b1b --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/generics/TestGenericMethodOverloading3.java @@ -0,0 +1,17 @@ +/** + * Created by IntelliJ IDEA. + * User: ik + * Date: 28.05.2003 + * Time: 16:50:51 + * To change this template use Options | File Templates. + */ +public class TestGenericMethodOverloading3 { + class A{ + public boolean equals(T t){ + return false; + } + } + { + new A().equals(new Object()); + } +} diff --git a/java/java-tests/testData/psi/resolve/method/generics/TestGenericMethodOverloading4.java b/java/java-tests/testData/psi/resolve/method/generics/TestGenericMethodOverloading4.java new file mode 100644 index 000000000000..0e9bc7a9ed71 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/generics/TestGenericMethodOverloading4.java @@ -0,0 +1,17 @@ +/** + * Created by IntelliJ IDEA. + * User: ik + * Date: 28.05.2003 + * Time: 16:50:51 + * To change this template use Options | File Templates. + */ +public class TestGenericMethodOverloading4 { + class A{ + public boolean equals(T t){ + return false; + } + } + { + new A().equals(new String()); + } +} diff --git a/java/java-tests/testData/psi/resolve/method/generics/TestReturnType1.java b/java/java-tests/testData/psi/resolve/method/generics/TestReturnType1.java new file mode 100644 index 000000000000..ba870b0bad8c --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/generics/TestReturnType1.java @@ -0,0 +1,17 @@ +/** + * Created by IntelliJ IDEA. + * User: ik + * Date: 28.05.2003 + * Time: 16:50:51 + * To change this template use Options | File Templates. + */ +public class TestReturnType1 { + class A{ + public T foo(T t){ + return null; + } + } + { + new A().foo(new String()).toCharArray(); + } +} diff --git a/java/java-tests/testData/psi/resolve/method/generics/TestReturnType2.java b/java/java-tests/testData/psi/resolve/method/generics/TestReturnType2.java new file mode 100644 index 000000000000..b81bce1fbe7d --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/generics/TestReturnType2.java @@ -0,0 +1,17 @@ +/** + * Created by IntelliJ IDEA. + * User: ik + * Date: 28.05.2003 + * Time: 16:50:51 + * To change this template use Options | File Templates. + */ +public class TestReturnType2 { + class A{ + public T foo(T t){ + return null; + } + } + { + new A().foo(new String()).toCharArray(); + } +} diff --git a/java/java-tests/testData/psi/resolve/method/generics/TestThisExpression.java b/java/java-tests/testData/psi/resolve/method/generics/TestThisExpression.java new file mode 100644 index 000000000000..8ae922ac6ee3 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/generics/TestThisExpression.java @@ -0,0 +1,12 @@ +public class WithInner { + T foo () { + return null; + } + + class Inner { + T foo () { + return WithInner.this.foo(); + } + } + +} diff --git a/java/java-tests/testData/psi/resolve/method/generics/TypeInference1.java b/java/java-tests/testData/psi/resolve/method/generics/TypeInference1.java new file mode 100644 index 000000000000..603959deba30 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/generics/TypeInference1.java @@ -0,0 +1,25 @@ +class B{ + void b(){}; +} + +interface E{ + void e(); +} + +class C extends B{ + void c(){} +} + +class D extends B implements E{ + void d(){} + void e(){} +} + + +class A{ + T foo(T t, A a){ return null; } + + { + foo(new C(), new A()).b(); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/method/generics/TypeParamBoundConflict.java b/java/java-tests/testData/psi/resolve/method/generics/TypeParamBoundConflict.java new file mode 100644 index 000000000000..53577e9b74fe --- /dev/null +++ b/java/java-tests/testData/psi/resolve/method/generics/TypeParamBoundConflict.java @@ -0,0 +1,22 @@ +import java.util.*; + +class Thing { +} +class Testergen { + T x(T thing) { + return null; + } + + T x(Collection thing) { + return null; + } +} +class TestergenUser { + public void context(Testergen test) { + // the error is shown when x is called: + Collection t = null; + test.x(t); + } + +} + diff --git a/java/java-tests/testData/psi/resolve/var/AnonymousConstructorArg.java b/java/java-tests/testData/psi/resolve/var/AnonymousConstructorArg.java new file mode 100644 index 000000000000..f5a325f41e80 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/var/AnonymousConstructorArg.java @@ -0,0 +1,10 @@ +class Test { + static Test createTest(int value) { + return new Test(value) {}; + } + + int value; + + Test(int value) { + } +} diff --git a/java/java-tests/testData/psi/resolve/var/Array1.java b/java/java-tests/testData/psi/resolve/var/Array1.java new file mode 100644 index 000000000000..6acbad6f44d2 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/var/Array1.java @@ -0,0 +1,6 @@ +public class Array1 { + void foo(){ + int value[] = {}; + int val = value.length; + } +} diff --git a/java/java-tests/testData/psi/resolve/var/Bug7869.java b/java/java-tests/testData/psi/resolve/var/Bug7869.java new file mode 100644 index 000000000000..db0cf99ae60b --- /dev/null +++ b/java/java-tests/testData/psi/resolve/var/Bug7869.java @@ -0,0 +1,12 @@ +/** + * Created by IntelliJ IDEA. + * User: ik + * Date: 22.01.2003 + * Time: 14:50:35 + * To change this template use Options | File Templates. + */ +public class Bug7869 { + public static void main(String[] args){ + String str = (str = String.valueOf(123.456d)) != null ? str : "default"; + } +} diff --git a/java/java-tests/testData/psi/resolve/var/FieldConflict.java b/java/java-tests/testData/psi/resolve/var/FieldConflict.java new file mode 100644 index 000000000000..de9f28a61d04 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/var/FieldConflict.java @@ -0,0 +1,16 @@ +interface Base { + Base[] EMPTY_ARRAY = new Base[0]; +} + +interface Derived1 extends Base {} + +interface Derived2 extends Base { + Derived2[] EMPTY_ARRAY = new Derived2[0]; +} + +class Implementor implements Derived1, Derived2 { + //Implementor[] EMPTY_ARRAY = new Implementor[0]; + Derived2[] f() { + return EMPTY_ARRAY; //conflict + } +} diff --git a/java/java-tests/testData/psi/resolve/var/FieldFromInterface.java b/java/java-tests/testData/psi/resolve/var/FieldFromInterface.java new file mode 100644 index 000000000000..91589f5ea372 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/var/FieldFromInterface.java @@ -0,0 +1,12 @@ +class Client { + int foo(){ + return A.FIELD; + } +} + +class A implements I{ +} + +interface I { + public static final int FIELD = 1; +} diff --git a/java/java-tests/testData/psi/resolve/var/FieldsAndLocals.java b/java/java-tests/testData/psi/resolve/var/FieldsAndLocals.java new file mode 100644 index 000000000000..68abcf2ba3dd --- /dev/null +++ b/java/java-tests/testData/psi/resolve/var/FieldsAndLocals.java @@ -0,0 +1,23 @@ +/** + * Created by IntelliJ IDEA. + * User: ik + * Date: 23.01.2003 + * Time: 17:59:45 + * To change this template use Options | File Templates. + */ +public class FieldsAndLocals { + private int a = 0; + { + int a = -1; + new B(){ + public void run(){ + int b = a + } + } + } +} + +abstract class B implements Runnable { + private int a = 0; +} + diff --git a/java/java-tests/testData/psi/resolve/var/ForeachParameter.java b/java/java-tests/testData/psi/resolve/var/ForeachParameter.java new file mode 100644 index 000000000000..197dfb53a74a --- /dev/null +++ b/java/java-tests/testData/psi/resolve/var/ForeachParameter.java @@ -0,0 +1,7 @@ +class Foo { + { + for(Object o : collection) { + System.out.println(o); + } + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/var/InheritedOuter.java b/java/java-tests/testData/psi/resolve/var/InheritedOuter.java new file mode 100644 index 000000000000..e18dea3fe3dc --- /dev/null +++ b/java/java-tests/testData/psi/resolve/var/InheritedOuter.java @@ -0,0 +1,9 @@ +class Outer { + private String string; + + class Inner extends Outer { + void test() { + System.out.println(string); + } + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/var/Inner1.java b/java/java-tests/testData/psi/resolve/var/Inner1.java new file mode 100644 index 000000000000..648c6f7c944a --- /dev/null +++ b/java/java-tests/testData/psi/resolve/var/Inner1.java @@ -0,0 +1,20 @@ +/** + * Created by IntelliJ IDEA. + * User: ik + * Date: 23.01.2003 + * Time: 17:59:45 + * To change this template use Options | File Templates. + */ +public class Inner1 { + private int a = 0; + private class A extends B{ + { + int j = a; + } + } +} + +class B { + private int a = 0; +} + diff --git a/java/java-tests/testData/psi/resolve/var/InnerPrivates1.java b/java/java-tests/testData/psi/resolve/var/InnerPrivates1.java new file mode 100644 index 000000000000..500b5ee2e8a9 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/var/InnerPrivates1.java @@ -0,0 +1,9 @@ +class A{ + { + new B().b = 0; + } + + class B{ + private int b; + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/var/InterfaceConflict1.java b/java/java-tests/testData/psi/resolve/var/InterfaceConflict1.java new file mode 100644 index 000000000000..23e2fd304d20 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/var/InterfaceConflict1.java @@ -0,0 +1,16 @@ +public class InterfaceConflict1{ + public interface A{ + int a = 0; + } + + public interface B{ + int a = 0; + } + + public static class C + implements A, B{ + static{ + System.out.println("" + a); + } + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/var/InterfaceConflict10.java b/java/java-tests/testData/psi/resolve/var/InterfaceConflict10.java new file mode 100644 index 000000000000..4c3e6a3c3de1 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/var/InterfaceConflict10.java @@ -0,0 +1,20 @@ +public class InterfaceConflict10{ + public interface A{ + int a = 0; + } + + public static class B + implements A{ + } + + public interface C{ + int a = 0; + } + + public static class D extends A + implements A, C{ + void foo(){ + System.out.println("" + a); + } + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/var/InterfaceConflict11.java b/java/java-tests/testData/psi/resolve/var/InterfaceConflict11.java new file mode 100644 index 000000000000..99b0a0226db8 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/var/InterfaceConflict11.java @@ -0,0 +1,15 @@ +public class InterfaceConflict11{ + public static class A{ + static int a = 0; + } + + public static class B extends A{ + int a = 0; + } + + public static class C extends B{ + static void foo(){ + System.out.println("" + a); + } + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/var/InterfaceConflict2.java b/java/java-tests/testData/psi/resolve/var/InterfaceConflict2.java new file mode 100644 index 000000000000..7b978c17fcb4 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/var/InterfaceConflict2.java @@ -0,0 +1,19 @@ +public class InterfaceConflict2{ + public interface A{ + int a = 0; + } + + public interface B{ + int a = 0; + } + + public interface E extends A{ + } + + public static class C + implements E, B{ + static{ + System.out.println("" + a); + } + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/var/InterfaceConflict3.java b/java/java-tests/testData/psi/resolve/var/InterfaceConflict3.java new file mode 100644 index 000000000000..2a56e3e55b41 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/var/InterfaceConflict3.java @@ -0,0 +1,19 @@ +public class InterfaceConflict3{ + public interface A{ + int a = 0; + } + + public interface B{ + int a = 0; + } + + public class E implements A{ + } + + public static class C extends E + implements B{ + static{ + System.out.println("" + a); + } + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/var/InterfaceConflict4.java b/java/java-tests/testData/psi/resolve/var/InterfaceConflict4.java new file mode 100644 index 000000000000..c3392b386b77 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/var/InterfaceConflict4.java @@ -0,0 +1,17 @@ +public class InterfaceConflict4{ + public interface A{ + int a = 0; + } + + + public class B{ + public static final int a = 0; + } + + public static class C extends B + implements A{ + static{ + System.out.println("" + a); + } + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/var/InterfaceConflict5.java b/java/java-tests/testData/psi/resolve/var/InterfaceConflict5.java new file mode 100644 index 000000000000..17b39e8a627e --- /dev/null +++ b/java/java-tests/testData/psi/resolve/var/InterfaceConflict5.java @@ -0,0 +1,17 @@ +public class InterfaceConflict5{ + public interface A{ + int a = 0; + } + + + public class B implements A{ + public int a = 0; + } + + public static class C extends B + implements A{ + void foo(){ + System.out.println("" + a); + } + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/var/InterfaceConflict6.java b/java/java-tests/testData/psi/resolve/var/InterfaceConflict6.java new file mode 100644 index 000000000000..eaec8f9bad7f --- /dev/null +++ b/java/java-tests/testData/psi/resolve/var/InterfaceConflict6.java @@ -0,0 +1,17 @@ +public class InterfaceConflict6{ + public interface A{ + int a = 0; + } + + + public class B{ + public int a = 0; + } + + public static class C extends B + implements A{ + void foo(){ + System.out.println("" + a); + } + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/var/InterfaceConflict7.java b/java/java-tests/testData/psi/resolve/var/InterfaceConflict7.java new file mode 100644 index 000000000000..74a16765340d --- /dev/null +++ b/java/java-tests/testData/psi/resolve/var/InterfaceConflict7.java @@ -0,0 +1,16 @@ +public class InterfaceConflict7{ + public interface A{ + int a = 0; + } + + + public class B implements A{ + public int a = 0; + } + + public static class C extends B{ + void foo(){ + System.out.println("" + a); + } + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/var/InterfaceConflict8.java b/java/java-tests/testData/psi/resolve/var/InterfaceConflict8.java new file mode 100644 index 000000000000..70051c721c92 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/var/InterfaceConflict8.java @@ -0,0 +1,16 @@ +public class InterfaceConflict8{ + public interface A{ + int a = 0; + } + + + public static class B implements A{ + } + + public static class C extends B + implements A{ + void foo(){ + System.out.println("" + a); + } + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/var/InterfaceConflict9.java b/java/java-tests/testData/psi/resolve/var/InterfaceConflict9.java new file mode 100644 index 000000000000..17d2df5eba62 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/var/InterfaceConflict9.java @@ -0,0 +1,20 @@ +public class InterfaceConflict9{ + public interface A{ + int a = 0; + } + + public interface B{ + int a = 0; + } + + public interface C{ + int a = 0; + } + + public static class D + implements A, B, C{ + void foo(){ + System.out.println("" + a); + } + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/var/LocalVariable1.java b/java/java-tests/testData/psi/resolve/var/LocalVariable1.java new file mode 100644 index 000000000000..fcc1f3b60cf3 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/var/LocalVariable1.java @@ -0,0 +1,6 @@ +class Test { + void foo(){ + int value; + int val1 = value; + } +} diff --git a/java/java-tests/testData/psi/resolve/var/PrivateOverloading.java b/java/java-tests/testData/psi/resolve/var/PrivateOverloading.java new file mode 100644 index 000000000000..7b6612a53bf1 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/var/PrivateOverloading.java @@ -0,0 +1,20 @@ +class A { + int i; + + public void method() { + } + } + + class B extends A { + private int i; + + public void method() { + } + } + + class C extends B { + + public void method() { + i = 10; + } + } \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/var/Qualified1.java b/java/java-tests/testData/psi/resolve/var/Qualified1.java new file mode 100644 index 000000000000..48920facbe2b --- /dev/null +++ b/java/java-tests/testData/psi/resolve/var/Qualified1.java @@ -0,0 +1,10 @@ +public class Test{ + int a = 0; +} + +class Test1 { + static Test test = new Test(); + static { + System.out.println("" + test.a); + } +} diff --git a/java/java-tests/testData/psi/resolve/var/Qualified2.java b/java/java-tests/testData/psi/resolve/var/Qualified2.java new file mode 100644 index 000000000000..898b933ef70c --- /dev/null +++ b/java/java-tests/testData/psi/resolve/var/Qualified2.java @@ -0,0 +1,7 @@ +public class Test{ + static int a = 0; + + public int foo(){ + return Test.a; + } +} diff --git a/java/java-tests/testData/psi/resolve/var/Qualified3.java b/java/java-tests/testData/psi/resolve/var/Qualified3.java new file mode 100644 index 000000000000..b2fe726cdc0c --- /dev/null +++ b/java/java-tests/testData/psi/resolve/var/Qualified3.java @@ -0,0 +1,7 @@ +public class Test{ + static int a = 0; + + public int foo(){ + return new Test().a; + } +} diff --git a/java/java-tests/testData/psi/resolve/var/Qualified4.java b/java/java-tests/testData/psi/resolve/var/Qualified4.java new file mode 100644 index 000000000000..6fa0a320a0db --- /dev/null +++ b/java/java-tests/testData/psi/resolve/var/Qualified4.java @@ -0,0 +1,9 @@ +class A{ + static class B{ + static int a = 0; + } + + { + System.out.println("" + A.B.a); + } +} diff --git a/java/java-tests/testData/psi/resolve/var/RefInOuter.java b/java/java-tests/testData/psi/resolve/var/RefInOuter.java new file mode 100644 index 000000000000..24029c51993b --- /dev/null +++ b/java/java-tests/testData/psi/resolve/var/RefInOuter.java @@ -0,0 +1,8 @@ +class Outer { + int i; + class Inner { + { + int j = i; + } + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/var/RefInSuper.java b/java/java-tests/testData/psi/resolve/var/RefInSuper.java new file mode 100644 index 000000000000..1f7ce6553281 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/var/RefInSuper.java @@ -0,0 +1,8 @@ +class Outer { + int i; + class Inner extends Outer { + { + int j = i; + } + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/var/ShadowFieldsInHierarchy.java b/java/java-tests/testData/psi/resolve/var/ShadowFieldsInHierarchy.java new file mode 100644 index 000000000000..d77f4da01af7 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/var/ShadowFieldsInHierarchy.java @@ -0,0 +1,20 @@ +class TestPage extends WWW { + private static final Object log = null; + + static class B extends W3 { + public B() { + log.hashCode(); + } + } +} + +class WWW extends W3{ + private static final Object log = new Object(); + protected void run(Object runnable){} +} +class W3 extends W4 { + private static final Object log = new Object(); +} +class W4 { + private static final Object log = new Object(); +} diff --git a/java/java-tests/testData/psi/resolve/var/ShadowFieldsInHierarchy2.java b/java/java-tests/testData/psi/resolve/var/ShadowFieldsInHierarchy2.java new file mode 100644 index 000000000000..123cf095ff16 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/var/ShadowFieldsInHierarchy2.java @@ -0,0 +1,18 @@ + +interface Base { + public static final int EXIT_ON_CLOSE = 3; + +} +class E implements Base { + public static final int EXIT_ON_CLOSE = 3; + void show(){} +} +class S { + private void h() { + new E() { + { + int o = EXIT_ON_CLOSE; + } + }.show(); + } +} diff --git a/java/java-tests/testData/psi/resolve/var/Unresolved1.java b/java/java-tests/testData/psi/resolve/var/Unresolved1.java new file mode 100644 index 000000000000..5b1f0ef0aefd --- /dev/null +++ b/java/java-tests/testData/psi/resolve/var/Unresolved1.java @@ -0,0 +1,5 @@ +public class Test{ + public static void foo() {} + int a = 0; + int b = foo; +} diff --git a/java/java-tests/testData/psi/resolve/var/Visibility1.java b/java/java-tests/testData/psi/resolve/var/Visibility1.java new file mode 100644 index 000000000000..fa8646ff9433 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/var/Visibility1.java @@ -0,0 +1,9 @@ +class Test { + static int variable = 1; + static class Inner{ + int variable = 0; + static void foo(){ + int val1 = variable; + } + } +} diff --git a/java/java-tests/testData/psi/resolve/var/Visibility2.java b/java/java-tests/testData/psi/resolve/var/Visibility2.java new file mode 100644 index 000000000000..f25e2c70fe25 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/var/Visibility2.java @@ -0,0 +1,3 @@ +class Test { + int a = 1 + a; +} diff --git a/java/java-tests/testData/psi/resolve/var/Visibility3.java b/java/java-tests/testData/psi/resolve/var/Visibility3.java new file mode 100644 index 000000000000..d9b85ba85a19 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/var/Visibility3.java @@ -0,0 +1,12 @@ +class Test { + static class ABC{ + public int i = 0; + } + static { + System.out.println("" + getABC().i); + } + + static ABC getABC(){ + return new ABC(); + } +} diff --git a/java/java-tests/testData/psi/resolve/var/Visibility4.java b/java/java-tests/testData/psi/resolve/var/Visibility4.java new file mode 100644 index 000000000000..958a628d3dde --- /dev/null +++ b/java/java-tests/testData/psi/resolve/var/Visibility4.java @@ -0,0 +1,5 @@ +class Test { + static { + int a = 1 + a; + } +} diff --git a/java/java-tests/testData/psi/resolve/var/Visibility5.java b/java/java-tests/testData/psi/resolve/var/Visibility5.java new file mode 100644 index 000000000000..958a628d3dde --- /dev/null +++ b/java/java-tests/testData/psi/resolve/var/Visibility5.java @@ -0,0 +1,5 @@ +class Test { + static { + int a = 1 + a; + } +} diff --git a/java/java-tests/testData/psi/resolve/var/Visibility6.java b/java/java-tests/testData/psi/resolve/var/Visibility6.java new file mode 100644 index 000000000000..b2ed7a5375e5 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/var/Visibility6.java @@ -0,0 +1,11 @@ + class Foo { + private void f() { + Bar bar=null; + bar.f(); + } + void g() { + f(); + } + } + class Bar extends Foo { + } diff --git a/java/java-tests/testData/psi/resolve/var15/DuplicateStaticImport.java b/java/java-tests/testData/psi/resolve/var15/DuplicateStaticImport.java new file mode 100644 index 000000000000..6c740052a09e --- /dev/null +++ b/java/java-tests/testData/psi/resolve/var15/DuplicateStaticImport.java @@ -0,0 +1,8 @@ +import static java.lang.System.out; +import static java.lang.System.out; + +class DuplicateStaticImport { + public static void main(String[] args) { + out.println(""); // cannot resolve symbol 'out' + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/resolve/var15/RhombExtending.java b/java/java-tests/testData/psi/resolve/var15/RhombExtending.java new file mode 100644 index 000000000000..7a1d4995ad77 --- /dev/null +++ b/java/java-tests/testData/psi/resolve/var15/RhombExtending.java @@ -0,0 +1,15 @@ +/** @noinspection UnusedDeclaration*/ +interface I { + String SSS = "SSS"; +} + +interface II extends I {} + +class A implements I {} + +/** @noinspection UnusedDeclaration*/ +class AA extends A implements II { + public static void f() { + String s = SSS; //this is not ambigous reference + } +} diff --git a/java/java-tests/testSrc/com/intellij/psi/resolve/FilePathResolveTest.java b/java/java-tests/testSrc/com/intellij/psi/resolve/FilePathResolveTest.java new file mode 100644 index 000000000000..8805ae946393 --- /dev/null +++ b/java/java-tests/testSrc/com/intellij/psi/resolve/FilePathResolveTest.java @@ -0,0 +1,43 @@ +package com.intellij.psi.resolve; + +import com.intellij.codeInsight.CodeInsightTestCase; +import com.intellij.codeInsight.navigation.actions.GotoDeclarationAction; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiFile; +import com.intellij.psi.PsiFileSystemItem; +import com.intellij.psi.impl.include.FileIncludeInfo; +import com.intellij.psi.impl.include.FileIncludeManager; + +/** + * @author cdr + */ +public class FilePathResolveTest extends CodeInsightTestCase{ + private static final String BASE_PATH = "/psi/resolve/filePath/"; + + public void testC1() throws Exception{ + configure("C.java"); + checkNavigatesTo("MyClass.java"); + } + public void testC2() throws Exception{ + configure("C2.java"); + checkNavigatesTo("MyFile.txt"); + } + + public void testResolveFileReference() throws Exception { + configureByFile(BASE_PATH + "C.java", BASE_PATH); + FileIncludeManager fileIncludeManager = FileIncludeManager.getManager(getProject()); + PsiFileSystemItem item = fileIncludeManager.resolveFileInclude(new FileIncludeInfo("x/MyFile.txt"), getFile()); + assertNotNull(item); + assertEquals("MyFile.txt", item.getName()); + } + + private void checkNavigatesTo(String expected) { + final int offset = myEditor.getCaretModel().getOffset(); + final PsiElement targetElement = GotoDeclarationAction.findTargetElement(myProject, myEditor, offset); + assertEquals(expected, ((PsiFile)targetElement).getName()); + } + + private void configure(final String fileName) throws Exception { + configureByFile(BASE_PATH + fileName, BASE_PATH); + } +} diff --git a/java/java-tests/testSrc/com/intellij/psi/resolve/Resolve15TestCase.java b/java/java-tests/testSrc/com/intellij/psi/resolve/Resolve15TestCase.java new file mode 100644 index 000000000000..4abe3d580899 --- /dev/null +++ b/java/java-tests/testSrc/com/intellij/psi/resolve/Resolve15TestCase.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2006 JetBrains s.r.o. All Rights Reserved. + */ +package com.intellij.psi.resolve; + +import com.intellij.openapi.projectRoots.Sdk; +import com.intellij.openapi.projectRoots.impl.JavaSdkImpl; +import com.intellij.openapi.roots.LanguageLevelProjectExtension; +import com.intellij.pom.java.LanguageLevel; +import com.intellij.testFramework.ResolveTestCase; + +/** + * @author ven + */ +public abstract class Resolve15TestCase extends ResolveTestCase { + private LanguageLevel myOldLanguageLevel; + + @Override + protected void setUp() throws Exception { + super.setUp(); + myOldLanguageLevel = LanguageLevelProjectExtension.getInstance(myJavaFacade.getProject()).getLanguageLevel(); + LanguageLevelProjectExtension.getInstance(myJavaFacade.getProject()).setLanguageLevel(LanguageLevel.JDK_1_5); + } + + @Override + protected void tearDown() throws Exception { + LanguageLevelProjectExtension.getInstance(myJavaFacade.getProject()).setLanguageLevel(myOldLanguageLevel); + super.tearDown(); + } +} diff --git a/java/java-tests/testSrc/com/intellij/psi/resolve/ResolveClassTest.java b/java/java-tests/testSrc/com/intellij/psi/resolve/ResolveClassTest.java new file mode 100644 index 000000000000..da93be3935ca --- /dev/null +++ b/java/java-tests/testSrc/com/intellij/psi/resolve/ResolveClassTest.java @@ -0,0 +1,184 @@ +package com.intellij.psi.resolve; + +import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.module.ModifiableModuleModel; +import com.intellij.openapi.module.Module; +import com.intellij.openapi.module.ModuleManager; +import com.intellij.openapi.module.StdModuleTypes; +import com.intellij.openapi.roots.ContentEntry; +import com.intellij.openapi.roots.ModifiableRootModel; +import com.intellij.openapi.roots.ModuleRootManager; +import com.intellij.openapi.vfs.LocalFileSystem; +import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.psi.*; +import com.intellij.testFramework.ResolveTestCase; + +public class ResolveClassTest extends ResolveTestCase { + public void testFQName() throws Exception{ + PsiReference ref = configure(); + PsiElement target = ((PsiJavaReference)ref).advancedResolve(true).getElement(); + assertTrue(target instanceof PsiClass); + } + + public void testVarInNew() throws Exception{ + PsiReference ref = configure(); + PsiElement target = ((PsiJavaReference)ref).advancedResolve(true).getElement(); + assertTrue(target instanceof PsiClass); + } + + public void testVarInNew1() throws Exception{ + PsiReference ref = configure(); + PsiElement target = ((PsiJavaReference)ref).advancedResolve(true).getElement(); + assertTrue(target instanceof PsiClass); + } + + public void testPrivateInExtends() throws Exception{ + PsiReference ref = configure(); + final JavaResolveResult result = ((PsiJavaReference)ref).advancedResolve(true); + PsiElement target = result.getElement(); + assertTrue(target instanceof PsiClass); + assertFalse(result.isAccessible()); + } + + public void testQNew1() throws Exception{ + PsiReference ref = configure(); + PsiElement target = ((PsiJavaReference)ref).advancedResolve(true).getElement(); + assertTrue(target instanceof PsiClass); + } + + public void testInnerPrivateMember1() throws Exception{ + PsiReference ref = configure(); + final JavaResolveResult result = ((PsiJavaReference)ref).advancedResolve(true); + PsiElement target = result.getElement(); + assertTrue(target instanceof PsiClass); + assertTrue(result.isValidResult()); + } + + + public void testQNew2() throws Exception{ + PsiJavaCodeReferenceElement ref = (PsiJavaCodeReferenceElement)configure(); + PsiElement target = ref.advancedResolve(true).getElement(); + assertTrue(target instanceof PsiClass); + + PsiElement parent = ref.getParent(); + assertTrue(parent instanceof PsiAnonymousClass); + ((PsiAnonymousClass)parent).getBaseClassType().resolve(); + + assertEquals(target, ((PsiAnonymousClass)parent).getBaseClassType().resolve()); + } + + public void testClassExtendsItsInner1() throws Exception{ + PsiReference ref = configure(); + PsiElement target = ((PsiJavaReference)ref).advancedResolve(true).getElement(); + assertTrue(target instanceof PsiClass); + assertEquals("B.Foo", ((PsiClass)target).getQualifiedName()); + + PsiReference refCopy = ref.getElement().copy().getReference(); + assert refCopy != null; + PsiElement target1 = ((PsiJavaReference)refCopy).advancedResolve(true).getElement(); + assertTrue(target1 instanceof PsiClass); + //assertNull(target1.getContainingFile().getVirtualFile()); + assertEquals("B.Foo", ((PsiClass)target1).getQualifiedName()); + } + + public void testClassExtendsItsInner2() throws Exception{ + PsiReference ref = configure(); + PsiElement target = ((PsiJavaReference)ref).advancedResolve(true).getElement(); + assertNull(target); //[ven] this should not be resolved + /*assertTrue(target instanceof PsiClass); + assertEquals("TTT.Bar", ((PsiClass)target).getQualifiedName());*/ + } + + public void testSCR40332() throws Exception{ + PsiReference ref = configure(); + PsiElement target = ((PsiJavaReference)ref).advancedResolve(true).getElement(); + assertNull(target); + } + + public void testImportConflict1() throws Exception{ + PsiReference ref = configure(); + PsiElement target = ((PsiJavaReference)ref).advancedResolve(true).getElement(); + assertTrue(target == null); + } + + public void testImportConflict2() throws Exception{ + PsiReference ref = configure(); + PsiElement target = ((PsiJavaReference)ref).advancedResolve(true).getElement(); + assertTrue(target instanceof PsiClass); + assertEquals("java.util.Date", ((PsiClass)target).getQualifiedName()); + } + + public void testLocals1() throws Exception{ + PsiReference ref = configure(); + PsiElement target = ((PsiJavaReference)ref).advancedResolve(true).getElement(); + assertTrue(target instanceof PsiClass); + // local class + assertNull(((PsiClass)target).getQualifiedName()); + } + + public void testLocals2() throws Exception{ + PsiReference ref = configure(); + PsiElement target = ((PsiJavaReference)ref).advancedResolve(true).getElement(); + assertTrue(target instanceof PsiClass); + // local class + assertNull(((PsiClass)target).getQualifiedName()); + } + + public void testShadowing() throws Exception { + PsiReference ref = configure(); + JavaResolveResult result = ((PsiJavaReference)ref).advancedResolve(true); + assertTrue(result.getElement() instanceof PsiClass); + assertTrue(!result.isValidResult()); + assertTrue(!result.isAccessible()); + } + + public void testStaticImportVsImplicit() throws Exception { + PsiReference ref = configure(); + JavaResolveResult result = ((PsiJavaReference)ref).advancedResolve(true); + final PsiElement element = result.getElement(); + assertTrue(element instanceof PsiClass); + assertTrue("Outer.Double".equals(((PsiClass)element).getQualifiedName())); + } + + public void testTwoModules() throws Exception{ + configureDependency(); + PsiReference ref = configure(); + PsiElement target = ((PsiJavaReference)ref).advancedResolve(true).getElement(); + assertTrue(target instanceof PsiClass); + } + + public void testTwoModules2() throws Exception{ + configureDependency(); + PsiReference ref = configure(); + PsiElement target = ((PsiJavaReference)ref).advancedResolve(true).getElement(); + assertNull(target); + } + + @SuppressWarnings({"ConstantConditions"}) + private void configureDependency() { + ApplicationManager.getApplication().runWriteAction(new Runnable() { + public void run() { + ModifiableModuleModel modifiableModel = ModuleManager.getInstance(getProject()).getModifiableModel(); + Module module = modifiableModel.newModule("a.iml", StdModuleTypes.JAVA); + modifiableModel.commit(); + + ModifiableRootModel rootModel = ModuleRootManager.getInstance(module).getModifiableModel(); + VirtualFile root = LocalFileSystem.getInstance().refreshAndFindFileByPath(getTestDataPath() + "/class/dependentModule"); + assert root != null; + + ContentEntry contentEntry = rootModel.addContentEntry(root); + contentEntry.addSourceFolder(root.findChild("src"), false); + contentEntry.addSourceFolder(root.findChild("test"), true); + rootModel.commit(); + + ModifiableRootModel modifiableRootModel = ModuleRootManager.getInstance(getModule()).getModifiableModel(); + modifiableRootModel.addModuleOrderEntry(module); + modifiableRootModel.commit(); + } + }); + } + + private PsiReference configure() throws Exception { + return configureByFile("class/" + getTestName(false) + ".java"); + } +} diff --git a/java/java-tests/testSrc/com/intellij/psi/resolve/ResolveInCodeFragmentTest.java b/java/java-tests/testSrc/com/intellij/psi/resolve/ResolveInCodeFragmentTest.java new file mode 100644 index 000000000000..83feca6dc40b --- /dev/null +++ b/java/java-tests/testSrc/com/intellij/psi/resolve/ResolveInCodeFragmentTest.java @@ -0,0 +1,48 @@ +package com.intellij.psi.resolve; + +import com.intellij.psi.*; +import com.intellij.psi.util.PsiTreeUtil; +import com.intellij.testFramework.ResolveTestCase; + +/** + * @author max + */ +public class ResolveInCodeFragmentTest extends ResolveTestCase { + public void testLocalVariable() throws Exception { + final PsiReference iRef = configure(); + + PsiElement context = PsiTreeUtil.getParentOfType(iRef.getElement(), PsiCodeBlock.class); + JavaCodeFragment codeFragment = JavaPsiFacade.getInstance(myProject).getElementFactory() + .createExpressionCodeFragment(iRef.getElement().getText(), context, null, true); + codeFragment.setVisibilityChecker(JavaCodeFragment.VisibilityChecker.EVERYTHING_VISIBLE); + + PsiElement[] fileContent = codeFragment.getChildren(); + assertEquals(1, fileContent.length); + assertTrue(fileContent[0] instanceof PsiExpression); + + PsiExpression expr = (PsiExpression) fileContent[0]; + expr.accept(new JavaRecursiveElementWalkingVisitor() { + @Override public void visitReferenceExpression(PsiReferenceExpression expression) { + assertEquals(iRef.resolve(), + expression.resolve()); + } + }); + } + + public void testjavaLangClass() throws Exception { + PsiCodeFragment codeFragment = JavaPsiFacade.getInstance(myProject).getElementFactory().createExpressionCodeFragment( + "Boolean.getBoolean(\"true\")", null, null, true); + + PsiElement[] fileContent = codeFragment.getChildren(); + assertEquals(1, fileContent.length); + assertTrue(fileContent[0] instanceof PsiExpression); + + PsiExpression expr = (PsiExpression) fileContent[0]; + assertNotNull(expr.getType()); + assertEquals("boolean", expr.getType().getCanonicalText()); + } + + private PsiReference configure() throws Exception { + return configureByFile("codeFragment/" + getTestName(false) + ".java"); + } +} diff --git a/java/java-tests/testSrc/com/intellij/psi/resolve/ResolveMethod15Test.java b/java/java-tests/testSrc/com/intellij/psi/resolve/ResolveMethod15Test.java new file mode 100644 index 000000000000..f5694a3df0a0 --- /dev/null +++ b/java/java-tests/testSrc/com/intellij/psi/resolve/ResolveMethod15Test.java @@ -0,0 +1,532 @@ +package com.intellij.psi.resolve; + +import com.intellij.psi.*; +import com.intellij.psi.util.PsiTreeUtil; +import com.intellij.psi.infos.MethodCandidateInfo; +import com.intellij.navigation.NavigationItem; +import org.jetbrains.annotations.NonNls; +import static org.junit.Assert.assertThat; +import static org.hamcrest.core.IsInstanceOf.instanceOf; + +/** + * @author dsl + */ +public class ResolveMethod15Test extends Resolve15TestCase { + public void testStaticImportOnDemand() throws Exception { + final PsiReference ref = configureByFile(); + final PsiElement element = ref.resolve(); + assertNotNull(element); + assertThat(element, instanceOf(PsiMethod.class)); + final PsiMethod method = (PsiMethod)element; + assertEquals("asList", method.getName()); + assertEquals("java.util.Arrays", method.getContainingClass().getQualifiedName()); + } + + public void testStaticImportHidden() throws Exception { + final PsiJavaReference ref = (PsiJavaReference)configureByFile(); + final JavaResolveResult result = ref.advancedResolve(false); + assertFalse(result.isValidResult()); + final PsiElement element = result.getElement(); + assertNotNull(element); + assertThat(element, instanceOf(PsiMethod.class)); + final PsiMethod method = (PsiMethod)element; + assertEquals("java.lang.Object", method.getContainingClass().getQualifiedName()); + } + + public void testStaticImportDirect() throws Exception { + final PsiReference ref = configureByFile(); + final PsiElement element = ref.resolve(); + assertNotNull(element); + assertThat(element, instanceOf(PsiMethod.class)); + final PsiMethod method = (PsiMethod)element; + assertEquals("asList", method.getName()); + assertEquals("java.util.Arrays", method.getContainingClass().getQualifiedName()); + assertThat(ref, instanceOf(PsiReferenceExpression.class)); + final PsiReferenceExpression refExpr = (PsiReferenceExpression)ref; + final JavaResolveResult[] resolveResults = refExpr.multiResolve(false); + assertEquals(1, resolveResults.length); + final JavaResolveResult resolveResult = resolveResults[0]; + assertTrue(resolveResult.isValidResult()); + assertThat(resolveResult.getCurrentFileResolveScope(), instanceOf(PsiImportStaticStatement.class)); + assertThat(resolveResult, instanceOf(MethodCandidateInfo.class)); + final MethodCandidateInfo methodCandidateInfo = (MethodCandidateInfo)resolveResult; + assertTrue(methodCandidateInfo.isApplicable()); + } + + + public void testStaticImportConflict() throws Exception { + final PsiReference ref = configureByFile(); + final PsiElement element = ref.resolve(); + assertNotNull(element); + assertThat(element, instanceOf(PsiMethod.class)); + final PsiMethod method = (PsiMethod)element; + assertEquals("sort", method.getName()); + assertEquals("java.util.Collections", method.getContainingClass().getQualifiedName()); + assertThat(ref, instanceOf(PsiReferenceExpression.class)); + final PsiReferenceExpression refExpr = (PsiReferenceExpression)ref; + final JavaResolveResult[] resolveResults = refExpr.multiResolve(false); + assertEquals(1, resolveResults.length); + final JavaResolveResult resolveResult = resolveResults[0]; + assertFalse(resolveResult.isValidResult()); + assertThat(resolveResult.getCurrentFileResolveScope(), instanceOf(PsiImportStaticStatement.class)); + assertThat(resolveResult, instanceOf(MethodCandidateInfo.class)); + final MethodCandidateInfo methodCandidateInfo = (MethodCandidateInfo)resolveResult; + assertFalse(methodCandidateInfo.isApplicable()); + } + + public void testStaticImportConflict1() throws Exception { + final PsiJavaCodeReferenceElement ref = (PsiJavaCodeReferenceElement)configureByFile(); + final JavaResolveResult result = ref.advancedResolve(false); + PsiElement element = result.getElement(); + assertTrue(!result.isValidResult()); + assertThat(element, instanceOf(PsiMethod.class)); + final PsiMethod method = (PsiMethod)element; + PsiMethod parentMethod = PsiTreeUtil.getParentOfType(ref.getElement(), PsiMethod.class); + assertEquals(method, parentMethod); + } + + public void testGenericsAndVarargsNoConflict() throws Exception { + final PsiReference ref = configureByFile(); + final PsiElement element = ref.resolve(); + assertNotNull(element); + assertThat(element, instanceOf(PsiMethod.class)); + final PsiMethod method = (PsiMethod)element; + assertEquals("method", method.getName()); + assertEquals(method.getTypeParameters().length, 0); + assertThat(ref, instanceOf(PsiReferenceExpression.class)); + final PsiReferenceExpression refExpr = (PsiReferenceExpression)ref; + final JavaResolveResult[] resolveResults = refExpr.multiResolve(false); + assertEquals(1, resolveResults.length); + final JavaResolveResult resolveResult = resolveResults[0]; + assertTrue(resolveResult.isValidResult()); + assertThat(resolveResult, instanceOf(MethodCandidateInfo.class)); + final MethodCandidateInfo methodCandidateInfo = (MethodCandidateInfo)resolveResult; + assertTrue(methodCandidateInfo.isApplicable()); + } + + //JLS3 15.2.8 hack + public void testGetClass() throws Exception { + final PsiReference ref = configureByFile(); + assertThat(ref, instanceOf(PsiReferenceExpression.class)); + final PsiReferenceExpression refExpr = (PsiReferenceExpression)ref; + PsiType type = ((PsiExpression)refExpr.getParent()).getType(); + assertEquals("java.lang.Class", type.getCanonicalText()); + } + + public void testFilterFixedVsVarargs1() throws Exception { + final PsiReference ref = configureByFile(); + assertThat(ref, instanceOf(PsiReferenceExpression.class)); + final PsiReferenceExpression refExpr = (PsiReferenceExpression)ref; + PsiMethodCallExpression call = (PsiMethodCallExpression) refExpr.getParent(); + assertNull(call.resolveMethod()); + } + + public void testFilterFixedVsVarargs2() throws Exception { + final PsiReference ref = configureByFile(); + assertThat(ref, instanceOf(PsiReferenceExpression.class)); + final PsiReferenceExpression refExpr = (PsiReferenceExpression)ref; + PsiMethodCallExpression call = (PsiMethodCallExpression) refExpr.getParent(); + assertNull(call.resolveMethod()); + } + + public void testFilterFixedVsVarargs3() throws Exception { + final PsiReference ref = configureByFile(); + assertThat(ref, instanceOf(PsiReferenceExpression.class)); + final PsiReferenceExpression refExpr = (PsiReferenceExpression)ref; + PsiMethodCallExpression call = (PsiMethodCallExpression) refExpr.getParent(); + assertNull(call.resolveMethod()); + } + + public void testFilterFixedVsVarargs4() throws Exception { + final PsiReference ref = configureByFile(); + assertThat(ref, instanceOf(PsiReferenceExpression.class)); + final PsiReferenceExpression refExpr = (PsiReferenceExpression)ref; + PsiMethodCallExpression call = (PsiMethodCallExpression) refExpr.getParent(); + JavaResolveResult resolveResult = call.resolveMethodGenerics(); + assertNotNull(resolveResult.getElement()); + assertTrue(resolveResult.isValidResult()); + } + + public void testFilterFixedVsVarargs5() throws Exception { + final PsiReference ref = configureByFile(); + assertThat(ref, instanceOf(PsiReferenceExpression.class)); + final PsiReferenceExpression refExpr = (PsiReferenceExpression)ref; + PsiMethodCallExpression call = (PsiMethodCallExpression) refExpr.getParent(); + JavaResolveResult resolveResult = call.resolveMethodGenerics(); + PsiElement element = resolveResult.getElement(); + assertNotNull(element); + assertTrue(resolveResult.isValidResult()); + assertTrue(!((PsiMethod) element).isVarArgs()); + } + + public void testFilterFixedVsVarargs6() throws Exception { + final PsiReference ref = configureByFile(); + assertThat(ref, instanceOf(PsiReferenceExpression.class)); + final PsiReferenceExpression refExpr = (PsiReferenceExpression)ref; + PsiMethodCallExpression call = (PsiMethodCallExpression) refExpr.getParent(); + JavaResolveResult resolveResult = call.resolveMethodGenerics(); + PsiElement element = resolveResult.getElement(); + assertNotNull(element); + assertTrue(resolveResult.isValidResult()); + assertTrue(((PsiMethod) element).isVarArgs()); + } + + public void testFilterFixedVsVarargs7() throws Exception { + final PsiReference ref = configureByFile(); + assertThat(ref, instanceOf(PsiReferenceExpression.class)); + final PsiReferenceExpression refExpr = (PsiReferenceExpression)ref; + PsiMethodCallExpression call = (PsiMethodCallExpression) refExpr.getParent(); + JavaResolveResult resolveResult = call.resolveMethodGenerics(); + PsiElement element = resolveResult.getElement(); + assertNotNull(element); + assertTrue(resolveResult.isValidResult()); + assertTrue(!((PsiMethod) element).isVarArgs()); + } + + public void testFilterFixedVsVarargs8() throws Exception { + final PsiReference ref = configureByFile(); + assertThat(ref, instanceOf(PsiReferenceExpression.class)); + final PsiReferenceExpression refExpr = (PsiReferenceExpression)ref; + PsiCallExpression call = (PsiCallExpression) refExpr.getParent(); + JavaResolveResult resolveResult = call.resolveMethodGenerics(); + PsiElement element = resolveResult.getElement(); + assertNotNull(element); + assertTrue(resolveResult.isValidResult()); + assertTrue(!((PsiMethod) element).isVarArgs()); + } + public void testFilterFixedVsVarargs9() throws Exception { + final PsiReference ref = configureByFile(); + assertThat(ref, instanceOf(PsiReferenceExpression.class)); + final PsiReferenceExpression refExpr = (PsiReferenceExpression)ref; + PsiCallExpression call = (PsiCallExpression) refExpr.getParent(); + JavaResolveResult resolveResult = call.resolveMethodGenerics(); + PsiElement element = resolveResult.getElement(); + assertNotNull(element); + assertTrue(resolveResult.isValidResult()); + assertTrue(((PsiMethod) element).isVarArgs()); + } + + public void testFilterBoxing1() throws Exception { + final PsiReference ref = configureByFile(); + assertThat(ref, instanceOf(PsiReferenceExpression.class)); + final PsiReferenceExpression refExpr = (PsiReferenceExpression)ref; + PsiCallExpression call = (PsiCallExpression) refExpr.getParent(); + JavaResolveResult resolveResult = call.resolveMethodGenerics(); + PsiElement element = resolveResult.getElement(); + assertNotNull(element); + assertTrue(resolveResult.isValidResult()); + final PsiMethod method = (PsiMethod)element; + assertEquals(PsiType.BOOLEAN, method.getParameterList().getParameters()[1].getType()); + } + + public void testFilterVarargsVsVarargs1() throws Exception { + final PsiReference ref = configureByFile(); + assertThat(ref, instanceOf(PsiReferenceExpression.class)); + final PsiReferenceExpression refExpr = (PsiReferenceExpression)ref; + PsiCallExpression call = (PsiCallExpression) refExpr.getParent(); + JavaResolveResult resolveResult = call.resolveMethodGenerics(); + PsiElement element = resolveResult.getElement(); + assertNotNull(element); + assertTrue(resolveResult.isValidResult()); + assertEquals(((PsiMethod)element).getParameterList().getParametersCount(), 3); + } + + public void testFilterVarargsVsVarargs2() throws Exception { + final PsiReference ref = configureByFile(); + assertThat(ref, instanceOf(PsiReferenceExpression.class)); + final PsiReferenceExpression refExpr = (PsiReferenceExpression)ref; + PsiCallExpression call = (PsiCallExpression) refExpr.getParent(); + JavaResolveResult resolveResult = call.resolveMethodGenerics(); + assertNull(resolveResult.getElement()); + assertFalse(resolveResult.isValidResult()); + + final JavaResolveResult[] candidates = refExpr.multiResolve(false); + assertEquals(2, candidates.length); + } + + //IDEADEV-3313 + public void testCovariantReturnTypes() throws Exception { + final PsiReference ref = configureByFile(); + assertThat(ref, instanceOf(PsiReferenceExpression.class)); + final PsiReferenceExpression refExpr = (PsiReferenceExpression)ref; + final PsiElement parent = refExpr.getParent(); + assertThat(parent, instanceOf(PsiMethodCallExpression.class)); + final PsiMethod method = ((PsiCall)parent).resolveMethod(); + assertNotNull(method); + assertEquals("E", method.getContainingClass().getName()); + } + + public void testGenericMethods1() throws Exception { + final PsiReference ref = configureByFile(); + assertThat(ref, instanceOf(PsiReferenceExpression.class)); + final PsiReferenceExpression refExpr = (PsiReferenceExpression)ref; + final PsiElement parent = refExpr.getParent(); + assertThat(parent, instanceOf(PsiMethodCallExpression.class)); + final PsiMethodCallExpression expression = (PsiMethodCallExpression)parent; + assertNull(expression.resolveMethod()); + final JavaResolveResult[] results = expression.getMethodExpression().multiResolve(false); + assertEquals(2, results.length); + } + + public void testGenericMethods2() throws Exception { + final PsiReference ref = configureByFile(); + final PsiMethod method = checkResolvesUnique(ref); + assertEquals(0, method.getTypeParameters().length); + } + + public void testGenericMethods3() throws Exception { + final PsiReference ref = configureByFile(); + final PsiMethod method = checkResolvesUnique(ref); + assertEquals(0, method.getTypeParameters().length); + } + + public void testGenericMethods4() throws Exception { + final PsiReference ref = configureByFile(); + final PsiMethod method = checkResolvesUnique(ref); + assertEquals(0, method.getTypeParameters().length); + } + + public void testGenericMethods5() throws Exception { + final PsiReference ref = configureByFile(); + final PsiMethod method = checkResolvesUnique(ref); + assertEquals(2, method.getTypeParameters().length); + } + + public void testGenericMethods6() throws Exception { + final PsiReference ref = configureByFile(); + checkResolvesUnique(ref); + } + + public void testGenericClass1() throws Exception { + final PsiReference ref = configureByFile(); + final PsiMethod method = checkResolvesUnique(ref); + assertEquals("Foo", method.getContainingClass().getName()); + } + + public void testGenericClass2() throws Exception { + final PsiReference ref = configureByFile(); + final PsiMethod method = checkResolvesUnique(ref); + assertEquals(0, method.getTypeParameters().length); + } + + public void testMoreSpecificSameErasure() throws Exception { + final PsiReference ref = configureByFile(); + final PsiMethod method = checkResolvesUnique(ref); + assertEquals(0, method.getTypeParameters().length); + } + + private PsiReference configureByFile() throws Exception { + return configureByFile("method/generics/" + getTestName(false) + ".java"); + } + private static PsiMethod checkResolvesUnique(final PsiReference ref) { + assertThat(ref, instanceOf(PsiReferenceExpression.class)); + final PsiReferenceExpression refExpr = (PsiReferenceExpression)ref; + final PsiElement parent = refExpr.getParent(); + assertThat(parent, instanceOf(PsiMethodCallExpression.class)); + final PsiMethodCallExpression expression = (PsiMethodCallExpression)parent; + final PsiMethod method = expression.resolveMethod(); + assertNotNull(method); + return method; + } + + public void testTestGenericMethodOverloading1() throws Exception{ + PsiReference ref = configureByFile(); + PsiElement target = ref.resolve(); + assertThat(target, instanceOf(PsiMethod.class)); + assertThat(target.getParent(), instanceOf(PsiClass.class)); + assertEquals("Object", ((NavigationItem)target.getParent()).getName()); + } + + public void testPreferArrayTypeToObject() throws Exception { + PsiReference ref = configureByFile(); + PsiElement target = ref.resolve(); + assertThat(target, instanceOf(PsiMethod.class)); + assertThat(target.getParent(), instanceOf(PsiClass.class)); + final PsiParameter[] parameters = ((PsiMethod)target).getParameterList().getParameters(); + assertTrue(parameters.length == 1); + assertTrue(parameters[0].getType() instanceof PsiArrayType); + } + + public void testTestGenericMethodOverloading2() throws Exception{ + PsiReference ref = configureByFile(); + PsiElement target = ref.resolve(); + assertThat(target, instanceOf(PsiMethod.class)); + assertThat(target.getParent(), instanceOf(PsiClass.class)); + assertEquals("A", ((NavigationItem)target.getParent()).getName()); + } + + public void testTestGenericMethodOverloading3() throws Exception{ + PsiReference ref = configureByFile(); + PsiElement target = ref.resolve(); + assertThat(target, instanceOf(PsiMethod.class)); + assertThat(target.getParent(), instanceOf(PsiClass.class)); + assertEquals("Object", ((NavigationItem)target.getParent()).getName()); + } + + public void testTestGenericMethodOverloading4() throws Exception{ + PsiReference ref = configureByFile(); + PsiElement target = ref.resolve(); + assertThat(target, instanceOf(PsiMethod.class)); + assertThat(target.getParent(), instanceOf(PsiClass.class)); + assertEquals("A", ((NavigationItem)target.getParent()).getName()); + } + + public void testTestReturnType1() throws Exception{ + PsiReference ref = configureByFile(); + PsiElement target = ref.resolve(); + assertThat(target, instanceOf(PsiMethod.class)); + } + + public void testTestReturnType2() throws Exception{ + PsiReference ref = configureByFile(); + PsiElement target = ref.resolve(); + assertNull(target); + } + + public void testMerge1() throws Exception{ + PsiReference ref = configureByFile(); + PsiElement target = ref.resolve(); + assertNull(target); + } + public void testExtends1() throws Exception{ + PsiReference ref = configureByFile(); + PsiElement target = ref.resolve(); + assertThat(target, instanceOf(PsiMethod.class)); + } + public void testInheritance1() throws Exception{ + PsiReference ref = configureByFile(); + PsiElement target = ref.resolve(); + assertThat(target, instanceOf(PsiMethod.class)); + } + + public void testInheritance2() throws Exception{ + PsiReference ref = configureByFile(); + PsiElement target = ref.resolve(); + assertThat(target, instanceOf(PsiMethod.class)); + } + + public void testInheritance3() throws Exception{ + PsiReference ref = configureByFile(); + PsiElement target = ref.resolve(); + assertThat(target, instanceOf(PsiMethod.class)); + } + + public void testInheritance4() throws Exception{ + PsiReference ref = configureByFile(); + PsiElement target = ref.resolve(); + assertThat(target, instanceOf(PsiMethod.class)); + } + + public void testExplicitParams1() throws Exception { + PsiReference ref = configureByFile(); + assertGenericResolve(ref, "f", new String[] {"java.lang.String"}, "java.lang.String"); + } + + public void testExplicitParams2() throws Exception { + PsiReference ref = configureByFile(); + assertGenericResolve(ref, "f", new String[] {"java.lang.Integer"}, "Foo"); + } + + public void testConstructorExplicitParams() throws Exception { + PsiReference ref = configureByFile(); + assertThat(ref.getElement(), instanceOf(PsiJavaCodeReferenceElement.class)); + assertThat(ref.getElement().getParent(), instanceOf(PsiNewExpression.class)); + } + + + private static void assertGenericResolve(PsiReference ref, final String methodName, final String[] expectedTypeParameterValues, final String expectedCallType) { + PsiElement target = ref.resolve(); + assertThat(target, instanceOf(PsiMethod.class)); + + PsiMethod psiMethod = (PsiMethod)target; + assertEquals(methodName, psiMethod.getName()); + assertThat(ref.getElement(), instanceOf(PsiJavaCodeReferenceElement.class)); + PsiJavaCodeReferenceElement refElement = (PsiJavaCodeReferenceElement)ref.getElement(); + JavaResolveResult resolveResult = refElement.advancedResolve(false); + PsiSubstitutor substitutor = resolveResult.getSubstitutor(); + PsiTypeParameter[] typeParameters = psiMethod.getTypeParameters(); + assertEquals(expectedTypeParameterValues.length, typeParameters.length); + for (int i = 0; i < expectedTypeParameterValues.length; i++) { + String expectedTypeParameterValue = expectedTypeParameterValues[i]; + assertTrue(substitutor.substitute(typeParameters[i]).equalsToText(expectedTypeParameterValue)); + } + PsiType type = ((PsiExpression)refElement.getParent()).getType(); + assertTrue(type.equalsToText(expectedCallType)); + } + + public void testRawMethod1() throws Exception{ + PsiJavaReference ref = (PsiJavaReference) configureByFile(); + PsiElement target = ref.resolve(); + assertThat(target, instanceOf(PsiMethod.class)); + } + public void testDependingParams2() throws Exception{ + PsiJavaReference ref = (PsiJavaReference) configureByFile(); + final JavaResolveResult result = ref.advancedResolve(true); + assertTrue(result.isValidResult()); + } + + public void testTypeInference1() throws Exception{ + PsiJavaReference ref = (PsiJavaReference) configureByFile(); + final JavaResolveResult result = ref.advancedResolve(true); + assertNotNull(result.getElement()); + } + + + public void testRawVsGenericConflict() throws Exception{ + PsiJavaReference ref = (PsiJavaReference) configureByFile(); + final JavaResolveResult result = ref.advancedResolve(true); + assertResolvesToMethodInClass(result, "A"); + } + + public void testAutoboxingAndWidening() throws Exception{ + PsiJavaReference ref = (PsiJavaReference) configureByFile(); + final JavaResolveResult result = ref.advancedResolve(true); + assertNotNull(result.getElement()); + assertTrue(result.isValidResult()); + } + + public void testSOE() throws Exception { + PsiReference ref = configureByFile(); + ref.resolve(); + } + public void testHidingSuperPrivate() throws Exception { + PsiJavaReference ref = (PsiJavaReference)configureByFile(); + final JavaResolveResult result = ref.advancedResolve(true); + assertResolvesToMethodInClass(result, "S"); + } + public void testNestedTypeParams() throws Exception { + PsiJavaReference ref = (PsiJavaReference)configureByFile(); + final JavaResolveResult result = ref.advancedResolve(true); + assertResolvesToMethodInClass(result, "TestImpl"); + } + public void testTypeParamBoundConflict() throws Exception { + PsiJavaReference ref = (PsiJavaReference)configureByFile(); + final JavaResolveResult result = ref.advancedResolve(true); + assertResolvesToMethodInClass(result, "Testergen"); + } + public void testAmbiguousBoxing() throws Exception { + PsiJavaReference ref = (PsiJavaReference)configureByFile(); + final JavaResolveResult result = ref.advancedResolve(true); + assertFalse(result.isValidResult()); + + JavaResolveResult[] results = ref.multiResolve(false); + assertEquals(2, results.length); + assertEquals("f", ((PsiMethod)results[0].getElement()).getName()); + assertEquals("f", ((PsiMethod)results[1].getElement()).getName()); + } + + public void testStaticMethodInSubclass() throws Exception { + PsiJavaReference ref = (PsiJavaReference)configureByFile(); + final JavaResolveResult result = ref.advancedResolve(true); + assertTrue(result.isValidResult()); + + assertResolvesToMethodInClass(result, "SomeSubClass"); + } + + private static void assertResolvesToMethodInClass(JavaResolveResult result, @NonNls String name) { + PsiMethod method = (PsiMethod)result.getElement(); + assertNotNull(method); + assertTrue(result.isValidResult()); + assertEquals(name, method.getContainingClass().getName()); + } +} diff --git a/java/java-tests/testSrc/com/intellij/psi/resolve/ResolveMethodTest.java b/java/java-tests/testSrc/com/intellij/psi/resolve/ResolveMethodTest.java new file mode 100644 index 000000000000..5ae52f7d5b86 --- /dev/null +++ b/java/java-tests/testSrc/com/intellij/psi/resolve/ResolveMethodTest.java @@ -0,0 +1,265 @@ +package com.intellij.psi.resolve; + +import com.intellij.openapi.projectRoots.Sdk; +import com.intellij.openapi.projectRoots.impl.JavaSdkImpl; +import com.intellij.openapi.roots.LanguageLevelProjectExtension; +import com.intellij.pom.java.LanguageLevel; +import com.intellij.psi.*; +import com.intellij.psi.infos.MethodCandidateInfo; +import com.intellij.testFramework.ResolveTestCase; + +public class ResolveMethodTest extends ResolveTestCase { + @Override + protected void setUp() throws Exception { + super.setUp(); + LanguageLevelProjectExtension.getInstance(myJavaFacade.getProject()).setLanguageLevel(LanguageLevel.JDK_1_5); + } + + @Override + protected Sdk getTestProjectJdk() { + return JavaSdkImpl.getMockJdk14(); + } + + private PsiElement resolve() throws Exception { + PsiReference ref = configureByFile("method/" + getTestName(false) + ".java"); + return ref.resolve(); + } + private JavaResolveResult advancedResolve() throws Exception { + PsiJavaCodeReferenceElement ref = (PsiJavaCodeReferenceElement)configureByFile("method/" + getTestName(false) + ".java"); + return ref.advancedResolve(true); + } + + public void testShortVsInt() throws Exception { + PsiElement target = resolve(); + assertTrue(target instanceof PsiMethod); + PsiParameter parm = ((PsiMethod)target).getParameterList().getParameters()[0]; + assertEquals(PsiType.INT, parm.getType()); + } + + public void testSimple() throws Exception { + PsiElement target = resolve(); + assertTrue(target instanceof PsiMethod); + assertEquals("method", ((PsiMethod) target).getName()); + } + + public void testIndexOf() throws Exception{ + PsiElement target = resolve(); + assertTrue(target instanceof PsiMethod); + PsiParameter parm = ((PsiMethod)target).getParameterList().getParameters()[0]; + assertEquals(PsiType.INT, parm.getType()); + } + + public void testSuper1() throws Exception{ + PsiElement target = resolve(); + assertTrue(target instanceof PsiMethod); + } + + public void testInherit1() throws Exception{ + PsiElement target = resolve(); + assertTrue(target instanceof PsiMethod); + assertTrue(target.getParent() instanceof PsiClass); + assertEquals("B", ((PsiClass)target.getParent()).getQualifiedName()); + } + + public void testNextMethod() throws Exception{ + PsiElement target = resolve(); + assertTrue(target instanceof PsiMethod); + assertEquals(PsiType.BOOLEAN, ((PsiMethod)target).getParameterList().getParameters()[1].getType()); + } + + public void testMethodConflict1() throws Exception{ + PsiElement target = resolve(); + assertNull(target); + } + + public void testValueOf() throws Exception{ + PsiElement target = resolve(); + assertTrue(target instanceof PsiMethod); + assertEquals(PsiType.INT, ((PsiMethod)target).getParameterList().getParameters()[0].getType()); + } + + public void testMethodFromAnonBase() throws Exception{ + PsiElement target = resolve(); + assertTrue(target instanceof PsiMethod); + } + + public void testSCR5859() throws Exception{ + PsiElement target = resolve(); + assertTrue(target instanceof PsiMethod); + PsiParameter[] parms = ((PsiMethod)target).getParameterList().getParameters(); + assertEquals("Derived", parms[0].getType().getPresentableText()); + assertEquals("Derived", parms[1].getType().getPresentableText()); + } + + public void testPreferPublic() throws Exception{ + PsiElement target = resolve(); + assertTrue(target instanceof PsiMethod); + assertTrue(((PsiMethod)target).hasModifierProperty(PsiModifier.PUBLIC)); + } + + public void testRemove1() throws Exception{ + PsiElement target = resolve(); + assertTrue(target instanceof PsiMethod); + assertTrue(target.getParent() instanceof PsiClass); + assertEquals("Remove1.A", ((PsiClass)target.getParent()).getQualifiedName()); + } + + public void testRemove2() throws Exception{ + PsiElement target = resolve(); + assertTrue(target instanceof PsiMethod); + assertTrue(target.getParent() instanceof PsiClass); + assertEquals("java.util.AbstractCollection", ((PsiClass)target.getParent()).getQualifiedName()); + } + + public void testArray1() throws Exception{ + PsiElement target = resolve(); + assertTrue(target instanceof PsiMethod); + } + + public void testCycle1() throws Exception{ + PsiElement target = resolve(); + assertTrue(target instanceof PsiMethod); + assertTrue(target.getParent() instanceof PsiClass); + assertEquals("Cycle1.C", ((PsiClass)target.getParent()).getQualifiedName()); + } + + public void testAnonymousSuper1() throws Exception{ + PsiElement target = resolve(); + assertTrue(target instanceof PsiMethod); + assertTrue(target.getParent() instanceof PsiClass); + assertEquals("Test1.A", ((PsiClass)target.getParent()).getQualifiedName()); + } + + public void testBug7968() throws Exception{ + PsiElement target = resolve(); + assertTrue(target instanceof PsiMethod); + assertTrue(target.getParent() instanceof PsiClass); + assertEquals("Bug7968.Bar", ((PsiClass)target.getParent()).getQualifiedName()); + } + + public void testInheranceWithExtendsConflict() throws Exception{ + PsiElement target = resolve(); + assertTrue(target instanceof PsiMethod); + assertTrue(target.getParent() instanceof PsiClass); + assertEquals("B", ((PsiClass)target.getParent()).getQualifiedName()); + } + + public void testSout() throws Exception { + PsiElement target = resolve(); + assertTrue(target instanceof PsiMethod); + assertEquals("println", ((PsiMethod)target).getName()); + } + + /* + public void testSCR5134() throws Exception{ + PsiReference ref = configureByFile("method/SCR5134.java"); + PsiElement target = ref.resolve(); + assertTrue(target instanceof PsiMethod); + PsiParameter parm = ((PsiMethod)target).getParameterList().getParameters()[0]; + assertTrue(parm.getType().getText().equals("Integer")); + } + */ + + public void testPartlyImplement1() throws Exception{ + PsiElement target = resolve(); + assertTrue(target instanceof PsiMethod); + assertTrue(target.getParent() instanceof PsiClass); + assertEquals("A.Predicate", ((PsiClass)target.getParent()).getQualifiedName()); + } + + public void testTestOverloading1() throws Exception{ + PsiElement target = resolve(); + assertTrue(target instanceof PsiMethod); + assertTrue(target.getParent() instanceof PsiClass); + assertEquals("B", ((PsiClass) target.getParent()).getName()); + } + + + public void testSuperOfObject() throws Exception { + PsiElement target = resolve(); + assertTrue(target instanceof PsiMethod); + final PsiMethod method = (PsiMethod)target; + assertEquals("clone", method.getName()); + assertEquals("java.lang.Object", method.getContainingClass().getQualifiedName()); + } + + + public void testStaticVSNonStatic() throws Exception{ + PsiElement target = resolve(); + assertTrue(target instanceof PsiMethod); + PsiMethod method = (PsiMethod) target; + assertEquals(1, method.getParameterList().getParametersCount()); + } + + public void testClone() throws Exception{ + PsiElement target = resolve(); + assertTrue(target instanceof PsiMethod); + } + + public void testThrowWithoutNew() throws Exception{ + PsiElement target = resolve(); + assertNull(target); + } + + public void testThrowWithoutNew2() throws Exception { + PsiElement target = advancedResolve().getElement(); + assertTrue(target instanceof PsiClass); + } + + public void testNotAccessibleAccessClass() throws Exception{ + JavaResolveResult result = advancedResolve(); + assertFalse(result.isAccessible()); + } + + public void testInnerClass() throws Exception{ + JavaResolveResult result = advancedResolve(); + assertNotNull(result.getElement()); + assertTrue(result instanceof MethodCandidateInfo); + assertTrue(!result.isValidResult()); + assertTrue(!((MethodCandidateInfo)result).isApplicable()); + final PsiClass aClass = ((PsiMethod)result.getElement()).getContainingClass(); + assertNotNull(aClass.getContainingClass()); + } + + public void testPrivateInSuperInner() throws Exception{ + JavaResolveResult result = advancedResolve(); + assertNotNull(result.getElement()); + assertTrue(result instanceof MethodCandidateInfo); + assertTrue(!result.isValidResult()); + assertTrue(!result.isStaticsScopeCorrect()); + } + + public void testPrivateInSuperInner1() throws Exception{ + JavaResolveResult result = advancedResolve(); + assertNotNull(result.getElement()); + assertTrue(result instanceof MethodCandidateInfo); + assertTrue(result.isValidResult()); + } + + public void testProtectedM() throws Exception { + JavaResolveResult result = advancedResolve(); + assertTrue(result.getElement() instanceof PsiMethod); + assertFalse(result.isAccessible()); + } + + // This test complile but it seems to be a bug. + //public void testDependingParams1() throws Exception{ + // PsiJavaReference ref = (PsiJavaReference) configureByFile("method/generics/DependingParams.java"); + // final JavaResolveResult result = ref.advancedResolve(true); + // assertTrue(result.isValidResult()); + //} + + public void testImplementOrder() throws Exception { + PsiElement target = resolve(); + assertTrue(target instanceof PsiMethod); + PsiMethod method = (PsiMethod) target; + assertEquals("II", method.getContainingClass().getName()); + } + + public void testObjectVsInterface() throws Exception { + PsiElement target = resolve(); + assertTrue(target instanceof PsiMethod); + PsiMethod method = (PsiMethod) target; + assertEquals("PublicCloneable", method.getContainingClass().getName()); + } +} diff --git a/java/java-tests/testSrc/com/intellij/psi/resolve/ResolveVariable15Test.java b/java/java-tests/testSrc/com/intellij/psi/resolve/ResolveVariable15Test.java new file mode 100644 index 000000000000..691c0951a378 --- /dev/null +++ b/java/java-tests/testSrc/com/intellij/psi/resolve/ResolveVariable15Test.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2006 JetBrains s.r.o. All Rights Reserved. + */ +package com.intellij.psi.resolve; + +import com.intellij.psi.PsiReference; +import com.intellij.psi.JavaResolveResult; +import com.intellij.psi.PsiJavaReference; +import com.intellij.psi.PsiElement; + +/** + * @author ven + */ +public class ResolveVariable15Test extends Resolve15TestCase { + + public void testDuplicateStaticImport() throws Exception { + PsiReference ref = configure(); + final JavaResolveResult result = ((PsiJavaReference)ref).advancedResolve(true); + PsiElement target = result.getElement(); + assertNotNull(target); + assertTrue(result.isValidResult()); + } + + public void testRhombExtending() throws Exception { + PsiReference ref = configure(); + final JavaResolveResult result = ((PsiJavaReference)ref).advancedResolve(true); + PsiElement target = result.getElement(); + assertNotNull(target); + assertTrue(result.isValidResult()); + } + + + private PsiReference configure() throws Exception { + return configureByFile("var15/" + getTestName(false) + ".java"); + } +} diff --git a/java/java-tests/testSrc/com/intellij/psi/resolve/ResolveVariableTest.java b/java/java-tests/testSrc/com/intellij/psi/resolve/ResolveVariableTest.java new file mode 100644 index 000000000000..8358f37ea1ea --- /dev/null +++ b/java/java-tests/testSrc/com/intellij/psi/resolve/ResolveVariableTest.java @@ -0,0 +1,255 @@ +package com.intellij.psi.resolve; + +import com.intellij.psi.*; +import com.intellij.psi.search.GlobalSearchScope; +import com.intellij.testFramework.ResolveTestCase; + +public class ResolveVariableTest extends ResolveTestCase { + public ResolveVariableTest() { + myRunCommandForTest = true; + } + + public void testAnonymousConstructorArg() throws Exception { + PsiElement target = configureAndResolve(); + assertTrue(target instanceof PsiParameter); + assertEquals("value", ((PsiParameter)target).getName()); + } + + public void testLocalVariable1() throws Exception { + PsiElement target = configureAndResolve(); + assertTrue(target instanceof PsiLocalVariable); + assertEquals("value", ((PsiLocalVariable)target).getName()); + } + + public void testVisibility1() throws Exception { + PsiElement target = configureAndResolve(); + assertTrue(target instanceof PsiField); + assertEquals("variable", ((PsiField)target).getName()); + } + + public void testVisibility2() throws Exception { + PsiElement target = configureAndResolve(); + assertTrue(target instanceof PsiField); + assertEquals("a", ((PsiField)target).getName()); + } + + private PsiElement configureAndResolve() throws Exception { + PsiReference ref = configure(); + PsiElement target = ref.resolve(); + return target; + } + + public void testVisibility3() throws Exception { + PsiElement target = configureAndResolve(); + assertTrue(target instanceof PsiField); + assertEquals("i", ((PsiField)target).getName()); + } + + public void testVisibility4() throws Exception { + PsiElement target = configureAndResolve(); + assertEquals("a", ((PsiLocalVariable)target).getName()); + assertTrue(target instanceof PsiLocalVariable); + } + + public void testQualified1() throws Exception { + PsiElement target = configureAndResolve(); + assertTrue(target instanceof PsiField); + assertEquals("a", ((PsiField)target).getName()); + } + + public void testQualified2() throws Exception { + PsiElement target = configureAndResolve(); + assertTrue(target instanceof PsiField); + assertEquals("a", ((PsiField)target).getName()); + } + + public void testQualified3() throws Exception { + PsiElement target = configureAndResolve(); + assertTrue(target instanceof PsiField); + assertEquals("a", ((PsiField)target).getName()); + } + + public void testQualified4() throws Exception { + PsiElement target = configureAndResolve(); + assertTrue(target instanceof PsiField); + assertEquals("a", ((PsiField)target).getName()); + } + + public void testUnresolved1() throws Exception { + PsiElement target = configureAndResolve(); + assertNull(target); + } + + public void testFieldFromInterface() throws Exception { + PsiElement target = configureAndResolve(); + assertTrue(target instanceof PsiField); + } + + public void testInterfaceConflict1() throws Exception { + PsiElement target = configureAndResolve(); + assertNull(target); + } + + public void testInterfaceConflict2() throws Exception { + PsiElement target = configureAndResolve(); + assertNull(target); + } + + public void testInterfaceConflict3() throws Exception { + PsiElement target = configureAndResolve(); + assertNull(target); + } + + public void testInterfaceConflict4() throws Exception { + PsiElement target = configureAndResolve(); + assertNull(target); + } + + // This is a bug but it's too hard to fix this :( + // TODO: try to fix + public void dontTestInterfaceConflict5() throws Exception { + PsiElement target = configureAndResolve(); + assertNull(target); + } + + public void testInterfaceConflict6() throws Exception { + PsiElement target = configureAndResolve(); + assertNull(target); + } + + public void testInterfaceConflict7() throws Exception { + PsiElement target = configureAndResolve(); + assertNotNull(target); + } + + public void testInterfaceConflict8() throws Exception { + PsiElement target = configureAndResolve(); + assertNotNull(target); + } + + public void testInterfaceConflict9() throws Exception { + PsiElement target = configureAndResolve(); + assertNull(target); + } + + public void testInterfaceConflict10() throws Exception { + PsiElement target = configureAndResolve(); + assertNull(target); + } + + public void testArray1() throws Exception { + PsiElement target = configureAndResolve(); + assertNotNull(target); + } + + public void testInterfaceConflict11() throws Exception { + PsiElement target = configureAndResolve(); + assertNotNull(target); + assertTrue(target instanceof PsiField); + assertEquals("B", ((PsiField)target).getContainingClass().getName()); + } + + public void testBug7869() throws Exception { + PsiElement target = configureAndResolve(); + assertNotNull(target); + } + + public void testInner1() throws Exception { + PsiElement target = configureAndResolve(); + assertNotNull(target); + assertEquals("Inner1", ((PsiField)target).getContainingClass().getName()); + } + + public void testFieldsAndLocals() throws Exception { + PsiElement target = configureAndResolve(); + assertTrue(target instanceof PsiLocalVariable); + } + + public void testPrivateOverloading() throws Exception { + PsiReference ref = configureByFile("var/PrivateOverloading.java"); + final JavaResolveResult result = ((PsiJavaReference)ref).advancedResolve(true); + PsiElement target = result.getElement(); + assertNotNull(target); + assertFalse(result.isValidResult()); + } + + public void testVisibility6() throws Exception { + PsiReference ref = configureByFile("var/Visibility6.java"); + final JavaResolveResult result = ((PsiJavaReference)ref).advancedResolve(true); + PsiElement target = result.getElement(); + assertNotNull(target); + assertFalse(result.isValidResult()); + } + + public void testVisibility7() throws Exception { + PsiReference ref = configureByFile("var/InnerPrivates1.java"); + final JavaResolveResult result = ((PsiJavaReference)ref).advancedResolve(true); + PsiElement target = result.getElement(); + assertNotNull(target); + assertTrue(result.isValidResult()); + } + + public void testForeachParameter() throws Exception { + final PsiReference ref = configureByFile("var/ForeachParameter.java"); + final PsiElement element = ref.resolve(); + assertTrue(element instanceof PsiParameter); + assertEquals("o", ((PsiParameter)element).getName()); + assertTrue(element.getParent() instanceof PsiForeachStatement); + } + + public void testRefInSuper() throws Exception { + final PsiJavaReference ref = (PsiJavaReference)configureByFile("var/RefInSuper.java"); + final JavaResolveResult resolveResult = ref.advancedResolve(false); + assertTrue(resolveResult.isValidResult()); + PsiElement currentFileResolveScope = resolveResult.getCurrentFileResolveScope(); + assertTrue(currentFileResolveScope instanceof PsiClass); + assertEquals("Inner", ((PsiClass)currentFileResolveScope).getName()); + PsiElement element = resolveResult.getElement(); + assertTrue(element instanceof PsiField); + assertEquals("i", ((PsiField)element).getName()); + } + + public void testRefInOuter() throws Exception { + final PsiJavaReference ref = (PsiJavaReference)configureByFile("var/RefInOuter.java"); + final JavaResolveResult resolveResult = ref.advancedResolve(false); + assertTrue(resolveResult.isValidResult()); + PsiElement currentFileResolveScope = resolveResult.getCurrentFileResolveScope(); + assertTrue(currentFileResolveScope instanceof PsiClass); + assertEquals("Outer", ((PsiClass)currentFileResolveScope).getName()); + PsiElement element = resolveResult.getElement(); + assertTrue(element instanceof PsiField); + assertEquals("i", ((PsiField)element).getName()); + } + + public void testInheritedOuter() throws Exception { + final PsiJavaReference ref = (PsiJavaReference)configureByFile("var/InheritedOuter.java"); + final JavaResolveResult resolveResult = ref.advancedResolve(false); + assertTrue(resolveResult.isValidResult()); + } + + public void testStaticFieldsInInterfacesConflict() throws Exception { + final PsiJavaReference ref = (PsiJavaReference)configureByFile("var/FieldConflict.java"); + final JavaResolveResult resolveResult = ref.advancedResolve(false); + assertTrue(!resolveResult.isValidResult()); + final JavaResolveResult[] results = ref.multiResolve(false); + assertEquals(2, results.length); + } + + public void testShadowFieldsInHierarchy() throws Exception { + final PsiJavaReference ref = (PsiJavaReference)configure(); + final JavaResolveResult resolveResult = ref.advancedResolve(false); + assertTrue(resolveResult.isValidResult()); + PsiField field = myJavaFacade.findClass("TestPage", GlobalSearchScope.allScope(getProject())).getFields()[0]; + assertEquals(field, resolveResult.getElement()); + } + + public void testShadowFieldsInHierarchy2() throws Exception { + PsiElement ref = configureAndResolve(); + assertTrue(ref instanceof PsiField); + assertEquals("E", ((PsiField)ref).getContainingClass().getName()); + } + + private PsiReference configure() throws Exception { + return configureByFile("var/" + getTestName(false) + ".java"); + } +} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/psi/resolve/TypeInferenceTest.java b/java/java-tests/testSrc/com/intellij/psi/resolve/TypeInferenceTest.java new file mode 100644 index 000000000000..e6f9e694f675 --- /dev/null +++ b/java/java-tests/testSrc/com/intellij/psi/resolve/TypeInferenceTest.java @@ -0,0 +1,157 @@ +package com.intellij.psi.resolve; + +import com.intellij.psi.*; +import org.jetbrains.annotations.NonNls; + +/** + * @author ven + */ +public class TypeInferenceTest extends Resolve15TestCase { + public void testInferInCall1 () throws Exception { + PsiReferenceExpression ref = configure(); + PsiType type = ref.getType(); + assertTrue(type instanceof PsiClassType); + PsiType[] paramTypes = ((PsiClassType)type).getParameters(); + assertEquals(1, paramTypes.length); + assertEquals( "java.lang.Object", paramTypes[0].getCanonicalText()); + } + + public void testInferInAssign1 () throws Exception { + PsiReferenceExpression ref = configure(); + PsiType type = ref.getType(); + assertTrue(type instanceof PsiClassType); + PsiType[] paramTypes = ((PsiClassType)type).getParameters(); + assertEquals(1, paramTypes.length); + assertEquals( "java.lang.String", paramTypes[0].getCanonicalText()); + } + + public void testInferInAssign2() throws Exception { + PsiReferenceExpression ref = configure(); + PsiType type = ref.getType(); + assertTrue(type instanceof PsiClassType); + PsiType[] paramTypes = ((PsiClassType)type).getParameters(); + assertEquals(1, paramTypes.length); + assertEquals( "java.lang.Object", paramTypes[0].getCanonicalText()); + } + + public void testInferInCast () throws Exception { + PsiReferenceExpression ref = configure(); + PsiType type = ref.getType(); + assertTrue(type instanceof PsiClassType); + PsiType[] paramTypes = ((PsiClassType)type).getParameters(); + assertEquals(1, paramTypes.length); + assertEquals( "java.lang.Object", paramTypes[0].getCanonicalText()); + } + + public void testInferWithBounds () throws Exception { + checkResolvesTo("C.Inner"); + } + + public void testInferWithBounds1 () throws Exception { + PsiReferenceExpression ref = configure(); + JavaResolveResult resolveResult = ref.advancedResolve(false); + PsiSubstitutor substitutor = resolveResult.getSubstitutor(); + PsiMethod method = (PsiMethod)resolveResult.getElement(); + PsiType type = substitutor.substitute(method.getTypeParameters()[0]); + assertEquals("java.lang.String", type.getCanonicalText()); + } + + private PsiReferenceExpression configure() throws Exception { + return (PsiReferenceExpression)configureByFile("inference/" + getTestName(false) + ".java"); + } + + public void testInferInParamsOnly () throws Exception { + checkResolvesTo("C.I"); + } + + public void testInferRawType () throws Exception { + checkResolvesTo("java.lang.Object"); + } + + private void checkResolvesTo(@NonNls String typeName) throws Exception { + PsiReferenceExpression ref = configure(); + PsiType type = ref.getType(); + assertNotNull(type); + assertEquals(typeName, type.getCanonicalText()); + } + + public void testInferInSuperAssignment () throws Exception { + checkResolvesTo("B"); + } + + public void testInferWithWildcards () throws Exception { + checkResolvesTo("Collections.SelfComparable"); + } + + public void testInferWithWildcards1 () throws Exception { + checkResolvesTo("java.lang.String"); + } + + public void testInferWithWildcards2 () throws Exception { + checkResolvesTo("Collection"); + } + + public void testInferWithWildcards3 () throws Exception { + checkResolvesTo("X.Y"); + } + + public void testInferWithWildcards4 () throws Exception { + checkResolvesTo("X.Y"); + } + + public void testInferWithWildcards5 () throws Exception { + checkResolvesTo("X.Y"); + } + + public void testInferInReturn () throws Exception { + checkResolvesTo("T"); + } + + public void testInferAutoboxed () throws Exception { + checkResolvesTo("java.lang.Integer"); + } + + public void testInferWithVarargs1 () throws Exception { + checkResolvesTo("C2"); + } + + public void testInferWithVarargs2 () throws Exception { + checkResolvesTo("C1"); + } + + public void testInferWithVarargs3 () throws Exception { + checkResolvesTo("List"); + } + + public void testInferWithVarargs4 () throws Exception { + checkResolvesTo("List"); + } + + public void testInferWithVarargs5 () throws Exception { + checkResolvesTo("List"); + } + + public void testInferWithVarargs6 () throws Exception { + checkResolvesTo("List"); + } + + public void testInferPrimitiveArray () throws Exception { + checkResolvesTo("double[]"); + } + + public void testSCR41031 () throws Exception { + checkResolvesTo("List"); + } + + public void testInferUnchecked () throws Exception { + checkResolvesTo("java.lang.Object"); + } + + public void testInferNotNull () throws Exception { + checkResolvesTo("E"); + } + + public void testBoundComposition() throws Exception { + checkResolvesTo("java.lang.Class"); + } +} From c53fd6688f64de4f4524723c3ae4ba8de2c4ff0d Mon Sep 17 00:00:00 2001 From: irengrig Date: Tue, 8 Feb 2011 13:26:44 +0300 Subject: [PATCH 11/11] IDEA-65202 No default focused component in 'Create patch' dialog --- .../changes/patch/CreatePatchConfigurationPanel.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/CreatePatchConfigurationPanel.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/CreatePatchConfigurationPanel.java index b0fb6d2d886a..2e4ad0036759 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/CreatePatchConfigurationPanel.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/CreatePatchConfigurationPanel.java @@ -33,7 +33,9 @@ import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.VirtualFileWrapper; +import com.intellij.openapi.wm.IdeFocusManager; import com.intellij.util.Consumer; +import com.intellij.util.ui.AdjustComponentWhenShown; import javax.swing.*; import java.awt.*; @@ -89,6 +91,15 @@ public class CreatePatchConfigurationPanel { }); myErrorLabel.setForeground(Color.RED); checkName(); + new AdjustComponentWhenShown() { + @Override + protected boolean init() { + if (myPanel.isVisible()) { + IdeFocusManager.findInstanceByComponent(myPanel).requestFocus(myFileNameField.getTextField(), true); + } + return false; + } + }.install(myPanel); } private void checkName() {