diff --git a/idea/testData/android/lint/alarm.kt.181 b/idea/testData/android/lint/alarm.kt.181
new file mode 100644
index 00000000000..be50e16aedc
--- /dev/null
+++ b/idea/testData/android/lint/alarm.kt.181
@@ -0,0 +1,23 @@
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintShortAlarmInspection
+
+import android.app.AlarmManager
+
+@Suppress("UsePropertyAccessSyntax", "UNUSED_VARIABLE", "unused", "UNUSED_PARAMETER", "DEPRECATION")
+class TestAlarm {
+ fun test(alarmManager: AlarmManager) {
+ alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME, 5000, 60000, null); // OK
+ alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME, 6000, 70000, null); // OK
+ alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME, 50, 10, null); // ERROR
+
+ alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME, 5000, // ERROR
+ OtherClass.MY_INTERVAL, null); // ERROR
+
+ val interval = 10;
+ val interval2 = 2L * interval;
+ alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME, 5000, interval2, null); // ERROR
+ }
+
+ private object OtherClass {
+ val MY_INTERVAL = 1000L;
+ }
+}
\ No newline at end of file
diff --git a/idea/testData/android/lint/apiCheck.kt.181 b/idea/testData/android/lint/apiCheck.kt.181
new file mode 100644
index 00000000000..ea9329d4644
--- /dev/null
+++ b/idea/testData/android/lint/apiCheck.kt.181
@@ -0,0 +1,486 @@
+
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintNewApiInspection
+// INSPECTION_CLASS2: com.android.tools.idea.lint.AndroidLintInlinedApiInspection
+// INSPECTION_CLASS3: com.android.tools.idea.lint.AndroidLintOverrideInspection
+
+import android.animation.RectEvaluator
+import android.annotation.SuppressLint
+import android.annotation.TargetApi
+import org.w3c.dom.DOMError
+import org.w3c.dom.DOMErrorHandler
+import org.w3c.dom.DOMLocator
+
+import android.view.View
+import android.view.ViewGroup
+import android.view.ViewGroup.LayoutParams
+import android.app.Activity
+import android.app.ApplicationErrorReport
+import android.graphics.drawable.VectorDrawable
+import android.graphics.Path
+import android.graphics.PorterDuff
+import android.graphics.Rect
+import android.os.Build
+import android.widget.*
+import dalvik.bytecode.OpcodeInfo
+
+import android.os.Build.VERSION
+import android.os.Build.VERSION.SDK_INT
+import android.os.Build.VERSION_CODES
+import android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH
+import android.os.Build.VERSION_CODES.JELLY_BEAN
+import android.os.Bundle
+import android.os.Parcelable
+import android.system.ErrnoException
+import android.widget.TextView
+
+@Suppress("SENSELESS_COMPARISON", "UNUSED_EXPRESSION", "UsePropertyAccessSyntax", "UNUSED_VARIABLE", "unused", "UNUSED_PARAMETER", "DEPRECATION", "USELESS_CAST")
+class ApiCallTest: Activity() {
+
+ fun method(chronometer: Chronometer, locator: DOMLocator) {
+ chronometer.setBackground(null)
+
+ // Ok
+ Bundle().getInt("")
+
+ View.SYSTEM_UI_FLAG_FULLSCREEN
+
+ // Virtual call
+ getActionBar() // API 11
+ actionBar // API 11
+
+ // Class references (no call or field access)
+ val error: DOMError? = null // API 8
+ val clz = DOMErrorHandler::class // API 8
+
+ // Method call
+ chronometer.onChronometerTickListener // API 3
+
+ // Inherited method call (from TextView
+ chronometer.setTextIsSelectable(true) // API 11
+
+ GridLayout::class
+
+ // Field access
+ val field = OpcodeInfo.MAXIMUM_VALUE // API 11
+
+
+ val fillParent = LayoutParams.FILL_PARENT // API 1
+ // This is a final int, which means it gets inlined
+ val matchParent = LayoutParams.MATCH_PARENT // API 8
+ // Field access: non final
+ val batteryInfo = report!!.batteryInfo
+
+ // Enum access
+ if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP) {
+ val mode = PorterDuff.Mode.OVERLAY // API 11
+ }
+ }
+
+ fun test(rect: Rect) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+ RectEvaluator(rect); // OK
+ }
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+ if (rect != null) {
+ RectEvaluator(rect); // OK
+ }
+ }
+ }
+
+ fun test2(rect: Rect) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+ RectEvaluator(rect); // OK
+ }
+ }
+
+ fun test3(rect: Rect) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
+ RectEvaluator(); // ERROR
+ }
+ }
+
+ fun test4(rect: Rect) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+ System.out.println("Something");
+ RectEvaluator(rect); // OK
+ } else {
+ RectEvaluator(rect); // ERROR
+ }
+ }
+
+ fun test5(rect: Rect) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.CUPCAKE) {
+ RectEvaluator(rect); // ERROR
+ } else {
+ RectEvaluator(rect); // ERROR
+ }
+ }
+
+ fun test(priority: Boolean, layout: ViewGroup) {
+ if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
+ GridLayout(null).getOrientation(); // Not flagged
+ } else {
+ GridLayout(null).getOrientation(); // Flagged
+ }
+
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
+ GridLayout(null).getOrientation(); // Not flagged
+ } else {
+ GridLayout(null).getOrientation(); // Flagged
+ }
+
+ if (SDK_INT >= ICE_CREAM_SANDWICH) {
+ GridLayout(null).getOrientation(); // Not flagged
+ } else {
+ GridLayout(null).getOrientation(); // Flagged
+ }
+
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
+ GridLayout(null).getOrientation(); // Not flagged
+ } else {
+ GridLayout(null).getOrientation(); // Flagged
+ }
+
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
+ GridLayout(null).getOrientation(); // Flagged
+ } else {
+ GridLayout(null).getOrientation(); // Not flagged
+ }
+
+ if (Build.VERSION.SDK_INT >= 14) {
+ GridLayout(null).getOrientation(); // Not flagged
+ } else {
+ GridLayout(null).getOrientation(); // Flagged
+ }
+
+ if (VERSION.SDK_INT >= VERSION_CODES.ICE_CREAM_SANDWICH) {
+ GridLayout(null).getOrientation(); // Not flagged
+ } else {
+ GridLayout(null).getOrientation(); // Flagged
+ }
+
+ // Nested conditionals
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
+ if (priority) {
+ GridLayout(null).getOrientation(); // Flagged
+ } else {
+ GridLayout(null).getOrientation(); // Flagged
+ }
+ } else {
+ GridLayout(null).getOrientation(); // Flagged
+ }
+
+ // Nested conditionals 2
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
+ if (priority) {
+ GridLayout(null).getOrientation(); // Not flagged
+ } else {
+ GridLayout(null).getOrientation(); // Not flagged
+ }
+ } else {
+ GridLayout(null); // Flagged
+ }
+ }
+
+ fun test2(priority: Boolean) {
+ if (android.os.Build.VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) {
+ GridLayout(null).getOrientation(); // Not flagged
+ } else {
+ GridLayout(null); // Flagged
+ }
+
+ if (android.os.Build.VERSION.SDK_INT >= 16) {
+ GridLayout(null).getOrientation(); // Not flagged
+ } else {
+ GridLayout(null); // Flagged
+ }
+
+ if (android.os.Build.VERSION.SDK_INT >= 13) {
+ GridLayout(null).getOrientation(); // Flagged
+ } else {
+ GridLayout(null); // Flagged
+ }
+
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
+ GridLayout(null).getOrientation(); // Not flagged
+ } else {
+ GridLayout(null); // Flagged
+ }
+
+ if (SDK_INT >= JELLY_BEAN) {
+ GridLayout(null).getOrientation(); // Not flagged
+ } else {
+ GridLayout(null); // Flagged
+ }
+
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
+ GridLayout(null).getOrientation(); // Not flagged
+ } else {
+ GridLayout(null); // Flagged
+ }
+
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
+ GridLayout(null); // Flagged
+ } else {
+ GridLayout(null).getOrientation(); // Not flagged
+ }
+
+ if (Build.VERSION.SDK_INT >= 16) {
+ GridLayout(null).getOrientation(); // Not flagged
+ } else {
+ GridLayout(null); // Flagged
+ }
+
+ if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) {
+ GridLayout(null).getOrientation(); // Not flagged
+ } else {
+ GridLayout(null); // Flagged
+ }
+ }
+
+ fun test(textView: TextView) {
+ if (textView.isSuggestionsEnabled()) {
+ //ERROR
+ }
+ if (textView.isSuggestionsEnabled) {
+ //ERROR
+ }
+
+ if (SDK_INT >= JELLY_BEAN && textView.isSuggestionsEnabled()) {
+ //NO ERROR
+ }
+
+ if (SDK_INT >= JELLY_BEAN && textView.isSuggestionsEnabled) {
+ //NO ERROR
+ }
+
+ if (SDK_INT >= JELLY_BEAN && (textView.text != "" || textView.isSuggestionsEnabled)) {
+ //NO ERROR
+ }
+
+ if (SDK_INT < JELLY_BEAN && (textView.text != "" || textView.isSuggestionsEnabled)) {
+ //ERROR
+ }
+
+ if (SDK_INT < JELLY_BEAN && textView.isSuggestionsEnabled()) {
+ //ERROR
+ }
+
+ if (SDK_INT < JELLY_BEAN && textView.isSuggestionsEnabled) {
+ //ERROR
+ }
+
+ if (SDK_INT < JELLY_BEAN || textView.isSuggestionsEnabled) {
+ //NO ERROR
+ }
+
+ if (SDK_INT > JELLY_BEAN || textView.isSuggestionsEnabled) {
+ //ERROR
+ }
+
+
+ // getActionBar() API 11
+ if (SDK_INT <= 10 || getActionBar() == null) {
+ //NO ERROR
+ }
+
+ if (SDK_INT < 10 || getActionBar() == null) {
+ //ERROR
+ }
+
+ if (SDK_INT < 11 || getActionBar() == null) {
+ //NO ERROR
+ }
+
+ if (SDK_INT != 11 || getActionBar() == null) {
+ //NO ERROR
+ }
+
+ if (SDK_INT != 12 || getActionBar() == null) {
+ //ERROR
+ }
+
+ if (SDK_INT <= 11 || getActionBar() == null) {
+ //NO ERROR
+ }
+
+ if (SDK_INT < 12 || getActionBar() == null) {
+ //NO ERROR
+ }
+
+ if (SDK_INT <= 12 || getActionBar() == null) {
+ //NO ERROR
+ }
+
+ if (SDK_INT < 9 || getActionBar() == null) {
+ //ERROR
+ }
+
+ if (SDK_INT <= 9 || getActionBar() == null) {
+ //ERROR
+ }
+ }
+
+ fun testReturn() {
+ if (SDK_INT < 11) {
+ return
+ }
+
+ // No Error
+ val actionBar = getActionBar()
+ }
+
+ fun testThrow() {
+ if (SDK_INT < 11) {
+ throw IllegalStateException()
+ }
+
+ // No Error
+ val actionBar = getActionBar()
+ }
+
+ fun testError() {
+ if (SDK_INT < 11) {
+ error("Api")
+ }
+
+ // No Error
+ val actionBar = getActionBar()
+ }
+
+ fun testWithoutAnnotation(textView: TextView) {
+ if (textView.isSuggestionsEnabled()) {
+
+ }
+
+ if (textView.isSuggestionsEnabled) {
+
+ }
+ }
+
+ @TargetApi(JELLY_BEAN)
+ fun testWithTargetApiAnnotation(textView: TextView) {
+ if (textView.isSuggestionsEnabled()) {
+ //NO ERROR, annotation
+ }
+
+ if (textView.isSuggestionsEnabled) {
+ //NO ERROR, annotation
+ }
+ }
+
+ @SuppressLint("NewApi")
+ fun testWithSuppressLintAnnotation(textView: TextView) {
+ if (textView.isSuggestionsEnabled()) {
+ //NO ERROR, annotation
+ }
+
+ if (textView.isSuggestionsEnabled) {
+ //NO ERROR, annotation
+ }
+ }
+
+ fun testCatch() {
+ try {
+
+ } catch (e: ErrnoException) {
+
+ }
+ }
+
+ fun testOverload() {
+ // this overloaded addOval available only on API Level 21
+ Path().addOval(0f, 0f, 0f, 0f, Path.Direction.CW)
+ }
+
+ // KT-14737 False error with short-circuit evaluation
+ fun testShortCircuitEvaluation() {
+ getDrawable(0) // error here as expected
+ if(Build.VERSION.SDK_INT >= 23
+ && null == getDrawable(0)) // error here should not occur
+ {
+ getDrawable(0) // no error here as expected
+ }
+ }
+
+ // KT-1482 Kotlin Lint: "Calling new methods on older versions" does not report call on receiver in extension function
+ private fun Bundle.caseE1a() { getBinder("") }
+
+ private fun Bundle.caseE1c() { this.getBinder("") }
+
+ private fun caseE1b(bundle: Bundle) { bundle.getBinder("") }
+
+ // KT-12023 Kotlin Lint: Cast doesn't trigger minSdk error
+ fun testCast(layout: ViewGroup) {
+ if (layout is LinearLayout) {} // OK API 1
+ layout as? LinearLayout // OK API 1
+ layout as LinearLayout // OK API 1
+
+ if (layout !is GridLayout) {}
+ layout as? GridLayout
+ layout as GridLayout
+
+ val grid = layout as? GridLayout
+ val linear = layout as LinearLayout // OK API 1
+ }
+
+ abstract class ErrorVectorDravable : VectorDrawable(), Parcelable
+
+ @TargetApi(21)
+ class MyVectorDravable : VectorDrawable()
+
+ fun testTypes() {
+ GridLayout(this)
+ val c = VectorDrawable::class.java
+ }
+
+ fun testCallWithApiAnnotation(textView: TextView) {
+ MyVectorDravable()
+ testWithTargetApiAnnotation(textView)
+ }
+
+ companion object : Activity() {
+ fun test() {
+ getDrawable(0)
+ }
+ }
+
+ // Return type
+ internal // API 14
+ val gridLayout: GridLayout?
+ get() = null
+
+ private val report: ApplicationErrorReport?
+ get() = null
+}
+
+object O: Activity() {
+ fun test() {
+ getDrawable(0)
+ }
+}
+
+fun testJava8() {
+ // Error, Api 24, Java8
+ mutableListOf(1, 2, 3).removeIf {
+ true
+ }
+
+ // Ok, Kotlin
+ mutableListOf(1, 2, 3).removeAll {
+ true
+ }
+
+ // Error, Api 24, Java8
+ mapOf(1 to 2).forEach { key, value -> key + value }
+
+ // Ok, Kotlin
+ mapOf(1 to 2).forEach { (key, value) -> key + value }
+}
+
+interface WithDefault {
+ // Should be ok
+ fun methodWithBody() {
+ return
+ }
+}
\ No newline at end of file
diff --git a/idea/testData/android/lint/callSuper.kt.181 b/idea/testData/android/lint/callSuper.kt.181
new file mode 100644
index 00000000000..8f7fd188881
--- /dev/null
+++ b/idea/testData/android/lint/callSuper.kt.181
@@ -0,0 +1,97 @@
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintMissingSuperCallInspection
+
+package android.support.annotation
+
+@Retention(AnnotationRetention.BINARY)
+@Target(AnnotationTarget.FUNCTION)
+annotation class CallSuper
+
+@Suppress("UsePropertyAccessSyntax", "UNUSED_VARIABLE", "unused", "UNUSED_PARAMETER", "DEPRECATION")
+class CallSuperTest {
+ private class Child : Parent() {
+ override fun test1() {
+ // ERROR
+ }
+
+ override fun test2() {
+ // ERROR
+ }
+
+ override fun test3() {
+ // ERROR
+ }
+
+ override fun test4(arg: Int) {
+ // ERROR
+ }
+
+ override fun test4(arg: String) {
+ // OK
+ }
+
+
+ override fun test5(arg1: Int, arg2: Boolean, arg3: Map, *>, // ERROR
+ arg4: Array, vararg arg5: Int) {
+ }
+
+ override fun test5() {
+ // ERROR
+ super.test6() // (wrong super)
+ }
+
+ override fun test6() {
+ // OK
+ val x = 5
+ super.test6()
+ System.out.println(x)
+ }
+ }
+
+ private open class Parent : ParentParent() {
+ @CallSuper
+ protected open fun test1() {
+ }
+
+ override fun test3() {
+ super.test3()
+ }
+
+ @CallSuper
+ protected open fun test4(arg: Int) {
+ }
+
+ protected open fun test4(arg: String) {
+ }
+
+ @CallSuper
+ protected open fun test5() {
+ }
+
+ @CallSuper
+ protected open fun test5(arg1: Int, arg2: Boolean, arg3: Map, *>,
+ arg4: Array, vararg arg5: Int) {
+ }
+ }
+
+ private open class ParentParent : ParentParentParent() {
+ @CallSuper
+ protected open fun test2() {
+ }
+
+ @CallSuper
+ protected open fun test3() {
+ }
+
+ @CallSuper
+ protected open fun test6() {
+ }
+
+ @CallSuper
+ protected fun test7() {
+ }
+
+
+ }
+
+ private open class ParentParentParent
+}
diff --git a/idea/testData/android/lint/closeCursor.kt.181 b/idea/testData/android/lint/closeCursor.kt.181
new file mode 100644
index 00000000000..82a01cd75cf
--- /dev/null
+++ b/idea/testData/android/lint/closeCursor.kt.181
@@ -0,0 +1,36 @@
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintRecycleInspection
+
+@file:Suppress("UNUSED_VARIABLE")
+
+import android.app.Activity
+import android.os.Bundle
+
+class MainActivity : Activity() {
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+
+ val cursor = contentResolver.query(null, null, null, null, null)
+
+ // WARNING
+ contentResolver.query(null, null, null, null, null)
+
+ // OK, closed in chained call
+ contentResolver.query(null, null, null, null, null).close()
+
+ // KT-14677: Kotlin Lint: "Missing recycle() calls" report cursor with `use()` call
+ val cursorUsed = contentResolver.query(null, null, null, null, null)
+ cursorUsed.use { }
+
+ // OK, used in chained call
+ contentResolver.query(null, null, null, null, null).use {
+
+ }
+
+ // KT-13372: Android Lint for Kotlin: false positive "Cursor should be freed" inside 'if' expression
+ if (true) {
+ val c = contentResolver.query(null, null, null, null, null)
+ c.close()
+ }
+ }
+}
diff --git a/idea/testData/android/lint/commitFragment.kt.181 b/idea/testData/android/lint/commitFragment.kt.181
new file mode 100644
index 00000000000..25ad12e680c
--- /dev/null
+++ b/idea/testData/android/lint/commitFragment.kt.181
@@ -0,0 +1,41 @@
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintCommitTransactionInspection
+
+@file:Suppress("UNUSED_VARIABLE")
+
+import android.app.Activity
+import android.app.FragmentTransaction
+import android.app.FragmentManager
+import android.os.Bundle
+
+class MainActivity : Activity() {
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+
+ //OK
+ val transaction = fragmentManager.beginTransaction()
+ val transaction2: FragmentTransaction
+ transaction2 = fragmentManager.beginTransaction()
+ transaction.commit()
+ transaction2.commit()
+
+ //WARNING
+ val transaction3 = fragmentManager.beginTransaction()
+
+ //OK
+ fragmentManager.beginTransaction().commit()
+ fragmentManager.beginTransaction().add(null, "A").commit()
+
+ //OK KT-14470
+ Runnable {
+ val a = fragmentManager.beginTransaction()
+ a.commit()
+ }
+ }
+
+ // KT-14780: Kotlin Lint: "Missing commit() calls" false positive when the result of `commit()` is assigned or used as receiver
+ fun testResultOfCommit(fm: FragmentManager) {
+ val r1 = fm.beginTransaction().hide(fm.findFragmentByTag("aTag")).commit()
+ val r2 = fm.beginTransaction().hide(fm.findFragmentByTag("aTag")).commit().toString()
+ }
+}
diff --git a/idea/testData/android/lint/javaPerformance.kt.181 b/idea/testData/android/lint/javaPerformance.kt.181
new file mode 100644
index 00000000000..25025526173
--- /dev/null
+++ b/idea/testData/android/lint/javaPerformance.kt.181
@@ -0,0 +1,193 @@
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintDrawAllocationInspection
+// INSPECTION_CLASS2: com.android.tools.idea.lint.AndroidLintUseSparseArraysInspection
+// INSPECTION_CLASS3: com.android.tools.idea.lint.AndroidLintUseValueOfInspection
+
+import android.annotation.SuppressLint
+import java.util.HashMap
+import android.content.Context
+import android.graphics.*
+import android.util.AttributeSet
+import android.util.SparseArray
+import android.widget.Button
+
+@SuppressWarnings("unused")
+@Suppress("UsePropertyAccessSyntax", "UNUSED_VARIABLE", "unused", "UNUSED_PARAMETER", "DEPRECATION")
+class JavaPerformanceTest(context: Context, attrs: AttributeSet, defStyle: Int) : Button(context, attrs, defStyle) {
+
+ private var cachedRect: Rect? = null
+ private var shader: LinearGradient? = null
+ private var lastHeight: Int = 0
+ private var lastWidth: Int = 0
+
+ override fun onDraw(canvas: android.graphics.Canvas) {
+ super.onDraw(canvas)
+
+ // Various allocations:
+ java.lang.String("foo")
+ val s = java.lang.String("bar")
+
+ // This one should not be reported:
+ @SuppressLint("DrawAllocation")
+ val i = 5
+
+ // Cached object initialized lazily: should not complain about these
+ if (cachedRect == null) {
+ cachedRect = Rect(0, 0, 100, 100)
+ }
+ if (cachedRect == null || cachedRect!!.width() != 50) {
+ cachedRect = Rect(0, 0, 50, 100)
+ }
+
+ val b = java.lang.Boolean.valueOf(true)!! // auto-boxing
+ dummy(1, 2)
+
+ // Non-allocations
+ super.animate()
+ dummy2(1, 2)
+
+ // This will involve allocations, but we don't track
+ // inter-procedural stuff here
+ someOtherMethod()
+ }
+
+ internal fun dummy(foo: Int?, bar: Int) {
+ dummy2(foo!!, bar)
+ }
+
+ internal fun dummy2(foo: Int, bar: Int) {
+ }
+
+ internal fun someOtherMethod() {
+ // Allocations are okay here
+ java.lang.String("foo")
+ val s = java.lang.String("bar")
+ val b = java.lang.Boolean.valueOf(true)!! // auto-boxing
+
+
+ // Sparse array candidates
+ val myMap = HashMap()
+ // Should use SparseBooleanArray
+ val myBoolMap = HashMap()
+ // Should use SparseIntArray
+ val myIntMap = java.util.HashMap()
+
+ // This one should not be reported:
+ @SuppressLint("UseSparseArrays")
+ val myOtherMap = HashMap()
+ }
+
+ protected fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int,
+ x: Boolean) {
+ // wrong signature
+ java.lang.String("not an error")
+ }
+
+ protected fun onMeasure(widthMeasureSpec: Int) {
+ // wrong signature
+ java.lang.String("not an error")
+ }
+
+ protected fun onLayout(changed: Boolean, left: Int, top: Int, right: Int,
+ bottom: Int, wrong: Int) {
+ // wrong signature
+ java.lang.String("not an error")
+ }
+
+ protected fun onLayout(changed: Boolean, left: Int, top: Int, right: Int) {
+ // wrong signature
+ java.lang.String("not an error")
+ }
+
+ override fun onLayout(changed: Boolean, left: Int, top: Int, right: Int,
+ bottom: Int) {
+ java.lang.String("flag me")
+ }
+
+ @SuppressWarnings("null") // not real code
+ override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
+ java.lang.String("flag me")
+
+ // Forbidden factory methods:
+ Bitmap.createBitmap(100, 100, null)
+ android.graphics.Bitmap.createScaledBitmap(null, 100, 100, false)
+ BitmapFactory.decodeFile(null)
+ val canvas: Canvas? = null
+ canvas!!.getClipBounds() // allocates on your behalf
+ canvas.clipBounds // allocates on your behalf
+ canvas.getClipBounds(null) // NOT an error
+
+ val layoutWidth = width
+ val layoutHeight = height
+ if (mAllowCrop && (mOverlay == null || mOverlay!!.width != layoutWidth ||
+ mOverlay!!.height != layoutHeight)) {
+ mOverlay = Bitmap.createBitmap(layoutWidth, layoutHeight, Bitmap.Config.ARGB_8888)
+ mOverlayCanvas = Canvas(mOverlay!!)
+ }
+
+ if (widthMeasureSpec == 42) {
+ throw IllegalStateException("Test") // NOT an allocation
+ }
+
+ // More lazy init tests
+ var initialized = false
+ if (!initialized) {
+ java.lang.String("foo")
+ initialized = true
+ }
+
+ // NOT lazy initialization
+ if (!initialized || mOverlay == null) {
+ java.lang.String("foo")
+ }
+ }
+
+ internal fun factories() {
+ val i1 = 42
+ val l1 = 42L
+ val b1 = true
+ val c1 = 'c'
+ val f1 = 1.0f
+ val d1 = 1.0
+
+ // The following should not generate errors:
+ val i3 = Integer.valueOf(42)
+ }
+
+ private val mAllowCrop: Boolean = false
+ private var mOverlayCanvas: Canvas? = null
+ private var mOverlay: Bitmap? = null
+
+ override fun layout(l: Int, t: Int, r: Int, b: Int) {
+ // Using "this." to reference fields
+ if (this.shader == null)
+ this.shader = LinearGradient(0f, 0f, width.toFloat(), 0f, intArrayOf(0), null,
+ Shader.TileMode.REPEAT)
+
+ val width = width
+ val height = height
+
+ if (shader == null || lastWidth != width || lastHeight != height) {
+ lastWidth = width
+ lastHeight = height
+
+ shader = LinearGradient(0f, 0f, width.toFloat(), 0f, intArrayOf(0), null, Shader.TileMode.REPEAT)
+ }
+ }
+
+ fun inefficientSparseArray() {
+ SparseArray() // Use SparseIntArray instead
+ SparseArray() // Use SparseLongArray instead
+ SparseArray() // Use SparseBooleanArray instead
+ SparseArray() // OK
+ }
+
+ fun longSparseArray() {
+ // but only minSdkVersion >= 17 or if has v4 support lib
+ val myStringMap = HashMap()
+ }
+
+ fun byteSparseArray() {
+ // bytes easily apply to ints
+ val myByteMap = HashMap()
+ }
+}
diff --git a/idea/testData/android/lint/javaScriptInterface.kt.181 b/idea/testData/android/lint/javaScriptInterface.kt.181
new file mode 100644
index 00000000000..cc916fb41cb
--- /dev/null
+++ b/idea/testData/android/lint/javaScriptInterface.kt.181
@@ -0,0 +1,66 @@
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintJavascriptInterfaceInspection
+
+import android.annotation.SuppressLint
+import android.webkit.JavascriptInterface
+import android.webkit.WebView
+
+@Suppress("UsePropertyAccessSyntax", "UNUSED_VARIABLE", "UNUSED_VALUE", "unused", "UNUSED_PARAMETER", "DEPRECATION")
+class JavaScriptTestK {
+ fun test(webview: WebView) {
+ webview.addJavascriptInterface(AnnotatedObject(), "myobj")
+
+ webview.addJavascriptInterface(InheritsFromAnnotated(), "myobj")
+ webview.addJavascriptInterface(NonAnnotatedObject(), "myobj")
+
+ webview.addJavascriptInterface(null, "nothing")
+ webview.addJavascriptInterface(object : Any() { @JavascriptInterface fun method() {} }, "nothing")
+ webview.addJavascriptInterface(JavascriptFace(), "nothing")
+
+ var o: Any = NonAnnotatedObject()
+ webview.addJavascriptInterface(o, "myobj")
+ o = InheritsFromAnnotated()
+ webview.addJavascriptInterface(o, "myobj")
+ }
+
+ fun test(webview: WebView, object1: AnnotatedObject, object2: NonAnnotatedObject) {
+ webview.addJavascriptInterface(object1, "myobj")
+ webview.addJavascriptInterface(object2, "myobj")
+ }
+
+ @SuppressLint("JavascriptInterface")
+ fun testSuppressed(webview: WebView) {
+ webview.addJavascriptInterface(NonAnnotatedObject(), "myobj")
+ }
+
+ fun testLaterReassignment(webview: WebView) {
+ var o: Any = NonAnnotatedObject()
+ val t = o
+ webview.addJavascriptInterface(t, "myobj")
+ o = AnnotatedObject()
+ }
+
+ class NonAnnotatedObject() {
+ fun test1() {}
+ fun test2() {}
+ }
+
+ open class AnnotatedObject {
+ @JavascriptInterface
+ open fun test1() {}
+
+ open fun test2() {}
+
+ @JavascriptInterface
+ fun test3() {}
+ }
+
+ class InheritsFromAnnotated : AnnotatedObject() {
+ override fun test1() {}
+ override fun test2() {}
+ }
+
+}
+
+class JavascriptFace {
+ fun method() {}
+}
\ No newline at end of file
diff --git a/idea/testData/android/lint/layoutInflation.kt.181 b/idea/testData/android/lint/layoutInflation.kt.181
new file mode 100644
index 00000000000..dbe0461ede5
--- /dev/null
+++ b/idea/testData/android/lint/layoutInflation.kt.181
@@ -0,0 +1,50 @@
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintInflateParamsInspection
+
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import android.widget.BaseAdapter
+
+@Suppress("UsePropertyAccessSyntax", "UNUSED_VARIABLE", "unused", "UNUSED_PARAMETER", "DEPRECATION")
+abstract class LayoutInflationTest : BaseAdapter() {
+ lateinit var mInflater: LayoutInflater
+
+ override fun getView(position: Int, convertView: View, parent: ViewGroup): View {
+ var view = convertView
+ view = mInflater.inflate(R.layout.your_layout, null)
+ view = mInflater.inflate(R.layout.your_layout, null, true)
+ view = mInflater.inflate(R.layout.your_layout, parent)
+ view = WeirdInflater.inflate(view, null)
+
+ return view
+ }
+
+ object WeirdInflater {
+ fun inflate(view: View, parent: View?) = view
+ }
+
+ object R {
+ object layout {
+ val your_layout = 1
+ }
+ }
+}
+
+@Suppress("UsePropertyAccessSyntax", "UNUSED_VARIABLE", "unused", "UNUSED_PARAMETER", "DEPRECATION")
+abstract class LayoutInflationTest2 : BaseAdapter() {
+ lateinit var mInflater: LayoutInflater
+
+ override fun getView(position: Int, convertView: View, parent: ViewGroup): View? {
+ return if (true) {
+ mInflater.inflate(R.layout.your_layout, parent)
+ } else {
+ null
+ }
+ }
+
+ object R {
+ object layout {
+ val your_layout = 1
+ }
+ }
+}
\ No newline at end of file
diff --git a/idea/testData/android/lint/log.kt.181 b/idea/testData/android/lint/log.kt.181
new file mode 100644
index 00000000000..f82e52b3dab
--- /dev/null
+++ b/idea/testData/android/lint/log.kt.181
@@ -0,0 +1,111 @@
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintLogConditionalInspection
+// INSPECTION_CLASS2: com.android.tools.idea.lint.AndroidLintLogTagMismatchInspection
+// INSPECTION_CLASS3: com.android.tools.idea.lint.AndroidLintLongLogTagInspection
+
+import android.annotation.SuppressLint
+import android.util.Log
+import android.util.Log.DEBUG
+
+@SuppressWarnings("UnusedDeclaration")
+@Suppress("UsePropertyAccessSyntax", "UNUSED_VARIABLE", "unused", "UNUSED_PARAMETER", "DEPRECATION")
+class LogTest {
+
+ fun checkConditional(m: String) {
+ Log.d(TAG1, "message") // ok: unconditional, but not performing computation
+ Log.d(TAG1, m) // ok: unconditional, but not performing computation
+ Log.d(TAG1, "a" + "b") // ok: unconditional, but not performing non-constant computation
+ Log.d(TAG1, Constants.MY_MESSAGE) // ok: unconditional, but constant string
+ Log.i(TAG1, "message" + m) // error: unconditional w/ computation
+ Log.i(TAG1, toString()) // error: unconditional w/ computation
+ Log.e(TAG1, toString()) // ok: only flagging debug/info messages
+ Log.w(TAG1, toString()) // ok: only flagging debug/info messages
+ Log.wtf(TAG1, toString()) // ok: only flagging debug/info messages
+ if (Log.isLoggable(TAG1, 0)) {
+ Log.d(TAG1, toString()) // ok: conditional
+ }
+ }
+
+ fun checkWrongTag(tag: String) {
+ if (Log.isLoggable(TAG1, Log.DEBUG)) {
+ Log.d(TAG2, "message") // warn: mismatched tags!
+ }
+ if (Log.isLoggable("my_tag", Log.DEBUG)) {
+ Log.d("other_tag", "message") // warn: mismatched tags!
+ }
+ if (Log.isLoggable("my_tag", Log.DEBUG)) {
+ Log.d("my_tag", "message") // ok: strings equal
+ }
+ if (Log.isLoggable(tag, Log.DEBUG)) {
+ Log.d(tag, "message") // ok: same variable
+ }
+ }
+
+ fun checkLongTag(shouldLog: Boolean) {
+ if (shouldLog) {
+ // String literal tags
+ Log.d("short_tag", "message") // ok: short
+ Log.d("really_really_really_really_really_long_tag", "message") // error: too long
+
+ // Resolved field tags
+ Log.d(TAG1, "message") // ok: short
+ Log.d(TAG22, "message") // ok: short
+ Log.d(TAG23, "message") // ok: threshold
+ Log.d(TAG24, "message") // error: too long
+ Log.d(LONG_TAG, "message") // error: way too long
+
+ // Locally defined variable tags
+ val LOCAL_TAG = "MyReallyReallyReallyReallyReallyLongTag"
+ Log.d(LOCAL_TAG, "message") // error: too long
+
+ // Concatenated tags
+ Log.d(TAG22 + TAG1, "message") // error: too long
+ Log.d(TAG22 + "MyTag", "message") // error: too long
+ }
+ }
+
+ fun checkWrongLevel(tag: String) {
+ if (Log.isLoggable(TAG1, Log.DEBUG)) {
+ Log.d(TAG1, "message") // ok: right level
+ }
+ if (Log.isLoggable(TAG1, Log.INFO)) {
+ Log.i(TAG1, "message") // ok: right level
+ }
+ if (Log.isLoggable(TAG1, Log.DEBUG)) {
+ Log.v(TAG1, "message") // warn: wrong level
+ }
+ if (Log.isLoggable(TAG1, DEBUG)) {
+ // static import of level
+ Log.v(TAG1, "message") // warn: wrong level
+ }
+ if (Log.isLoggable(TAG1, Log.VERBOSE)) {
+ Log.d(TAG1, "message") // warn? verbose is a lower logging level, which includes debug
+ }
+ if (Log.isLoggable(TAG1, Constants.MY_LEVEL)) {
+ Log.d(TAG1, "message") // ok: unknown level alias
+ }
+ }
+
+ @SuppressLint("all")
+ fun suppressed1() {
+ Log.d(TAG1, "message") // ok: suppressed
+ }
+
+ @SuppressLint("LogConditional")
+ fun suppressed2() {
+ Log.d(TAG1, "message") // ok: suppressed
+ }
+
+ private object Constants {
+ val MY_MESSAGE = "My Message"
+ val MY_LEVEL = 5
+ }
+
+ companion object {
+ private val TAG1 = "MyTag1"
+ private val TAG2 = "MyTag2"
+ private val TAG22 = "1234567890123456789012"
+ private val TAG23 = "12345678901234567890123"
+ private val TAG24 = "123456789012345678901234"
+ private val LONG_TAG = "MyReallyReallyReallyReallyReallyLongTag"
+ }
+}
\ No newline at end of file
diff --git a/idea/testData/android/lint/noInternationalSms.kt.181 b/idea/testData/android/lint/noInternationalSms.kt.181
new file mode 100644
index 00000000000..3f26bafc201
--- /dev/null
+++ b/idea/testData/android/lint/noInternationalSms.kt.181
@@ -0,0 +1,19 @@
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintUnlocalizedSmsInspection
+
+import android.content.Context
+import android.telephony.SmsManager
+
+@Suppress("UsePropertyAccessSyntax", "UNUSED_VARIABLE", "unused", "UNUSED_PARAMETER", "DEPRECATION")
+class NonInternationalizedSmsDetectorTest {
+ private fun sendLocalizedMessage(context: Context) {
+ // Don't warn here
+ val sms = SmsManager.getDefault()
+ sms.sendTextMessage("+1234567890", null, null, null, null)
+ }
+
+ private fun sendAlternativeCountryPrefix(context: Context) {
+ // Do warn here
+ val sms = SmsManager.getDefault()
+ sms.sendMultipartTextMessage("001234567890", null, null, null, null)
+ }
+}
\ No newline at end of file
diff --git a/idea/testData/android/lint/overrideConcrete.kt.181 b/idea/testData/android/lint/overrideConcrete.kt.181
new file mode 100644
index 00000000000..278250137cf
--- /dev/null
+++ b/idea/testData/android/lint/overrideConcrete.kt.181
@@ -0,0 +1,61 @@
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintOverrideAbstractInspection
+
+import android.annotation.SuppressLint
+import android.annotation.TargetApi
+import android.os.Build
+import android.service.notification.NotificationListenerService
+import android.service.notification.StatusBarNotification
+
+@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
+@Suppress("UsePropertyAccessSyntax", "UNUSED_VARIABLE", "unused", "UNUSED_PARAMETER", "DEPRECATION")
+class OverrideConcreteTest2 {
+ // OK: This one specifies both methods
+ private open class MyNotificationListenerService1 : NotificationListenerService() {
+ override fun onNotificationPosted(statusBarNotification: StatusBarNotification) {
+ }
+
+ override fun onNotificationRemoved(statusBarNotification: StatusBarNotification) {
+ }
+ }
+
+ // Error: Misses onNotificationPosted
+ private class MyNotificationListenerService2 : NotificationListenerService() {
+ override fun onNotificationRemoved(statusBarNotification: StatusBarNotification) {
+ }
+ }
+
+ // Error: Misses onNotificationRemoved
+ private open class MyNotificationListenerService3 : NotificationListenerService() {
+ override fun onNotificationPosted(statusBarNotification: StatusBarNotification) {
+ }
+ }
+
+ // Error: Missing both; wrong signatures (first has wrong arg count, second has wrong type)
+ private class MyNotificationListenerService4 : NotificationListenerService() {
+ fun onNotificationPosted(statusBarNotification: StatusBarNotification, flags: Int) {
+ }
+
+ fun onNotificationRemoved(statusBarNotification: Int) {
+ }
+ }
+
+ // OK: Inherits from a class which define both
+ private class MyNotificationListenerService5 : MyNotificationListenerService1()
+
+ // OK: Inherits from a class which defines only one, but the other one is defined here
+ private class MyNotificationListenerService6 : MyNotificationListenerService3() {
+ override fun onNotificationRemoved(statusBarNotification: StatusBarNotification) {
+ }
+ }
+
+ // Error: Inheriting from a class which only defines one
+ private class MyNotificationListenerService7 : MyNotificationListenerService3()
+
+ // OK: Has target api setting a local version that is high enough
+ @TargetApi(21)
+ private class MyNotificationListenerService8 : NotificationListenerService()
+
+ // OK: Suppressed
+ @SuppressLint("OverrideAbstract")
+ private class MyNotificationListenerService9 : MyNotificationListenerService1()
+}
\ No newline at end of file
diff --git a/idea/testData/android/lint/parcel.kt.181 b/idea/testData/android/lint/parcel.kt.181
new file mode 100644
index 00000000000..3021ded2603
--- /dev/null
+++ b/idea/testData/android/lint/parcel.kt.181
@@ -0,0 +1,104 @@
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintParcelCreatorInspection
+
+@file:Suppress("UsePropertyAccessSyntax", "UNUSED_VARIABLE", "unused", "UNUSED_PARAMETER", "DEPRECATION")
+import android.os.Parcel
+import android.os.Parcelable
+import kotlinx.android.parcel.Parcelize
+
+class MyParcelable1 : Parcelable {
+ override fun describeContents() = 0
+ override fun writeToParcel(arg0: Parcel, arg1: Int) {}
+}
+
+internal class MyParcelable2 : Parcelable {
+ override fun describeContents() = 0
+
+ override fun writeToParcel(arg0: Parcel, arg1: Int) {}
+
+ companion object {
+ @JvmField
+ val CREATOR: Parcelable.Creator = object : Parcelable.Creator {
+ override fun newArray(size: Int) = null!!
+ override fun createFromParcel(source: Parcel?) = null!!
+ }
+ }
+}
+
+internal class MyParcelable3 : Parcelable {
+ override fun describeContents() = 0
+ override fun writeToParcel(arg0: Parcel, arg1: Int) {}
+
+ companion object {
+ @JvmField
+ val CREATOR = 0 // Wrong type
+ }
+}
+
+class RecyclerViewScrollPosition(val position: Int, val topOffset: Int): Parcelable {
+ override fun describeContents(): Int = 0
+ override fun writeToParcel(dest: Parcel, flags: Int) {
+ dest.writeInt(position)
+ dest.writeInt(topOffset)
+ }
+
+ companion object {
+ @JvmField
+ val CREATOR = object : Parcelable.Creator {
+ override fun createFromParcel(parcel: Parcel): RecyclerViewScrollPosition {
+ val position = parcel.readInt()
+ val topOffset = parcel.readInt()
+ return RecyclerViewScrollPosition(position, topOffset)
+ }
+
+ override fun newArray(size: Int): Array = arrayOfNulls(size)
+ }
+
+ }
+}
+
+class RecyclerViewScrollPositionWithoutJvmF(val position: Int, val topOffset: Int): Parcelable {
+ override fun describeContents(): Int = 0
+ override fun writeToParcel(dest: Parcel, flags: Int) {
+ dest.writeInt(position)
+ dest.writeInt(topOffset)
+ }
+
+ companion object {
+ val CREATOR = object : Parcelable.Creator {
+ override fun createFromParcel(parcel: Parcel): RecyclerViewScrollPosition {
+ val position = parcel.readInt()
+ val topOffset = parcel.readInt()
+ return RecyclerViewScrollPosition(position, topOffset)
+ }
+
+ override fun newArray(size: Int): Array = arrayOfNulls(size)
+ }
+
+ }
+}
+
+class RecyclerViewScrollPosition2(val position: Int, val topOffset: Int): Parcelable {
+ override fun describeContents(): Int = 0
+ override fun writeToParcel(dest: Parcel, flags: Int) {
+ dest.writeInt(position)
+ dest.writeInt(topOffset)
+ }
+
+ companion object CREATOR: Parcelable.Creator {
+ override fun createFromParcel(parcel: Parcel): RecyclerViewScrollPosition {
+ val position = parcel.readInt()
+ val topOffset = parcel.readInt()
+ return RecyclerViewScrollPosition(position, topOffset)
+ }
+
+ override fun newArray(size: Int): Array = arrayOfNulls(size)
+ }
+}
+
+internal abstract class MyParcelable4 : Parcelable {
+ override fun describeContents() = 0
+ override fun writeToParcel(arg0: Parcel, arg1: Int) {}
+}
+
+@Parcelize
+class ParcelizeUser(val firstName: String, val lastName: String) : Parcelable
\ No newline at end of file
diff --git a/idea/testData/android/lint/sdCardTest.kt.181 b/idea/testData/android/lint/sdCardTest.kt.181
new file mode 100644
index 00000000000..f62ba6fc6e4
--- /dev/null
+++ b/idea/testData/android/lint/sdCardTest.kt.181
@@ -0,0 +1,45 @@
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintSdCardPathInspection
+
+import java.io.File
+import android.content.Intent
+import android.net.Uri
+
+/**
+ * Ignore comments - create("/sdcard/foo")
+ */
+@Suppress("UsePropertyAccessSyntax", "UNUSED_VARIABLE", "unused", "UNUSED_PARAMETER", "DEPRECATION")
+class SdCardTest {
+ internal var deviceDir = File("/sdcard/vr")
+
+ init {
+ if (PROFILE_STARTUP) {
+ android.os.Debug.startMethodTracing("/sdcard/launcher")
+ }
+
+ if (File("/sdcard").exists()) {
+ }
+ val FilePath = "/sdcard/" + File("test")
+ System.setProperty("foo.bar", "file://sdcard")
+
+
+ val intent = Intent(Intent.ACTION_PICK)
+ intent.setDataAndType(Uri.parse("file://sdcard/foo.json"), "application/bar-json")
+ intent.putExtra("path-filter", "/sdcard(/.+)*")
+ intent.putExtra("start-dir", "/sdcard")
+ val mypath = "/data/data/foo"
+ val base = "/data/data/foo.bar/test-profiling"
+ val s = "file://sdcard/foo"
+
+ val sdCardPath by lazy { "/sdcard" }
+ fun localPropertyTest() {
+ val sdCardPathLocal by lazy { "/sdcard" }
+ }
+}
+
+companion object {
+ private val PROFILE_STARTUP = true
+ private val SDCARD_TEST_HTML = "/sdcard/test.html"
+ val SDCARD_ROOT = "/sdcard"
+ val PACKAGES_PATH = "/sdcard/o/packages/"
+}
+}
diff --git a/idea/testData/android/lint/setJavaScriptEnabled.kt.181 b/idea/testData/android/lint/setJavaScriptEnabled.kt.181
new file mode 100644
index 00000000000..ca41821d6ac
--- /dev/null
+++ b/idea/testData/android/lint/setJavaScriptEnabled.kt.181
@@ -0,0 +1,24 @@
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintSetJavaScriptEnabledInspection
+
+import android.annotation.SuppressLint
+import android.app.Activity
+import android.webkit.WebView
+
+@Suppress("UsePropertyAccessSyntax", "UNUSED_VARIABLE", "unused", "UNUSED_PARAMETER", "DEPRECATION")
+public class HelloWebApp : Activity() {
+
+ fun test(webView: WebView) {
+ webView.settings.javaScriptEnabled = true // bad
+ webView.getSettings().setJavaScriptEnabled(true) // bad
+ webView.getSettings().setJavaScriptEnabled(false) // good
+ webView.loadUrl("file:///android_asset/www/index.html")
+ }
+
+ @SuppressLint("SetJavaScriptEnabled")
+ fun suppressed(webView: WebView) {
+ webView.getSettings().javaScriptEnabled = true; // bad
+ webView.getSettings().setJavaScriptEnabled(true) // bad
+ webView.getSettings().setJavaScriptEnabled(false); // good
+ webView.loadUrl("file:///android_asset/www/index.html");
+ }
+}
\ No newline at end of file
diff --git a/idea/testData/android/lint/sharedPrefs.kt.181 b/idea/testData/android/lint/sharedPrefs.kt.181
new file mode 100644
index 00000000000..023c04d7040
--- /dev/null
+++ b/idea/testData/android/lint/sharedPrefs.kt.181
@@ -0,0 +1,74 @@
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintCommitPrefEditsInspection
+
+import android.app.Activity
+import android.content.Context
+import android.os.Bundle
+import android.preference.PreferenceManager
+
+@Suppress("UsePropertyAccessSyntax", "UNUSED_VARIABLE", "unused", "UNUSED_PARAMETER", "DEPRECATION")
+class SharedPrefsText(context: Context) : Activity() {
+ // OK 1
+ fun onCreate1(savedInstanceState: Bundle) {
+ super.onCreate(savedInstanceState)
+ val preferences = PreferenceManager.getDefaultSharedPreferences(this)
+ val editor = preferences.edit()
+ editor.putString("foo", "bar")
+ editor.putInt("bar", 42)
+ editor.commit()
+ }
+
+ // OK 2
+ fun onCreate2(savedInstanceState: Bundle, apply: Boolean) {
+ super.onCreate(savedInstanceState)
+ val preferences = PreferenceManager.getDefaultSharedPreferences(this)
+ val editor = preferences.edit()
+ editor.putString("foo", "bar")
+ editor.putInt("bar", 42)
+ if (apply) {
+ editor.apply()
+ }
+ }
+
+ // Not a bug
+ fun test(foo: Foo) {
+ val bar1 = foo.edit()
+ val bar3 = edit()
+ apply()
+ }
+
+ internal fun apply() {
+
+ }
+
+ fun edit(): Bar {
+ return Bar()
+ }
+
+ class Foo {
+ internal fun edit(): Bar {
+ return Bar()
+ }
+ }
+
+ class Bar
+
+ // Bug
+ fun bug1(savedInstanceState: Bundle) {
+ super.onCreate(savedInstanceState)
+ val preferences = PreferenceManager.getDefaultSharedPreferences(this)
+ val editor = preferences.edit()
+ editor.putString("foo", "bar")
+ editor.putInt("bar", 42)
+ }
+
+ init {
+ val preferences = PreferenceManager.getDefaultSharedPreferences(context)
+ val editor = preferences.edit()
+ editor.putString("foo", "bar")
+ }
+
+ fun testResultOfCommit() {
+ val r1 = PreferenceManager.getDefaultSharedPreferences(this).edit().putString("wat", "wat").commit()
+ val r2 = PreferenceManager.getDefaultSharedPreferences(this).edit().putString("wat", "wat").commit().toString()
+ }
+}
\ No newline at end of file
diff --git a/idea/testData/android/lint/showDiagnosticsWhenFileIsRed.kt.181 b/idea/testData/android/lint/showDiagnosticsWhenFileIsRed.kt.181
new file mode 100644
index 00000000000..3932ff648a8
--- /dev/null
+++ b/idea/testData/android/lint/showDiagnosticsWhenFileIsRed.kt.181
@@ -0,0 +1,9 @@
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintSQLiteStringInspection
+
+import android.database.sqlite.SQLiteDatabase
+
+fun test(db: SQLiteDatabase) {
+ val a: String = 1
+
+ db.execSQL("CREATE TABLE COMPANY(NAME STRING)")
+}
\ No newline at end of file
diff --git a/idea/testData/android/lint/sqlite.kt.181 b/idea/testData/android/lint/sqlite.kt.181
new file mode 100644
index 00000000000..8c12de0e902
--- /dev/null
+++ b/idea/testData/android/lint/sqlite.kt.181
@@ -0,0 +1,7 @@
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintSQLiteStringInspection
+
+import android.database.sqlite.SQLiteDatabase
+
+fun test(db: SQLiteDatabase) {
+ db.execSQL("CREATE TABLE COMPANY(NAME STRING)")
+}
\ No newline at end of file
diff --git a/idea/testData/android/lint/supportAnnotation.kt.181 b/idea/testData/android/lint/supportAnnotation.kt.181
new file mode 100644
index 00000000000..67eeeb3e98b
--- /dev/null
+++ b/idea/testData/android/lint/supportAnnotation.kt.181
@@ -0,0 +1,36 @@
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintSupportAnnotationUsageInspection
+// DEPENDENCY: IntRange.java -> android/support/annotation/IntRange.java
+// DEPENDENCY: RequiresPermission.java -> android/support/annotation/RequiresPermission.java
+
+
+import android.support.annotation.IntRange
+import android.support.annotation.RequiresPermission
+import android.Manifest
+import android.view.View
+
+const val constantVal = 0L
+
+@IntRange(from = 10, to = 0)
+fun invalidRange1a(): Int = 5
+
+@IntRange(from = constantVal, to = 10) // ok
+fun invalidRange0b(): Int = 5
+
+@IntRange(from = 10, to = constantVal)
+fun invalidRange1b(): Int = 5
+
+
+// should be ok, KT-16600
+@RequiresPermission(anyOf = arrayOf(Manifest.permission.ACCESS_CHECKIN_PROPERTIES,
+ Manifest.permission.ACCESS_FINE_LOCATION))
+fun needsPermissions1() { }
+
+// should be ok, KT-16600
+@RequiresPermission(Manifest.permission.ACCESS_CHECKIN_PROPERTIES)
+fun needsPermissions2() { }
+
+// error
+@RequiresPermission(
+ value = Manifest.permission.ACCESS_CHECKIN_PROPERTIES,
+ anyOf = arrayOf(Manifest.permission.ACCESS_CHECKIN_PROPERTIES, Manifest.permission.ACCESS_FINE_LOCATION))
+fun needsPermissions3() { }
\ No newline at end of file
diff --git a/idea/testData/android/lint/systemServices.kt.181 b/idea/testData/android/lint/systemServices.kt.181
new file mode 100644
index 00000000000..3433575a10f
--- /dev/null
+++ b/idea/testData/android/lint/systemServices.kt.181
@@ -0,0 +1,29 @@
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintServiceCastInspection
+
+import android.content.ClipboardManager
+import android.app.Activity
+import android.app.WallpaperManager
+import android.content.Context
+import android.hardware.display.DisplayManager
+import android.service.wallpaper.WallpaperService
+
+@Suppress("UsePropertyAccessSyntax", "UNUSED_VARIABLE", "unused", "UNUSED_PARAMETER", "DEPRECATION")
+class SystemServiceTest : Activity() {
+
+ fun test1() {
+ val displayServiceOk = getSystemService(DISPLAY_SERVICE) as DisplayManager
+ val displayServiceWrong = getSystemService(DEVICE_POLICY_SERVICE) as DisplayManager
+ val wallPaperWrong = getSystemService(WALLPAPER_SERVICE) as WallpaperService
+ val wallPaperOk = getSystemService(WALLPAPER_SERVICE) as WallpaperManager
+ }
+
+ fun test2(context: Context) {
+ val displayServiceOk = context.getSystemService(DISPLAY_SERVICE) as DisplayManager
+ val displayServiceWrong = context.getSystemService(DEVICE_POLICY_SERVICE) as DisplayManager
+ }
+
+ fun clipboard(context: Context) {
+ val clipboard = context.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
+ val clipboard2 = context.getSystemService(Context.CLIPBOARD_SERVICE) as android.content.ClipboardManager
+ }
+}
\ No newline at end of file
diff --git a/idea/testData/android/lint/toast.kt.181 b/idea/testData/android/lint/toast.kt.181
new file mode 100644
index 00000000000..573382e15c5
--- /dev/null
+++ b/idea/testData/android/lint/toast.kt.181
@@ -0,0 +1,75 @@
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintShowToastInspection
+
+import android.app.Activity
+import android.content.Context
+import android.widget.Toast
+
+@Suppress("UsePropertyAccessSyntax", "UNUSED_VARIABLE", "unused", "UNUSED_PARAMETER", "DEPRECATION")
+class ToastTest(context: Context) : Activity() {
+ private fun createToast(context: Context): Toast {
+ // Don't warn here
+ return Toast.makeText(context, "foo", Toast.LENGTH_LONG)
+ }
+
+ private fun insideRunnable(context: Context) {
+ Runnable {
+ Toast.makeText(context, "foo", Toast.LENGTH_LONG).show()
+ }
+
+ Runnable {
+ val toast = Toast.makeText(context, "foo", Toast.LENGTH_LONG)
+ if (5 > 3) {
+ toast.show()
+ }
+ }
+
+ Runnable {
+ Toast.makeText(context, "foo", Toast.LENGTH_LONG)
+ }
+ }
+
+ private fun showToast(context: Context) {
+ // Don't warn here
+ val toast = Toast.makeText(context, "foo", Toast.LENGTH_LONG)
+ System.out.println("Other intermediate code here")
+ val temp = 5 + 2
+ toast.show()
+ }
+
+ private fun showToast2(context: Context) {
+ // Don't warn here
+ val duration = Toast.LENGTH_LONG
+ Toast.makeText(context, "foo", Toast.LENGTH_LONG).show()
+ Toast.makeText(context, R.string.app_name, duration).show()
+ }
+
+ private fun broken(context: Context) {
+ // Errors
+ Toast.makeText(context, "foo", Toast.LENGTH_LONG)
+ val toast = Toast.makeText(context, R.string.app_name, 5000)
+ toast.duration
+ }
+
+ init {
+ Toast.makeText(context, "foo", Toast.LENGTH_LONG)
+ }
+
+ @android.annotation.SuppressLint("ShowToast")
+ private fun checkSuppress1(context: Context) {
+ val toast = Toast.makeText(this, "MyToast", Toast.LENGTH_LONG)
+ }
+
+ private fun checkSuppress2(context: Context) {
+ @android.annotation.SuppressLint("ShowToast")
+ val toast1 = Toast.makeText(this, "MyToast", Toast.LENGTH_LONG)
+
+ @android.annotation.SuppressLint("ShowToast", "Lorem ipsum")
+ val toast2 = Toast.makeText(this, "MyToast", Toast.LENGTH_LONG)
+ }
+
+ class R {
+ object string {
+ val app_name = 1
+ }
+ }
+}
\ No newline at end of file
diff --git a/idea/testData/android/lint/valueOf.kt.181 b/idea/testData/android/lint/valueOf.kt.181
new file mode 100644
index 00000000000..83565a66746
--- /dev/null
+++ b/idea/testData/android/lint/valueOf.kt.181
@@ -0,0 +1,8 @@
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintUseValueOfInspection
+
+@Suppress("UsePropertyAccessSyntax", "UNUSED_VARIABLE", "unused", "UNUSED_PARAMETER", "DEPRECATION")
+class Simple {
+ fun test() {
+ Integer(5)
+ }
+}
\ No newline at end of file
diff --git a/idea/testData/android/lint/velocityTrackerRecycle.kt.181 b/idea/testData/android/lint/velocityTrackerRecycle.kt.181
new file mode 100644
index 00000000000..9d258a5130b
--- /dev/null
+++ b/idea/testData/android/lint/velocityTrackerRecycle.kt.181
@@ -0,0 +1,23 @@
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintRecycleInspection
+
+@file:Suppress("UNUSED_VARIABLE")
+
+import android.app.Activity
+import android.os.Bundle
+import android.view.VelocityTracker
+
+class MainActivity : Activity() {
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+
+ VelocityTracker.obtain()
+
+ VelocityTracker.obtain().recycle()
+
+ val v1 = VelocityTracker.obtain()
+
+ val v2 = VelocityTracker.obtain()
+ v2.recycle()
+ }
+}
diff --git a/idea/testData/android/lint/viewConstructor.kt.181 b/idea/testData/android/lint/viewConstructor.kt.181
new file mode 100644
index 00000000000..9b1e29e7fff
--- /dev/null
+++ b/idea/testData/android/lint/viewConstructor.kt.181
@@ -0,0 +1,32 @@
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintViewConstructorInspection
+
+import android.content.Context
+import android.util.AttributeSet
+import android.view.View
+import android.widget.TextView
+
+class View1(context: Context?) : View(context)
+class View2(context: Context?, attrs: AttributeSet?) : View(context, attrs)
+class View3(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : TextView(context, attrs, defStyleAttr)
+
+// Error
+class View4(int: Int, context: Context?) : View(context)
+
+// Error
+class View5(context: Context?, attrs: AttributeSet?, val name: String) : View(context, attrs)
+
+class View6 : View {
+ constructor(context: Context) : super(context) {
+
+ }
+}
+
+class View7 : View {
+ constructor(context: Context) : super(context)
+ constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
+}
+
+// Error
+class View8 : View {
+ constructor(context: Context, a: Int) : super(context)
+}
\ No newline at end of file
diff --git a/idea/testData/android/lint/viewHolder.kt.181 b/idea/testData/android/lint/viewHolder.kt.181
new file mode 100644
index 00000000000..d0b8d23d7cb
--- /dev/null
+++ b/idea/testData/android/lint/viewHolder.kt.181
@@ -0,0 +1,154 @@
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintViewHolderInspection
+
+@file:Suppress("NAME_SHADOWING", "unused", "UNUSED_VALUE", "VARIABLE_WITH_REDUNDANT_INITIALIZER", "UNUSED_VARIABLE")
+
+import android.content.Context
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import android.widget.BaseAdapter
+import android.widget.LinearLayout
+import android.widget.TextView
+import java.util.ArrayList
+
+@SuppressWarnings("ConstantConditions", "UnusedDeclaration")
+abstract class ViewHolderTest : BaseAdapter() {
+ override fun getCount() = 0
+ override fun getItem(position: Int) = null
+ override fun getItemId(position: Int) = 0L
+
+ class Adapter1 : ViewHolderTest() {
+ override fun getView(position: Int, convertView: View, parent: ViewGroup) = null
+ }
+
+ class Adapter2 : ViewHolderTest() {
+ lateinit var mInflater: LayoutInflater
+
+ override fun getView(position: Int, convertView: View, parent: ViewGroup): View {
+ var convertView = convertView
+ // Should use View Holder pattern here
+ convertView = mInflater.inflate(R.layout.your_layout, null)
+
+ val text: TextView = convertView.findViewById(R.id.text)
+ text.text = "Position " + position
+
+ return convertView
+ }
+ }
+
+ class Adapter3 : ViewHolderTest() {
+ lateinit var mInflater: LayoutInflater
+
+ override fun getView(position: Int, convertView: View?, parent: ViewGroup): View {
+ var convertView = convertView
+ // Already using View Holder pattern
+ if (convertView == null) {
+ convertView = mInflater.inflate(R.layout.your_layout, null)
+ }
+
+ val text: TextView = convertView!!.findViewById(R.id.text)
+ text.text = "Position " + position
+
+ return convertView
+ }
+ }
+
+ class Adapter4 : ViewHolderTest() {
+ lateinit var mInflater: LayoutInflater
+
+ override fun getView(position: Int, convertView: View?, parent: ViewGroup): View {
+ var convertView = convertView
+ // Already using View Holder pattern
+ //noinspection StatementWithEmptyBody
+ if (convertView != null) {
+ } else {
+ convertView = mInflater.inflate(R.layout.your_layout, null)
+ }
+
+ val text: TextView = convertView!!.findViewById(R.id.text)
+ text.text = "Position " + position
+
+ return convertView
+ }
+ }
+
+ class Adapter5 : ViewHolderTest() {
+ lateinit var mInflater: LayoutInflater
+
+ override fun getView(position: Int, convertView: View?, parent: ViewGroup): View {
+ var convertView = convertView
+ // Already using View Holder pattern
+ convertView = if (convertView == null) mInflater.inflate(R.layout.your_layout, null) else convertView
+
+ val text: TextView = convertView!!.findViewById(R.id.text)
+ text.text = "Position " + position
+
+ return convertView
+ }
+ }
+
+ class Adapter6 : ViewHolderTest() {
+ private val mContext: Context? = null
+ private var mLayoutInflator: LayoutInflater? = null
+ private lateinit var mLapTimes: ArrayList
+
+ override fun getView(position: Int, convertView: View, parent: ViewGroup): View {
+ if (mLayoutInflator == null)
+ mLayoutInflator = mContext!!.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
+
+ var v: View? = convertView
+ if (v == null) v = mLayoutInflator!!.inflate(R.layout.your_layout, null)
+
+ val listItemHolder: LinearLayout = v!!.findViewById(R.id.laptimes_list_item_holder)
+ listItemHolder.removeAllViews()
+
+ for (i in 1..5) {
+ val lapItemView: View = mLayoutInflator!!.inflate(R.layout.laptime_item, null)
+ if (i == 0) {
+ val t: TextView = lapItemView.findViewById(R.id.laptime_text)
+ }
+
+ val t2: TextView = lapItemView.findViewById(R.id.laptime_text2)
+ if (i < mLapTimes.size - 1 && mLapTimes.size > 1) {
+ var laptime = mLapTimes[i] - mLapTimes[i + 1]
+ if (laptime < 0) laptime = mLapTimes[i]
+ }
+
+ listItemHolder.addView(lapItemView)
+
+ }
+ return v
+ }
+ }
+
+ class Adapter7 : ViewHolderTest() {
+ lateinit var inflater: LayoutInflater
+
+ override fun getView(position: Int, convertView: View, parent: ViewGroup): View {
+ var rootView: View? = convertView
+ val itemViewType = getItemViewType(position)
+ when (itemViewType) {
+ 0 -> {
+ if (rootView != null)
+ return rootView
+ rootView = inflater.inflate(android.R.layout.simple_list_item_1, parent, false)
+ }
+ }
+ return rootView!!
+ }
+ }
+
+ class R {
+ object layout {
+ val your_layout = 1
+ val laptime_item = 2
+ }
+
+ object id {
+ val laptime_text = 1
+ val laptime_text2 = 2
+ val laptimes_list_item_holder = 3
+ val text = 4
+ }
+ }
+}
\ No newline at end of file
diff --git a/idea/testData/android/lint/wrongAnnotation.kt.181 b/idea/testData/android/lint/wrongAnnotation.kt.181
new file mode 100644
index 00000000000..93f95fe555c
--- /dev/null
+++ b/idea/testData/android/lint/wrongAnnotation.kt.181
@@ -0,0 +1,42 @@
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintLocalSuppressInspection
+
+import android.annotation.SuppressLint
+import android.view.View
+
+@Suppress("UsePropertyAccessSyntax", "UNUSED_VARIABLE", "unused", "UNUSED_PARAMETER", "DEPRECATION")
+class WrongAnnotation2 {
+ @SuppressLint("NewApi")
+ private val field1: Int = 0
+
+ @SuppressLint("NewApi")
+ private val field2 = 5
+
+ companion object {
+ @SuppressLint("NewApi") // Valid: class-file check on method
+ fun foobar(view: View, @SuppressLint("NewApi") foo: Int) {
+ // Invalid: class-file check
+ @SuppressLint("NewApi") // Invalid
+ val a: Boolean
+
+ @SuppressLint("SdCardPath", "NewApi") // TODO: Invalid, class-file based check on local variable
+ val b: Boolean
+
+ @android.annotation.SuppressLint("SdCardPath", "NewApi") // TDOD: Invalid (FQN)
+ val c: Boolean
+
+ @SuppressLint("SdCardPath") // Valid: AST-based check
+ val d: Boolean
+ }
+
+ init {
+ // Local variable outside method: invalid
+ @SuppressLint("NewApi")
+ val localvar = 5
+ }
+
+ private fun test() {
+ @SuppressLint("NewApi") // Invalid
+ val a = View.MEASURED_STATE_MASK
+ }
+ }
+}
diff --git a/idea/testData/android/lint/wrongImport.kt.181 b/idea/testData/android/lint/wrongImport.kt.181
new file mode 100644
index 00000000000..1c45d892953
--- /dev/null
+++ b/idea/testData/android/lint/wrongImport.kt.181
@@ -0,0 +1,8 @@
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintSuspiciousImportInspection
+
+//Warning
+import android.R
+
+fun a() {
+ R.id.button1
+}
\ No newline at end of file
diff --git a/idea/testData/android/lint/wrongViewCall.kt.181 b/idea/testData/android/lint/wrongViewCall.kt.181
new file mode 100644
index 00000000000..ce7b5063d2f
--- /dev/null
+++ b/idea/testData/android/lint/wrongViewCall.kt.181
@@ -0,0 +1,23 @@
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintWrongCallInspection
+
+import android.content.Context
+import android.graphics.Canvas
+import android.util.AttributeSet
+import android.widget.FrameLayout
+import android.widget.LinearLayout
+
+abstract class WrongViewCall(context: Context, attrs: AttributeSet, defStyle: Int) : LinearLayout(context, attrs, defStyle) {
+ private val child: MyChild? = null
+
+ override fun onDraw(canvas: Canvas) {
+ super.onDraw(canvas)
+ child?.onDraw(canvas)
+ }
+
+ private inner class MyChild(context: Context, attrs: AttributeSet, defStyle: Int) : FrameLayout(context, attrs, defStyle) {
+
+ public override fun onDraw(canvas: Canvas) {
+ super.onDraw(canvas)
+ }
+ }
+}
diff --git a/idea/testData/android/lintQuickfix/parcelable/missingCreator.kt.181 b/idea/testData/android/lintQuickfix/parcelable/missingCreator.kt.181
new file mode 100644
index 00000000000..cdfb473d8a6
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/parcelable/missingCreator.kt.181
@@ -0,0 +1,14 @@
+// INTENTION_TEXT: Add Parcelable Implementation
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintParcelCreatorInspection
+import android.os.Parcel
+import android.os.Parcelable
+
+class MissingCreator : Parcelable {
+ override fun writeToParcel(dest: Parcel?, flags: Int) {
+ TODO("not implemented")
+ }
+
+ override fun describeContents(): Int {
+ TODO("not implemented")
+ }
+}
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/parcelable/missingCreator.kt.expected.181 b/idea/testData/android/lintQuickfix/parcelable/missingCreator.kt.expected.181
new file mode 100644
index 00000000000..29ea448d7ae
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/parcelable/missingCreator.kt.expected.181
@@ -0,0 +1,27 @@
+// INTENTION_TEXT: Add Parcelable Implementation
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintParcelCreatorInspection
+import android.os.Parcel
+import android.os.Parcelable
+
+class MissingCreator() : Parcelable {
+ constructor(parcel: Parcel) : this() {
+ }
+
+ override fun writeToParcel(dest: Parcel?, flags: Int) {
+ TODO("not implemented")
+ }
+
+ override fun describeContents(): Int {
+ TODO("not implemented")
+ }
+
+ companion object CREATOR : Parcelable.Creator {
+ override fun createFromParcel(parcel: Parcel): MissingCreator {
+ return MissingCreator(parcel)
+ }
+
+ override fun newArray(size: Int): Array {
+ return arrayOfNulls(size)
+ }
+ }
+}
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/parcelable/noImplementation.kt.181 b/idea/testData/android/lintQuickfix/parcelable/noImplementation.kt.181
new file mode 100644
index 00000000000..09eafd5b62e
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/parcelable/noImplementation.kt.181
@@ -0,0 +1,5 @@
+// INTENTION_TEXT: Add Parcelable Implementation
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintParcelCreatorInspection
+import android.os.Parcelable
+
+class NoImplementation : Parcelable
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/parcelable/noImplementation.kt.expected.181 b/idea/testData/android/lintQuickfix/parcelable/noImplementation.kt.expected.181
new file mode 100644
index 00000000000..f364327f3d2
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/parcelable/noImplementation.kt.expected.181
@@ -0,0 +1,27 @@
+// INTENTION_TEXT: Add Parcelable Implementation
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintParcelCreatorInspection
+import android.os.Parcel
+import android.os.Parcelable
+
+class NoImplementation() : Parcelable {
+ constructor(parcel: Parcel) : this() {
+ }
+
+ override fun writeToParcel(parcel: Parcel, flags: Int) {
+
+ }
+
+ override fun describeContents(): Int {
+ return 0
+ }
+
+ companion object CREATOR : Parcelable.Creator {
+ override fun createFromParcel(parcel: Parcel): NoImplementation {
+ return NoImplementation(parcel)
+ }
+
+ override fun newArray(size: Int): Array {
+ return arrayOfNulls(size)
+ }
+ }
+}
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/requiresApi/annotation.kt.181 b/idea/testData/android/lintQuickfix/requiresApi/annotation.kt.181
new file mode 100644
index 00000000000..19b6ba7d86a
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/requiresApi/annotation.kt.181
@@ -0,0 +1,12 @@
+// INTENTION_TEXT: Add @RequiresApi(LOLLIPOP) Annotation
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintNewApiInspection
+// DEPENDENCY: RequiresApi.java -> android/support/annotation/RequiresApi.java
+
+import android.graphics.drawable.VectorDrawable
+import kotlin.reflect.KClass
+
+annotation class SomeAnnotationWithClass(val cls: KClass<*>)
+
+@SomeAnnotationWithClass(VectorDrawable::class)
+class VectorDrawableProvider {
+}
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/requiresApi/annotation.kt.expected.181 b/idea/testData/android/lintQuickfix/requiresApi/annotation.kt.expected.181
new file mode 100644
index 00000000000..dbc848be75d
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/requiresApi/annotation.kt.expected.181
@@ -0,0 +1,15 @@
+// INTENTION_TEXT: Add @RequiresApi(LOLLIPOP) Annotation
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintNewApiInspection
+// DEPENDENCY: RequiresApi.java -> android/support/annotation/RequiresApi.java
+
+import android.graphics.drawable.VectorDrawable
+import android.os.Build
+import android.support.annotation.RequiresApi
+import kotlin.reflect.KClass
+
+annotation class SomeAnnotationWithClass(val cls: KClass<*>)
+
+@RequiresApi(Build.VERSION_CODES.LOLLIPOP)
+@SomeAnnotationWithClass(VectorDrawable::class)
+class VectorDrawableProvider {
+}
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/requiresApi/companion.kt.181 b/idea/testData/android/lintQuickfix/requiresApi/companion.kt.181
new file mode 100644
index 00000000000..be0bb206f63
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/requiresApi/companion.kt.181
@@ -0,0 +1,11 @@
+// INTENTION_TEXT: Add @RequiresApi(LOLLIPOP) Annotation
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintNewApiInspection
+// DEPENDENCY: RequiresApi.java -> android/support/annotation/RequiresApi.java
+
+import android.graphics.drawable.VectorDrawable
+
+class VectorDrawableProvider {
+ companion object {
+ val VECTOR_DRAWABLE = VectorDrawable()
+ }
+}
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/requiresApi/companion.kt.expected.181 b/idea/testData/android/lintQuickfix/requiresApi/companion.kt.expected.181
new file mode 100644
index 00000000000..d2fc869db12
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/requiresApi/companion.kt.expected.181
@@ -0,0 +1,14 @@
+// INTENTION_TEXT: Add @RequiresApi(LOLLIPOP) Annotation
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintNewApiInspection
+// DEPENDENCY: RequiresApi.java -> android/support/annotation/RequiresApi.java
+
+import android.graphics.drawable.VectorDrawable
+import android.os.Build
+import android.support.annotation.RequiresApi
+
+class VectorDrawableProvider {
+ companion object {
+ @RequiresApi(Build.VERSION_CODES.LOLLIPOP)
+ val VECTOR_DRAWABLE = VectorDrawable()
+ }
+}
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/requiresApi/defaultParameter.kt.181 b/idea/testData/android/lintQuickfix/requiresApi/defaultParameter.kt.181
new file mode 100644
index 00000000000..c8a4583498e
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/requiresApi/defaultParameter.kt.181
@@ -0,0 +1,10 @@
+// INTENTION_TEXT: Add @RequiresApi(LOLLIPOP) Annotation
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintNewApiInspection
+// DEPENDENCY: RequiresApi.java -> android/support/annotation/RequiresApi.java
+
+import android.graphics.drawable.VectorDrawable
+
+
+fun withDefaultParameter(vector: VectorDrawable = VectorDrawable()) {
+
+}
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/requiresApi/defaultParameter.kt.expected.181 b/idea/testData/android/lintQuickfix/requiresApi/defaultParameter.kt.expected.181
new file mode 100644
index 00000000000..8d3fcc4c207
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/requiresApi/defaultParameter.kt.expected.181
@@ -0,0 +1,13 @@
+// INTENTION_TEXT: Add @RequiresApi(LOLLIPOP) Annotation
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintNewApiInspection
+// DEPENDENCY: RequiresApi.java -> android/support/annotation/RequiresApi.java
+
+import android.graphics.drawable.VectorDrawable
+import android.os.Build
+import android.support.annotation.RequiresApi
+
+
+@RequiresApi(Build.VERSION_CODES.LOLLIPOP)
+fun withDefaultParameter(vector: VectorDrawable = VectorDrawable()) {
+
+}
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/requiresApi/extend.kt.181 b/idea/testData/android/lintQuickfix/requiresApi/extend.kt.181
new file mode 100644
index 00000000000..6e53535aa1d
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/requiresApi/extend.kt.181
@@ -0,0 +1,9 @@
+// INTENTION_TEXT: Add @RequiresApi(LOLLIPOP) Annotation
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintNewApiInspection
+// DEPENDENCY: RequiresApi.java -> android/support/annotation/RequiresApi.java
+
+import android.graphics.drawable.VectorDrawable
+
+class MyVectorDrawable : VectorDrawable() {
+
+}
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/requiresApi/extend.kt.expected.181 b/idea/testData/android/lintQuickfix/requiresApi/extend.kt.expected.181
new file mode 100644
index 00000000000..3307f07e34e
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/requiresApi/extend.kt.expected.181
@@ -0,0 +1,12 @@
+// INTENTION_TEXT: Add @RequiresApi(LOLLIPOP) Annotation
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintNewApiInspection
+// DEPENDENCY: RequiresApi.java -> android/support/annotation/RequiresApi.java
+
+import android.graphics.drawable.VectorDrawable
+import android.os.Build
+import android.support.annotation.RequiresApi
+
+@RequiresApi(Build.VERSION_CODES.LOLLIPOP)
+class MyVectorDrawable : VectorDrawable() {
+
+}
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/requiresApi/functionLiteral.kt.181 b/idea/testData/android/lintQuickfix/requiresApi/functionLiteral.kt.181
new file mode 100644
index 00000000000..c6016fd4012
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/requiresApi/functionLiteral.kt.181
@@ -0,0 +1,13 @@
+// INTENTION_TEXT: Add @RequiresApi(LOLLIPOP) Annotation
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintNewApiInspection
+// DEPENDENCY: RequiresApi.java -> android/support/annotation/RequiresApi.java
+
+import android.graphics.drawable.VectorDrawable
+
+class VectorDrawableProvider {
+ fun getVectorDrawable(): VectorDrawable {
+ with(this) {
+ return VectorDrawable()
+ }
+ }
+}
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/requiresApi/functionLiteral.kt.expected.181 b/idea/testData/android/lintQuickfix/requiresApi/functionLiteral.kt.expected.181
new file mode 100644
index 00000000000..ff231d64d5a
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/requiresApi/functionLiteral.kt.expected.181
@@ -0,0 +1,16 @@
+// INTENTION_TEXT: Add @RequiresApi(LOLLIPOP) Annotation
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintNewApiInspection
+// DEPENDENCY: RequiresApi.java -> android/support/annotation/RequiresApi.java
+
+import android.graphics.drawable.VectorDrawable
+import android.os.Build
+import android.support.annotation.RequiresApi
+
+class VectorDrawableProvider {
+ @RequiresApi(Build.VERSION_CODES.LOLLIPOP)
+ fun getVectorDrawable(): VectorDrawable {
+ with(this) {
+ return VectorDrawable()
+ }
+ }
+}
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/requiresApi/inlinedConstant.kt.181 b/idea/testData/android/lintQuickfix/requiresApi/inlinedConstant.kt.181
new file mode 100644
index 00000000000..025b3d3d130
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/requiresApi/inlinedConstant.kt.181
@@ -0,0 +1,9 @@
+// INTENTION_TEXT: Add @RequiresApi(KITKAT) Annotation
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintInlinedApiInspection
+// DEPENDENCY: RequiresApi.java -> android/support/annotation/RequiresApi.java
+
+class Test {
+ fun foo(): Int {
+ return android.R.attr.windowTranslucentStatus
+ }
+}
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/requiresApi/inlinedConstant.kt.expected.181 b/idea/testData/android/lintQuickfix/requiresApi/inlinedConstant.kt.expected.181
new file mode 100644
index 00000000000..8151e13fa3d
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/requiresApi/inlinedConstant.kt.expected.181
@@ -0,0 +1,13 @@
+import android.os.Build
+import android.support.annotation.RequiresApi
+
+// INTENTION_TEXT: Add @RequiresApi(KITKAT) Annotation
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintInlinedApiInspection
+// DEPENDENCY: RequiresApi.java -> android/support/annotation/RequiresApi.java
+
+class Test {
+ @RequiresApi(Build.VERSION_CODES.KITKAT)
+ fun foo(): Int {
+ return android.R.attr.windowTranslucentStatus
+ }
+}
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/requiresApi/method.kt.181 b/idea/testData/android/lintQuickfix/requiresApi/method.kt.181
new file mode 100644
index 00000000000..efbd6dcc173
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/requiresApi/method.kt.181
@@ -0,0 +1,11 @@
+// INTENTION_TEXT: Add @RequiresApi(LOLLIPOP) Annotation
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintNewApiInspection
+// DEPENDENCY: RequiresApi.java -> android/support/annotation/RequiresApi.java
+
+import android.graphics.drawable.VectorDrawable
+
+class VectorDrawableProvider {
+ fun getVectorDrawable(): VectorDrawable {
+ return VectorDrawable()
+ }
+}
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/requiresApi/method.kt.expected.181 b/idea/testData/android/lintQuickfix/requiresApi/method.kt.expected.181
new file mode 100644
index 00000000000..3183461bf58
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/requiresApi/method.kt.expected.181
@@ -0,0 +1,14 @@
+// INTENTION_TEXT: Add @RequiresApi(LOLLIPOP) Annotation
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintNewApiInspection
+// DEPENDENCY: RequiresApi.java -> android/support/annotation/RequiresApi.java
+
+import android.graphics.drawable.VectorDrawable
+import android.os.Build
+import android.support.annotation.RequiresApi
+
+class VectorDrawableProvider {
+ @RequiresApi(Build.VERSION_CODES.LOLLIPOP)
+ fun getVectorDrawable(): VectorDrawable {
+ return VectorDrawable()
+ }
+}
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/requiresApi/property.kt.181 b/idea/testData/android/lintQuickfix/requiresApi/property.kt.181
new file mode 100644
index 00000000000..d73223f8c0d
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/requiresApi/property.kt.181
@@ -0,0 +1,9 @@
+// INTENTION_TEXT: Add @RequiresApi(LOLLIPOP) Annotation
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintNewApiInspection
+// DEPENDENCY: RequiresApi.java -> android/support/annotation/RequiresApi.java
+
+import android.graphics.drawable.VectorDrawable
+
+class VectorDrawableProvider {
+ val VECTOR_DRAWABLE = VectorDrawable()
+}
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/requiresApi/property.kt.expected.181 b/idea/testData/android/lintQuickfix/requiresApi/property.kt.expected.181
new file mode 100644
index 00000000000..2da5890a952
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/requiresApi/property.kt.expected.181
@@ -0,0 +1,12 @@
+// INTENTION_TEXT: Add @RequiresApi(LOLLIPOP) Annotation
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintNewApiInspection
+// DEPENDENCY: RequiresApi.java -> android/support/annotation/RequiresApi.java
+
+import android.graphics.drawable.VectorDrawable
+import android.os.Build
+import android.support.annotation.RequiresApi
+
+class VectorDrawableProvider {
+ @RequiresApi(Build.VERSION_CODES.LOLLIPOP)
+ val VECTOR_DRAWABLE = VectorDrawable()
+}
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/requiresApi/topLevelProperty.kt.181 b/idea/testData/android/lintQuickfix/requiresApi/topLevelProperty.kt.181
new file mode 100644
index 00000000000..7e7564b542c
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/requiresApi/topLevelProperty.kt.181
@@ -0,0 +1,7 @@
+// INTENTION_TEXT: Add @RequiresApi(M) Annotation
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintNewApiInspection
+// DEPENDENCY: RequiresApi.java -> android/support/annotation/RequiresApi.java
+import android.app.Activity
+
+val top: Int
+ get() = Activity().checkSelfPermission(READ_CONTACTS)
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/requiresApi/topLevelProperty.kt.expected.181 b/idea/testData/android/lintQuickfix/requiresApi/topLevelProperty.kt.expected.181
new file mode 100644
index 00000000000..01d63d7c860
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/requiresApi/topLevelProperty.kt.expected.181
@@ -0,0 +1,10 @@
+// INTENTION_TEXT: Add @RequiresApi(M) Annotation
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintNewApiInspection
+// DEPENDENCY: RequiresApi.java -> android/support/annotation/RequiresApi.java
+import android.app.Activity
+import android.os.Build
+import android.support.annotation.RequiresApi
+
+val top: Int
+ @RequiresApi(Build.VERSION_CODES.M)
+ get() = Activity().checkSelfPermission(READ_CONTACTS)
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/requiresApi/when.kt.181 b/idea/testData/android/lintQuickfix/requiresApi/when.kt.181
new file mode 100644
index 00000000000..0ff7c0cc893
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/requiresApi/when.kt.181
@@ -0,0 +1,15 @@
+// INTENTION_TEXT: Add @RequiresApi(LOLLIPOP) Annotation
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintNewApiInspection
+// DEPENDENCY: RequiresApi.java -> android/support/annotation/RequiresApi.java
+
+import android.graphics.drawable.VectorDrawable
+
+class VectorDrawableProvider {
+ val flag = false
+ fun getVectorDrawable(): VectorDrawable {
+ return when (flag) {
+ true -> VectorDrawable()
+ else -> VectorDrawable()
+ }
+ }
+}
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/requiresApi/when.kt.expected.181 b/idea/testData/android/lintQuickfix/requiresApi/when.kt.expected.181
new file mode 100644
index 00000000000..ce78fc0c8fe
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/requiresApi/when.kt.expected.181
@@ -0,0 +1,18 @@
+// INTENTION_TEXT: Add @RequiresApi(LOLLIPOP) Annotation
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintNewApiInspection
+// DEPENDENCY: RequiresApi.java -> android/support/annotation/RequiresApi.java
+
+import android.graphics.drawable.VectorDrawable
+import android.os.Build
+import android.support.annotation.RequiresApi
+
+class VectorDrawableProvider {
+ val flag = false
+ @RequiresApi(Build.VERSION_CODES.LOLLIPOP)
+ fun getVectorDrawable(): VectorDrawable {
+ return when (flag) {
+ true -> VectorDrawable()
+ else -> VectorDrawable()
+ }
+ }
+}
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/suppressLint/activityMethod.kt.181 b/idea/testData/android/lintQuickfix/suppressLint/activityMethod.kt.181
new file mode 100644
index 00000000000..02d9669b194
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/suppressLint/activityMethod.kt.181
@@ -0,0 +1,10 @@
+// INTENTION_TEXT: Suppress: Add @SuppressLint("SdCardPath") annotation
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintSdCardPathInspection
+
+import android.app.Activity
+import android.os.Environment
+
+
+class MainActivity : Activity() {
+ fun getSdCard(fromEnvironment: Boolean) = if (fromEnvironment) Environment.getExternalStorageDirectory().path else "/sdcard"
+}
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/suppressLint/activityMethod.kt.expected.181 b/idea/testData/android/lintQuickfix/suppressLint/activityMethod.kt.expected.181
new file mode 100644
index 00000000000..e95b0a1980b
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/suppressLint/activityMethod.kt.expected.181
@@ -0,0 +1,12 @@
+// INTENTION_TEXT: Suppress: Add @SuppressLint("SdCardPath") annotation
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintSdCardPathInspection
+
+import android.annotation.SuppressLint
+import android.app.Activity
+import android.os.Environment
+
+
+class MainActivity : Activity() {
+ @SuppressLint("SdCardPath")
+ fun getSdCard(fromEnvironment: Boolean) = if (fromEnvironment) Environment.getExternalStorageDirectory().path else "/sdcard"
+}
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/suppressLint/addToExistingAnnotation.kt.181 b/idea/testData/android/lintQuickfix/suppressLint/addToExistingAnnotation.kt.181
new file mode 100644
index 00000000000..26adf3d65c7
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/suppressLint/addToExistingAnnotation.kt.181
@@ -0,0 +1,12 @@
+// INTENTION_TEXT: Suppress: Add @SuppressLint("SdCardPath") annotation
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintSdCardPathInspection
+
+import android.annotation.SuppressLint
+import android.app.Activity
+import android.os.Environment
+
+
+class MainActivity : Activity() {
+ @SuppressLint("Something")
+ fun getSdCard(fromEnvironment: Boolean) = if (fromEnvironment) Environment.getExternalStorageDirectory().path else "/sdcard"
+}
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/suppressLint/addToExistingAnnotation.kt.expected.181 b/idea/testData/android/lintQuickfix/suppressLint/addToExistingAnnotation.kt.expected.181
new file mode 100644
index 00000000000..45d7bb0130b
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/suppressLint/addToExistingAnnotation.kt.expected.181
@@ -0,0 +1,12 @@
+// INTENTION_TEXT: Suppress: Add @SuppressLint("SdCardPath") annotation
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintSdCardPathInspection
+
+import android.annotation.SuppressLint
+import android.app.Activity
+import android.os.Environment
+
+
+class MainActivity : Activity() {
+ @SuppressLint("Something", "SdCardPath")
+ fun getSdCard(fromEnvironment: Boolean) = if (fromEnvironment) Environment.getExternalStorageDirectory().path else "/sdcard"
+}
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/suppressLint/constructorParameter.kt.181 b/idea/testData/android/lintQuickfix/suppressLint/constructorParameter.kt.181
new file mode 100644
index 00000000000..1d325d1db70
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/suppressLint/constructorParameter.kt.181
@@ -0,0 +1,4 @@
+// INTENTION_TEXT: Suppress: Add @SuppressLint("SdCardPath") annotation
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintSdCardPathInspection
+
+class SdCard(val path: String = "/sdcard")
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/suppressLint/constructorParameter.kt.expected.181 b/idea/testData/android/lintQuickfix/suppressLint/constructorParameter.kt.expected.181
new file mode 100644
index 00000000000..8b730ed0777
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/suppressLint/constructorParameter.kt.expected.181
@@ -0,0 +1,6 @@
+import android.annotation.SuppressLint
+
+// INTENTION_TEXT: Suppress: Add @SuppressLint("SdCardPath") annotation
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintSdCardPathInspection
+
+class SdCard(@SuppressLint("SdCardPath") val path: String = "/sdcard")
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/suppressLint/destructuringDeclaration.kt.181 b/idea/testData/android/lintQuickfix/suppressLint/destructuringDeclaration.kt.181
new file mode 100644
index 00000000000..6d8e858b66b
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/suppressLint/destructuringDeclaration.kt.181
@@ -0,0 +1,9 @@
+// INTENTION_TEXT: Suppress: Add @SuppressLint("SdCardPath") annotation
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintSdCardPathInspection
+
+fun foo() {
+ val (a: String, b: String) = "/sdcard"
+}
+
+operator fun CharSequence.component1(): String = "component1"
+operator fun CharSequence.component2(): String = "component2"
diff --git a/idea/testData/android/lintQuickfix/suppressLint/destructuringDeclaration.kt.expected.181 b/idea/testData/android/lintQuickfix/suppressLint/destructuringDeclaration.kt.expected.181
new file mode 100644
index 00000000000..7022cdfb459
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/suppressLint/destructuringDeclaration.kt.expected.181
@@ -0,0 +1,12 @@
+import android.annotation.SuppressLint
+
+// INTENTION_TEXT: Suppress: Add @SuppressLint("SdCardPath") annotation
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintSdCardPathInspection
+
+@SuppressLint("SdCardPath")
+fun foo() {
+ val (a: String, b: String) = "/sdcard"
+}
+
+operator fun CharSequence.component1(): String = "component1"
+operator fun CharSequence.component2(): String = "component2"
diff --git a/idea/testData/android/lintQuickfix/suppressLint/lambdaArgument.kt.181 b/idea/testData/android/lintQuickfix/suppressLint/lambdaArgument.kt.181
new file mode 100644
index 00000000000..9da3c3d1779
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/suppressLint/lambdaArgument.kt.181
@@ -0,0 +1,10 @@
+// INTENTION_TEXT: Suppress: Add @SuppressLint("SdCardPath") annotation
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintSdCardPathInspection
+
+fun foo(l: Any) = l
+
+fun bar() {
+ foo() {
+ "/sdcard"
+ }
+}
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/suppressLint/lambdaArgument.kt.expected.181 b/idea/testData/android/lintQuickfix/suppressLint/lambdaArgument.kt.expected.181
new file mode 100644
index 00000000000..db344edeea7
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/suppressLint/lambdaArgument.kt.expected.181
@@ -0,0 +1,13 @@
+import android.annotation.SuppressLint
+
+// INTENTION_TEXT: Suppress: Add @SuppressLint("SdCardPath") annotation
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintSdCardPathInspection
+
+fun foo(l: Any) = l
+
+@SuppressLint("SdCardPath")
+fun bar() {
+ foo() {
+ "/sdcard"
+ }
+}
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/suppressLint/lambdaArgumentProperty.kt.181 b/idea/testData/android/lintQuickfix/suppressLint/lambdaArgumentProperty.kt.181
new file mode 100644
index 00000000000..25de06b3bb6
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/suppressLint/lambdaArgumentProperty.kt.181
@@ -0,0 +1,6 @@
+// INTENTION_TEXT: Suppress: Add @SuppressLint("SdCardPath") annotation
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintSdCardPathInspection
+
+fun foo(l: Any) = l
+
+val bar = foo() { "/sdcard" }
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/suppressLint/lambdaArgumentProperty.kt.expected.181 b/idea/testData/android/lintQuickfix/suppressLint/lambdaArgumentProperty.kt.expected.181
new file mode 100644
index 00000000000..617e6b33731
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/suppressLint/lambdaArgumentProperty.kt.expected.181
@@ -0,0 +1,9 @@
+import android.annotation.SuppressLint
+
+// INTENTION_TEXT: Suppress: Add @SuppressLint("SdCardPath") annotation
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintSdCardPathInspection
+
+fun foo(l: Any) = l
+
+@SuppressLint("SdCardPath")
+val bar = foo() { "/sdcard" }
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/suppressLint/methodParameter.kt.181 b/idea/testData/android/lintQuickfix/suppressLint/methodParameter.kt.181
new file mode 100644
index 00000000000..9abdb51fd35
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/suppressLint/methodParameter.kt.181
@@ -0,0 +1,4 @@
+// INTENTION_TEXT: Suppress: Add @SuppressLint("SdCardPath") annotation
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintSdCardPathInspection
+
+fun foo(path: String = "/sdcard") = path
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/suppressLint/methodParameter.kt.expected.181 b/idea/testData/android/lintQuickfix/suppressLint/methodParameter.kt.expected.181
new file mode 100644
index 00000000000..99c23d0552e
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/suppressLint/methodParameter.kt.expected.181
@@ -0,0 +1,6 @@
+import android.annotation.SuppressLint
+
+// INTENTION_TEXT: Suppress: Add @SuppressLint("SdCardPath") annotation
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintSdCardPathInspection
+
+fun foo(@SuppressLint("SdCardPath") path: String = "/sdcard") = path
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/suppressLint/propertyWithLambda.kt.181 b/idea/testData/android/lintQuickfix/suppressLint/propertyWithLambda.kt.181
new file mode 100644
index 00000000000..b8f5cdf95e0
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/suppressLint/propertyWithLambda.kt.181
@@ -0,0 +1,4 @@
+// INTENTION_TEXT: Suppress: Add @SuppressLint("SdCardPath") annotation
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintSdCardPathInspection
+
+val getPath = { "/sdcard" }
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/suppressLint/propertyWithLambda.kt.expected.181 b/idea/testData/android/lintQuickfix/suppressLint/propertyWithLambda.kt.expected.181
new file mode 100644
index 00000000000..8f4ef7d5ea3
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/suppressLint/propertyWithLambda.kt.expected.181
@@ -0,0 +1,7 @@
+import android.annotation.SuppressLint
+
+// INTENTION_TEXT: Suppress: Add @SuppressLint("SdCardPath") annotation
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintSdCardPathInspection
+
+@SuppressLint("SdCardPath")
+val getPath = { "/sdcard" }
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/suppressLint/simpleProperty.kt.181 b/idea/testData/android/lintQuickfix/suppressLint/simpleProperty.kt.181
new file mode 100644
index 00000000000..335913d069c
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/suppressLint/simpleProperty.kt.181
@@ -0,0 +1,4 @@
+// INTENTION_TEXT: Suppress: Add @SuppressLint("SdCardPath") annotation
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintSdCardPathInspection
+
+val path = "/sdcard"
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/suppressLint/simpleProperty.kt.expected.181 b/idea/testData/android/lintQuickfix/suppressLint/simpleProperty.kt.expected.181
new file mode 100644
index 00000000000..9fc27e6b7dc
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/suppressLint/simpleProperty.kt.expected.181
@@ -0,0 +1,7 @@
+import android.annotation.SuppressLint
+
+// INTENTION_TEXT: Suppress: Add @SuppressLint("SdCardPath") annotation
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintSdCardPathInspection
+
+@SuppressLint("SdCardPath")
+val path = "/sdcard"
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/targetApi/annotation.kt.181 b/idea/testData/android/lintQuickfix/targetApi/annotation.kt.181
new file mode 100644
index 00000000000..e9431202f81
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/targetApi/annotation.kt.181
@@ -0,0 +1,11 @@
+// INTENTION_TEXT: Add @TargetApi(LOLLIPOP) Annotation
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintNewApiInspection
+
+import android.graphics.drawable.VectorDrawable
+import kotlin.reflect.KClass
+
+annotation class SomeAnnotationWithClass(val cls: KClass<*>)
+
+@SomeAnnotationWithClass(VectorDrawable::class)
+class VectorDrawableProvider {
+}
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/targetApi/annotation.kt.expected.181 b/idea/testData/android/lintQuickfix/targetApi/annotation.kt.expected.181
new file mode 100644
index 00000000000..0a51e121500
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/targetApi/annotation.kt.expected.181
@@ -0,0 +1,14 @@
+// INTENTION_TEXT: Add @TargetApi(LOLLIPOP) Annotation
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintNewApiInspection
+
+import android.annotation.TargetApi
+import android.graphics.drawable.VectorDrawable
+import android.os.Build
+import kotlin.reflect.KClass
+
+annotation class SomeAnnotationWithClass(val cls: KClass<*>)
+
+@TargetApi(Build.VERSION_CODES.LOLLIPOP)
+@SomeAnnotationWithClass(VectorDrawable::class)
+class VectorDrawableProvider {
+}
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/targetApi/companion.kt.181 b/idea/testData/android/lintQuickfix/targetApi/companion.kt.181
new file mode 100644
index 00000000000..d0dd43774c8
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/targetApi/companion.kt.181
@@ -0,0 +1,10 @@
+// INTENTION_TEXT: Add @TargetApi(LOLLIPOP) Annotation
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintNewApiInspection
+
+import android.graphics.drawable.VectorDrawable
+
+class VectorDrawableProvider {
+ companion object {
+ val VECTOR_DRAWABLE = VectorDrawable()
+ }
+}
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/targetApi/companion.kt.expected.181 b/idea/testData/android/lintQuickfix/targetApi/companion.kt.expected.181
new file mode 100644
index 00000000000..ae413f19a2a
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/targetApi/companion.kt.expected.181
@@ -0,0 +1,13 @@
+// INTENTION_TEXT: Add @TargetApi(LOLLIPOP) Annotation
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintNewApiInspection
+
+import android.annotation.TargetApi
+import android.graphics.drawable.VectorDrawable
+import android.os.Build
+
+class VectorDrawableProvider {
+ @TargetApi(Build.VERSION_CODES.LOLLIPOP)
+ companion object {
+ val VECTOR_DRAWABLE = VectorDrawable()
+ }
+}
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/targetApi/defaultParameter.kt.181 b/idea/testData/android/lintQuickfix/targetApi/defaultParameter.kt.181
new file mode 100644
index 00000000000..441ac662838
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/targetApi/defaultParameter.kt.181
@@ -0,0 +1,9 @@
+// INTENTION_TEXT: Add @TargetApi(LOLLIPOP) Annotation
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintNewApiInspection
+
+import android.graphics.drawable.VectorDrawable
+
+
+fun withDefaultParameter(vector: VectorDrawable = VectorDrawable()) {
+
+}
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/targetApi/defaultParameter.kt.expected.181 b/idea/testData/android/lintQuickfix/targetApi/defaultParameter.kt.expected.181
new file mode 100644
index 00000000000..4a7ffec0d23
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/targetApi/defaultParameter.kt.expected.181
@@ -0,0 +1,12 @@
+// INTENTION_TEXT: Add @TargetApi(LOLLIPOP) Annotation
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintNewApiInspection
+
+import android.annotation.TargetApi
+import android.graphics.drawable.VectorDrawable
+import android.os.Build
+
+
+@TargetApi(Build.VERSION_CODES.LOLLIPOP)
+fun withDefaultParameter(vector: VectorDrawable = VectorDrawable()) {
+
+}
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/targetApi/extend.kt.181 b/idea/testData/android/lintQuickfix/targetApi/extend.kt.181
new file mode 100644
index 00000000000..8e49ae1bd73
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/targetApi/extend.kt.181
@@ -0,0 +1,8 @@
+// INTENTION_TEXT: Add @TargetApi(LOLLIPOP) Annotation
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintNewApiInspection
+
+import android.graphics.drawable.VectorDrawable
+
+class MyVectorDrawable : VectorDrawable() {
+
+}
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/targetApi/extend.kt.expected.181 b/idea/testData/android/lintQuickfix/targetApi/extend.kt.expected.181
new file mode 100644
index 00000000000..7a1cd362baa
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/targetApi/extend.kt.expected.181
@@ -0,0 +1,11 @@
+// INTENTION_TEXT: Add @TargetApi(LOLLIPOP) Annotation
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintNewApiInspection
+
+import android.annotation.TargetApi
+import android.graphics.drawable.VectorDrawable
+import android.os.Build
+
+@TargetApi(Build.VERSION_CODES.LOLLIPOP)
+class MyVectorDrawable : VectorDrawable() {
+
+}
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/targetApi/functionLiteral.kt.181 b/idea/testData/android/lintQuickfix/targetApi/functionLiteral.kt.181
new file mode 100644
index 00000000000..321913b70a9
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/targetApi/functionLiteral.kt.181
@@ -0,0 +1,12 @@
+// INTENTION_TEXT: Add @TargetApi(LOLLIPOP) Annotation
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintNewApiInspection
+
+import android.graphics.drawable.VectorDrawable
+
+class VectorDrawableProvider {
+ fun getVectorDrawable(): VectorDrawable {
+ with(this) {
+ return VectorDrawable()
+ }
+ }
+}
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/targetApi/functionLiteral.kt.expected.181 b/idea/testData/android/lintQuickfix/targetApi/functionLiteral.kt.expected.181
new file mode 100644
index 00000000000..b99ca947fb6
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/targetApi/functionLiteral.kt.expected.181
@@ -0,0 +1,15 @@
+// INTENTION_TEXT: Add @TargetApi(LOLLIPOP) Annotation
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintNewApiInspection
+
+import android.annotation.TargetApi
+import android.graphics.drawable.VectorDrawable
+import android.os.Build
+
+class VectorDrawableProvider {
+ @TargetApi(Build.VERSION_CODES.LOLLIPOP)
+ fun getVectorDrawable(): VectorDrawable {
+ with(this) {
+ return VectorDrawable()
+ }
+ }
+}
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/targetApi/inlinedConstant.kt.181 b/idea/testData/android/lintQuickfix/targetApi/inlinedConstant.kt.181
new file mode 100644
index 00000000000..8b233964e07
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/targetApi/inlinedConstant.kt.181
@@ -0,0 +1,8 @@
+// INTENTION_TEXT: Add @TargetApi(KITKAT) Annotation
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintInlinedApiInspection
+
+class Test {
+ fun foo(): Int {
+ return android.R.attr.windowTranslucentStatus
+ }
+}
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/targetApi/inlinedConstant.kt.expected.181 b/idea/testData/android/lintQuickfix/targetApi/inlinedConstant.kt.expected.181
new file mode 100644
index 00000000000..84d86bc3776
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/targetApi/inlinedConstant.kt.expected.181
@@ -0,0 +1,12 @@
+import android.annotation.TargetApi
+import android.os.Build
+
+// INTENTION_TEXT: Add @TargetApi(KITKAT) Annotation
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintInlinedApiInspection
+
+class Test {
+ @TargetApi(Build.VERSION_CODES.KITKAT)
+ fun foo(): Int {
+ return android.R.attr.windowTranslucentStatus
+ }
+}
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/targetApi/method.kt.181 b/idea/testData/android/lintQuickfix/targetApi/method.kt.181
new file mode 100644
index 00000000000..89acdda7b32
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/targetApi/method.kt.181
@@ -0,0 +1,10 @@
+// INTENTION_TEXT: Add @TargetApi(LOLLIPOP) Annotation
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintNewApiInspection
+
+import android.graphics.drawable.VectorDrawable
+
+class VectorDrawableProvider {
+ fun getVectorDrawable(): VectorDrawable {
+ return VectorDrawable()
+ }
+}
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/targetApi/method.kt.expected.181 b/idea/testData/android/lintQuickfix/targetApi/method.kt.expected.181
new file mode 100644
index 00000000000..7f10d4b9893
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/targetApi/method.kt.expected.181
@@ -0,0 +1,13 @@
+// INTENTION_TEXT: Add @TargetApi(LOLLIPOP) Annotation
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintNewApiInspection
+
+import android.annotation.TargetApi
+import android.graphics.drawable.VectorDrawable
+import android.os.Build
+
+class VectorDrawableProvider {
+ @TargetApi(Build.VERSION_CODES.LOLLIPOP)
+ fun getVectorDrawable(): VectorDrawable {
+ return VectorDrawable()
+ }
+}
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/targetApi/property.kt.181 b/idea/testData/android/lintQuickfix/targetApi/property.kt.181
new file mode 100644
index 00000000000..2b2077c72bf
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/targetApi/property.kt.181
@@ -0,0 +1,8 @@
+// INTENTION_TEXT: Add @TargetApi(LOLLIPOP) Annotation
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintNewApiInspection
+
+import android.graphics.drawable.VectorDrawable
+
+class VectorDrawableProvider {
+ val VECTOR_DRAWABLE = VectorDrawable()
+}
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/targetApi/property.kt.expected.181 b/idea/testData/android/lintQuickfix/targetApi/property.kt.expected.181
new file mode 100644
index 00000000000..2103b804754
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/targetApi/property.kt.expected.181
@@ -0,0 +1,11 @@
+// INTENTION_TEXT: Add @TargetApi(LOLLIPOP) Annotation
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintNewApiInspection
+
+import android.annotation.TargetApi
+import android.graphics.drawable.VectorDrawable
+import android.os.Build
+
+@TargetApi(Build.VERSION_CODES.LOLLIPOP)
+class VectorDrawableProvider {
+ val VECTOR_DRAWABLE = VectorDrawable()
+}
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/targetApi/topLevelProperty.kt.181 b/idea/testData/android/lintQuickfix/targetApi/topLevelProperty.kt.181
new file mode 100644
index 00000000000..1997b7fc223
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/targetApi/topLevelProperty.kt.181
@@ -0,0 +1,6 @@
+// INTENTION_TEXT: Add @TargetApi(M) Annotation
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintNewApiInspection
+import android.app.Activity
+
+val top: Int
+ get() = Activity().checkSelfPermission(READ_CONTACTS)
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/targetApi/topLevelProperty.kt.expected.181 b/idea/testData/android/lintQuickfix/targetApi/topLevelProperty.kt.expected.181
new file mode 100644
index 00000000000..ce8347f83f9
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/targetApi/topLevelProperty.kt.expected.181
@@ -0,0 +1,9 @@
+// INTENTION_TEXT: Add @TargetApi(M) Annotation
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintNewApiInspection
+import android.annotation.TargetApi
+import android.app.Activity
+import android.os.Build
+
+val top: Int
+ @TargetApi(Build.VERSION_CODES.M)
+ get() = Activity().checkSelfPermission(READ_CONTACTS)
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/targetApi/when.kt.181 b/idea/testData/android/lintQuickfix/targetApi/when.kt.181
new file mode 100644
index 00000000000..b5a33d8e356
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/targetApi/when.kt.181
@@ -0,0 +1,14 @@
+// INTENTION_TEXT: Add @TargetApi(LOLLIPOP) Annotation
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintNewApiInspection
+
+import android.graphics.drawable.VectorDrawable
+
+class VectorDrawableProvider {
+ val flag = false
+ fun getVectorDrawable(): VectorDrawable {
+ return when (flag) {
+ true -> VectorDrawable()
+ else -> VectorDrawable()
+ }
+ }
+}
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/targetApi/when.kt.expected.181 b/idea/testData/android/lintQuickfix/targetApi/when.kt.expected.181
new file mode 100644
index 00000000000..275e59c2bbe
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/targetApi/when.kt.expected.181
@@ -0,0 +1,17 @@
+// INTENTION_TEXT: Add @TargetApi(LOLLIPOP) Annotation
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintNewApiInspection
+
+import android.annotation.TargetApi
+import android.graphics.drawable.VectorDrawable
+import android.os.Build
+
+class VectorDrawableProvider {
+ val flag = false
+ @TargetApi(Build.VERSION_CODES.LOLLIPOP)
+ fun getVectorDrawable(): VectorDrawable {
+ return when (flag) {
+ true -> VectorDrawable()
+ else -> VectorDrawable()
+ }
+ }
+}
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/targetVersionCheck/annotation.kt.181 b/idea/testData/android/lintQuickfix/targetVersionCheck/annotation.kt.181
new file mode 100644
index 00000000000..ff3f7cbec75
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/targetVersionCheck/annotation.kt.181
@@ -0,0 +1,12 @@
+// INTENTION_TEXT: Surround with if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) { ... }
+// INTENTION_NOT_AVAILABLE
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintNewApiInspection
+
+import android.graphics.drawable.VectorDrawable
+import kotlin.reflect.KClass
+
+annotation class SomeAnnotationWithClass(val cls: KClass<*>)
+
+@SomeAnnotationWithClass(VectorDrawable::class)
+class VectorDrawableProvider {
+}
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/targetVersionCheck/defaultParameter.kt.181 b/idea/testData/android/lintQuickfix/targetVersionCheck/defaultParameter.kt.181
new file mode 100644
index 00000000000..6169b9947a8
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/targetVersionCheck/defaultParameter.kt.181
@@ -0,0 +1,10 @@
+// INTENTION_TEXT: Surround with if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) { ... }
+// INTENTION_NOT_AVAILABLE
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintNewApiInspection
+
+import android.graphics.drawable.VectorDrawable
+
+
+fun withDefaultParameter(vector: VectorDrawable = VectorDrawable()) {
+
+}
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/targetVersionCheck/destructuringDeclaration.kt.181 b/idea/testData/android/lintQuickfix/targetVersionCheck/destructuringDeclaration.kt.181
new file mode 100644
index 00000000000..ec9f278cf18
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/targetVersionCheck/destructuringDeclaration.kt.181
@@ -0,0 +1,12 @@
+// INTENTION_TEXT: Surround with if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) { ... }
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintNewApiInspection
+
+import android.app.Activity
+import android.graphics.drawable.VectorDrawable
+
+data class ValueProvider(var p1: VectorDrawable, val p2: Int)
+
+val activity = Activity()
+fun foo() {
+ val (v1, v2) = ValueProvider(VectorDrawable(), 0)
+}
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/targetVersionCheck/destructuringDeclaration.kt.expected.181 b/idea/testData/android/lintQuickfix/targetVersionCheck/destructuringDeclaration.kt.expected.181
new file mode 100644
index 00000000000..23ea52ab746
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/targetVersionCheck/destructuringDeclaration.kt.expected.181
@@ -0,0 +1,17 @@
+// INTENTION_TEXT: Surround with if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) { ... }
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintNewApiInspection
+
+import android.app.Activity
+import android.graphics.drawable.VectorDrawable
+import android.os.Build
+
+data class ValueProvider(var p1: VectorDrawable, val p2: Int)
+
+val activity = Activity()
+fun foo() {
+ val (v1, v2) = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+ ValueProvider(VectorDrawable(), 0)
+ } else {
+ TODO("VERSION.SDK_INT < LOLLIPOP")
+ }
+}
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/targetVersionCheck/expressionBody.kt.181 b/idea/testData/android/lintQuickfix/targetVersionCheck/expressionBody.kt.181
new file mode 100644
index 00000000000..e3b7139ae3c
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/targetVersionCheck/expressionBody.kt.181
@@ -0,0 +1,8 @@
+// INTENTION_TEXT: Surround with if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) { ... }
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintNewApiInspection
+
+import android.graphics.drawable.VectorDrawable
+
+class VectorDrawableProvider {
+ fun getVectorDrawable(): VectorDrawable = VectorDrawable()
+}
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/targetVersionCheck/expressionBody.kt.expected.181 b/idea/testData/android/lintQuickfix/targetVersionCheck/expressionBody.kt.expected.181
new file mode 100644
index 00000000000..4dfc08cfb66
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/targetVersionCheck/expressionBody.kt.expected.181
@@ -0,0 +1,13 @@
+// INTENTION_TEXT: Surround with if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) { ... }
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintNewApiInspection
+
+import android.graphics.drawable.VectorDrawable
+import android.os.Build
+
+class VectorDrawableProvider {
+ fun getVectorDrawable(): VectorDrawable = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+ VectorDrawable()
+ } else {
+ TODO("VERSION.SDK_INT < LOLLIPOP")
+ }
+}
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/targetVersionCheck/functionLiteral.kt.181 b/idea/testData/android/lintQuickfix/targetVersionCheck/functionLiteral.kt.181
new file mode 100644
index 00000000000..403f79dd79a
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/targetVersionCheck/functionLiteral.kt.181
@@ -0,0 +1,12 @@
+// INTENTION_TEXT: Surround with if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) { ... }
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintNewApiInspection
+
+import android.graphics.drawable.VectorDrawable
+
+class VectorDrawableProvider {
+ fun getVectorDrawable(): VectorDrawable {
+ with(this) {
+ return VectorDrawable()
+ }
+ }
+}
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/targetVersionCheck/functionLiteral.kt.expected.181 b/idea/testData/android/lintQuickfix/targetVersionCheck/functionLiteral.kt.expected.181
new file mode 100644
index 00000000000..09a525dbc6b
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/targetVersionCheck/functionLiteral.kt.expected.181
@@ -0,0 +1,17 @@
+// INTENTION_TEXT: Surround with if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) { ... }
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintNewApiInspection
+
+import android.graphics.drawable.VectorDrawable
+import android.os.Build
+
+class VectorDrawableProvider {
+ fun getVectorDrawable(): VectorDrawable {
+ with(this) {
+ return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+ VectorDrawable()
+ } else {
+ TODO("VERSION.SDK_INT < LOLLIPOP")
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/targetVersionCheck/getterWIthExpressionBody.kt.181 b/idea/testData/android/lintQuickfix/targetVersionCheck/getterWIthExpressionBody.kt.181
new file mode 100644
index 00000000000..7ba6b98af31
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/targetVersionCheck/getterWIthExpressionBody.kt.181
@@ -0,0 +1,7 @@
+// INTENTION_TEXT: Surround with if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) { ... }
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintNewApiInspection
+
+import android.graphics.drawable.VectorDrawable
+
+val v: VectorDrawable
+ get() = VectorDrawable()
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/targetVersionCheck/getterWIthExpressionBody.kt.expected.181 b/idea/testData/android/lintQuickfix/targetVersionCheck/getterWIthExpressionBody.kt.expected.181
new file mode 100644
index 00000000000..ed06e869036
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/targetVersionCheck/getterWIthExpressionBody.kt.expected.181
@@ -0,0 +1,12 @@
+// INTENTION_TEXT: Surround with if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) { ... }
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintNewApiInspection
+
+import android.graphics.drawable.VectorDrawable
+import android.os.Build
+
+val v: VectorDrawable
+ get() = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+ VectorDrawable()
+ } else {
+ TODO("VERSION.SDK_INT < LOLLIPOP")
+ }
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/targetVersionCheck/if.kt.181 b/idea/testData/android/lintQuickfix/targetVersionCheck/if.kt.181
new file mode 100644
index 00000000000..e0224b675e4
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/targetVersionCheck/if.kt.181
@@ -0,0 +1,12 @@
+// INTENTION_TEXT: Surround with if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) { ... }
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintNewApiInspection
+
+import android.graphics.drawable.VectorDrawable
+
+class VectorDrawableProvider {
+ val flag = false
+ fun getVectorDrawable(): VectorDrawable {
+ if (flag)
+ return VectorDrawable()
+ }
+}
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/targetVersionCheck/if.kt.expected.181 b/idea/testData/android/lintQuickfix/targetVersionCheck/if.kt.expected.181
new file mode 100644
index 00000000000..be38a41256b
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/targetVersionCheck/if.kt.expected.181
@@ -0,0 +1,17 @@
+// INTENTION_TEXT: Surround with if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) { ... }
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintNewApiInspection
+
+import android.graphics.drawable.VectorDrawable
+import android.os.Build
+
+class VectorDrawableProvider {
+ val flag = false
+ fun getVectorDrawable(): VectorDrawable {
+ if (flag)
+ return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+ VectorDrawable()
+ } else {
+ TODO("VERSION.SDK_INT < LOLLIPOP")
+ }
+ }
+}
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/targetVersionCheck/ifWithBlock.kt.181 b/idea/testData/android/lintQuickfix/targetVersionCheck/ifWithBlock.kt.181
new file mode 100644
index 00000000000..e2f2a4f0ac1
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/targetVersionCheck/ifWithBlock.kt.181
@@ -0,0 +1,13 @@
+// INTENTION_TEXT: Surround with if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) { ... }
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintNewApiInspection
+
+import android.graphics.drawable.VectorDrawable
+
+class VectorDrawableProvider {
+ val flag = false
+ fun getVectorDrawable(): VectorDrawable {
+ if (flag) {
+ return VectorDrawable()
+ }
+ }
+}
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/targetVersionCheck/ifWithBlock.kt.expected.181 b/idea/testData/android/lintQuickfix/targetVersionCheck/ifWithBlock.kt.expected.181
new file mode 100644
index 00000000000..bda925fbbf2
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/targetVersionCheck/ifWithBlock.kt.expected.181
@@ -0,0 +1,18 @@
+// INTENTION_TEXT: Surround with if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) { ... }
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintNewApiInspection
+
+import android.graphics.drawable.VectorDrawable
+import android.os.Build
+
+class VectorDrawableProvider {
+ val flag = false
+ fun getVectorDrawable(): VectorDrawable {
+ if (flag) {
+ return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+ VectorDrawable()
+ } else {
+ TODO("VERSION.SDK_INT < LOLLIPOP")
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/targetVersionCheck/inlinedConstant.kt.181 b/idea/testData/android/lintQuickfix/targetVersionCheck/inlinedConstant.kt.181
new file mode 100644
index 00000000000..9c9bf6d37a7
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/targetVersionCheck/inlinedConstant.kt.181
@@ -0,0 +1,8 @@
+// INTENTION_TEXT: Surround with if (VERSION.SDK_INT >= VERSION_CODES.KITKAT) { ... }
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintInlinedApiInspection
+
+class Test {
+ fun foo(): Int {
+ return android.R.attr.windowTranslucentStatus
+ }
+}
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/targetVersionCheck/inlinedConstant.kt.expected.181 b/idea/testData/android/lintQuickfix/targetVersionCheck/inlinedConstant.kt.expected.181
new file mode 100644
index 00000000000..b4d5931c5c8
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/targetVersionCheck/inlinedConstant.kt.expected.181
@@ -0,0 +1,14 @@
+import android.os.Build
+
+// INTENTION_TEXT: Surround with if (VERSION.SDK_INT >= VERSION_CODES.KITKAT) { ... }
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintInlinedApiInspection
+
+class Test {
+ fun foo(): Int {
+ return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
+ android.R.attr.windowTranslucentStatus
+ } else {
+ TODO("VERSION.SDK_INT < KITKAT")
+ }
+ }
+}
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/targetVersionCheck/method.kt.181 b/idea/testData/android/lintQuickfix/targetVersionCheck/method.kt.181
new file mode 100644
index 00000000000..49ac9188e6b
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/targetVersionCheck/method.kt.181
@@ -0,0 +1,10 @@
+// INTENTION_TEXT: Surround with if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) { ... }
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintNewApiInspection
+
+import android.graphics.drawable.VectorDrawable
+
+class VectorDrawableProvider {
+ fun getVectorDrawable(): VectorDrawable {
+ return VectorDrawable()
+ }
+}
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/targetVersionCheck/method.kt.expected.181 b/idea/testData/android/lintQuickfix/targetVersionCheck/method.kt.expected.181
new file mode 100644
index 00000000000..531645ed71c
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/targetVersionCheck/method.kt.expected.181
@@ -0,0 +1,15 @@
+// INTENTION_TEXT: Surround with if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) { ... }
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintNewApiInspection
+
+import android.graphics.drawable.VectorDrawable
+import android.os.Build
+
+class VectorDrawableProvider {
+ fun getVectorDrawable(): VectorDrawable {
+ return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+ VectorDrawable()
+ } else {
+ TODO("VERSION.SDK_INT < LOLLIPOP")
+ }
+ }
+}
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/targetVersionCheck/when.kt.181 b/idea/testData/android/lintQuickfix/targetVersionCheck/when.kt.181
new file mode 100644
index 00000000000..b12f04272fc
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/targetVersionCheck/when.kt.181
@@ -0,0 +1,14 @@
+// INTENTION_TEXT: Surround with if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) { ... }
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintNewApiInspection
+
+import android.graphics.drawable.VectorDrawable
+
+class VectorDrawableProvider {
+ val flag = false
+ fun getVectorDrawable(): VectorDrawable {
+ return when (flag) {
+ true -> VectorDrawable()
+ else -> VectorDrawable()
+ }
+ }
+}
\ No newline at end of file
diff --git a/idea/testData/android/lintQuickfix/targetVersionCheck/when.kt.expected.181 b/idea/testData/android/lintQuickfix/targetVersionCheck/when.kt.expected.181
new file mode 100644
index 00000000000..e52140da298
--- /dev/null
+++ b/idea/testData/android/lintQuickfix/targetVersionCheck/when.kt.expected.181
@@ -0,0 +1,19 @@
+// INTENTION_TEXT: Surround with if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) { ... }
+// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintNewApiInspection
+
+import android.graphics.drawable.VectorDrawable
+import android.os.Build
+
+class VectorDrawableProvider {
+ val flag = false
+ fun getVectorDrawable(): VectorDrawable {
+ return when (flag) {
+ true -> if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+ VectorDrawable()
+ } else {
+ TODO("VERSION.SDK_INT < LOLLIPOP")
+ }
+ else -> VectorDrawable()
+ }
+ }
+}
\ No newline at end of file