Support View in android-compiler-plugin
This commit is contained in:
@@ -42,10 +42,11 @@ import org.jetbrains.org.objectweb.asm.Opcodes.ACC_PUBLIC
|
||||
import org.jetbrains.org.objectweb.asm.Type
|
||||
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter
|
||||
|
||||
private enum class AndroidClassType {
|
||||
ACTIVITY
|
||||
FRAGMENT
|
||||
UNKNOWN
|
||||
private enum class AndroidClassType(val internalClassName: String, val supportsCache: Boolean = false) {
|
||||
ACTIVITY : AndroidClassType("android/app/Activity", true)
|
||||
FRAGMENT : AndroidClassType("android/app/Fragment", true)
|
||||
VIEW : AndroidClassType("android/view/View")
|
||||
UNKNOWN : AndroidClassType("")
|
||||
}
|
||||
|
||||
public class AndroidExpressionCodegenExtension : ExpressionCodegenExtension {
|
||||
@@ -72,15 +73,10 @@ public class AndroidExpressionCodegenExtension : ExpressionCodegenExtension {
|
||||
|
||||
if (declarationDescriptor == null) return null
|
||||
|
||||
val supportsCache = when {
|
||||
extensionReceiver is ClassReceiver -> true
|
||||
else -> {
|
||||
val source = declarationDescriptor.getSource()
|
||||
if (source is KotlinSourceElement) true else false
|
||||
}
|
||||
}
|
||||
val supportsCache = declarationDescriptor.getSource() is KotlinSourceElement
|
||||
|
||||
if (supportsCache) {
|
||||
val androidClassType = getClassType(declarationDescriptor)
|
||||
if (supportsCache && androidClassType.supportsCache) {
|
||||
val className = DescriptorUtils.getFqName(declarationDescriptor).toString()
|
||||
val bytecodeClassName = className.replace('.', '/')
|
||||
|
||||
@@ -88,15 +84,15 @@ public class AndroidExpressionCodegenExtension : ExpressionCodegenExtension {
|
||||
c.v.getstatic(androidPackage.replace(".", "/") + "/R\$id", propertyDescriptor.getName().asString(), "I")
|
||||
c.v.invokevirtual(bytecodeClassName, METHOD_NAME, "(I)Landroid/view/View;", false)
|
||||
} else {
|
||||
when (getClassType(declarationDescriptor)) {
|
||||
AndroidClassType.ACTIVITY -> {
|
||||
receiver.put(Type.getType("Landroid/app/Activity;"), c.v)
|
||||
when (androidClassType) {
|
||||
AndroidClassType.ACTIVITY, AndroidClassType.VIEW -> {
|
||||
receiver.put(Type.getType("L${androidClassType.internalClassName};"), c.v)
|
||||
c.v.getstatic(androidPackage.replace(".", "/") + "/R\$id", propertyDescriptor.getName().asString(), "I")
|
||||
c.v.invokevirtual("android/app/Activity", "findViewById", "(I)Landroid/view/View;", false)
|
||||
c.v.invokevirtual(androidClassType.internalClassName, "findViewById", "(I)Landroid/view/View;", false)
|
||||
}
|
||||
AndroidClassType.FRAGMENT -> {
|
||||
receiver.put(Type.getType("Landroid/app/Fragment;"), c.v)
|
||||
c.v.invokevirtual("android/app/Fragment", "getView", "()Landroid/view/View;", false)
|
||||
receiver.put(Type.getType("L${androidClassType.internalClassName};"), c.v)
|
||||
c.v.invokevirtual(androidClassType.internalClassName, "getView", "()Landroid/view/View;", false)
|
||||
c.v.getstatic(androidPackage.replace(".", "/") + "/R\$id", propertyDescriptor.getName().asString(), "I")
|
||||
c.v.invokevirtual("android/view/View", "findViewById", "(I)Landroid/view/View;", false)
|
||||
}
|
||||
@@ -114,6 +110,7 @@ public class AndroidExpressionCodegenExtension : ExpressionCodegenExtension {
|
||||
fun getClassTypeInternal(name: String): AndroidClassType? = when (name) {
|
||||
"android.app.Activity" -> AndroidClassType.ACTIVITY
|
||||
"android.app.Fragment" -> AndroidClassType.FRAGMENT
|
||||
"android.view.View" -> AndroidClassType.VIEW
|
||||
else -> null
|
||||
}
|
||||
|
||||
@@ -196,7 +193,7 @@ public class AndroidExpressionCodegenExtension : ExpressionCodegenExtension {
|
||||
// Resolve View via findViewById if not in cache
|
||||
iv.load(0, classType)
|
||||
when (androidClassType) {
|
||||
AndroidClassType.ACTIVITY -> {
|
||||
AndroidClassType.ACTIVITY, AndroidClassType.VIEW -> {
|
||||
loadId()
|
||||
iv.invokevirtual(className, "findViewById", "(I)Landroid/view/View;", false)
|
||||
}
|
||||
|
||||
+33
-18
@@ -57,11 +57,7 @@ public abstract class AndroidUIXmlProcessor(protected val project: Project) {
|
||||
|
||||
public class NoAndroidManifestFound : Exception("No android manifest file found in project root")
|
||||
|
||||
private val androidImports = listOf(
|
||||
"android.app.Activity",
|
||||
"android.app.Fragment",
|
||||
"android.view.View",
|
||||
"android.widget.*")
|
||||
protected val LOG: Logger = Logger.getInstance(javaClass)
|
||||
|
||||
public abstract val resourceManager: AndroidResourceManager
|
||||
|
||||
@@ -91,31 +87,42 @@ public abstract class AndroidUIXmlProcessor(protected val project: Project) {
|
||||
}
|
||||
}
|
||||
|
||||
protected val LOG: Logger = Logger.getInstance(javaClass)
|
||||
|
||||
public fun parse(): List<String> {
|
||||
return resourceManager.getLayoutXmlFiles().map { file ->
|
||||
return resourceManager.getLayoutXmlFiles().flatMap { file ->
|
||||
val widgets = parseSingleFile(file)
|
||||
if (widgets.isNotEmpty()) {
|
||||
val layoutPackage = file.genSyntheticPackageName()
|
||||
val stringWriter = KotlinStringWriter()
|
||||
|
||||
stringWriter.writePackage(layoutPackage)
|
||||
stringWriter.writeAndroidImports()
|
||||
widgets.forEach {
|
||||
stringWriter.writeSyntheticProperty("Activity", it, "findViewById(0)")
|
||||
stringWriter.writeSyntheticProperty("Fragment", it, "getView().findViewById(0)")
|
||||
val mainLayoutFile = renderLayoutFile(layoutPackage, widgets) {
|
||||
writeSyntheticProperty("Activity", it, "findViewById(0)")
|
||||
writeSyntheticProperty("Fragment", it, "getView().findViewById(0)")
|
||||
}
|
||||
|
||||
val contents = stringWriter.toStringBuffer().toString()
|
||||
contents
|
||||
} else null
|
||||
val viewLayoutFile = renderLayoutFile("$layoutPackage.view", widgets) {
|
||||
writeSyntheticProperty("View", it, "findViewById(0)")
|
||||
}
|
||||
|
||||
listOf(mainLayoutFile, viewLayoutFile)
|
||||
} else listOf()
|
||||
}.filterNotNull()
|
||||
}
|
||||
|
||||
public fun parseToPsi(): List<JetFile>? = cachedJetFiles.getValue()
|
||||
|
||||
protected abstract fun parseSingleFile(file: PsiFile): Collection<AndroidWidget>
|
||||
protected abstract fun parseSingleFile(file: PsiFile): List<AndroidWidget>
|
||||
|
||||
private fun renderLayoutFile(
|
||||
packageName: String,
|
||||
widgets: List<AndroidWidget>,
|
||||
widgetWriter: KotlinStringWriter.(AndroidWidget) -> Unit
|
||||
): String {
|
||||
val stringWriter = KotlinStringWriter()
|
||||
stringWriter.writePackage(packageName)
|
||||
stringWriter.writeAndroidImports()
|
||||
widgets.forEach { stringWriter.widgetWriter(it) }
|
||||
|
||||
return stringWriter.toStringBuffer().toString()
|
||||
}
|
||||
|
||||
private fun KotlinStringWriter.writeAndroidImports() {
|
||||
androidImports.forEach { writeImport(it) }
|
||||
@@ -138,4 +145,12 @@ public abstract class AndroidUIXmlProcessor(protected val project: Project) {
|
||||
return CachedValuesManager.getManager(project).createCachedValue(result, false)
|
||||
}
|
||||
|
||||
default object {
|
||||
private val androidImports = listOf(
|
||||
"android.app.Activity",
|
||||
"android.app.Fragment",
|
||||
"android.view.View",
|
||||
"android.widget.*")
|
||||
}
|
||||
|
||||
}
|
||||
+2
-2
@@ -38,8 +38,8 @@ public class CliAndroidUIXmlProcessor(
|
||||
project.getExtensions(PsiTreeChangePreprocessor.EP_NAME).first { it is AndroidPsiTreeChangePreprocessor }
|
||||
}
|
||||
|
||||
override fun parseSingleFile(file: PsiFile): Collection<AndroidWidget> {
|
||||
val widgets: MutableCollection<AndroidWidget> = ArrayList()
|
||||
override fun parseSingleFile(file: PsiFile): List<AndroidWidget> {
|
||||
val widgets = arrayListOf<AndroidWidget>()
|
||||
val handler = AndroidXmlHandler { id, clazz -> widgets.add(AndroidWidget(id, clazz)) }
|
||||
|
||||
try {
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
package kotlinx.android.synthetic.layout.view
|
||||
|
||||
import android.app.Activity
|
||||
import android.app.Fragment
|
||||
import android.view.View
|
||||
import android.widget.*
|
||||
|
||||
val View.MyButton: org.my.cool.Button
|
||||
get() = findViewById(0) as org.my.cool.Button
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
package kotlinx.android.synthetic.layout.view
|
||||
|
||||
import android.app.Activity
|
||||
import android.app.Fragment
|
||||
import android.view.View
|
||||
import android.widget.*
|
||||
|
||||
val View.MyButton: org.my.cool.Button
|
||||
get() = findViewById(0) as org.my.cool.Button
|
||||
|
||||
+5
-16
@@ -1,30 +1,19 @@
|
||||
package kotlinx.android.synthetic.layout1
|
||||
package kotlinx.android.synthetic.layout.view
|
||||
|
||||
import android.app.Activity
|
||||
import android.app.Fragment
|
||||
import android.view.View
|
||||
import android.widget.*
|
||||
|
||||
val Activity.frameLayout: FrameLayout
|
||||
val View.item_detail_container: FrameLayout
|
||||
get() = findViewById(0) as FrameLayout
|
||||
|
||||
val Fragment.frameLayout: FrameLayout
|
||||
get() = getView().findViewById(0) as FrameLayout
|
||||
|
||||
val Activity.passwordField: TextView
|
||||
val View.textView1: TextView
|
||||
get() = findViewById(0) as TextView
|
||||
|
||||
val Fragment.passwordField: TextView
|
||||
get() = getView().findViewById(0) as TextView
|
||||
|
||||
val Activity.passwordCaption: EditText
|
||||
val View.password: EditText
|
||||
get() = findViewById(0) as EditText
|
||||
|
||||
val Fragment.passwordCaption: EditText
|
||||
get() = getView().findViewById(0) as EditText
|
||||
|
||||
val Activity.loginButton: Button
|
||||
val View.login: Button
|
||||
get() = findViewById(0) as Button
|
||||
|
||||
val Fragment.loginButton: Button
|
||||
get() = getView().findViewById(0) as Button
|
||||
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
package kotlinx.android.synthetic.layout1
|
||||
|
||||
import android.app.Activity
|
||||
import android.app.Fragment
|
||||
import android.view.View
|
||||
import android.widget.*
|
||||
|
||||
val Activity.frameLayout: FrameLayout
|
||||
get() = findViewById(0) as FrameLayout
|
||||
|
||||
val Fragment.frameLayout: FrameLayout
|
||||
get() = getView().findViewById(0) as FrameLayout
|
||||
|
||||
val Activity.passwordField: TextView
|
||||
get() = findViewById(0) as TextView
|
||||
|
||||
val Fragment.passwordField: TextView
|
||||
get() = getView().findViewById(0) as TextView
|
||||
|
||||
val Activity.passwordCaption: EditText
|
||||
get() = findViewById(0) as EditText
|
||||
|
||||
val Fragment.passwordCaption: EditText
|
||||
get() = getView().findViewById(0) as EditText
|
||||
|
||||
val Activity.loginButton: Button
|
||||
get() = findViewById(0) as Button
|
||||
|
||||
val Fragment.loginButton: Button
|
||||
get() = getView().findViewById(0) as Button
|
||||
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package kotlinx.android.synthetic.layout1.view
|
||||
|
||||
import android.app.Activity
|
||||
import android.app.Fragment
|
||||
import android.view.View
|
||||
import android.widget.*
|
||||
|
||||
val View.frameLayout: FrameLayout
|
||||
get() = findViewById(0) as FrameLayout
|
||||
|
||||
val View.passwordField: TextView
|
||||
get() = findViewById(0) as TextView
|
||||
|
||||
val View.passwordCaption: EditText
|
||||
get() = findViewById(0) as EditText
|
||||
|
||||
val View.loginButton: Button
|
||||
get() = findViewById(0) as Button
|
||||
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package kotlinx.android.synthetic.layout.view
|
||||
|
||||
import android.app.Activity
|
||||
import android.app.Fragment
|
||||
import android.view.View
|
||||
import android.widget.*
|
||||
|
||||
val View.item_detail_container: FrameLayout
|
||||
get() = findViewById(0) as FrameLayout
|
||||
|
||||
val View.textView1: TextView
|
||||
get() = findViewById(0) as TextView
|
||||
|
||||
val View.password: EditText
|
||||
get() = findViewById(0) as EditText
|
||||
|
||||
val View.login: Button
|
||||
get() = findViewById(0) as Button
|
||||
|
||||
@@ -3,6 +3,6 @@ package android.app
|
||||
import android.view.View
|
||||
import android.content.Context
|
||||
|
||||
abstract class Activity: Context {
|
||||
abstract fun findViewById(id: Int): View?
|
||||
open class Activity: Context {
|
||||
open fun findViewById(id: Int): View? = null
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package android.app
|
||||
|
||||
import android.view.View
|
||||
import android.content.Context
|
||||
import android.app.Activity
|
||||
|
||||
abstract class Fragment {
|
||||
abstract fun getView(): View
|
||||
open fun getActivity(): Activity = throw Exception("Function getActivity() is not overridden")
|
||||
open fun getView(): View = throw Exception("Function getView() is not overridden")
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.myapp
|
||||
|
||||
import android.app.Activity
|
||||
import android.app.Fragment
|
||||
import android.content.Context
|
||||
import android.view.View
|
||||
import android.widget.*
|
||||
import org.my.cool.MyButton
|
||||
import kotlinx.android.synthetic.layout.*
|
||||
|
||||
class R {
|
||||
class id {
|
||||
class object {
|
||||
val login = 5
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class BaseView(ctx: Context) : View(ctx) {
|
||||
val buttonWidget = MyButton(ctx)
|
||||
|
||||
override fun findViewById(id: Int): View? {
|
||||
return when (id) {
|
||||
R.id.login -> buttonWidget
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class MyFragment(): Fragment() {
|
||||
val baseActivity = Activity()
|
||||
val baseView = BaseView(baseActivity)
|
||||
|
||||
override fun getActivity(): Activity = baseActivity
|
||||
|
||||
override fun getView(): View = baseView
|
||||
|
||||
public fun box(): String {
|
||||
return if (login.toString() == "MyButton") "OK" else ""
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return MyFragment().box()
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.myapp
|
||||
|
||||
import android.app.Activity
|
||||
import android.app.Fragment
|
||||
import android.content.Context
|
||||
import android.view.View
|
||||
import android.widget.*
|
||||
import org.my.cool.MyButton
|
||||
import kotlinx.android.synthetic.layout.*
|
||||
|
||||
class R {
|
||||
class id {
|
||||
class object {
|
||||
val login = 5
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class BaseView(ctx: Context) : View(ctx) {
|
||||
val buttonWidget = MyButton(ctx)
|
||||
}
|
||||
|
||||
class MyFragment(): Fragment() {
|
||||
val baseActivity = Activity()
|
||||
val baseView = BaseView(baseActivity)
|
||||
|
||||
override fun getView(): View = baseView
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.myapp"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0" >
|
||||
|
||||
<uses-permission android:name="android.permission.READ_CONTACTS"/>
|
||||
<uses-sdk
|
||||
android:minSdkVersion="18"
|
||||
android:targetSdkVersion="18" />
|
||||
<permission android:name="android"></permission>
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/Theme.Sample" >
|
||||
<activity
|
||||
android:name="com.example.android.basiccontactables.MainActivity"
|
||||
android:label="@string/app_name"
|
||||
android:launchMode="singleTop">
|
||||
<meta-data
|
||||
android:name="android.app.searchable"
|
||||
android:resource="@xml/searchable" />
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.SEARCH" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
</manifest>
|
||||
@@ -0,0 +1,8 @@
|
||||
package org.my.cool
|
||||
|
||||
import android.widget.Button
|
||||
import android.content.Context
|
||||
|
||||
class MyButton(ctx: Context): Button(ctx) {
|
||||
override fun toString(): String {return "MyButton"}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".ItemDetailActivity"
|
||||
tools:ignore="MergeRootFrame" >
|
||||
|
||||
<view
|
||||
class="org.my.cool.MyButton"
|
||||
android:id="@+id/login"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Sign in" />
|
||||
|
||||
</FrameLayout>
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.myapp
|
||||
|
||||
import android.app.Activity
|
||||
import android.view.View
|
||||
import android.widget.*
|
||||
import kotlinx.android.synthetic.layout.*
|
||||
import kotlinx.android.synthetic.layout.view.*
|
||||
|
||||
class R {
|
||||
class id {
|
||||
class object {
|
||||
val container = 0
|
||||
val login = 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class MyActivity(): Activity() {
|
||||
val containerWidget = object : FrameLayout(this) {
|
||||
val loginWidget = Button(this@MyActivity)
|
||||
|
||||
override fun findViewById(id: Int): View? {
|
||||
return when (id) {
|
||||
R.id.login -> loginWidget
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun findViewById(id: Int): View? {
|
||||
return when (id) {
|
||||
R.id.container -> containerWidget
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
||||
public fun box(): String{
|
||||
return if (container.login.toString() == "Button") "OK" else ""
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return MyActivity().box()
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.myapp
|
||||
|
||||
import android.app.Activity
|
||||
import android.view.View
|
||||
import android.widget.*
|
||||
import kotlinx.android.synthetic.layout.*
|
||||
import kotlinx.android.synthetic.layout.view.*
|
||||
|
||||
class R {
|
||||
class id {
|
||||
class object {
|
||||
val container = 0
|
||||
val login = 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class MyActivity(): Activity() {
|
||||
val containerWidget = object : FrameLayout(this) {
|
||||
val loginWidget = Button(this@MyActivity)
|
||||
}
|
||||
|
||||
override fun findViewById(id: Int): View? {
|
||||
return when (id) {
|
||||
R.id.container -> containerWidget
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.myapp"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0" >
|
||||
|
||||
<uses-permission android:name="android.permission.READ_CONTACTS"/>
|
||||
<uses-sdk
|
||||
android:minSdkVersion="18"
|
||||
android:targetSdkVersion="18" />
|
||||
<permission android:name="android"></permission>
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/Theme.Sample" >
|
||||
<activity
|
||||
android:name="com.example.android.basiccontactables.MainActivity"
|
||||
android:label="@string/app_name"
|
||||
android:launchMode="singleTop">
|
||||
<meta-data
|
||||
android:name="android.app.searchable"
|
||||
android:resource="@xml/searchable" />
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.SEARCH" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
</manifest>
|
||||
@@ -0,0 +1,23 @@
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/item_detail_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".ItemDetailActivity"
|
||||
tools:ignore="MergeRootFrame" >
|
||||
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/container"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<Button
|
||||
android:id="@+id/login"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Sign in" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
</FrameLayout>
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package com.myapp
|
||||
|
||||
import android.view.View
|
||||
import kotlinx.android.synthetic.layout.view.*
|
||||
|
||||
fun View.a() {
|
||||
val x = login
|
||||
val y = this.login
|
||||
}
|
||||
|
||||
// 2 GETSTATIC
|
||||
// 2 INVOKEVIRTUAL
|
||||
// 2 CHECKCAST
|
||||
// 0 _\$_findCachedViewById
|
||||
// 2 findViewById
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/item_detail_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".ItemDetailActivity"
|
||||
tools:ignore="MergeRootFrame" >
|
||||
|
||||
|
||||
|
||||
<Button
|
||||
android:id="@+id/login"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Sign in" />
|
||||
|
||||
</FrameLayout>
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/item_detail_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".ItemDetailActivity"
|
||||
tools:ignore="MergeRootFrame" >
|
||||
|
||||
|
||||
|
||||
<Button
|
||||
android:id="@+id/login"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Sign in" />
|
||||
|
||||
</FrameLayout>
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package com.myapp
|
||||
|
||||
import android.view.View
|
||||
import android.app.Activity
|
||||
import kotlinx.android.synthetic.layout.view.*
|
||||
|
||||
public class MyActivity : Activity() {
|
||||
{ View(this).login }
|
||||
}
|
||||
|
||||
// 1 GETSTATIC
|
||||
// 4 INVOKEVIRTUAL
|
||||
// 3 CHECKCAST
|
||||
// 1 _\$_findCachedViewById
|
||||
// 2 findViewById
|
||||
+12
@@ -77,6 +77,12 @@ public class AndroidBoxTestGenerated extends AbstractAndroidBoxTest {
|
||||
String fileName = JetTestUtils.navigationMetadata("plugins/android-compiler-plugin/testData/codegen/android/singleFile/");
|
||||
doCompileAgainstAndroidSdkTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("view")
|
||||
public void testView() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("plugins/android-compiler-plugin/testData/codegen/android/view/");
|
||||
doCompileAgainstAndroidSdkTest(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("plugins/android-compiler-plugin/testData/codegen/android")
|
||||
@@ -122,5 +128,11 @@ public class AndroidBoxTestGenerated extends AbstractAndroidBoxTest {
|
||||
String fileName = JetTestUtils.navigationMetadata("plugins/android-compiler-plugin/testData/codegen/android/singleFile/");
|
||||
doFakeInvocationTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("view")
|
||||
public void testView() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("plugins/android-compiler-plugin/testData/codegen/android/view/");
|
||||
doFakeInvocationTest(fileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+12
@@ -72,6 +72,12 @@ public class AndroidBytecodeShapeTestGenerated extends AbstractAndroidBytecodeSh
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("extensionFunctionsView")
|
||||
public void testExtensionFunctionsView() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("plugins/android-compiler-plugin/testData/codegen/bytecodeShape/extensionFunctionsView/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("fqNameInAttr")
|
||||
public void testFqNameInAttr() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("plugins/android-compiler-plugin/testData/codegen/bytecodeShape/fqNameInAttr/");
|
||||
@@ -119,4 +125,10 @@ public class AndroidBytecodeShapeTestGenerated extends AbstractAndroidBytecodeSh
|
||||
String fileName = JetTestUtils.navigationMetadata("plugins/android-compiler-plugin/testData/codegen/bytecodeShape/simpleFragment/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("simpleView")
|
||||
public void testSimpleView() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("plugins/android-compiler-plugin/testData/codegen/bytecodeShape/simpleView/");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user