summaryrefslogtreecommitdiff
path: root/lint/src
diff options
context:
space:
mode:
authorMatthew Gharrity <gharrma@google.com>2020-12-09 16:03:50 -0500
committerMatthew Gharrity <gharrma@google.com>2020-12-10 01:00:33 +0000
commit86ca1637b253599199c6206c61388ae707a3311a (patch)
tree3e64fdd67231959fcfb664752958242c0ddf0f51 /lint/src
parent1031442f93d3c95fcd82cbf4441027afa00a67f4 (diff)
downloadidea-86ca1637b253599199c6206c61388ae707a3311a.tar.gz
Lint: add some checkCanceled() calls
There were some code paths where Lint performed many file I/O operations consecutively without checking for cancelation. This caused UI freezes in the IDE, especially in ASwB where files might be on the network. Fixes: 175232217 Test: existing + will monitor UI freeze reports Change-Id: Ic34f0d14a77ed6bbabf52e467670308296dd98b0
Diffstat (limited to 'lint/src')
-rw-r--r--lint/src/com/android/tools/idea/lint/common/LintIdeClient.java16
1 files changed, 16 insertions, 0 deletions
diff --git a/lint/src/com/android/tools/idea/lint/common/LintIdeClient.java b/lint/src/com/android/tools/idea/lint/common/LintIdeClient.java
index f25b6f9cdd9..aa22e2047b5 100644
--- a/lint/src/com/android/tools/idea/lint/common/LintIdeClient.java
+++ b/lint/src/com/android/tools/idea/lint/common/LintIdeClient.java
@@ -18,6 +18,7 @@ package com.android.tools.idea.lint.common;
import static com.android.tools.lint.detector.api.TextFormat.RAW;
import com.android.annotations.NonNull;
+import com.android.ide.common.util.PathString;
import com.android.tools.lint.checks.ApiLookup;
import com.android.tools.lint.client.api.Configuration;
import com.android.tools.lint.client.api.ConfigurationHierarchy;
@@ -55,6 +56,7 @@ import com.intellij.openapi.editor.event.DocumentListener;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleUtilCore;
import com.intellij.openapi.progress.ProcessCanceledException;
+import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.progress.util.AbstractProgressIndicatorExBase;
import com.intellij.openapi.progress.util.ProgressIndicatorUtils;
import com.intellij.openapi.project.Project;
@@ -542,6 +544,8 @@ public class LintIdeClient extends LintClient implements Disposable {
@Override
@NonNull
public String readFile(@NonNull File file) {
+ ProgressManager.checkCanceled();
+
if (myLintResult instanceof LintEditorResult) {
return readFile((LintEditorResult)myLintResult, file);
}
@@ -586,6 +590,18 @@ public class LintIdeClient extends LintClient implements Disposable {
return content;
}
+ @Override
+ public byte @NotNull [] readBytes(@NotNull File file) throws IOException {
+ ProgressManager.checkCanceled();
+ return super.readBytes(file);
+ }
+
+ @Override
+ public byte @NotNull [] readBytes(@NotNull PathString resourcePath) throws IOException {
+ ProgressManager.checkCanceled();
+ return super.readBytes(resourcePath);
+ }
+
@Nullable
private String getFileContent(@NonNull LintEditorResult lintResult, final VirtualFile vFile) {
if (Objects.equals(lintResult.getMainFile(), vFile)) {