Implement quickfixes for Android Lint api issues

#KT-16624 Fixed
#KT-16625 Fixed
#KT-14947 Fixed
This commit is contained in:
Vyacheslav Gerasimov
2017-03-03 16:12:54 +03:00
parent a907ec92b5
commit 1376c8f8cf
178 changed files with 1307 additions and 221 deletions
+8
View File
@@ -0,0 +1,8 @@
package com.myapp
class R {
object string {
val app_name = 0x7f060021
val resource_id = 0x7f060022
}
}
@@ -0,0 +1,10 @@
package com.myapp;
public final class R {
public static final class string {
}
public static final class color {
public static final int super_green = 0x7f060021;
}
}
@@ -0,0 +1,4 @@
{
"isApplicable": false,
"intentionText": "Create color value resource 'super_green'"
}
@@ -0,0 +1,4 @@
import android.app.Activity
import com.myapp.R
fun Activity.getSuperGreenColor() = getColor(R.color.<caret>super_green)
@@ -0,0 +1,10 @@
package com.myapp;
public final class R {
public static final class string {
}
public static final class color {
}
}
@@ -0,0 +1,4 @@
import android.app.Activity
import com.myapp.R
fun Activity.getSuperGreenColor() = getColor(R.color.super_green)
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="super_green">a</color>
</resources>
@@ -0,0 +1,2 @@
<resources>
</resources>
@@ -0,0 +1,4 @@
import android.app.Activity
import com.myapp.R
fun Activity.getSuperGreenColor() = getColor(R.color.<caret>super_green)
@@ -0,0 +1,4 @@
{
"resDirectory": "../../res",
"intentionText": "Create color value resource 'super_green'"
}
@@ -0,0 +1,10 @@
package com.myapp;
public final class R {
public static final class string {
}
public static final class layout {
public static final int activity_main = 0x7f060021;
}
}
@@ -0,0 +1,4 @@
{
"isApplicable": false,
"intentionText": "Create layout resource file 'activity_main.xml'"
}
@@ -0,0 +1,4 @@
import android.app.Activity
import com.myapp.R
fun Activity.getSetMainContentView() = setContentView(R.layout.<caret>activity_main)
@@ -0,0 +1,10 @@
package com.myapp;
public final class R {
public static final class string {
}
public static final class layout {
}
}
@@ -0,0 +1,4 @@
import android.app.Activity
import com.myapp.R
fun Activity.getSetMainContentView() = setContentView(R.layout.activity_main)
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
</LinearLayout>
@@ -0,0 +1,2 @@
<resources>
</resources>
@@ -0,0 +1,4 @@
import android.app.Activity
import com.myapp.R
fun Activity.getSetMainContentView() = setContentView(R.layout.<caret>activity_main)
@@ -0,0 +1,4 @@
{
"resDirectory": "../../res",
"intentionText": "Create layout resource file 'activity_main.xml'"
}
@@ -0,0 +1,7 @@
package com.myapp;
public final class R {
public static final class string {
public static final int my_activity_title = 0x7f060021;
}
}
@@ -0,0 +1,4 @@
{
"isApplicable": false,
"intentionText": "Create string value resource 'my_activity_title'"
}
@@ -0,0 +1,5 @@
import android.content.Context
import com.myapp.R
fun Context.getActivityTitle() = getString(R.string.<caret>my_activity_title)
@@ -0,0 +1,8 @@
package com.myapp;
public final class R {
public static final class string {
public static final int app_name = 0x7f060021;
public static final int resource_id = 0x7f060022;
}
}
@@ -0,0 +1,5 @@
import android.content.Context
import com.myapp.R
fun Context.getActivityTitle() = getString(R.string.<caret>my_activity_title)
@@ -0,0 +1,3 @@
<resources>
<string name="my_activity_title">a</string>
</resources>
@@ -0,0 +1,5 @@
import android.content.Context
import com.myapp.R
fun Context.getActivityTitle() = getString(R.string.<caret>my_activity_title)
@@ -0,0 +1,4 @@
{
"resDirectory": "../../res",
"intentionText": "Create string value resource 'my_activity_title'"
}
@@ -0,0 +1,5 @@
{
"rFile": "../../R.kt",
"resDirectory": "../../res",
"intentionClass": "org.jetbrains.kotlin.android.intention.KotlinAndroidAddStringResource"
}
@@ -0,0 +1,7 @@
package com.myapp
import android.app.Activity
fun Activity.getSomeText() {
getString(R.string.resource_id)
}
@@ -0,0 +1,3 @@
<resources>
<string name="resource_id">some text</string>
</resources>
@@ -0,0 +1,7 @@
package com.myapp
import android.app.Activity
fun Activity.getSomeText() {
"some <caret>text"
}
@@ -0,0 +1,5 @@
{
"rFile": "../../R.kt",
"resDirectory": "../../res",
"intentionClass": "org.jetbrains.kotlin.android.intention.KotlinAndroidAddStringResource"
}
@@ -0,0 +1,9 @@
package com.myapp
import android.app.Activity
class MyActivity: Activity() {
fun foo() {
val a = getString(R.string.resource_id)
}
}
@@ -0,0 +1,3 @@
<resources>
<string name="resource_id">some string</string>
</resources>
@@ -0,0 +1,9 @@
package com.myapp
import android.app.Activity
class MyActivity: Activity() {
fun foo() {
val a = "some <caret>string"
}
}
@@ -0,0 +1,5 @@
{
"rFile": "../../R.kt",
"resDirectory": "../../res",
"intentionClass": "org.jetbrains.kotlin.android.intention.KotlinAndroidAddStringResource"
}
@@ -0,0 +1,12 @@
package com.myapp
import android.app.Activity
import android.content.Context
class MyActivity: Activity() {
class Helper {
fun test(context: Context) {
val b = context.getString(R.string.resource_id)
}
}
}
@@ -0,0 +1,3 @@
<resources>
<string name="resource_id">some string</string>
</resources>
@@ -0,0 +1,12 @@
package com.myapp
import android.app.Activity
import android.content.Context
class MyActivity: Activity() {
class Helper {
fun test(context: Context) {
val b = "some <caret>string"
}
}
}
@@ -0,0 +1,13 @@
package com.myapp
import android.content.Context
fun foo(context: Context) {
with (context) {
with (2) {
getString(R.string.resource_id)
}
}
}
inline fun <T, R> with(receiver: T, block: T.() -> R): R = receiver.block()
@@ -0,0 +1,3 @@
<resources>
<string name="resource_id">zxc</string>
</resources>
@@ -0,0 +1,5 @@
{
"rFile": "../../R.kt",
"resDirectory": "../../res",
"intentionClass": "org.jetbrains.kotlin.android.intention.KotlinAndroidAddStringResource"
}
@@ -0,0 +1,13 @@
package com.myapp
import android.content.Context
fun foo(context: Context) {
with (context) {
with (2) {
"z<caret>xc"
}
}
}
inline fun <T, R> with(receiver: T, block: T.() -> R): R = receiver.block()
@@ -0,0 +1,7 @@
package com.myapp
import android.content.Context
fun getSomeText(context: Context) {
context.getString(R.string.resource_id)
}
@@ -0,0 +1,3 @@
<resources>
<string name="resource_id">some text</string>
</resources>
@@ -0,0 +1,5 @@
{
"rFile": "../../R.kt",
"resDirectory": "../../res",
"intentionClass": "org.jetbrains.kotlin.android.intention.KotlinAndroidAddStringResource"
}
@@ -0,0 +1,7 @@
package com.myapp
import android.content.Context
fun getSomeText(context: Context) {
"some <caret>text"
}
@@ -0,0 +1,5 @@
package com.myapp
import android.content.Context
fun <T: Context> T.getText(): String? = getString(R.string.resource_id)
@@ -0,0 +1,3 @@
<resources>
<string name="resource_id">some text</string>
</resources>
@@ -0,0 +1,5 @@
{
"rFile": "../../R.kt",
"resDirectory": "../../res",
"intentionClass": "org.jetbrains.kotlin.android.intention.KotlinAndroidAddStringResource"
}
@@ -0,0 +1,5 @@
package com.myapp
import android.content.Context
fun <T: Context> T.getText(): String? = "some <caret>text"
@@ -0,0 +1,13 @@
package com.myapp
import android.app.Activity
class MyActivity: Activity() {
inner class Helper {
fun a(): String = "q"
inner class HelperOfHelper {
fun b(): String = getString(R.string.resource_id)
}
}
}
@@ -0,0 +1,3 @@
<resources>
<string name="resource_id">some string</string>
</resources>
@@ -0,0 +1,5 @@
{
"rFile": "../../R.kt",
"resDirectory": "../../res",
"intentionClass": "org.jetbrains.kotlin.android.intention.KotlinAndroidAddStringResource"
}
@@ -0,0 +1,13 @@
package com.myapp
import android.app.Activity
class MyActivity: Activity() {
inner class Helper {
fun a(): String = "q"
inner class HelperOfHelper {
fun b(): String = "some <caret>string"
}
}
}
@@ -0,0 +1,13 @@
package com.myapp
import android.app.Activity
import android.content.Context
import android.view.View
class MyActivity: Activity() {
inner class SubView constructor(context: Context): View(context) {
fun test() {
val b = context.getString(R.string.resource_id)
}
}
}
@@ -0,0 +1,3 @@
<resources>
<string name="resource_id">some string</string>
</resources>
@@ -0,0 +1,5 @@
{
"rFile": "../../R.kt",
"resDirectory": "../../res",
"intentionClass": "org.jetbrains.kotlin.android.intention.KotlinAndroidAddStringResource"
}
@@ -0,0 +1,13 @@
package com.myapp
import android.app.Activity
import android.content.Context
import android.view.View
class MyActivity: Activity() {
inner class SubView constructor(context: Context): View(context) {
fun test() {
val b = "some <caret>string"
}
}
}
@@ -0,0 +1,12 @@
package com.myapp
import android.app.Activity
import android.content.Context
class MyActivity: Activity() {
object A {
fun doSomething(context: Context) {
context.getString(R.string.resource_id)
}
}
}
@@ -0,0 +1,3 @@
<resources>
<string name="resource_id">some string</string>
</resources>
@@ -0,0 +1,12 @@
package com.myapp
import android.app.Activity
import android.content.Context
class MyActivity: Activity() {
object A {
fun doSomething(context: Context) {
"some <caret>string"
}
}
}
@@ -0,0 +1,5 @@
{
"rFile": "../../R.kt",
"resDirectory": "../../res",
"intentionClass": "org.jetbrains.kotlin.android.intention.KotlinAndroidAddStringResource"
}
@@ -0,0 +1,11 @@
package com.myapp
import android.app.Activity
class MyActivity: Activity() {
fun foo() {
object {
val text = getString(R.string.resource_id)
}
}
}
@@ -0,0 +1,3 @@
<resources>
<string name="resource_id">some string</string>
</resources>
@@ -0,0 +1,11 @@
package com.myapp
import android.app.Activity
class MyActivity: Activity() {
fun foo() {
object {
val text = "some <caret>string"
}
}
}
@@ -0,0 +1,5 @@
{
"rFile": "../../R.kt",
"resDirectory": "../../res",
"intentionClass": "org.jetbrains.kotlin.android.intention.KotlinAndroidAddStringResource"
}
@@ -0,0 +1,10 @@
package com.myapp
import android.app.Activity
import android.content.Context
fun foo(context: Context) {
object {
val text = context.getString(R.string.resource_id)
}
}
@@ -0,0 +1,3 @@
<resources>
<string name="resource_id">some string</string>
</resources>
@@ -0,0 +1,10 @@
package com.myapp
import android.app.Activity
import android.content.Context
fun foo(context: Context) {
object {
val text = "some <caret>string"
}
}
@@ -0,0 +1,5 @@
{
"rFile": "../../R.kt",
"resDirectory": "../../res",
"intentionClass": "org.jetbrains.kotlin.android.intention.KotlinAndroidAddStringResource"
}
@@ -0,0 +1,5 @@
fun foo() {
val a = "some"
val b = "text"
val bar = "$a <caret>+ $b"
}
@@ -0,0 +1,4 @@
{
"intentionClass": "org.jetbrains.kotlin.android.intention.KotlinAndroidAddStringResource",
"isApplicable": false
}
@@ -0,0 +1,10 @@
package com.myapp
import android.app.Activity
import android.view.View
class MyActivity: Activity() {
fun View.foo() {
val a = context.getString(R.string.resource_id)
}
}
@@ -0,0 +1,3 @@
<resources>
<string name="resource_id">some string</string>
</resources>
@@ -0,0 +1,10 @@
package com.myapp
import android.app.Activity
import android.view.View
class MyActivity: Activity() {
fun View.foo() {
val a = "some <caret>string"
}
}
@@ -0,0 +1,5 @@
{
"rFile": "../../R.kt",
"resDirectory": "../../res",
"intentionClass": "org.jetbrains.kotlin.android.intention.KotlinAndroidAddStringResource"
}
@@ -0,0 +1,10 @@
package com.myapp
import android.content.Context
import android.view.View
class DemoView constructor(context: Context): View(context) {
fun test() {
val b = context.getString(R.string.resource_id)
}
}
@@ -0,0 +1,3 @@
<resources>
<string name="resource_id">some string</string>
</resources>
@@ -0,0 +1,10 @@
package com.myapp
import android.content.Context
import android.view.View
class DemoView constructor(context: Context): View(context) {
fun test() {
val b = "some <caret>string"
}
}
@@ -0,0 +1,5 @@
{
"rFile": "../../R.kt",
"resDirectory": "../../res",
"intentionClass": "org.jetbrains.kotlin.android.intention.KotlinAndroidAddStringResource"
}
@@ -0,0 +1,2 @@
<resources>
</resources>