mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-25 21:44:49 +07:00
test for not building stubs for java files in module but not under source roots, in library but not in class root
This commit is contained in:
@@ -0,0 +1 @@
|
||||
class Foo {}
|
||||
@@ -15,11 +15,13 @@
|
||||
*/
|
||||
package com.intellij.psi.resolve
|
||||
import com.intellij.openapi.application.ex.PathManagerEx
|
||||
import com.intellij.openapi.vfs.JarFileSystem
|
||||
import com.intellij.openapi.vfs.LocalFileSystem
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import com.intellij.psi.JavaPsiFacade
|
||||
import com.intellij.psi.PsiClass
|
||||
import com.intellij.psi.PsiFile
|
||||
import com.intellij.psi.PsiManager
|
||||
import com.intellij.psi.PsiMethod
|
||||
import com.intellij.psi.search.GlobalSearchScope
|
||||
import com.intellij.psi.search.searches.ClassInheritorsSearch
|
||||
@@ -158,4 +160,41 @@ class ResolveInLibrariesTest extends JavaCodeInsightFixtureTestCase {
|
||||
assert !javaSrc.node.parsed
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean toAddSourceRoot() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void "test do not build stubs in source jars"() {
|
||||
def facade = JavaPsiFacade.getInstance(project)
|
||||
def scope = GlobalSearchScope.allScope(project)
|
||||
|
||||
String testDataPathForTest = PathManagerEx.getTestDataPath() + "/libResolve/classesAndSources"
|
||||
def lib = LocalFileSystem.getInstance().refreshAndFindFileByPath(testDataPathForTest)
|
||||
def localFile = myFixture.copyFileToProject(testDataPathForTest + File.separator + "Foo.java", 'Foo.java')
|
||||
assert localFile != null
|
||||
|
||||
checkFileIsNotLoadedAndHasNoStub(localFile)
|
||||
assert facade.findClasses('Foo', scope).size() == 0
|
||||
PsiTestUtil.addLibrary(myModule, 'cas', lib.path, [] as String[], ["/classesAndSources.jar!/"] as String[])
|
||||
|
||||
def vfile = lib.findChild("classesAndSources.jar")
|
||||
assert vfile != null
|
||||
vfile = JarFileSystem.getInstance().getJarRootForLocalFile(vfile);
|
||||
assert vfile != null
|
||||
vfile = vfile.findChild('LibraryClass.java');
|
||||
assert vfile != null
|
||||
|
||||
assert facade.findClasses('LibraryClass', scope).size() == 0
|
||||
|
||||
checkFileIsNotLoadedAndHasNoStub(vfile)
|
||||
}
|
||||
|
||||
private void checkFileIsNotLoadedAndHasNoStub(VirtualFile vfile) {
|
||||
def file = PsiManager.getInstance(project).findFile(vfile);
|
||||
assert file != null
|
||||
|
||||
assert !file.contentsLoaded
|
||||
assert !file.stub
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user