Register Android api quickfixes for inlined api inspection
#KT-14857 Fixed
This commit is contained in:
+18
@@ -74,6 +74,12 @@ public class AndroidLintQuickfixTestGenerated extends AbstractAndroidLintQuickfi
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("inlinedConstant.kt")
|
||||
public void testInlinedConstant() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/android/lintQuickfix/requiresApi/inlinedConstant.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("method.kt")
|
||||
public void testMethod() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/android/lintQuickfix/requiresApi/method.kt");
|
||||
@@ -194,6 +200,12 @@ public class AndroidLintQuickfixTestGenerated extends AbstractAndroidLintQuickfi
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("inlinedConstant.kt")
|
||||
public void testInlinedConstant() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/android/lintQuickfix/targetApi/inlinedConstant.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("method.kt")
|
||||
public void testMethod() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/android/lintQuickfix/targetApi/method.kt");
|
||||
@@ -257,6 +269,12 @@ public class AndroidLintQuickfixTestGenerated extends AbstractAndroidLintQuickfi
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("inlinedConstant.kt")
|
||||
public void testInlinedConstant() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/android/lintQuickfix/targetVersionCheck/inlinedConstant.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("method.kt")
|
||||
public void testMethod() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/android/lintQuickfix/targetVersionCheck/method.kt");
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
// INTENTION_TEXT: Add @RequiresApi(KITKAT) Annotation
|
||||
// INSPECTION_CLASS: org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintInlinedApiInspection
|
||||
// DEPENDENCY: RequiresApi.java -> android/support/annotation/RequiresApi.java
|
||||
|
||||
class Test {
|
||||
fun foo(): Int {
|
||||
return android.R.attr.<caret>windowTranslucentStatus
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import android.os.Build
|
||||
import android.support.annotation.RequiresApi
|
||||
|
||||
// INTENTION_TEXT: Add @RequiresApi(KITKAT) Annotation
|
||||
// INSPECTION_CLASS: org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintInlinedApiInspection
|
||||
// DEPENDENCY: RequiresApi.java -> android/support/annotation/RequiresApi.java
|
||||
|
||||
class Test {
|
||||
@RequiresApi(Build.VERSION_CODES.KITKAT)
|
||||
fun foo(): Int {
|
||||
return android.R.attr.windowTranslucentStatus
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// INTENTION_TEXT: Add @TargetApi(KITKAT) Annotation
|
||||
// INSPECTION_CLASS: org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintInlinedApiInspection
|
||||
|
||||
class Test {
|
||||
fun foo(): Int {
|
||||
return android.R.attr.<caret>windowTranslucentStatus
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import android.annotation.TargetApi
|
||||
import android.os.Build
|
||||
|
||||
// INTENTION_TEXT: Add @TargetApi(KITKAT) Annotation
|
||||
// INSPECTION_CLASS: org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintInlinedApiInspection
|
||||
|
||||
class Test {
|
||||
@TargetApi(Build.VERSION_CODES.KITKAT)
|
||||
fun foo(): Int {
|
||||
return android.R.attr.windowTranslucentStatus
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// INTENTION_TEXT: Surround with if (VERSION.SDK_INT >= VERSION_CODES.KITKAT) { ... }
|
||||
// INSPECTION_CLASS: org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintInlinedApiInspection
|
||||
|
||||
class Test {
|
||||
fun foo(): Int {
|
||||
return android.R.attr.<caret>windowTranslucentStatus
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
import android.os.Build
|
||||
|
||||
// INTENTION_TEXT: Surround with if (VERSION.SDK_INT >= VERSION_CODES.KITKAT) { ... }
|
||||
// INSPECTION_CLASS: org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintInlinedApiInspection
|
||||
|
||||
class Test {
|
||||
fun foo(): Int {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
return android.R.attr.windowTranslucentStatus
|
||||
}
|
||||
}
|
||||
}
|
||||
+10
@@ -383,6 +383,11 @@ public class AndroidLintInspectionToolProvider {
|
||||
@NotNull
|
||||
@Override
|
||||
public AndroidLintQuickFix[] getQuickFixes(@NotNull PsiElement startElement, @NotNull PsiElement endElement, @NotNull String message) {
|
||||
return getApiQuickFixes(startElement, endElement, message);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static AndroidLintQuickFix[] getApiQuickFixes(@NotNull PsiElement startElement, @NotNull PsiElement endElement, @NotNull String message) {
|
||||
int api = ApiDetector.getRequiredVersion(TextFormat.RAW.toText(message));
|
||||
if (api == -1) {
|
||||
return AndroidLintQuickFix.EMPTY_ARRAY;
|
||||
@@ -409,6 +414,11 @@ public class AndroidLintInspectionToolProvider {
|
||||
super(AndroidBundle.message("android.lint.inspections.inlined.api"), ApiDetector.INLINED);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public AndroidLintQuickFix[] getQuickFixes(@NotNull PsiElement startElement, @NotNull PsiElement endElement, @NotNull String message) {
|
||||
return AndroidKLintNewApiInspection.getApiQuickFixes(startElement, endElement, message);
|
||||
}
|
||||
}
|
||||
|
||||
public static class AndroidKLintOverrideInspection extends AndroidLintInspectionBase {
|
||||
|
||||
Reference in New Issue
Block a user