diff --git a/idea/testData/android/lint/toast.kt b/idea/testData/android/lint/toast.kt index a7f485638fa..0b03f46a5e7 100644 --- a/idea/testData/android/lint/toast.kt +++ b/idea/testData/android/lint/toast.kt @@ -61,7 +61,13 @@ class ToastTest(context: Context) : Activity() { private fun checkSuppress2(context: Context) { @android.annotation.SuppressLint("ShowToast") - val toast = Toast.makeText(this, "MyToast", Toast.LENGTH_LONG) + val toast1 = Toast.makeText(this, "MyToast", Toast.LENGTH_LONG) + + @android.annotation.SuppressLint("ShowToast", "Lorem ipsum") + val toast2 = Toast.makeText(this, "MyToast", Toast.LENGTH_LONG) + + @android.annotation.SuppressLint(value = "ShowToast") + val toast3 = Toast.makeText(this, "MyToast", Toast.LENGTH_LONG) } class R { diff --git a/plugins/lint/lint-api/src/com/android/tools/klint/client/api/LintDriver.java b/plugins/lint/lint-api/src/com/android/tools/klint/client/api/LintDriver.java index 2cc5b23172b..aafa8abf106 100644 --- a/plugins/lint/lint-api/src/com/android/tools/klint/client/api/LintDriver.java +++ b/plugins/lint/lint-api/src/com/android/tools/klint/client/api/LintDriver.java @@ -92,6 +92,7 @@ import org.jetbrains.org.objectweb.asm.tree.FieldNode; import org.jetbrains.org.objectweb.asm.tree.InsnList; import org.jetbrains.org.objectweb.asm.tree.MethodInsnNode; import org.jetbrains.org.objectweb.asm.tree.MethodNode; +import org.jetbrains.uast.util.UastExpressionUtils; import org.w3c.dom.Attr; import org.w3c.dom.Element; @@ -2841,10 +2842,22 @@ public class LintDriver { if (fqcn != null && (fqcn.equals(FQCN_SUPPRESS_LINT) || fqcn.equals(SUPPRESS_WARNINGS_FQCN) || fqcn.equals(SUPPRESS_LINT))) { // when missing imports - for (UNamedExpression attribute : annotation.getAttributeValues()) { - Object value = attribute.getExpression().evaluate(); - if (value instanceof String && isSuppressed(issue, (String) value)) { - return true; + UExpression valueAttributeExpression = annotation.findAttributeValue("value"); + if (valueAttributeExpression != null) { + if (UastExpressionUtils.isArrayInitializer(valueAttributeExpression)) { + UCallExpression arrayInitializer = (UCallExpression) valueAttributeExpression; + for (UExpression issueIdExpression : arrayInitializer.getValueArguments()) { + Object value = issueIdExpression.evaluate(); + if (value instanceof String && isSuppressed(issue, (String) value)) { + return true; + } + } + } + else { + Object value = valueAttributeExpression.evaluate(); + if (value instanceof String && isSuppressed(issue, (String) value)) { + return true; + } } } }