mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
unnecessary module dependencies: don't warn on generated sources
This commit is contained in:
+11
@@ -33,6 +33,17 @@ public class UnnecessaryModuleDependencyInspection extends GlobalInspectionTool
|
||||
final RefModule refModule = (RefModule)refEntity;
|
||||
final Module module = refModule.getModule();
|
||||
final ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module);
|
||||
boolean onlyGeneratedSources = true;
|
||||
for (ContentEntry entry : moduleRootManager.getContentEntries()) {
|
||||
for (SourceFolder folder : entry.getSourceFolders()) {
|
||||
if (!JavaProjectRootsUtil.isForGeneratedSources(folder)) {
|
||||
onlyGeneratedSources = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (onlyGeneratedSources) return null;
|
||||
|
||||
final OrderEntry[] declaredDependencies = moduleRootManager.getOrderEntries();
|
||||
|
||||
final List<CommonProblemDescriptor> descriptors = new ArrayList<>();
|
||||
|
||||
+25
@@ -16,6 +16,8 @@ import com.intellij.testFramework.InspectionTestUtil
|
||||
import com.intellij.testFramework.PsiTestUtil
|
||||
import com.intellij.testFramework.createGlobalContextForTool
|
||||
import com.intellij.testFramework.fixtures.JavaCodeInsightFixtureTestCase
|
||||
import org.jetbrains.jps.model.java.JavaSourceRootType
|
||||
import org.jetbrains.jps.model.java.JpsJavaExtensionService
|
||||
import org.junit.Assert
|
||||
|
||||
class UnnecessaryModuleDependencyInspectionTest : JavaCodeInsightFixtureTestCase() {
|
||||
@@ -108,6 +110,29 @@ class UnnecessaryModuleDependencyInspectionTest : JavaCodeInsightFixtureTestCase
|
||||
presentation.problemDescriptors.joinToString { problem -> problem.descriptionTemplate })
|
||||
}
|
||||
|
||||
fun testDuplicatedDependencies() {
|
||||
val mod1 = PsiTestUtil.addModule(project, JavaModuleType.getModuleType(), "mod1", myFixture.tempDirFixture.findOrCreateDir("mod1"))
|
||||
val mod2 = PsiTestUtil.addModule(project, JavaModuleType.getModuleType(), "mod2", myFixture.tempDirFixture.findOrCreateDir("mod2"))
|
||||
val mod3 = PsiTestUtil.addModule(project, JavaModuleType.getModuleType(), "mod3", myFixture.tempDirFixture.findOrCreateDir("mod3"))
|
||||
ModuleRootModificationUtil.updateModel(mod3) {
|
||||
val contentEntry = it.contentEntries[0]
|
||||
contentEntry.removeSourceFolder(contentEntry.sourceFolders[0])
|
||||
contentEntry.addSourceFolder(myFixture.tempDirFixture.findOrCreateDir("mod3"),
|
||||
JavaSourceRootType.SOURCE,
|
||||
JpsJavaExtensionService.getInstance().createSourceRootProperties("", true))
|
||||
}
|
||||
|
||||
ModuleRootModificationUtil.addDependency(mod2, mod1, DependencyScope.COMPILE, true)
|
||||
ModuleRootModificationUtil.addDependency(mod1, myModule, DependencyScope.COMPILE, true)
|
||||
|
||||
ModuleRootModificationUtil.addDependency(mod3, mod1)
|
||||
ModuleRootModificationUtil.addDependency(mod3, mod2)
|
||||
|
||||
myFixture.addClass("public class Class0 {}")
|
||||
myFixture.addFileToProject("mod3/Class3.java", "public class Class3 extends Class0 {}")
|
||||
assertInspectionProducesZeroResults()
|
||||
}
|
||||
|
||||
fun testDeepExportedDependenciesNoDirectDependency() {
|
||||
deepDepends()
|
||||
assertInspectionProducesZeroResults()
|
||||
|
||||
Reference in New Issue
Block a user