Fix Android SuppressLint and Api quickfixes: proper annotation placing

#KT-17783 Fixed
 #KT-17787 Fixed
This commit is contained in:
Vyacheslav Gerasimov
2017-05-29 16:41:31 +03:00
parent e6001f57fa
commit 33c3ba815f
8 changed files with 90 additions and 20 deletions
@@ -16,7 +16,18 @@
package org.jetbrains.kotlin.android
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.editor.fixers.range
import org.jetbrains.kotlin.idea.search.usagesSearch.descriptor
import org.jetbrains.kotlin.psi.KtClass
import org.jetbrains.kotlin.psi.KtProperty
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
internal fun KtClass.insideBody(offset: Int): Boolean = getBody()?.range?.contains(offset) ?: false
fun KtProperty.hasBackingField(): Boolean {
val propertyDescriptor = descriptor as? PropertyDescriptor ?: return false
return analyze(BodyResolveMode.PARTIAL)[BindingContext.BACKING_FIELD_REQUIRED, propertyDescriptor] ?: false
}
@@ -113,6 +113,12 @@ public class AndroidLintQuickfixTestGenerated extends AbstractAndroidLintQuickfi
doTest(fileName);
}
@TestMetadata("topLevelProperty.kt")
public void testTopLevelProperty() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/android/lintQuickfix/requiresApi/topLevelProperty.kt");
doTest(fileName);
}
@TestMetadata("when.kt")
public void testWhen() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/android/lintQuickfix/requiresApi/when.kt");
@@ -239,6 +245,12 @@ public class AndroidLintQuickfixTestGenerated extends AbstractAndroidLintQuickfi
doTest(fileName);
}
@TestMetadata("topLevelProperty.kt")
public void testTopLevelProperty() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/android/lintQuickfix/targetApi/topLevelProperty.kt");
doTest(fileName);
}
@TestMetadata("when.kt")
public void testWhen() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/android/lintQuickfix/targetApi/when.kt");