summaryrefslogtreecommitdiff
path: root/lint/src
diff options
context:
space:
mode:
authorTor Norbye <tnorbye@google.com>2020-10-23 19:33:55 -0700
committerTor Norbye <tnorbye@google.com>2020-10-26 23:28:47 +0000
commita654946ebaa0648209bf09877a82a4674ee1c45c (patch)
tree9e9dc9c1430152cfc6d2af18cef3474cb72f464e /lint/src
parentb34120b8b4fb878186f72332f5f2ad51fc037e20 (diff)
downloadidea-a654946ebaa0648209bf09877a82a4674ee1c45c.tar.gz
131360561: IDE prompt to not use FJD or GcmNetworkManager
Also allow a warning to have a quickfix which shows a URL. Fixes: 131360561 Test: Manual (and inspection tested in tools/base) Change-Id: I38505b6211f9ae9a108a608980873fbdec30079c
Diffstat (limited to 'lint/src')
-rw-r--r--lint/src/com/android/tools/idea/lint/common/AndroidLintInspectionBase.java5
-rw-r--r--lint/src/com/android/tools/idea/lint/common/ShowUrlQuickFix.kt34
2 files changed, 38 insertions, 1 deletions
diff --git a/lint/src/com/android/tools/idea/lint/common/AndroidLintInspectionBase.java b/lint/src/com/android/tools/idea/lint/common/AndroidLintInspectionBase.java
index 2e38c92f032..13bd340c4ab 100644
--- a/lint/src/com/android/tools/idea/lint/common/AndroidLintInspectionBase.java
+++ b/lint/src/com/android/tools/idea/lint/common/AndroidLintInspectionBase.java
@@ -32,6 +32,7 @@ import com.android.tools.lint.detector.api.LintFix;
import com.android.tools.lint.detector.api.LintFix.LintFixGroup;
import com.android.tools.lint.detector.api.LintFix.ReplaceString;
import com.android.tools.lint.detector.api.LintFix.SetAttribute;
+import com.android.tools.lint.detector.api.LintFix.ShowUrl;
import com.android.tools.lint.detector.api.Position;
import com.android.tools.lint.detector.api.Scope;
import com.android.tools.lint.detector.api.Severity;
@@ -69,7 +70,6 @@ import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VfsUtil;
-import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
import com.intellij.psi.PsiBinaryFile;
@@ -728,6 +728,9 @@ public abstract class AndroidLintInspectionBase extends GlobalInspectionTool {
return fixes;
}
}
+ else if (lintFix instanceof ShowUrl) {
+ return new LintIdeQuickFix[]{new ShowUrlQuickFix((ShowUrl)lintFix)};
+ }
return LintIdeQuickFix.EMPTY_ARRAY;
}
diff --git a/lint/src/com/android/tools/idea/lint/common/ShowUrlQuickFix.kt b/lint/src/com/android/tools/idea/lint/common/ShowUrlQuickFix.kt
new file mode 100644
index 00000000000..97984162631
--- /dev/null
+++ b/lint/src/com/android/tools/idea/lint/common/ShowUrlQuickFix.kt
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.tools.idea.lint.common
+
+import com.android.tools.lint.detector.api.LintFix.ShowUrl
+import com.intellij.ide.BrowserUtil
+import com.intellij.psi.PsiElement
+import org.jetbrains.annotations.Nls
+
+class ShowUrlQuickFix(private val fix: ShowUrl) : DefaultLintQuickFix(null) {
+ @Nls
+ override fun getName(): String {
+ return fix.displayName ?: fix.familyName ?: "Show ${fix.url}"
+ }
+
+ override fun startInWriteAction(): Boolean = false
+
+ override fun apply(startElement: PsiElement, endElement: PsiElement, context: AndroidQuickfixContexts.Context) {
+ BrowserUtil.browse(fix.url)
+ }
+}