diff options
author | Tor Norbye <tnorbye@google.com> | 2014-09-08 18:48:10 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2014-09-08 18:48:12 +0000 |
commit | 2250e7e055295bee73366d360d15ea0270573ef6 (patch) | |
tree | 23752441df6fcaa7ca934c1353b15af595a85db0 | |
parent | fb5a02906f644d044eb0286bf27d413ba0e05216 (diff) | |
parent | c810bbf46e7246636afe1d18947a460cedc5d24d (diff) | |
download | idea-2250e7e055295bee73366d360d15ea0270573ef6.tar.gz |
Merge "Don't run inspections in extracted AAR folders"
-rw-r--r-- | platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java index 695c2a72d200..9bbaa278d207 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java @@ -310,6 +310,21 @@ public class GlobalInspectionContextImpl extends GlobalInspectionContextBase imp }); } + // Android Studio: Is the given file a file we should ignore during batch inspections? + private static final String EXPLODED_AAR = "exploded-aar"; + private static boolean isIgnoredFile(@NotNull PsiFile psiFile) { + VirtualFile file = psiFile.getVirtualFile(); + while (file != null) { + if (EXPLODED_AAR.equals(file.getName())) { + return true; + } else { + file = file.getParent(); + } + } + + return false; + } + @Override protected void runTools(@NotNull AnalysisScope scope, boolean runGlobalToolsOnly) { final InspectionManagerEx inspectionManager = (InspectionManagerEx)InspectionManager.getInstance(getProject()); @@ -343,6 +358,33 @@ public class GlobalInspectionContextImpl extends GlobalInspectionContextBase imp throw new ProcessCanceledException(); } + // Android Studio tweak: + // Most "outputs" (such as build/intermediates/) are marked as generated + // source roots, which means IntelliJ won't scan those folders for + // warnings. + // + // However, AAR libraries are extracted into special build folders + // (currently build/intermediates/exploded-aar) which are *not* marked as + // generated; that's necessary such that those folders are scanned (for + // indexing purposes), handled as potential go-to-declaration targets + // (since resource files there can contain for example themes extended in + // the user's application). Therefore, by default, IntelliJ will analyze + // all the files in the exploded AAR folders. When you have large + // libraries like appcompat or play services, this not only takes a lot + // of extra time to analyze. You also end up with a lot of errors in + // files you can't edit. For example, with appcompat, you end up with + // over 700 spelling mistake warnings, and with play services, you end up + // with over a hundred unused namespace warnings, and over a hundred tag + // has no children warnings! + // + // Therefore, in the below this CL tweaks the batch analysis runner which iterates + // over PSI files to skip files that are found to be within an AAR + // folder. This removes all the false positives and speeds up code + // analysis quite significantly! + if (isIgnoredFile(file)) { + return; + } + if (LOG.isDebugEnabled()) { LOG.debug("Running local inspections on " + virtualFile.getPath()); } |