Fix Android resource reference folding

Properly fold qualified expressions and handle nested references

 #KT-18429 Fixed
This commit is contained in:
Vyacheslav Gerasimov
2017-07-03 16:15:06 +03:00
parent 7c6ffff198
commit ee53e81e8e
5 changed files with 42 additions and 21 deletions
+2
View File
@@ -30,5 +30,7 @@ public final class R {
public static final int mydimen1=0x7f07005b;
public static final int mydimen2=0x7f07005c;
public static final int mydimen3=0x7f07005d;
public static final int dimenRef=0x7f07005e;
public static final int dimenAndroidRef=0x7f07005f;
}
}
+5
View File
@@ -15,5 +15,10 @@ class MyActivity : Activity() <fold text='{...}' expand='true'>{
val strings = intArrayOf(<fold text='"1111"' expand='false'>R.string.string1</fold>, <fold text='"2222"' expand='false'>R.string.string2</fold>, <fold text='"3333"' expand='false'>R.string.string3</fold>)
val dimensions = intArrayOf(<fold text='1dip' expand='false'>R.dimen.mydimen1</fold>, <fold text='2dip' expand='false'>R.dimen.mydimen2</fold>)
val maxButtons = <fold text='max_action_buttons: 2' expand='false'>resources.getInteger(R.integer.max_action_buttons)</fold>
val dimensionWithReference = <fold text='1dip' expand='false'>resources.getDimension(R.dimen.dimenRef)</fold>
val dimensionWithAndroidReference = <fold text='@android:dimen/app_icon_size' expand='false'>resources.getDimension(R.dimen.dimenAndroidRef)</fold>
with(resources) <fold text='{...}' expand='true'>{
val dimension = <fold text='56dip' expand='false'>resources.getDimension(R.dimen.action_bar_default_height)</fold>.toInt()
}</fold>
}</fold>
}</fold>
+1 -1
View File
@@ -4,6 +4,6 @@ import android.content.Context
fun Context.testPlurals(quantity: Int) <fold text='{...}' expand='true'>{
val plural1 = <fold text='"Reference One"' expand='false'>resources.getQuantityString(R.plurals.first, quantity)</fold>
val plural2 = <fold text='Quantity One' expand='false'>this.getResources().getQuantityString(R.plurals.second, quantity)</fold>
val plural2 = <fold text='"Quantity One"' expand='false'>this.getResources().getQuantityString(R.plurals.second, quantity)</fold>
}</fold>
+2
View File
@@ -36,4 +36,6 @@
<dimen name="mydimen3">3dip</dimen>
<dimen name="mydimen1">1dip</dimen>
<dimen name="mydimen2">2dip</dimen>
<dimen name="dimenRef">@dimen/mydimen1</dimen>
<dimen name="dimenAndroidRef">@android:dimen/app_icon_size</dimen>
</resources>