mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-55557: Attaching jar file sources in a module dependency (to another modules src) causes classpath issues
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
public class ModuleSourceAsLibrarySource {
|
||||
<ref>ModuleSourceAsLibrarySourceDep field;
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
public class ModuleSourceAsLibrarySourceDep {}
|
||||
@@ -8,6 +8,7 @@ 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.roots.OrderRootType;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.*;
|
||||
@@ -155,6 +156,16 @@ public class ResolveClassTest extends ResolveTestCase {
|
||||
assertNull(target);
|
||||
}
|
||||
|
||||
public void testModuleSourceAsLibrarySource() throws Exception {
|
||||
final PsiReference ref = configure();
|
||||
final VirtualFile file = ref.getElement().getContainingFile().getVirtualFile();
|
||||
assertNotNull(file);
|
||||
createFile(myModule, file.getParent(), "ModuleSourceAsLibrarySourceDep.java", loadFile("class/ModuleSourceAsLibrarySourceDep.java"));
|
||||
addLibraryToRoots(file.getParent(), OrderRootType.SOURCES);
|
||||
|
||||
assertInstanceOf(ref.resolve(), PsiClass.class);
|
||||
}
|
||||
|
||||
public void testStaticImportInTheSameClass() throws Exception {
|
||||
PsiReference ref = configure();
|
||||
long start = System.currentTimeMillis();
|
||||
|
||||
@@ -216,7 +216,7 @@ public abstract class PsiTestCase extends ModuleTestCase {
|
||||
addLibraryToRoots(myModule, jarFile, rootType);
|
||||
}
|
||||
|
||||
protected static void addLibraryToRoots(final Module module, final VirtualFile jarFile, final OrderRootType rootType) {
|
||||
protected static void addLibraryToRoots(final Module module, final VirtualFile root, final OrderRootType rootType) {
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -224,7 +224,7 @@ public abstract class PsiTestCase extends ModuleTestCase {
|
||||
final ModifiableRootModel rootModel = manager.getModifiableModel();
|
||||
final Library jarLibrary = rootModel.getModuleLibraryTable().createLibrary();
|
||||
final Library.ModifiableModel libraryModel = jarLibrary.getModifiableModel();
|
||||
libraryModel.addRoot(jarFile, rootType);
|
||||
libraryModel.addRoot(root, rootType);
|
||||
libraryModel.commit();
|
||||
rootModel.commit();
|
||||
}
|
||||
|
||||
@@ -248,7 +248,7 @@ public class DirectoryIndexImpl extends DirectoryIndex implements ProjectCompone
|
||||
DirectoryInfo info = stateAndDirs.first.myDirToInfoMap.get(dir);
|
||||
assert info != null;
|
||||
|
||||
if (!info.isInLibrarySource || info.libraryClassRoot != null) {
|
||||
if (!info.isInLibrarySource || info.isInModuleSource || info.libraryClassRoot != null) {
|
||||
if (!consumer.process(dir)) return false;
|
||||
}
|
||||
}
|
||||
@@ -613,7 +613,6 @@ public class DirectoryIndexImpl extends DirectoryIndex implements ProjectCompone
|
||||
if (definedPackage != null && definedPackage.isEmpty()) return; // another library source root starts here
|
||||
}
|
||||
|
||||
info.isInModuleSource = false;
|
||||
info.isInLibrarySource = true;
|
||||
info.sourceRoot = sourceRoot;
|
||||
setPackageName(dir, packageName);
|
||||
|
||||
Reference in New Issue
Block a user