javac ast indices: more tests

This commit is contained in:
Dmitry Batkovich
2016-10-28 08:50:24 +03:00
parent 44269836b8
commit 04f6faf096
5 changed files with 46 additions and 0 deletions
@@ -0,0 +1,7 @@
class Bar {
void m() {
new FooImpl().someMethod();
}
}
@@ -0,0 +1,10 @@
interface Foo {
void someMethod();
}
class FooImpl implements Foo {
@Override
public void someMethod() {
}
}
@@ -0,0 +1,7 @@
class Bar {
void m() {
new Foo().run();
}
}
@@ -0,0 +1,6 @@
interface Foo implements Runnable {
@Override
public void run() {
}
}
@@ -55,6 +55,22 @@ public class CompilerReferencesFindUsagesTest extends DaemonAnalyzerTestCase {
return JavaTestUtil.getJavaTestDataPath() + "/compiler/compilerReferenceFindUsages/";
}
public void testMethodUsageInClassHierarchy() throws Exception {
configureByFiles(getName(), getName() + "/Bar.java", getName() + "/Foo.java");
PsiMethod methodToSearch = findClass("Foo").findMethodsByName("someMethod", false)[0];
assertOneElement(MethodReferencesSearch.search(methodToSearch).findAll());
myCompilerTester.rebuild();
assertOneElement(MethodReferencesSearch.search(methodToSearch).findAll());
}
public void testMethodUsageInClassHierarchy2() throws Exception {
configureByFiles(getName(), getName() + "/Bar.java", getName() + "/Foo.java");
PsiMethod methodToSearch = myJavaFacade.findClass(CommonClassNames.JAVA_LANG_RUNNABLE).findMethodsByName("run", false)[0];
assertOneElement(MethodReferencesSearch.search(methodToSearch).findAll());
myCompilerTester.rebuild();
assertOneElement(MethodReferencesSearch.search(methodToSearch).findAll());
}
public void testLibMethodUsage() throws Exception {
configureByFile(getName() + "/Foo.java");
myCompilerTester.rebuild();