findClass should correctly sort compiled classes located inside project content (IDEA-101806)

This commit is contained in:
peter
2015-04-01 13:34:56 +02:00
parent 57b192320e
commit 7683276ed8
4 changed files with 23 additions and 5 deletions
@@ -160,7 +160,7 @@ class ResolveInLibrariesTest extends JavaCodeInsightFixtureTestCase {
@Override
protected boolean toAddSourceRoot() {
return false;
return name != "test do not build stubs in source jars";
}
public void "test do not build stubs in source jars"() {
@@ -197,4 +197,24 @@ class ResolveInLibrariesTest extends JavaCodeInsightFixtureTestCase {
assert !StubTreeLoader.instance.canHaveStub(vfile)
assert file.stub // from text
}
public void "test directory with class files inside project content"() {
def testData = PathManagerEx.getTestDataPath() + "/codeInsight/interJarDependencies"
myFixture.setTestDataPath(testData)
PsiTestUtil.addLibrary(myModule, "lib2", testData, "lib2.jar");
myFixture.copyDirectoryToProject("lib1", "lib1")
PsiTestUtil.addLibrary(myModule, "lib1", myFixture.tempDirFixture.getFile("").path, "lib1");
myFixture.configureFromExistingVirtualFile(myFixture.addFileToProject("TestCase.java", """
class Testcase {
public static void main( String[] args ) {
new B().<error descr="Cannot resolve method 'a()'">a</error>(); // should not work, because the A in lib1 has no method a
new B().a2(); // should work, because the A with this method is in lib1
}
}
""").virtualFile)
myFixture.checkHighlighting()
}
}
@@ -176,10 +176,8 @@ public class ModuleWithDependenciesScope extends GlobalSearchScope {
@Nullable
private VirtualFile getFileRoot(@NotNull VirtualFile file) {
if (myProjectFileIndex.isInContent(file)) {
return myProjectFileIndex.getSourceRootForFile(file);
}
return myProjectFileIndex.getClassRootForFile(file);
VirtualFile root = myProjectFileIndex.getClassRootForFile(file);
return root != null ? root : myProjectFileIndex.getSourceRootForFile(file);
}
@TestOnly