summaryrefslogtreecommitdiff
path: root/android-lint/src
diff options
context:
space:
mode:
authorBradley Smith <smithbradley@google.com>2022-01-25 09:15:03 -0800
committerBradley Smith <smithbradley@google.com>2022-01-27 18:24:15 +0000
commit374ef91a3dfc2023d561df72d6e90fbfacf74e5d (patch)
treeec4b87ad20e8037f70f0be7539c81229c6de4cdd /android-lint/src
parent83e2acbab2aa7a1919bddefd5be6c4479a7345b3 (diff)
downloadidea-374ef91a3dfc2023d561df72d6e90fbfacf74e5d.tar.gz
Fix lint which was broken as a result of MPSS
Module per source set caused lint to get duplicate paths while building a map of directory to LintProject, this failed an assertion and caused lint to crash. Instead of obtaining the dir for java modules from the linked project path, get them from the first content root. This guarantees that they will be unique. Modules do not really have an associated directory anymore and are a collection of content roots. A long term fix would be to address this and stop using a map from directories to LintProjects. This change does not attempt to address the underlying issue but instead just ensures the lint is usable and doesn't crash on java modules. Bug: 216291399 Test: test added in I588cf0ceda5 Change-Id: I3d51cbd9d8676386d45ccfb71bd37a322b353ce9
Diffstat (limited to 'android-lint/src')
-rw-r--r--android-lint/src/com/android/tools/idea/lint/AndroidLintIdeProject.java8
1 files changed, 7 insertions, 1 deletions
diff --git a/android-lint/src/com/android/tools/idea/lint/AndroidLintIdeProject.java b/android-lint/src/com/android/tools/idea/lint/AndroidLintIdeProject.java
index 29497b8fb79..25d7aa11059 100644
--- a/android-lint/src/com/android/tools/idea/lint/AndroidLintIdeProject.java
+++ b/android-lint/src/com/android/tools/idea/lint/AndroidLintIdeProject.java
@@ -47,6 +47,7 @@ import com.intellij.facet.ProjectFacetManager;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleManager;
+import com.intellij.openapi.roots.ModuleRootManager;
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.vfs.LocalFileSystem;
@@ -364,7 +365,12 @@ public class AndroidLintIdeProject extends LintIdeProject {
dir = VfsUtilCore.virtualToIoFile(mainContentRoot);
}
else {
- dir = AndroidRootUtil.findModuleRootFolderPath(module);
+ // For Java modules we just use the first content root that is we can find
+ VirtualFile[] roots = ModuleRootManager.getInstance(module).getContentRoots();
+ if (roots.length == 0) {
+ return null;
+ }
+ dir = VfsUtilCore.virtualToIoFile(roots[0]);
}
return dir;
}