diff --git a/libraries/tools/kotlin-android-extensions/src/main/kotlin/org/jetbrains/kotlin/android/AndroidSubplugin.kt b/libraries/tools/kotlin-android-extensions/src/main/kotlin/org/jetbrains/kotlin/android/AndroidSubplugin.kt index 781f8608205..08ab9df7beb 100644 --- a/libraries/tools/kotlin-android-extensions/src/main/kotlin/org/jetbrains/kotlin/android/AndroidSubplugin.kt +++ b/libraries/tools/kotlin-android-extensions/src/main/kotlin/org/jetbrains/kotlin/android/AndroidSubplugin.kt @@ -19,8 +19,12 @@ package org.jetbrains.kotlin.android import org.jetbrains.kotlin.gradle.plugin.KotlinGradleSubplugin import org.gradle.api.Project import com.android.build.gradle.BaseExtension +import com.android.build.gradle.api.AndroidSourceSet import org.gradle.api.tasks.compile.AbstractCompile import org.jetbrains.kotlin.gradle.plugin.SubpluginOption +import org.w3c.dom.Document +import java.io.File +import javax.xml.parsers.DocumentBuilderFactory public class AndroidSubplugin : KotlinGradleSubplugin { @@ -28,20 +32,37 @@ public class AndroidSubplugin : KotlinGradleSubplugin { val androidExtension = project.extensions.getByName("android") as? BaseExtension ?: return null val sourceSets = androidExtension.sourceSets + + val pluginOptions = arrayListOf() + val mainSourceSet = sourceSets.getByName("main") - - val resourceDirs = mainSourceSet.res.srcDirs val manifestFile = mainSourceSet.manifest.srcFile + val applicationPackage = androidExtension.defaultConfig.applicationId + ?: getApplicationPackageFromManifest(manifestFile) ?: "" + pluginOptions += SubpluginOption("package", applicationPackage) - if (resourceDirs.isNotEmpty()) { - val resourceDirOptions = resourceDirs.map { resourceDir -> - resourceDir.listFiles { it.isDirectory && it.name.startsWith("layout") }?.forEach { task.source(it) } - SubpluginOption("androidRes", resourceDir.absolutePath) - } - return listOf(SubpluginOption("androidManifest", manifestFile.absolutePath)) + resourceDirOptions + fun addVariant(sourceSet: AndroidSourceSet) { + pluginOptions += SubpluginOption("variant", sourceSet.name + ';' + + mainSourceSet.res.srcDirs.joinToString(";") { it.absolutePath }) } - return null + addVariant(mainSourceSet) + + val flavorSourceSets = androidExtension.productFlavors.map { sourceSets.findByName(it.name) }.filterNotNull() + for (sourceSet in flavorSourceSets) { + addVariant(sourceSet) + } + + return pluginOptions + } + + private fun getApplicationPackageFromManifest(manifestFile: File): String? { + try { + return manifestFile.parseXml().documentElement.getAttribute("package") + } + catch (e: Exception) { + return null + } } override fun getPluginName() = "org.jetbrains.kotlin.android" @@ -49,4 +70,10 @@ public class AndroidSubplugin : KotlinGradleSubplugin { override fun getGroupName() = "org.jetbrains.kotlin" override fun getArtifactName() = "kotlin-android-extensions" + + fun File.parseXml(): Document { + val factory = DocumentBuilderFactory.newInstance() + val builder = factory.newDocumentBuilder() + return builder.parse(this) + } } \ No newline at end of file diff --git a/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/android/synthetic/AndroidComponentRegistrar.kt b/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/android/synthetic/AndroidComponentRegistrar.kt index 9d69ed93e98..8f42aa37c7b 100644 --- a/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/android/synthetic/AndroidComponentRegistrar.kt +++ b/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/android/synthetic/AndroidComponentRegistrar.kt @@ -25,10 +25,7 @@ import org.jetbrains.kotlin.android.synthetic.codegen.AndroidExpressionCodegenEx import org.jetbrains.kotlin.android.synthetic.codegen.AndroidOnDestroyClassBuilderInterceptorExtension import org.jetbrains.kotlin.android.synthetic.diagnostic.AndroidExtensionPropertiesCallChecker import org.jetbrains.kotlin.android.synthetic.diagnostic.DefaultErrorMessagesAndroid -import org.jetbrains.kotlin.android.synthetic.res.AndroidLayoutXmlFileManager -import org.jetbrains.kotlin.android.synthetic.res.CliAndroidLayoutXmlFileManager -import org.jetbrains.kotlin.android.synthetic.res.CliSyntheticFileGenerator -import org.jetbrains.kotlin.android.synthetic.res.SyntheticFileGenerator +import org.jetbrains.kotlin.android.synthetic.res.* import org.jetbrains.kotlin.codegen.extensions.ClassBuilderInterceptorExtension import org.jetbrains.kotlin.codegen.extensions.ExpressionCodegenExtension import org.jetbrains.kotlin.compiler.plugin.CliOption @@ -47,30 +44,30 @@ import org.jetbrains.kotlin.resolve.TargetPlatform import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatform public object AndroidConfigurationKeys { - public val ANDROID_RES_PATH: CompilerConfigurationKey> = CompilerConfigurationKey.create>("android resources search path") - public val ANDROID_MANIFEST: CompilerConfigurationKey = CompilerConfigurationKey.create("android manifest file") + public val VARIANT: CompilerConfigurationKey> = CompilerConfigurationKey.create>("Android build variant") + public val PACKAGE: CompilerConfigurationKey = CompilerConfigurationKey.create("application package fq name") } public class AndroidCommandLineProcessor : CommandLineProcessor { companion object { public val ANDROID_COMPILER_PLUGIN_ID: String = "org.jetbrains.kotlin.android" - public val RESOURCE_PATH_OPTION: CliOption = CliOption("androidRes", "", "Android resources path", allowMultipleOccurrences = true) - public val MANIFEST_FILE_OPTION: CliOption = CliOption("androidManifest", "", "Android manifest file") + public val VARIANT_OPTION: CliOption = CliOption("variant", "", "Android build variant", allowMultipleOccurrences = true) + public val PACKAGE_OPTION: CliOption = CliOption("package", "", "Application package") } override val pluginId: String = ANDROID_COMPILER_PLUGIN_ID - override val pluginOptions: Collection = listOf(RESOURCE_PATH_OPTION, MANIFEST_FILE_OPTION) + override val pluginOptions: Collection = listOf(VARIANT_OPTION, PACKAGE_OPTION) override fun processOption(option: CliOption, value: String, configuration: CompilerConfiguration) { when (option) { - RESOURCE_PATH_OPTION -> { - val paths = configuration.getList(AndroidConfigurationKeys.ANDROID_RES_PATH).toArrayList() + VARIANT_OPTION -> { + val paths = configuration.getList(AndroidConfigurationKeys.VARIANT).toArrayList() paths.add(value) - configuration.put(AndroidConfigurationKeys.ANDROID_RES_PATH, paths) + configuration.put(AndroidConfigurationKeys.VARIANT, paths) } - MANIFEST_FILE_OPTION -> configuration.put(AndroidConfigurationKeys.ANDROID_MANIFEST, value) + PACKAGE_OPTION -> configuration.put(AndroidConfigurationKeys.PACKAGE, value) else -> throw CliOptionProcessingException("Unknown option: ${option.name}") } } @@ -86,14 +83,16 @@ public class CliAndroidDeclarationsProvider(private val project: Project) : Exte public class AndroidComponentRegistrar : ComponentRegistrar { public override fun registerProjectComponents(project: MockProject, configuration: CompilerConfiguration) { - val androidResPath = configuration.get(AndroidConfigurationKeys.ANDROID_RES_PATH) - val androidManifest = configuration.get(AndroidConfigurationKeys.ANDROID_MANIFEST) + val applicationPackage = configuration.get(AndroidConfigurationKeys.PACKAGE) + val variants = configuration.get(AndroidConfigurationKeys.VARIANT)?.map { parseVariant(it) }?.filterNotNull() ?: emptyList() - if (androidResPath != null && androidManifest != null) { - val xmlProcessor = CliSyntheticFileGenerator(project, androidManifest, androidResPath) + if (variants.isNotEmpty() && !applicationPackage.isNullOrBlank()) { + val xmlProcessor = CliSyntheticFileGenerator(project, applicationPackage!!, variants) project.registerService(SyntheticFileGenerator::class.java, xmlProcessor) - project.registerService(AndroidLayoutXmlFileManager::class.java, CliAndroidLayoutXmlFileManager(project, androidManifest, androidResPath)) + + val layoutXmlFileManager = CliAndroidLayoutXmlFileManager(project, applicationPackage, variants) + project.registerService(AndroidLayoutXmlFileManager::class.java, layoutXmlFileManager) ExternalDeclarationsProvider.registerExtension(project, CliAndroidDeclarationsProvider(project)) ExpressionCodegenExtension.registerExtension(project, AndroidExpressionCodegenExtension()) @@ -102,6 +101,12 @@ public class AndroidComponentRegistrar : ComponentRegistrar { ClassBuilderInterceptorExtension.registerExtension(project, AndroidOnDestroyClassBuilderInterceptorExtension()) } } + + private fun parseVariant(s: String): AndroidVariant? { + val parts = s.split(';') + if (parts.size < 2) return null + return AndroidVariant(parts[0], parts.drop(0)) + } } public class AndroidExtensionPropertiesComponentContainerContributor : StorageComponentContainerContributor { diff --git a/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/android/synthetic/Context.kt b/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/android/synthetic/Context.kt index 45845560db5..bf6c7890ff9 100644 --- a/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/android/synthetic/Context.kt +++ b/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/android/synthetic/Context.kt @@ -34,7 +34,7 @@ open class Context(val buffer: StringBuffer = StringBuffer(), private var indent indentDepth-- if (indentDepth < 0) throw InvalidIndent(indentDepth) - currentIndent = currentIndent.substring(0, currentIndent.length() - indentUnit.length()) + currentIndent = currentIndent.substring(0, currentIndent.length - indentUnit.length) } public open fun write(what: String) { @@ -57,7 +57,7 @@ open class Context(val buffer: StringBuffer = StringBuffer(), private var indent public fun trim(num: Int) { - buffer.delete(buffer.length() - num, buffer.length()) + buffer.delete(buffer.length - num, buffer.length()) } public fun fork(newBuffer: StringBuffer = StringBuffer(), diff --git a/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/android/synthetic/KotlinWriter.kt b/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/android/synthetic/KotlinWriter.kt index 3be97da40f8..f4840911913 100644 --- a/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/android/synthetic/KotlinWriter.kt +++ b/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/android/synthetic/KotlinWriter.kt @@ -32,7 +32,7 @@ class KotlinStringWriter : KotlinWriter { body.writeln("val $name: $retType") body.incIndent() body.write("get() ") - if (getterBody.size() > 1) { + if (getterBody.size > 1) { body.writeNoIndent("{\n") body.incIndent() for (stmt in getterBody) { diff --git a/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/android/synthetic/res/AndroidLayoutXmlFileManager.kt b/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/android/synthetic/res/AndroidLayoutXmlFileManager.kt index bda004db6f4..14e5ed15cd9 100644 --- a/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/android/synthetic/res/AndroidLayoutXmlFileManager.kt +++ b/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/android/synthetic/res/AndroidLayoutXmlFileManager.kt @@ -27,15 +27,25 @@ import com.intellij.psi.PsiManager import org.jetbrains.kotlin.psi.KtProperty import java.util.* -public abstract class AndroidLayoutXmlFileManager(val project: Project) { +class AndroidVariantData(val variant: AndroidVariant, private val layouts: Map>): Map> by layouts +class AndroidModuleData(val module: AndroidModule, private val variants: List): Iterable by variants { + companion object { + val EMPTY = AndroidModuleData(AndroidModule("android", listOf()), listOf()) + } +} - public abstract val androidModuleInfo: AndroidModuleInfo? +abstract class AndroidLayoutXmlFileManager(val project: Project) { + + public abstract val androidModule: AndroidModule? public open fun propertyToXmlAttributes(property: KtProperty): List = listOf() - public fun getLayoutXmlFiles(): Map> { - val info = androidModuleInfo ?: return mapOf() + public fun getLayoutXmlFiles(): AndroidModuleData { + val androidModule = androidModule ?: return AndroidModuleData.EMPTY + return AndroidModuleData(androidModule, androidModule.variants.map { getVariantData(it) }) + } + public fun getVariantData(variant: AndroidVariant): AndroidVariantData { val psiManager = PsiManager.getInstance(project) val fileManager = VirtualFileManager.getInstance() @@ -53,11 +63,11 @@ public abstract class AndroidLayoutXmlFileManager(val project: Project) { return allChildren } - val resDirectories = info.resDirectories.map { fileManager.findFileByUrl("file://$it") } + val resDirectories = variant.resDirectories.map { fileManager.findFileByUrl("file://$it") } val allChildren = resDirectories.flatMap { it?.getAllChildren() ?: listOf() } val allLayoutFiles = allChildren.filter { it.parent.name.startsWith("layout") && it.name.toLowerCase().endsWith(".xml") } - val allLayoutPsiFiles = allLayoutFiles.fold(ArrayList(allLayoutFiles.size())) { list, file -> + val allLayoutPsiFiles = allLayoutFiles.fold(ArrayList(allLayoutFiles.size)) { list, file -> val psiFile = psiManager.findFile(file) if (psiFile != null && psiFile.parent != null) { list += psiFile @@ -67,9 +77,9 @@ public abstract class AndroidLayoutXmlFileManager(val project: Project) { val layoutNameToXmlFiles = allLayoutPsiFiles .groupBy { it.name.substringBeforeLast('.') } - .mapValues { it.getValue().sortedBy { it.parent!!.name.length() } } + .mapValues { it.value.sortedBy { it.parent!!.name.length } } - return layoutNameToXmlFiles + return AndroidVariantData(variant, layoutNameToXmlFiles) } companion object { diff --git a/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/android/synthetic/res/CliAndroidLayoutXmlFileManager.kt b/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/android/synthetic/res/CliAndroidLayoutXmlFileManager.kt index 867d695041d..29be4a2b0ab 100644 --- a/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/android/synthetic/res/CliAndroidLayoutXmlFileManager.kt +++ b/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/android/synthetic/res/CliAndroidLayoutXmlFileManager.kt @@ -17,23 +17,16 @@ package org.jetbrains.kotlin.android.synthetic.res import com.intellij.openapi.project.Project -import org.jetbrains.kotlin.android.synthetic.toMap -import org.xml.sax.Attributes -import org.xml.sax.helpers.DefaultHandler -import java.io.File -import java.io.FileInputStream import javax.xml.parsers.SAXParser import javax.xml.parsers.SAXParserFactory public class CliAndroidLayoutXmlFileManager( project: Project, - private val manifestPath: String, - private val resDirectories: List + private val applicationPackage: String, + private val variants: List ) : AndroidLayoutXmlFileManager(project) { - override val androidModuleInfo by lazy { - AndroidModuleInfo(getApplicationPackage(manifestPath), resDirectories) - } + override val androidModule by lazy { AndroidModule(applicationPackage, variants) } val saxParser: SAXParser = initSAX() @@ -43,26 +36,4 @@ public class CliAndroidLayoutXmlFileManager( return saxFactory.newSAXParser() } - private fun getApplicationPackage(manifestPath: String): String { - try { - val manifestXml = File(manifestPath) - var applicationPackage: String = "" - try { - saxParser.parse(FileInputStream(manifestXml), object : DefaultHandler() { - override fun startElement(uri: String, localName: String, qName: String, attributes: Attributes) { - if (localName == "manifest") - applicationPackage = attributes.toMap()["package"] ?: "" - } - }) - } - catch (e: Exception) { - throw e - } - return applicationPackage - } - catch (e: Exception) { - throw SyntheticFileGenerator.NoAndroidManifestFound() - } - } - } diff --git a/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/android/synthetic/res/CliSyntheticFileGenerator.kt b/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/android/synthetic/res/CliSyntheticFileGenerator.kt index d0b2b05fea1..e327c9b42f1 100644 --- a/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/android/synthetic/res/CliSyntheticFileGenerator.kt +++ b/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/android/synthetic/res/CliSyntheticFileGenerator.kt @@ -20,17 +20,17 @@ import com.intellij.openapi.diagnostic.Logger import com.intellij.openapi.project.Project import com.intellij.psi.PsiElementFinder import com.intellij.psi.PsiFile -import java.io.ByteArrayInputStream import com.intellij.psi.impl.PsiElementFinderImpl import com.intellij.psi.search.GlobalSearchScope import org.jetbrains.kotlin.android.synthetic.AndroidConst import org.jetbrains.kotlin.android.synthetic.AndroidXmlHandler import org.jetbrains.kotlin.psi.KtFile +import java.io.ByteArrayInputStream public open class CliSyntheticFileGenerator( project: Project, private val manifestPath: String, - private val resDirectories: List + private val variants: List ) : SyntheticFileGenerator(project) { private val cachedJetFiles by lazy { @@ -40,7 +40,7 @@ public open class CliSyntheticFileGenerator( } override val layoutXmlFileManager: CliAndroidLayoutXmlFileManager by lazy { - CliAndroidLayoutXmlFileManager(project, manifestPath, resDirectories) + CliAndroidLayoutXmlFileManager(project, manifestPath, variants) } public override fun getSyntheticFiles(): List = cachedJetFiles diff --git a/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/android/synthetic/res/SyntheticFileGenerator.kt b/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/android/synthetic/res/SyntheticFileGenerator.kt index f70236e2031..d51addbd798 100644 --- a/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/android/synthetic/res/SyntheticFileGenerator.kt +++ b/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/android/synthetic/res/SyntheticFileGenerator.kt @@ -47,16 +47,18 @@ public abstract class SyntheticFileGenerator(protected val project: Project) { protected open fun generateSyntheticFiles(generateCommonFiles: Boolean, supportV4: Boolean): List { val commonFiles = if (generateCommonFiles) generateCommonFiles(supportV4) else listOf() - return layoutXmlFileManager.getLayoutXmlFiles().flatMap { entry -> - val files = entry.getValue() - val resources = extractLayoutResources(files) + return layoutXmlFileManager.getLayoutXmlFiles().flatMap { variantData -> + variantData.flatMap { entry -> + val files = entry.value + val resources = extractLayoutResources(files) - val layoutName = entry.getKey() + val layoutName = entry.key - val mainLayoutFile = renderMainLayoutFile(layoutName, resources, supportV4) - val viewLayoutFile = renderViewLayoutFile(layoutName, resources) - - listOf(mainLayoutFile, viewLayoutFile) + arrayListOf().apply { + this += renderMainLayoutFiles(variantData.variant, layoutName, resources, supportV4) + this += renderViewLayoutFiles(variantData.variant, layoutName, resources) + } + } }.filterNotNull() + commonFiles } @@ -79,34 +81,59 @@ public abstract class SyntheticFileGenerator(protected val project: Project) { protected abstract fun checkIfClassExist(fqName: String): Boolean - private fun renderMainLayoutFile(layoutName: String, resources: List, supportV4: Boolean): AndroidSyntheticFile { - return renderLayoutFile(layoutName + AndroidConst.LAYOUT_POSTFIX, escapeAndroidIdentifier(layoutName), resources) { + private fun renderMainLayoutFiles( + variant: AndroidVariant, + layoutName: String, + resources: List, + supportV4: Boolean + ): List { + return renderLayoutFile(variant, layoutName + AndroidConst.LAYOUT_POSTFIX, escapeAndroidIdentifier(layoutName), resources) { val properties = it.mainProperties.toArrayList() if (supportV4) properties.addAll(it.mainPropertiesForSupportV4) properties } } - private fun renderViewLayoutFile(layoutName: String, resources: List): AndroidSyntheticFile { - return renderLayoutFile(layoutName + AndroidConst.VIEW_LAYOUT_POSTFIX, + private fun renderViewLayoutFiles( + variant: AndroidVariant, + layoutName: String, + resources: List + ): List { + return renderLayoutFile(variant, layoutName + AndroidConst.VIEW_LAYOUT_POSTFIX, escapeAndroidIdentifier(layoutName) + ".view", resources) { it.viewProperties } } private fun renderLayoutFile( + variant: AndroidVariant, filename: String, - packageSegment: String, + layoutName: String, resources: List, - properties: (AndroidResource) -> List>): AndroidSyntheticFile { - return renderSyntheticFile(filename) { - writePackage(AndroidConst.SYNTHETIC_PACKAGE + "." + packageSegment) - writeAndroidImports() + properties: (AndroidResource) -> List>): List { + fun render(defaultVariant: Boolean = false): AndroidSyntheticFile { + val fullFilename = (if (defaultVariant) "" else "${variant.name}_") + filename + return renderSyntheticFile(fullFilename) { + val packageName = if (defaultVariant) + AndroidConst.SYNTHETIC_PACKAGE + "." + layoutName + else + AndroidConst.SYNTHETIC_PACKAGE + '.' + variant.name + '.' + layoutName - for (res in resources) { - properties(res).forEach { property -> - writeSyntheticProperty(property.first, res, property.second) + writePackage(packageName) + writeAndroidImports() + + for (res in resources) { + properties(res).forEach { property -> + if (defaultVariant) { + val deprecatedText = "Use the property from the 'main' variant instead" + val import = AndroidConst.SYNTHETIC_PACKAGE + '.' + variant.name + '.' + layoutName + '.' + res.id + writeText("@Deprecated(\"$deprecatedText\", ReplaceWith(\"${res.id}\", \"$import\"))") + } + writeSyntheticProperty(property.first, res, property.second) + } } } } + + return if (variant.isMainVariant) listOf(render(), render(true)) else listOf(render()) } private fun renderSyntheticFile(filename: String, init: KotlinStringWriter.() -> Unit): AndroidSyntheticFile { @@ -199,7 +226,7 @@ public abstract class SyntheticFileGenerator(protected val project: Project) { protected fun generateSyntheticJetFiles(files: List): List { val psiManager = PsiManager.getInstance(project) - val applicationPackage = layoutXmlFileManager.androidModuleInfo?.applicationPackage + val applicationPackage = layoutXmlFileManager.androidModule?.applicationPackage return files.mapIndexed { index, syntheticFile -> val fileName = AndroidConst.SYNTHETIC_FILENAME_PREFIX + syntheticFile.name + ".kt" diff --git a/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/android/synthetic/res/androidResources.kt b/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/android/synthetic/res/androidResources.kt index 1945b34aba4..3c51021daf9 100644 --- a/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/android/synthetic/res/androidResources.kt +++ b/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/android/synthetic/res/androidResources.kt @@ -18,13 +18,19 @@ package org.jetbrains.kotlin.android.synthetic.res import org.jetbrains.kotlin.android.synthetic.AndroidConst -public class AndroidModuleInfo(val applicationPackage: String, resDirectories: List) { +class AndroidVariant(val name: String, val resDirectories: List) { + val packageName: String = name + val isMainVariant: Boolean + get() = name == "main" - override fun equals(other: Any?) = other is AndroidModuleInfo && applicationPackage == other.applicationPackage + companion object { + fun createMainVariant(resDirectories: List) = AndroidVariant("main", resDirectories) + } +} +public class AndroidModule(val applicationPackage: String, val variants: List) { + override fun equals(other: Any?) = other is AndroidModule && applicationPackage == other.applicationPackage override fun hashCode() = applicationPackage.hashCode() - - val resDirectories = resDirectories.sorted() } public abstract class AndroidResource(val id: String) { diff --git a/plugins/android-compiler-plugin/testData/android/converter/simple/escapedLayoutName/get_LAYOUT.kt b/plugins/android-compiler-plugin/testData/android/converter/simple/escapedLayoutName/get_LAYOUT.kt index d69ac8cd111..aea221b74f9 100644 --- a/plugins/android-compiler-plugin/testData/android/converter/simple/escapedLayoutName/get_LAYOUT.kt +++ b/plugins/android-compiler-plugin/testData/android/converter/simple/escapedLayoutName/get_LAYOUT.kt @@ -2,27 +2,35 @@ package kotlinx.android.synthetic.`get` import kotlin.internal.flexible.ft +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("item_detail_container", "kotlinx.android.synthetic.main.`get`.item_detail_container")) val android.app.Activity.item_detail_container: ft get() = findViewById(0) as? android.widget.FrameLayout +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("item_detail_container", "kotlinx.android.synthetic.main.`get`.item_detail_container")) val android.app.Fragment.item_detail_container: ft get() = getView().findViewById(0) as? android.widget.FrameLayout +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("textView1", "kotlinx.android.synthetic.main.`get`.textView1")) val android.app.Activity.textView1: ft get() = findViewById(0) as? android.widget.TextView +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("textView1", "kotlinx.android.synthetic.main.`get`.textView1")) val android.app.Fragment.textView1: ft get() = getView().findViewById(0) as? android.widget.TextView +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("password", "kotlinx.android.synthetic.main.`get`.password")) val android.app.Activity.password: ft get() = findViewById(0) as? android.widget.EditText +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("password", "kotlinx.android.synthetic.main.`get`.password")) val android.app.Fragment.password: ft get() = getView().findViewById(0) as? android.widget.EditText +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("login", "kotlinx.android.synthetic.main.`get`.login")) val android.app.Activity.login: ft get() = findViewById(0) as? android.widget.Button +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("login", "kotlinx.android.synthetic.main.`get`.login")) val android.app.Fragment.login: ft get() = getView().findViewById(0) as? android.widget.Button diff --git a/plugins/android-compiler-plugin/testData/android/converter/simple/escapedLayoutName/get_VIEW.kt b/plugins/android-compiler-plugin/testData/android/converter/simple/escapedLayoutName/get_VIEW.kt index 7bf143b3923..a6b29250276 100644 --- a/plugins/android-compiler-plugin/testData/android/converter/simple/escapedLayoutName/get_VIEW.kt +++ b/plugins/android-compiler-plugin/testData/android/converter/simple/escapedLayoutName/get_VIEW.kt @@ -2,15 +2,19 @@ package kotlinx.android.synthetic.`get`.view import kotlin.internal.flexible.ft +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("item_detail_container", "kotlinx.android.synthetic.main.`get`.view.item_detail_container")) val android.view.View.item_detail_container: ft get() = findViewById(0) as? android.widget.FrameLayout +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("textView1", "kotlinx.android.synthetic.main.`get`.view.textView1")) val android.view.View.textView1: ft get() = findViewById(0) as? android.widget.TextView +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("password", "kotlinx.android.synthetic.main.`get`.view.password")) val android.view.View.password: ft get() = findViewById(0) as? android.widget.EditText +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("login", "kotlinx.android.synthetic.main.`get`.view.login")) val android.view.View.login: ft get() = findViewById(0) as? android.widget.Button diff --git a/plugins/android-compiler-plugin/testData/android/converter/simple/escapedLayoutName/main_get_LAYOUT.kt b/plugins/android-compiler-plugin/testData/android/converter/simple/escapedLayoutName/main_get_LAYOUT.kt new file mode 100644 index 00000000000..9d88bbcf654 --- /dev/null +++ b/plugins/android-compiler-plugin/testData/android/converter/simple/escapedLayoutName/main_get_LAYOUT.kt @@ -0,0 +1,28 @@ +package kotlinx.android.synthetic.main.`get` + +import kotlin.internal.flexible.ft + +val android.app.Activity.item_detail_container: ft + get() = findViewById(0) as? android.widget.FrameLayout + +val android.app.Fragment.item_detail_container: ft + get() = getView().findViewById(0) as? android.widget.FrameLayout + +val android.app.Activity.textView1: ft + get() = findViewById(0) as? android.widget.TextView + +val android.app.Fragment.textView1: ft + get() = getView().findViewById(0) as? android.widget.TextView + +val android.app.Activity.password: ft + get() = findViewById(0) as? android.widget.EditText + +val android.app.Fragment.password: ft + get() = getView().findViewById(0) as? android.widget.EditText + +val android.app.Activity.login: ft + get() = findViewById(0) as? android.widget.Button + +val android.app.Fragment.login: ft + get() = getView().findViewById(0) as? android.widget.Button + diff --git a/plugins/android-compiler-plugin/testData/android/converter/simple/escapedLayoutName/main_get_VIEW.kt b/plugins/android-compiler-plugin/testData/android/converter/simple/escapedLayoutName/main_get_VIEW.kt new file mode 100644 index 00000000000..25c99b6a6c3 --- /dev/null +++ b/plugins/android-compiler-plugin/testData/android/converter/simple/escapedLayoutName/main_get_VIEW.kt @@ -0,0 +1,16 @@ +package kotlinx.android.synthetic.main.`get`.view + +import kotlin.internal.flexible.ft + +val android.view.View.item_detail_container: ft + get() = findViewById(0) as? android.widget.FrameLayout + +val android.view.View.textView1: ft + get() = findViewById(0) as? android.widget.TextView + +val android.view.View.password: ft + get() = findViewById(0) as? android.widget.EditText + +val android.view.View.login: ft + get() = findViewById(0) as? android.widget.Button + diff --git a/plugins/android-compiler-plugin/testData/android/converter/simple/fqNameInAttr/main_test_LAYOUT.kt b/plugins/android-compiler-plugin/testData/android/converter/simple/fqNameInAttr/main_test_LAYOUT.kt new file mode 100644 index 00000000000..280e96a093a --- /dev/null +++ b/plugins/android-compiler-plugin/testData/android/converter/simple/fqNameInAttr/main_test_LAYOUT.kt @@ -0,0 +1,10 @@ +package kotlinx.android.synthetic.main.test + +import kotlin.internal.flexible.ft + +val android.app.Activity.MyKeyboardView: ft + get() = findViewById(0) as? android.inputmethodservice.KeyboardView + +val android.app.Fragment.MyKeyboardView: ft + get() = getView().findViewById(0) as? android.inputmethodservice.KeyboardView + diff --git a/plugins/android-compiler-plugin/testData/android/converter/simple/fqNameInAttr/main_test_VIEW.kt b/plugins/android-compiler-plugin/testData/android/converter/simple/fqNameInAttr/main_test_VIEW.kt new file mode 100644 index 00000000000..bc3854bfaee --- /dev/null +++ b/plugins/android-compiler-plugin/testData/android/converter/simple/fqNameInAttr/main_test_VIEW.kt @@ -0,0 +1,7 @@ +package kotlinx.android.synthetic.main.test.view + +import kotlin.internal.flexible.ft + +val android.view.View.MyKeyboardView: ft + get() = findViewById(0) as? android.inputmethodservice.KeyboardView + diff --git a/plugins/android-compiler-plugin/testData/android/converter/simple/fqNameInAttr/test_LAYOUT.kt b/plugins/android-compiler-plugin/testData/android/converter/simple/fqNameInAttr/test_LAYOUT.kt index f20b57107f5..74b3059a973 100644 --- a/plugins/android-compiler-plugin/testData/android/converter/simple/fqNameInAttr/test_LAYOUT.kt +++ b/plugins/android-compiler-plugin/testData/android/converter/simple/fqNameInAttr/test_LAYOUT.kt @@ -2,9 +2,11 @@ package kotlinx.android.synthetic.test import kotlin.internal.flexible.ft +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("MyKeyboardView", "kotlinx.android.synthetic.main.test.MyKeyboardView")) val android.app.Activity.MyKeyboardView: ft get() = findViewById(0) as? android.inputmethodservice.KeyboardView +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("MyKeyboardView", "kotlinx.android.synthetic.main.test.MyKeyboardView")) val android.app.Fragment.MyKeyboardView: ft get() = getView().findViewById(0) as? android.inputmethodservice.KeyboardView diff --git a/plugins/android-compiler-plugin/testData/android/converter/simple/fqNameInAttr/test_VIEW.kt b/plugins/android-compiler-plugin/testData/android/converter/simple/fqNameInAttr/test_VIEW.kt index 13f26ddc97c..e82dcf1f9d7 100644 --- a/plugins/android-compiler-plugin/testData/android/converter/simple/fqNameInAttr/test_VIEW.kt +++ b/plugins/android-compiler-plugin/testData/android/converter/simple/fqNameInAttr/test_VIEW.kt @@ -2,6 +2,7 @@ package kotlinx.android.synthetic.test.view import kotlin.internal.flexible.ft +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("MyKeyboardView", "kotlinx.android.synthetic.main.test.view.MyKeyboardView")) val android.view.View.MyKeyboardView: ft get() = findViewById(0) as? android.inputmethodservice.KeyboardView diff --git a/plugins/android-compiler-plugin/testData/android/converter/simple/fqNameInTag/main_test_LAYOUT.kt b/plugins/android-compiler-plugin/testData/android/converter/simple/fqNameInTag/main_test_LAYOUT.kt new file mode 100644 index 00000000000..280e96a093a --- /dev/null +++ b/plugins/android-compiler-plugin/testData/android/converter/simple/fqNameInTag/main_test_LAYOUT.kt @@ -0,0 +1,10 @@ +package kotlinx.android.synthetic.main.test + +import kotlin.internal.flexible.ft + +val android.app.Activity.MyKeyboardView: ft + get() = findViewById(0) as? android.inputmethodservice.KeyboardView + +val android.app.Fragment.MyKeyboardView: ft + get() = getView().findViewById(0) as? android.inputmethodservice.KeyboardView + diff --git a/plugins/android-compiler-plugin/testData/android/converter/simple/fqNameInTag/main_test_VIEW.kt b/plugins/android-compiler-plugin/testData/android/converter/simple/fqNameInTag/main_test_VIEW.kt new file mode 100644 index 00000000000..bc3854bfaee --- /dev/null +++ b/plugins/android-compiler-plugin/testData/android/converter/simple/fqNameInTag/main_test_VIEW.kt @@ -0,0 +1,7 @@ +package kotlinx.android.synthetic.main.test.view + +import kotlin.internal.flexible.ft + +val android.view.View.MyKeyboardView: ft + get() = findViewById(0) as? android.inputmethodservice.KeyboardView + diff --git a/plugins/android-compiler-plugin/testData/android/converter/simple/fqNameInTag/test_LAYOUT.kt b/plugins/android-compiler-plugin/testData/android/converter/simple/fqNameInTag/test_LAYOUT.kt index f20b57107f5..74b3059a973 100644 --- a/plugins/android-compiler-plugin/testData/android/converter/simple/fqNameInTag/test_LAYOUT.kt +++ b/plugins/android-compiler-plugin/testData/android/converter/simple/fqNameInTag/test_LAYOUT.kt @@ -2,9 +2,11 @@ package kotlinx.android.synthetic.test import kotlin.internal.flexible.ft +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("MyKeyboardView", "kotlinx.android.synthetic.main.test.MyKeyboardView")) val android.app.Activity.MyKeyboardView: ft get() = findViewById(0) as? android.inputmethodservice.KeyboardView +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("MyKeyboardView", "kotlinx.android.synthetic.main.test.MyKeyboardView")) val android.app.Fragment.MyKeyboardView: ft get() = getView().findViewById(0) as? android.inputmethodservice.KeyboardView diff --git a/plugins/android-compiler-plugin/testData/android/converter/simple/fqNameInTag/test_VIEW.kt b/plugins/android-compiler-plugin/testData/android/converter/simple/fqNameInTag/test_VIEW.kt index 13f26ddc97c..e82dcf1f9d7 100644 --- a/plugins/android-compiler-plugin/testData/android/converter/simple/fqNameInTag/test_VIEW.kt +++ b/plugins/android-compiler-plugin/testData/android/converter/simple/fqNameInTag/test_VIEW.kt @@ -2,6 +2,7 @@ package kotlinx.android.synthetic.test.view import kotlin.internal.flexible.ft +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("MyKeyboardView", "kotlinx.android.synthetic.main.test.view.MyKeyboardView")) val android.view.View.MyKeyboardView: ft get() = findViewById(0) as? android.inputmethodservice.KeyboardView diff --git a/plugins/android-compiler-plugin/testData/android/converter/simple/layoutVariants/main_test_LAYOUT.kt b/plugins/android-compiler-plugin/testData/android/converter/simple/layoutVariants/main_test_LAYOUT.kt new file mode 100644 index 00000000000..2bdde3abf39 --- /dev/null +++ b/plugins/android-compiler-plugin/testData/android/converter/simple/layoutVariants/main_test_LAYOUT.kt @@ -0,0 +1,10 @@ +package kotlinx.android.synthetic.main.test + +import kotlin.internal.flexible.ft + +val android.app.Activity.button: ft + get() = findViewById(0) + +val android.app.Fragment.button: ft + get() = getView().findViewById(0) + diff --git a/plugins/android-compiler-plugin/testData/android/converter/simple/layoutVariants/main_test_VIEW.kt b/plugins/android-compiler-plugin/testData/android/converter/simple/layoutVariants/main_test_VIEW.kt new file mode 100644 index 00000000000..66951352c21 --- /dev/null +++ b/plugins/android-compiler-plugin/testData/android/converter/simple/layoutVariants/main_test_VIEW.kt @@ -0,0 +1,7 @@ +package kotlinx.android.synthetic.main.test.view + +import kotlin.internal.flexible.ft + +val android.view.View.button: ft + get() = findViewById(0) + diff --git a/plugins/android-compiler-plugin/testData/android/converter/simple/layoutVariants/test_LAYOUT.kt b/plugins/android-compiler-plugin/testData/android/converter/simple/layoutVariants/test_LAYOUT.kt index 11283e65d24..0a1920568b4 100644 --- a/plugins/android-compiler-plugin/testData/android/converter/simple/layoutVariants/test_LAYOUT.kt +++ b/plugins/android-compiler-plugin/testData/android/converter/simple/layoutVariants/test_LAYOUT.kt @@ -2,9 +2,11 @@ package kotlinx.android.synthetic.test import kotlin.internal.flexible.ft +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("button", "kotlinx.android.synthetic.main.test.button")) val android.app.Activity.button: ft get() = findViewById(0) +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("button", "kotlinx.android.synthetic.main.test.button")) val android.app.Fragment.button: ft get() = getView().findViewById(0) diff --git a/plugins/android-compiler-plugin/testData/android/converter/simple/layoutVariants/test_VIEW.kt b/plugins/android-compiler-plugin/testData/android/converter/simple/layoutVariants/test_VIEW.kt index 2b7a5d0bde7..7e383cd7edb 100644 --- a/plugins/android-compiler-plugin/testData/android/converter/simple/layoutVariants/test_VIEW.kt +++ b/plugins/android-compiler-plugin/testData/android/converter/simple/layoutVariants/test_VIEW.kt @@ -2,6 +2,7 @@ package kotlinx.android.synthetic.test.view import kotlin.internal.flexible.ft +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("button", "kotlinx.android.synthetic.main.test.view.button")) val android.view.View.button: ft get() = findViewById(0) diff --git a/plugins/android-compiler-plugin/testData/android/converter/simple/multiFile/main_test1_LAYOUT.kt b/plugins/android-compiler-plugin/testData/android/converter/simple/multiFile/main_test1_LAYOUT.kt new file mode 100644 index 00000000000..511a80ccf1c --- /dev/null +++ b/plugins/android-compiler-plugin/testData/android/converter/simple/multiFile/main_test1_LAYOUT.kt @@ -0,0 +1,28 @@ +package kotlinx.android.synthetic.main.test1 + +import kotlin.internal.flexible.ft + +val android.app.Activity.frameLayout: ft + get() = findViewById(0) as? android.widget.FrameLayout + +val android.app.Fragment.frameLayout: ft + get() = getView().findViewById(0) as? android.widget.FrameLayout + +val android.app.Activity.passwordField: ft + get() = findViewById(0) as? android.widget.TextView + +val android.app.Fragment.passwordField: ft + get() = getView().findViewById(0) as? android.widget.TextView + +val android.app.Activity.passwordCaption: ft + get() = findViewById(0) as? android.widget.EditText + +val android.app.Fragment.passwordCaption: ft + get() = getView().findViewById(0) as? android.widget.EditText + +val android.app.Activity.loginButton: ft + get() = findViewById(0) as? android.widget.Button + +val android.app.Fragment.loginButton: ft + get() = getView().findViewById(0) as? android.widget.Button + diff --git a/plugins/android-compiler-plugin/testData/android/converter/simple/multiFile/main_test1_VIEW.kt b/plugins/android-compiler-plugin/testData/android/converter/simple/multiFile/main_test1_VIEW.kt new file mode 100644 index 00000000000..4fa5ec995e2 --- /dev/null +++ b/plugins/android-compiler-plugin/testData/android/converter/simple/multiFile/main_test1_VIEW.kt @@ -0,0 +1,16 @@ +package kotlinx.android.synthetic.main.test1.view + +import kotlin.internal.flexible.ft + +val android.view.View.frameLayout: ft + get() = findViewById(0) as? android.widget.FrameLayout + +val android.view.View.passwordField: ft + get() = findViewById(0) as? android.widget.TextView + +val android.view.View.passwordCaption: ft + get() = findViewById(0) as? android.widget.EditText + +val android.view.View.loginButton: ft + get() = findViewById(0) as? android.widget.Button + diff --git a/plugins/android-compiler-plugin/testData/android/converter/simple/multiFile/main_test_LAYOUT.kt b/plugins/android-compiler-plugin/testData/android/converter/simple/multiFile/main_test_LAYOUT.kt new file mode 100644 index 00000000000..3b45041d49b --- /dev/null +++ b/plugins/android-compiler-plugin/testData/android/converter/simple/multiFile/main_test_LAYOUT.kt @@ -0,0 +1,28 @@ +package kotlinx.android.synthetic.main.test + +import kotlin.internal.flexible.ft + +val android.app.Activity.item_detail_container: ft + get() = findViewById(0) as? android.widget.FrameLayout + +val android.app.Fragment.item_detail_container: ft + get() = getView().findViewById(0) as? android.widget.FrameLayout + +val android.app.Activity.textView1: ft + get() = findViewById(0) as? android.widget.TextView + +val android.app.Fragment.textView1: ft + get() = getView().findViewById(0) as? android.widget.TextView + +val android.app.Activity.password: ft + get() = findViewById(0) as? android.widget.EditText + +val android.app.Fragment.password: ft + get() = getView().findViewById(0) as? android.widget.EditText + +val android.app.Activity.login: ft + get() = findViewById(0) as? android.widget.Button + +val android.app.Fragment.login: ft + get() = getView().findViewById(0) as? android.widget.Button + diff --git a/plugins/android-compiler-plugin/testData/android/converter/simple/multiFile/main_test_VIEW.kt b/plugins/android-compiler-plugin/testData/android/converter/simple/multiFile/main_test_VIEW.kt new file mode 100644 index 00000000000..0fb8eba2243 --- /dev/null +++ b/plugins/android-compiler-plugin/testData/android/converter/simple/multiFile/main_test_VIEW.kt @@ -0,0 +1,16 @@ +package kotlinx.android.synthetic.main.test.view + +import kotlin.internal.flexible.ft + +val android.view.View.item_detail_container: ft + get() = findViewById(0) as? android.widget.FrameLayout + +val android.view.View.textView1: ft + get() = findViewById(0) as? android.widget.TextView + +val android.view.View.password: ft + get() = findViewById(0) as? android.widget.EditText + +val android.view.View.login: ft + get() = findViewById(0) as? android.widget.Button + diff --git a/plugins/android-compiler-plugin/testData/android/converter/simple/multiFile/test1_LAYOUT.kt b/plugins/android-compiler-plugin/testData/android/converter/simple/multiFile/test1_LAYOUT.kt index b5b154cde40..d8e00f7f52d 100644 --- a/plugins/android-compiler-plugin/testData/android/converter/simple/multiFile/test1_LAYOUT.kt +++ b/plugins/android-compiler-plugin/testData/android/converter/simple/multiFile/test1_LAYOUT.kt @@ -2,27 +2,35 @@ package kotlinx.android.synthetic.test1 import kotlin.internal.flexible.ft +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("frameLayout", "kotlinx.android.synthetic.main.test1.frameLayout")) val android.app.Activity.frameLayout: ft get() = findViewById(0) as? android.widget.FrameLayout +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("frameLayout", "kotlinx.android.synthetic.main.test1.frameLayout")) val android.app.Fragment.frameLayout: ft get() = getView().findViewById(0) as? android.widget.FrameLayout +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("passwordField", "kotlinx.android.synthetic.main.test1.passwordField")) val android.app.Activity.passwordField: ft get() = findViewById(0) as? android.widget.TextView +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("passwordField", "kotlinx.android.synthetic.main.test1.passwordField")) val android.app.Fragment.passwordField: ft get() = getView().findViewById(0) as? android.widget.TextView +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("passwordCaption", "kotlinx.android.synthetic.main.test1.passwordCaption")) val android.app.Activity.passwordCaption: ft get() = findViewById(0) as? android.widget.EditText +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("passwordCaption", "kotlinx.android.synthetic.main.test1.passwordCaption")) val android.app.Fragment.passwordCaption: ft get() = getView().findViewById(0) as? android.widget.EditText +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("loginButton", "kotlinx.android.synthetic.main.test1.loginButton")) val android.app.Activity.loginButton: ft get() = findViewById(0) as? android.widget.Button +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("loginButton", "kotlinx.android.synthetic.main.test1.loginButton")) val android.app.Fragment.loginButton: ft get() = getView().findViewById(0) as? android.widget.Button diff --git a/plugins/android-compiler-plugin/testData/android/converter/simple/multiFile/test1_VIEW.kt b/plugins/android-compiler-plugin/testData/android/converter/simple/multiFile/test1_VIEW.kt index 9df93aececa..100a711fa36 100644 --- a/plugins/android-compiler-plugin/testData/android/converter/simple/multiFile/test1_VIEW.kt +++ b/plugins/android-compiler-plugin/testData/android/converter/simple/multiFile/test1_VIEW.kt @@ -2,15 +2,19 @@ package kotlinx.android.synthetic.test1.view import kotlin.internal.flexible.ft +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("frameLayout", "kotlinx.android.synthetic.main.test1.view.frameLayout")) val android.view.View.frameLayout: ft get() = findViewById(0) as? android.widget.FrameLayout +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("passwordField", "kotlinx.android.synthetic.main.test1.view.passwordField")) val android.view.View.passwordField: ft get() = findViewById(0) as? android.widget.TextView +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("passwordCaption", "kotlinx.android.synthetic.main.test1.view.passwordCaption")) val android.view.View.passwordCaption: ft get() = findViewById(0) as? android.widget.EditText +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("loginButton", "kotlinx.android.synthetic.main.test1.view.loginButton")) val android.view.View.loginButton: ft get() = findViewById(0) as? android.widget.Button diff --git a/plugins/android-compiler-plugin/testData/android/converter/simple/multiFile/test_LAYOUT.kt b/plugins/android-compiler-plugin/testData/android/converter/simple/multiFile/test_LAYOUT.kt index 7039f391193..66df9759e20 100644 --- a/plugins/android-compiler-plugin/testData/android/converter/simple/multiFile/test_LAYOUT.kt +++ b/plugins/android-compiler-plugin/testData/android/converter/simple/multiFile/test_LAYOUT.kt @@ -2,27 +2,35 @@ package kotlinx.android.synthetic.test import kotlin.internal.flexible.ft +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("item_detail_container", "kotlinx.android.synthetic.main.test.item_detail_container")) val android.app.Activity.item_detail_container: ft get() = findViewById(0) as? android.widget.FrameLayout +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("item_detail_container", "kotlinx.android.synthetic.main.test.item_detail_container")) val android.app.Fragment.item_detail_container: ft get() = getView().findViewById(0) as? android.widget.FrameLayout +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("textView1", "kotlinx.android.synthetic.main.test.textView1")) val android.app.Activity.textView1: ft get() = findViewById(0) as? android.widget.TextView +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("textView1", "kotlinx.android.synthetic.main.test.textView1")) val android.app.Fragment.textView1: ft get() = getView().findViewById(0) as? android.widget.TextView +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("password", "kotlinx.android.synthetic.main.test.password")) val android.app.Activity.password: ft get() = findViewById(0) as? android.widget.EditText +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("password", "kotlinx.android.synthetic.main.test.password")) val android.app.Fragment.password: ft get() = getView().findViewById(0) as? android.widget.EditText +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("login", "kotlinx.android.synthetic.main.test.login")) val android.app.Activity.login: ft get() = findViewById(0) as? android.widget.Button +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("login", "kotlinx.android.synthetic.main.test.login")) val android.app.Fragment.login: ft get() = getView().findViewById(0) as? android.widget.Button diff --git a/plugins/android-compiler-plugin/testData/android/converter/simple/multiFile/test_VIEW.kt b/plugins/android-compiler-plugin/testData/android/converter/simple/multiFile/test_VIEW.kt index ef8008030e2..843a3f4d100 100644 --- a/plugins/android-compiler-plugin/testData/android/converter/simple/multiFile/test_VIEW.kt +++ b/plugins/android-compiler-plugin/testData/android/converter/simple/multiFile/test_VIEW.kt @@ -2,15 +2,19 @@ package kotlinx.android.synthetic.test.view import kotlin.internal.flexible.ft +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("item_detail_container", "kotlinx.android.synthetic.main.test.view.item_detail_container")) val android.view.View.item_detail_container: ft get() = findViewById(0) as? android.widget.FrameLayout +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("textView1", "kotlinx.android.synthetic.main.test.view.textView1")) val android.view.View.textView1: ft get() = findViewById(0) as? android.widget.TextView +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("password", "kotlinx.android.synthetic.main.test.view.password")) val android.view.View.password: ft get() = findViewById(0) as? android.widget.EditText +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("login", "kotlinx.android.synthetic.main.test.view.login")) val android.view.View.login: ft get() = findViewById(0) as? android.widget.Button diff --git a/plugins/android-compiler-plugin/testData/android/converter/simple/noIds/main_test_LAYOUT.kt b/plugins/android-compiler-plugin/testData/android/converter/simple/noIds/main_test_LAYOUT.kt new file mode 100644 index 00000000000..da2de470e96 --- /dev/null +++ b/plugins/android-compiler-plugin/testData/android/converter/simple/noIds/main_test_LAYOUT.kt @@ -0,0 +1,4 @@ +package kotlinx.android.synthetic.main.test + +import kotlin.internal.flexible.ft + diff --git a/plugins/android-compiler-plugin/testData/android/converter/simple/noIds/main_test_VIEW.kt b/plugins/android-compiler-plugin/testData/android/converter/simple/noIds/main_test_VIEW.kt new file mode 100644 index 00000000000..5d9446d276a --- /dev/null +++ b/plugins/android-compiler-plugin/testData/android/converter/simple/noIds/main_test_VIEW.kt @@ -0,0 +1,4 @@ +package kotlinx.android.synthetic.main.test.view + +import kotlin.internal.flexible.ft + diff --git a/plugins/android-compiler-plugin/testData/android/converter/simple/sameIds/main_test_LAYOUT.kt b/plugins/android-compiler-plugin/testData/android/converter/simple/sameIds/main_test_LAYOUT.kt new file mode 100644 index 00000000000..975b70661ed --- /dev/null +++ b/plugins/android-compiler-plugin/testData/android/converter/simple/sameIds/main_test_LAYOUT.kt @@ -0,0 +1,16 @@ +package kotlinx.android.synthetic.main.test + +import kotlin.internal.flexible.ft + +val android.app.Activity.textView1: ft + get() = findViewById(0) + +val android.app.Fragment.textView1: ft + get() = getView().findViewById(0) + +val android.app.Activity.textView2: ft + get() = findViewById(0) as? android.widget.TextView + +val android.app.Fragment.textView2: ft + get() = getView().findViewById(0) as? android.widget.TextView + diff --git a/plugins/android-compiler-plugin/testData/android/converter/simple/sameIds/main_test_VIEW.kt b/plugins/android-compiler-plugin/testData/android/converter/simple/sameIds/main_test_VIEW.kt new file mode 100644 index 00000000000..8faa7179607 --- /dev/null +++ b/plugins/android-compiler-plugin/testData/android/converter/simple/sameIds/main_test_VIEW.kt @@ -0,0 +1,10 @@ +package kotlinx.android.synthetic.main.test.view + +import kotlin.internal.flexible.ft + +val android.view.View.textView1: ft + get() = findViewById(0) + +val android.view.View.textView2: ft + get() = findViewById(0) as? android.widget.TextView + diff --git a/plugins/android-compiler-plugin/testData/android/converter/simple/sameIds/test_LAYOUT.kt b/plugins/android-compiler-plugin/testData/android/converter/simple/sameIds/test_LAYOUT.kt index 35ba2197c3a..a96febcf40d 100644 --- a/plugins/android-compiler-plugin/testData/android/converter/simple/sameIds/test_LAYOUT.kt +++ b/plugins/android-compiler-plugin/testData/android/converter/simple/sameIds/test_LAYOUT.kt @@ -2,15 +2,19 @@ package kotlinx.android.synthetic.test import kotlin.internal.flexible.ft +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("textView1", "kotlinx.android.synthetic.main.test.textView1")) val android.app.Activity.textView1: ft get() = findViewById(0) +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("textView1", "kotlinx.android.synthetic.main.test.textView1")) val android.app.Fragment.textView1: ft get() = getView().findViewById(0) +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("textView2", "kotlinx.android.synthetic.main.test.textView2")) val android.app.Activity.textView2: ft get() = findViewById(0) as? android.widget.TextView +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("textView2", "kotlinx.android.synthetic.main.test.textView2")) val android.app.Fragment.textView2: ft get() = getView().findViewById(0) as? android.widget.TextView diff --git a/plugins/android-compiler-plugin/testData/android/converter/simple/sameIds/test_VIEW.kt b/plugins/android-compiler-plugin/testData/android/converter/simple/sameIds/test_VIEW.kt index e44723f7b7c..7bdb95d4734 100644 --- a/plugins/android-compiler-plugin/testData/android/converter/simple/sameIds/test_VIEW.kt +++ b/plugins/android-compiler-plugin/testData/android/converter/simple/sameIds/test_VIEW.kt @@ -2,9 +2,11 @@ package kotlinx.android.synthetic.test.view import kotlin.internal.flexible.ft +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("textView1", "kotlinx.android.synthetic.main.test.view.textView1")) val android.view.View.textView1: ft get() = findViewById(0) +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("textView2", "kotlinx.android.synthetic.main.test.view.textView2")) val android.view.View.textView2: ft get() = findViewById(0) as? android.widget.TextView diff --git a/plugins/android-compiler-plugin/testData/android/converter/simple/severalResDirs/main_test_LAYOUT.kt b/plugins/android-compiler-plugin/testData/android/converter/simple/severalResDirs/main_test_LAYOUT.kt new file mode 100644 index 00000000000..df92ecadac8 --- /dev/null +++ b/plugins/android-compiler-plugin/testData/android/converter/simple/severalResDirs/main_test_LAYOUT.kt @@ -0,0 +1,22 @@ +package kotlinx.android.synthetic.main.test + +import kotlin.internal.flexible.ft + +val android.app.Activity.button: ft + get() = findViewById(0) + +val android.app.Fragment.button: ft + get() = getView().findViewById(0) + +val android.app.Activity.button2: ft + get() = findViewById(0) as? android.widget.Button + +val android.app.Fragment.button2: ft + get() = getView().findViewById(0) as? android.widget.Button + +val android.app.Activity.button3: ft + get() = findViewById(0) as? android.widget.Button + +val android.app.Fragment.button3: ft + get() = getView().findViewById(0) as? android.widget.Button + diff --git a/plugins/android-compiler-plugin/testData/android/converter/simple/severalResDirs/main_test_VIEW.kt b/plugins/android-compiler-plugin/testData/android/converter/simple/severalResDirs/main_test_VIEW.kt new file mode 100644 index 00000000000..ed81da95ea4 --- /dev/null +++ b/plugins/android-compiler-plugin/testData/android/converter/simple/severalResDirs/main_test_VIEW.kt @@ -0,0 +1,13 @@ +package kotlinx.android.synthetic.main.test.view + +import kotlin.internal.flexible.ft + +val android.view.View.button: ft + get() = findViewById(0) + +val android.view.View.button2: ft + get() = findViewById(0) as? android.widget.Button + +val android.view.View.button3: ft + get() = findViewById(0) as? android.widget.Button + diff --git a/plugins/android-compiler-plugin/testData/android/converter/simple/severalResDirs/test_LAYOUT.kt b/plugins/android-compiler-plugin/testData/android/converter/simple/severalResDirs/test_LAYOUT.kt index acdb6f93efb..4dc525e9417 100644 --- a/plugins/android-compiler-plugin/testData/android/converter/simple/severalResDirs/test_LAYOUT.kt +++ b/plugins/android-compiler-plugin/testData/android/converter/simple/severalResDirs/test_LAYOUT.kt @@ -2,21 +2,27 @@ package kotlinx.android.synthetic.test import kotlin.internal.flexible.ft +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("button", "kotlinx.android.synthetic.main.test.button")) val android.app.Activity.button: ft get() = findViewById(0) +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("button", "kotlinx.android.synthetic.main.test.button")) val android.app.Fragment.button: ft get() = getView().findViewById(0) +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("button2", "kotlinx.android.synthetic.main.test.button2")) val android.app.Activity.button2: ft get() = findViewById(0) as? android.widget.Button +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("button2", "kotlinx.android.synthetic.main.test.button2")) val android.app.Fragment.button2: ft get() = getView().findViewById(0) as? android.widget.Button +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("button3", "kotlinx.android.synthetic.main.test.button3")) val android.app.Activity.button3: ft get() = findViewById(0) as? android.widget.Button +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("button3", "kotlinx.android.synthetic.main.test.button3")) val android.app.Fragment.button3: ft get() = getView().findViewById(0) as? android.widget.Button diff --git a/plugins/android-compiler-plugin/testData/android/converter/simple/severalResDirs/test_VIEW.kt b/plugins/android-compiler-plugin/testData/android/converter/simple/severalResDirs/test_VIEW.kt index f63faf48685..c4b377a6b37 100644 --- a/plugins/android-compiler-plugin/testData/android/converter/simple/severalResDirs/test_VIEW.kt +++ b/plugins/android-compiler-plugin/testData/android/converter/simple/severalResDirs/test_VIEW.kt @@ -2,12 +2,15 @@ package kotlinx.android.synthetic.test.view import kotlin.internal.flexible.ft +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("button", "kotlinx.android.synthetic.main.test.view.button")) val android.view.View.button: ft get() = findViewById(0) +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("button2", "kotlinx.android.synthetic.main.test.view.button2")) val android.view.View.button2: ft get() = findViewById(0) as? android.widget.Button +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("button3", "kotlinx.android.synthetic.main.test.view.button3")) val android.view.View.button3: ft get() = findViewById(0) as? android.widget.Button diff --git a/plugins/android-compiler-plugin/testData/android/converter/simple/singleFile/main_test_LAYOUT.kt b/plugins/android-compiler-plugin/testData/android/converter/simple/singleFile/main_test_LAYOUT.kt new file mode 100644 index 00000000000..3b45041d49b --- /dev/null +++ b/plugins/android-compiler-plugin/testData/android/converter/simple/singleFile/main_test_LAYOUT.kt @@ -0,0 +1,28 @@ +package kotlinx.android.synthetic.main.test + +import kotlin.internal.flexible.ft + +val android.app.Activity.item_detail_container: ft + get() = findViewById(0) as? android.widget.FrameLayout + +val android.app.Fragment.item_detail_container: ft + get() = getView().findViewById(0) as? android.widget.FrameLayout + +val android.app.Activity.textView1: ft + get() = findViewById(0) as? android.widget.TextView + +val android.app.Fragment.textView1: ft + get() = getView().findViewById(0) as? android.widget.TextView + +val android.app.Activity.password: ft + get() = findViewById(0) as? android.widget.EditText + +val android.app.Fragment.password: ft + get() = getView().findViewById(0) as? android.widget.EditText + +val android.app.Activity.login: ft + get() = findViewById(0) as? android.widget.Button + +val android.app.Fragment.login: ft + get() = getView().findViewById(0) as? android.widget.Button + diff --git a/plugins/android-compiler-plugin/testData/android/converter/simple/singleFile/main_test_VIEW.kt b/plugins/android-compiler-plugin/testData/android/converter/simple/singleFile/main_test_VIEW.kt new file mode 100644 index 00000000000..0fb8eba2243 --- /dev/null +++ b/plugins/android-compiler-plugin/testData/android/converter/simple/singleFile/main_test_VIEW.kt @@ -0,0 +1,16 @@ +package kotlinx.android.synthetic.main.test.view + +import kotlin.internal.flexible.ft + +val android.view.View.item_detail_container: ft + get() = findViewById(0) as? android.widget.FrameLayout + +val android.view.View.textView1: ft + get() = findViewById(0) as? android.widget.TextView + +val android.view.View.password: ft + get() = findViewById(0) as? android.widget.EditText + +val android.view.View.login: ft + get() = findViewById(0) as? android.widget.Button + diff --git a/plugins/android-compiler-plugin/testData/android/converter/simple/singleFile/test_LAYOUT.kt b/plugins/android-compiler-plugin/testData/android/converter/simple/singleFile/test_LAYOUT.kt index 7039f391193..66df9759e20 100644 --- a/plugins/android-compiler-plugin/testData/android/converter/simple/singleFile/test_LAYOUT.kt +++ b/plugins/android-compiler-plugin/testData/android/converter/simple/singleFile/test_LAYOUT.kt @@ -2,27 +2,35 @@ package kotlinx.android.synthetic.test import kotlin.internal.flexible.ft +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("item_detail_container", "kotlinx.android.synthetic.main.test.item_detail_container")) val android.app.Activity.item_detail_container: ft get() = findViewById(0) as? android.widget.FrameLayout +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("item_detail_container", "kotlinx.android.synthetic.main.test.item_detail_container")) val android.app.Fragment.item_detail_container: ft get() = getView().findViewById(0) as? android.widget.FrameLayout +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("textView1", "kotlinx.android.synthetic.main.test.textView1")) val android.app.Activity.textView1: ft get() = findViewById(0) as? android.widget.TextView +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("textView1", "kotlinx.android.synthetic.main.test.textView1")) val android.app.Fragment.textView1: ft get() = getView().findViewById(0) as? android.widget.TextView +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("password", "kotlinx.android.synthetic.main.test.password")) val android.app.Activity.password: ft get() = findViewById(0) as? android.widget.EditText +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("password", "kotlinx.android.synthetic.main.test.password")) val android.app.Fragment.password: ft get() = getView().findViewById(0) as? android.widget.EditText +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("login", "kotlinx.android.synthetic.main.test.login")) val android.app.Activity.login: ft get() = findViewById(0) as? android.widget.Button +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("login", "kotlinx.android.synthetic.main.test.login")) val android.app.Fragment.login: ft get() = getView().findViewById(0) as? android.widget.Button diff --git a/plugins/android-compiler-plugin/testData/android/converter/simple/singleFile/test_VIEW.kt b/plugins/android-compiler-plugin/testData/android/converter/simple/singleFile/test_VIEW.kt index ef8008030e2..843a3f4d100 100644 --- a/plugins/android-compiler-plugin/testData/android/converter/simple/singleFile/test_VIEW.kt +++ b/plugins/android-compiler-plugin/testData/android/converter/simple/singleFile/test_VIEW.kt @@ -2,15 +2,19 @@ package kotlinx.android.synthetic.test.view import kotlin.internal.flexible.ft +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("item_detail_container", "kotlinx.android.synthetic.main.test.view.item_detail_container")) val android.view.View.item_detail_container: ft get() = findViewById(0) as? android.widget.FrameLayout +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("textView1", "kotlinx.android.synthetic.main.test.view.textView1")) val android.view.View.textView1: ft get() = findViewById(0) as? android.widget.TextView +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("password", "kotlinx.android.synthetic.main.test.view.password")) val android.view.View.password: ft get() = findViewById(0) as? android.widget.EditText +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("login", "kotlinx.android.synthetic.main.test.view.login")) val android.view.View.login: ft get() = findViewById(0) as? android.widget.Button diff --git a/plugins/android-compiler-plugin/testData/android/converter/simple/specialTags/main_test_LAYOUT.kt b/plugins/android-compiler-plugin/testData/android/converter/simple/specialTags/main_test_LAYOUT.kt new file mode 100644 index 00000000000..dd50b25fb64 --- /dev/null +++ b/plugins/android-compiler-plugin/testData/android/converter/simple/specialTags/main_test_LAYOUT.kt @@ -0,0 +1,28 @@ +package kotlinx.android.synthetic.main.test + +import kotlin.internal.flexible.ft + +val android.app.Activity.includeTag: ft + get() = findViewById(0) + +val android.app.Fragment.includeTag: ft + get() = getView().findViewById(0) + +val android.app.Activity.fragmentTag: ft + get() = getFragmentManager().findFragmentById(0) as? android.app.Fragment + +val android.app.Fragment.fragmentTag: ft + get() = getFragmentManager().findFragmentById(0) as? android.app.Fragment + +val android.app.Activity.`fun`: ft + get() = findViewById(0) as? android.widget.TextView + +val android.app.Fragment.`fun`: ft + get() = getView().findViewById(0) as? android.widget.TextView + +val android.app.Activity.`set`: ft + get() = findViewById(0) as? android.widget.Button + +val android.app.Fragment.`set`: ft + get() = getView().findViewById(0) as? android.widget.Button + diff --git a/plugins/android-compiler-plugin/testData/android/converter/simple/specialTags/main_test_VIEW.kt b/plugins/android-compiler-plugin/testData/android/converter/simple/specialTags/main_test_VIEW.kt new file mode 100644 index 00000000000..3bdc07352bd --- /dev/null +++ b/plugins/android-compiler-plugin/testData/android/converter/simple/specialTags/main_test_VIEW.kt @@ -0,0 +1,13 @@ +package kotlinx.android.synthetic.main.test.view + +import kotlin.internal.flexible.ft + +val android.view.View.includeTag: ft + get() = findViewById(0) + +val android.view.View.`fun`: ft + get() = findViewById(0) as? android.widget.TextView + +val android.view.View.`set`: ft + get() = findViewById(0) as? android.widget.Button + diff --git a/plugins/android-compiler-plugin/testData/android/converter/simple/specialTags/test_LAYOUT.kt b/plugins/android-compiler-plugin/testData/android/converter/simple/specialTags/test_LAYOUT.kt index 1a033f42069..91f43dc26bf 100644 --- a/plugins/android-compiler-plugin/testData/android/converter/simple/specialTags/test_LAYOUT.kt +++ b/plugins/android-compiler-plugin/testData/android/converter/simple/specialTags/test_LAYOUT.kt @@ -2,27 +2,35 @@ package kotlinx.android.synthetic.test import kotlin.internal.flexible.ft +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("includeTag", "kotlinx.android.synthetic.main.test.includeTag")) val android.app.Activity.includeTag: ft get() = findViewById(0) +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("includeTag", "kotlinx.android.synthetic.main.test.includeTag")) val android.app.Fragment.includeTag: ft get() = getView().findViewById(0) +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("fragmentTag", "kotlinx.android.synthetic.main.test.fragmentTag")) val android.app.Activity.fragmentTag: ft get() = getFragmentManager().findFragmentById(0) as? android.app.Fragment +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("fragmentTag", "kotlinx.android.synthetic.main.test.fragmentTag")) val android.app.Fragment.fragmentTag: ft get() = getFragmentManager().findFragmentById(0) as? android.app.Fragment +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("`fun`", "kotlinx.android.synthetic.main.test.`fun`")) val android.app.Activity.`fun`: ft get() = findViewById(0) as? android.widget.TextView +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("`fun`", "kotlinx.android.synthetic.main.test.`fun`")) val android.app.Fragment.`fun`: ft get() = getView().findViewById(0) as? android.widget.TextView +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("`set`", "kotlinx.android.synthetic.main.test.`set`")) val android.app.Activity.`set`: ft get() = findViewById(0) as? android.widget.Button +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("`set`", "kotlinx.android.synthetic.main.test.`set`")) val android.app.Fragment.`set`: ft get() = getView().findViewById(0) as? android.widget.Button diff --git a/plugins/android-compiler-plugin/testData/android/converter/simple/specialTags/test_VIEW.kt b/plugins/android-compiler-plugin/testData/android/converter/simple/specialTags/test_VIEW.kt index b731bbe8620..68e55ae91a5 100644 --- a/plugins/android-compiler-plugin/testData/android/converter/simple/specialTags/test_VIEW.kt +++ b/plugins/android-compiler-plugin/testData/android/converter/simple/specialTags/test_VIEW.kt @@ -2,12 +2,15 @@ package kotlinx.android.synthetic.test.view import kotlin.internal.flexible.ft +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("includeTag", "kotlinx.android.synthetic.main.test.view.includeTag")) val android.view.View.includeTag: ft get() = findViewById(0) +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("`fun`", "kotlinx.android.synthetic.main.test.view.`fun`")) val android.view.View.`fun`: ft get() = findViewById(0) as? android.widget.TextView +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("`set`", "kotlinx.android.synthetic.main.test.view.`set`")) val android.view.View.`set`: ft get() = findViewById(0) as? android.widget.Button diff --git a/plugins/android-compiler-plugin/testData/android/converter/simple/supportSingleFile/main_test_LAYOUT.kt b/plugins/android-compiler-plugin/testData/android/converter/simple/supportSingleFile/main_test_LAYOUT.kt new file mode 100644 index 00000000000..0328c5f98a5 --- /dev/null +++ b/plugins/android-compiler-plugin/testData/android/converter/simple/supportSingleFile/main_test_LAYOUT.kt @@ -0,0 +1,40 @@ +package kotlinx.android.synthetic.main.test + +import kotlin.internal.flexible.ft + +val android.app.Activity.item_detail_container: ft + get() = findViewById(0) as? android.widget.FrameLayout + +val android.app.Fragment.item_detail_container: ft + get() = getView().findViewById(0) as? android.widget.FrameLayout + +val android.support.v4.app.Fragment.item_detail_container: ft + get() = getView().findViewById(0) as? android.widget.FrameLayout + +val android.app.Activity.textView1: ft + get() = findViewById(0) as? android.widget.TextView + +val android.app.Fragment.textView1: ft + get() = getView().findViewById(0) as? android.widget.TextView + +val android.support.v4.app.Fragment.textView1: ft + get() = getView().findViewById(0) as? android.widget.TextView + +val android.app.Activity.password: ft + get() = findViewById(0) as? android.widget.EditText + +val android.app.Fragment.password: ft + get() = getView().findViewById(0) as? android.widget.EditText + +val android.support.v4.app.Fragment.password: ft + get() = getView().findViewById(0) as? android.widget.EditText + +val android.app.Activity.login: ft + get() = findViewById(0) as? android.widget.Button + +val android.app.Fragment.login: ft + get() = getView().findViewById(0) as? android.widget.Button + +val android.support.v4.app.Fragment.login: ft + get() = getView().findViewById(0) as? android.widget.Button + diff --git a/plugins/android-compiler-plugin/testData/android/converter/simple/supportSingleFile/main_test_VIEW.kt b/plugins/android-compiler-plugin/testData/android/converter/simple/supportSingleFile/main_test_VIEW.kt new file mode 100644 index 00000000000..0fb8eba2243 --- /dev/null +++ b/plugins/android-compiler-plugin/testData/android/converter/simple/supportSingleFile/main_test_VIEW.kt @@ -0,0 +1,16 @@ +package kotlinx.android.synthetic.main.test.view + +import kotlin.internal.flexible.ft + +val android.view.View.item_detail_container: ft + get() = findViewById(0) as? android.widget.FrameLayout + +val android.view.View.textView1: ft + get() = findViewById(0) as? android.widget.TextView + +val android.view.View.password: ft + get() = findViewById(0) as? android.widget.EditText + +val android.view.View.login: ft + get() = findViewById(0) as? android.widget.Button + diff --git a/plugins/android-compiler-plugin/testData/android/converter/simple/supportSingleFile/test_LAYOUT.kt b/plugins/android-compiler-plugin/testData/android/converter/simple/supportSingleFile/test_LAYOUT.kt index de9bdc93bce..65f43d66b84 100644 --- a/plugins/android-compiler-plugin/testData/android/converter/simple/supportSingleFile/test_LAYOUT.kt +++ b/plugins/android-compiler-plugin/testData/android/converter/simple/supportSingleFile/test_LAYOUT.kt @@ -2,39 +2,51 @@ package kotlinx.android.synthetic.test import kotlin.internal.flexible.ft +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("item_detail_container", "kotlinx.android.synthetic.main.test.item_detail_container")) val android.app.Activity.item_detail_container: ft get() = findViewById(0) as? android.widget.FrameLayout +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("item_detail_container", "kotlinx.android.synthetic.main.test.item_detail_container")) val android.app.Fragment.item_detail_container: ft get() = getView().findViewById(0) as? android.widget.FrameLayout +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("item_detail_container", "kotlinx.android.synthetic.main.test.item_detail_container")) val android.support.v4.app.Fragment.item_detail_container: ft get() = getView().findViewById(0) as? android.widget.FrameLayout +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("textView1", "kotlinx.android.synthetic.main.test.textView1")) val android.app.Activity.textView1: ft get() = findViewById(0) as? android.widget.TextView +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("textView1", "kotlinx.android.synthetic.main.test.textView1")) val android.app.Fragment.textView1: ft get() = getView().findViewById(0) as? android.widget.TextView +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("textView1", "kotlinx.android.synthetic.main.test.textView1")) val android.support.v4.app.Fragment.textView1: ft get() = getView().findViewById(0) as? android.widget.TextView +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("password", "kotlinx.android.synthetic.main.test.password")) val android.app.Activity.password: ft get() = findViewById(0) as? android.widget.EditText +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("password", "kotlinx.android.synthetic.main.test.password")) val android.app.Fragment.password: ft get() = getView().findViewById(0) as? android.widget.EditText +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("password", "kotlinx.android.synthetic.main.test.password")) val android.support.v4.app.Fragment.password: ft get() = getView().findViewById(0) as? android.widget.EditText +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("login", "kotlinx.android.synthetic.main.test.login")) val android.app.Activity.login: ft get() = findViewById(0) as? android.widget.Button +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("login", "kotlinx.android.synthetic.main.test.login")) val android.app.Fragment.login: ft get() = getView().findViewById(0) as? android.widget.Button +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("login", "kotlinx.android.synthetic.main.test.login")) val android.support.v4.app.Fragment.login: ft get() = getView().findViewById(0) as? android.widget.Button diff --git a/plugins/android-compiler-plugin/testData/android/converter/simple/supportSingleFile/test_VIEW.kt b/plugins/android-compiler-plugin/testData/android/converter/simple/supportSingleFile/test_VIEW.kt index ef8008030e2..843a3f4d100 100644 --- a/plugins/android-compiler-plugin/testData/android/converter/simple/supportSingleFile/test_VIEW.kt +++ b/plugins/android-compiler-plugin/testData/android/converter/simple/supportSingleFile/test_VIEW.kt @@ -2,15 +2,19 @@ package kotlinx.android.synthetic.test.view import kotlin.internal.flexible.ft +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("item_detail_container", "kotlinx.android.synthetic.main.test.view.item_detail_container")) val android.view.View.item_detail_container: ft get() = findViewById(0) as? android.widget.FrameLayout +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("textView1", "kotlinx.android.synthetic.main.test.view.textView1")) val android.view.View.textView1: ft get() = findViewById(0) as? android.widget.TextView +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("password", "kotlinx.android.synthetic.main.test.view.password")) val android.view.View.password: ft get() = findViewById(0) as? android.widget.EditText +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("login", "kotlinx.android.synthetic.main.test.view.login")) val android.view.View.login: ft get() = findViewById(0) as? android.widget.Button diff --git a/plugins/android-compiler-plugin/testData/android/converter/simple/supportSpecialTags/main_test_LAYOUT.kt b/plugins/android-compiler-plugin/testData/android/converter/simple/supportSpecialTags/main_test_LAYOUT.kt new file mode 100644 index 00000000000..6d81bcde0a5 --- /dev/null +++ b/plugins/android-compiler-plugin/testData/android/converter/simple/supportSpecialTags/main_test_LAYOUT.kt @@ -0,0 +1,43 @@ +package kotlinx.android.synthetic.main.test + +import kotlin.internal.flexible.ft + +val android.app.Activity.includeTag: ft + get() = findViewById(0) + +val android.app.Fragment.includeTag: ft + get() = getView().findViewById(0) + +val android.support.v4.app.Fragment.includeTag: ft + get() = getView().findViewById(0) + +val android.app.Activity.fragmentTag: ft + get() = getFragmentManager().findFragmentById(0) as? android.app.Fragment + +val android.app.Fragment.fragmentTag: ft + get() = getFragmentManager().findFragmentById(0) as? android.app.Fragment + +val android.support.v4.app.Fragment.fragmentTag: ft + get() = getFragmentManager().findFragmentById(0) as? android.support.v4.app.Fragment + +val android.support.v4.app.FragmentActivity.fragmentTag: ft + get() = getSupportFragmentManager().findFragmentById(0) as? android.support.v4.app.Fragment + +val android.app.Activity.`fun`: ft + get() = findViewById(0) as? android.widget.TextView + +val android.app.Fragment.`fun`: ft + get() = getView().findViewById(0) as? android.widget.TextView + +val android.support.v4.app.Fragment.`fun`: ft + get() = getView().findViewById(0) as? android.widget.TextView + +val android.app.Activity.`set`: ft + get() = findViewById(0) as? android.widget.Button + +val android.app.Fragment.`set`: ft + get() = getView().findViewById(0) as? android.widget.Button + +val android.support.v4.app.Fragment.`set`: ft + get() = getView().findViewById(0) as? android.widget.Button + diff --git a/plugins/android-compiler-plugin/testData/android/converter/simple/supportSpecialTags/main_test_VIEW.kt b/plugins/android-compiler-plugin/testData/android/converter/simple/supportSpecialTags/main_test_VIEW.kt new file mode 100644 index 00000000000..3bdc07352bd --- /dev/null +++ b/plugins/android-compiler-plugin/testData/android/converter/simple/supportSpecialTags/main_test_VIEW.kt @@ -0,0 +1,13 @@ +package kotlinx.android.synthetic.main.test.view + +import kotlin.internal.flexible.ft + +val android.view.View.includeTag: ft + get() = findViewById(0) + +val android.view.View.`fun`: ft + get() = findViewById(0) as? android.widget.TextView + +val android.view.View.`set`: ft + get() = findViewById(0) as? android.widget.Button + diff --git a/plugins/android-compiler-plugin/testData/android/converter/simple/supportSpecialTags/test_LAYOUT.kt b/plugins/android-compiler-plugin/testData/android/converter/simple/supportSpecialTags/test_LAYOUT.kt index ab724cfcdb0..06f302f9c1d 100644 --- a/plugins/android-compiler-plugin/testData/android/converter/simple/supportSpecialTags/test_LAYOUT.kt +++ b/plugins/android-compiler-plugin/testData/android/converter/simple/supportSpecialTags/test_LAYOUT.kt @@ -2,42 +2,55 @@ package kotlinx.android.synthetic.test import kotlin.internal.flexible.ft +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("includeTag", "kotlinx.android.synthetic.main.test.includeTag")) val android.app.Activity.includeTag: ft get() = findViewById(0) +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("includeTag", "kotlinx.android.synthetic.main.test.includeTag")) val android.app.Fragment.includeTag: ft get() = getView().findViewById(0) +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("includeTag", "kotlinx.android.synthetic.main.test.includeTag")) val android.support.v4.app.Fragment.includeTag: ft get() = getView().findViewById(0) +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("fragmentTag", "kotlinx.android.synthetic.main.test.fragmentTag")) val android.app.Activity.fragmentTag: ft get() = getFragmentManager().findFragmentById(0) as? android.app.Fragment +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("fragmentTag", "kotlinx.android.synthetic.main.test.fragmentTag")) val android.app.Fragment.fragmentTag: ft get() = getFragmentManager().findFragmentById(0) as? android.app.Fragment +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("fragmentTag", "kotlinx.android.synthetic.main.test.fragmentTag")) val android.support.v4.app.Fragment.fragmentTag: ft get() = getFragmentManager().findFragmentById(0) as? android.support.v4.app.Fragment +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("fragmentTag", "kotlinx.android.synthetic.main.test.fragmentTag")) val android.support.v4.app.FragmentActivity.fragmentTag: ft get() = getSupportFragmentManager().findFragmentById(0) as? android.support.v4.app.Fragment +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("`fun`", "kotlinx.android.synthetic.main.test.`fun`")) val android.app.Activity.`fun`: ft get() = findViewById(0) as? android.widget.TextView +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("`fun`", "kotlinx.android.synthetic.main.test.`fun`")) val android.app.Fragment.`fun`: ft get() = getView().findViewById(0) as? android.widget.TextView +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("`fun`", "kotlinx.android.synthetic.main.test.`fun`")) val android.support.v4.app.Fragment.`fun`: ft get() = getView().findViewById(0) as? android.widget.TextView +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("`set`", "kotlinx.android.synthetic.main.test.`set`")) val android.app.Activity.`set`: ft get() = findViewById(0) as? android.widget.Button +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("`set`", "kotlinx.android.synthetic.main.test.`set`")) val android.app.Fragment.`set`: ft get() = getView().findViewById(0) as? android.widget.Button +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("`set`", "kotlinx.android.synthetic.main.test.`set`")) val android.support.v4.app.Fragment.`set`: ft get() = getView().findViewById(0) as? android.widget.Button diff --git a/plugins/android-compiler-plugin/testData/android/converter/simple/supportSpecialTags/test_VIEW.kt b/plugins/android-compiler-plugin/testData/android/converter/simple/supportSpecialTags/test_VIEW.kt index b731bbe8620..68e55ae91a5 100644 --- a/plugins/android-compiler-plugin/testData/android/converter/simple/supportSpecialTags/test_VIEW.kt +++ b/plugins/android-compiler-plugin/testData/android/converter/simple/supportSpecialTags/test_VIEW.kt @@ -2,12 +2,15 @@ package kotlinx.android.synthetic.test.view import kotlin.internal.flexible.ft +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("includeTag", "kotlinx.android.synthetic.main.test.view.includeTag")) val android.view.View.includeTag: ft get() = findViewById(0) +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("`fun`", "kotlinx.android.synthetic.main.test.view.`fun`")) val android.view.View.`fun`: ft get() = findViewById(0) as? android.widget.TextView +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("`set`", "kotlinx.android.synthetic.main.test.view.`set`")) val android.view.View.`set`: ft get() = findViewById(0) as? android.widget.Button diff --git a/plugins/android-compiler-plugin/testData/android/converter/simple/unresolvedFqName/main_test_LAYOUT.kt b/plugins/android-compiler-plugin/testData/android/converter/simple/unresolvedFqName/main_test_LAYOUT.kt new file mode 100644 index 00000000000..ac3e9be5d2c --- /dev/null +++ b/plugins/android-compiler-plugin/testData/android/converter/simple/unresolvedFqName/main_test_LAYOUT.kt @@ -0,0 +1,12 @@ +package kotlinx.android.synthetic.main.test + +import kotlin.internal.flexible.ft + +@kotlin.internal.flexible.InvalidWidgetType("a.b.c") +val android.app.Activity.MyView: ft + get() = findViewById(0) as? a.b.c + +@kotlin.internal.flexible.InvalidWidgetType("a.b.c") +val android.app.Fragment.MyView: ft + get() = getView().findViewById(0) as? a.b.c + diff --git a/plugins/android-compiler-plugin/testData/android/converter/simple/unresolvedFqName/main_test_VIEW.kt b/plugins/android-compiler-plugin/testData/android/converter/simple/unresolvedFqName/main_test_VIEW.kt new file mode 100644 index 00000000000..09dcdea1098 --- /dev/null +++ b/plugins/android-compiler-plugin/testData/android/converter/simple/unresolvedFqName/main_test_VIEW.kt @@ -0,0 +1,8 @@ +package kotlinx.android.synthetic.main.test.view + +import kotlin.internal.flexible.ft + +@kotlin.internal.flexible.InvalidWidgetType("a.b.c") +val android.view.View.MyView: ft + get() = findViewById(0) as? a.b.c + diff --git a/plugins/android-compiler-plugin/testData/android/converter/simple/unresolvedFqName/test_LAYOUT.kt b/plugins/android-compiler-plugin/testData/android/converter/simple/unresolvedFqName/test_LAYOUT.kt index 0d2ac0dac9f..01529acb59e 100644 --- a/plugins/android-compiler-plugin/testData/android/converter/simple/unresolvedFqName/test_LAYOUT.kt +++ b/plugins/android-compiler-plugin/testData/android/converter/simple/unresolvedFqName/test_LAYOUT.kt @@ -2,10 +2,12 @@ package kotlinx.android.synthetic.test import kotlin.internal.flexible.ft +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("MyView", "kotlinx.android.synthetic.main.test.MyView")) @kotlin.internal.flexible.InvalidWidgetType("a.b.c") val android.app.Activity.MyView: ft get() = findViewById(0) as? a.b.c +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("MyView", "kotlinx.android.synthetic.main.test.MyView")) @kotlin.internal.flexible.InvalidWidgetType("a.b.c") val android.app.Fragment.MyView: ft get() = getView().findViewById(0) as? a.b.c diff --git a/plugins/android-compiler-plugin/testData/android/converter/simple/unresolvedFqName/test_VIEW.kt b/plugins/android-compiler-plugin/testData/android/converter/simple/unresolvedFqName/test_VIEW.kt index 5753274e6c8..d501237cf4a 100644 --- a/plugins/android-compiler-plugin/testData/android/converter/simple/unresolvedFqName/test_VIEW.kt +++ b/plugins/android-compiler-plugin/testData/android/converter/simple/unresolvedFqName/test_VIEW.kt @@ -2,6 +2,7 @@ package kotlinx.android.synthetic.test.view import kotlin.internal.flexible.ft +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("MyView", "kotlinx.android.synthetic.main.test.view.MyView")) @kotlin.internal.flexible.InvalidWidgetType("a.b.c") val android.view.View.MyView: ft get() = findViewById(0) as? a.b.c diff --git a/plugins/android-compiler-plugin/testData/android/converter/simple/unresolvedWidget/main_test_LAYOUT.kt b/plugins/android-compiler-plugin/testData/android/converter/simple/unresolvedWidget/main_test_LAYOUT.kt new file mode 100644 index 00000000000..0f36b45c5e7 --- /dev/null +++ b/plugins/android-compiler-plugin/testData/android/converter/simple/unresolvedWidget/main_test_LAYOUT.kt @@ -0,0 +1,12 @@ +package kotlinx.android.synthetic.main.test + +import kotlin.internal.flexible.ft + +@kotlin.internal.flexible.InvalidWidgetType("KeyboardView") +val android.app.Activity.MyKeyboardView: ft + get() = findViewById(0) + +@kotlin.internal.flexible.InvalidWidgetType("KeyboardView") +val android.app.Fragment.MyKeyboardView: ft + get() = getView().findViewById(0) + diff --git a/plugins/android-compiler-plugin/testData/android/converter/simple/unresolvedWidget/main_test_VIEW.kt b/plugins/android-compiler-plugin/testData/android/converter/simple/unresolvedWidget/main_test_VIEW.kt new file mode 100644 index 00000000000..8bdeab7f77a --- /dev/null +++ b/plugins/android-compiler-plugin/testData/android/converter/simple/unresolvedWidget/main_test_VIEW.kt @@ -0,0 +1,8 @@ +package kotlinx.android.synthetic.main.test.view + +import kotlin.internal.flexible.ft + +@kotlin.internal.flexible.InvalidWidgetType("KeyboardView") +val android.view.View.MyKeyboardView: ft + get() = findViewById(0) + diff --git a/plugins/android-compiler-plugin/testData/android/converter/simple/unresolvedWidget/test_LAYOUT.kt b/plugins/android-compiler-plugin/testData/android/converter/simple/unresolvedWidget/test_LAYOUT.kt index 7aca17cfa00..8d40d8312a1 100644 --- a/plugins/android-compiler-plugin/testData/android/converter/simple/unresolvedWidget/test_LAYOUT.kt +++ b/plugins/android-compiler-plugin/testData/android/converter/simple/unresolvedWidget/test_LAYOUT.kt @@ -2,10 +2,12 @@ package kotlinx.android.synthetic.test import kotlin.internal.flexible.ft +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("MyKeyboardView", "kotlinx.android.synthetic.main.test.MyKeyboardView")) @kotlin.internal.flexible.InvalidWidgetType("KeyboardView") val android.app.Activity.MyKeyboardView: ft get() = findViewById(0) +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("MyKeyboardView", "kotlinx.android.synthetic.main.test.MyKeyboardView")) @kotlin.internal.flexible.InvalidWidgetType("KeyboardView") val android.app.Fragment.MyKeyboardView: ft get() = getView().findViewById(0) diff --git a/plugins/android-compiler-plugin/testData/android/converter/simple/unresolvedWidget/test_VIEW.kt b/plugins/android-compiler-plugin/testData/android/converter/simple/unresolvedWidget/test_VIEW.kt index 73c80f30c8c..b3dff2cbe30 100644 --- a/plugins/android-compiler-plugin/testData/android/converter/simple/unresolvedWidget/test_VIEW.kt +++ b/plugins/android-compiler-plugin/testData/android/converter/simple/unresolvedWidget/test_VIEW.kt @@ -2,6 +2,7 @@ package kotlinx.android.synthetic.test.view import kotlin.internal.flexible.ft +@Deprecated("Use the property from the 'main' variant instead", ReplaceWith("MyKeyboardView", "kotlinx.android.synthetic.main.test.view.MyKeyboardView")) @kotlin.internal.flexible.InvalidWidgetType("KeyboardView") val android.view.View.MyKeyboardView: ft get() = findViewById(0) diff --git a/plugins/android-compiler-plugin/testData/codegen/android/fqNameInAttr/0.kt b/plugins/android-compiler-plugin/testData/codegen/android/fqNameInAttr/0.kt index 637df9d4864..8821f1bc542 100644 --- a/plugins/android-compiler-plugin/testData/codegen/android/fqNameInAttr/0.kt +++ b/plugins/android-compiler-plugin/testData/codegen/android/fqNameInAttr/0.kt @@ -4,7 +4,7 @@ import android.app.Activity import android.view.View import android.widget.* import org.my.cool.MyButton -import kotlinx.android.synthetic.layout.* +import kotlinx.android.synthetic.main.layout.* class R { class id { diff --git a/plugins/android-compiler-plugin/testData/codegen/android/fqNameInAttr/1.kt b/plugins/android-compiler-plugin/testData/codegen/android/fqNameInAttr/1.kt index f872c70b195..9de5e082e51 100644 --- a/plugins/android-compiler-plugin/testData/codegen/android/fqNameInAttr/1.kt +++ b/plugins/android-compiler-plugin/testData/codegen/android/fqNameInAttr/1.kt @@ -4,7 +4,7 @@ import android.app.Activity import android.view.View import android.widget.* import org.my.cool.MyButton -import kotlinx.android.synthetic.layout.* +import kotlinx.android.synthetic.main.layout.* class R { class id { diff --git a/plugins/android-compiler-plugin/testData/codegen/android/fqNameInTag/0.kt b/plugins/android-compiler-plugin/testData/codegen/android/fqNameInTag/0.kt index 637df9d4864..8821f1bc542 100644 --- a/plugins/android-compiler-plugin/testData/codegen/android/fqNameInTag/0.kt +++ b/plugins/android-compiler-plugin/testData/codegen/android/fqNameInTag/0.kt @@ -4,7 +4,7 @@ import android.app.Activity import android.view.View import android.widget.* import org.my.cool.MyButton -import kotlinx.android.synthetic.layout.* +import kotlinx.android.synthetic.main.layout.* class R { class id { diff --git a/plugins/android-compiler-plugin/testData/codegen/android/fqNameInTag/1.kt b/plugins/android-compiler-plugin/testData/codegen/android/fqNameInTag/1.kt index f872c70b195..9de5e082e51 100644 --- a/plugins/android-compiler-plugin/testData/codegen/android/fqNameInTag/1.kt +++ b/plugins/android-compiler-plugin/testData/codegen/android/fqNameInTag/1.kt @@ -4,7 +4,7 @@ import android.app.Activity import android.view.View import android.widget.* import org.my.cool.MyButton -import kotlinx.android.synthetic.layout.* +import kotlinx.android.synthetic.main.layout.* class R { class id { diff --git a/plugins/android-compiler-plugin/testData/codegen/android/fragment/0.kt b/plugins/android-compiler-plugin/testData/codegen/android/fragment/0.kt index 5b2ee294ddb..682a9c4664c 100644 --- a/plugins/android-compiler-plugin/testData/codegen/android/fragment/0.kt +++ b/plugins/android-compiler-plugin/testData/codegen/android/fragment/0.kt @@ -6,7 +6,7 @@ import android.content.Context import android.view.View import android.widget.* import org.my.cool.MyButton -import kotlinx.android.synthetic.layout.* +import kotlinx.android.synthetic.main.layout.* class R { class id { diff --git a/plugins/android-compiler-plugin/testData/codegen/android/fragment/1.kt b/plugins/android-compiler-plugin/testData/codegen/android/fragment/1.kt index 92470a6b4cf..f58980ecd09 100644 --- a/plugins/android-compiler-plugin/testData/codegen/android/fragment/1.kt +++ b/plugins/android-compiler-plugin/testData/codegen/android/fragment/1.kt @@ -6,7 +6,7 @@ import android.content.Context import android.view.View import android.widget.* import org.my.cool.MyButton -import kotlinx.android.synthetic.layout.* +import kotlinx.android.synthetic.main.layout.* class R { class id { diff --git a/plugins/android-compiler-plugin/testData/codegen/android/multiFile/0.kt b/plugins/android-compiler-plugin/testData/codegen/android/multiFile/0.kt index 7cd6f5cebf9..8ba66303156 100644 --- a/plugins/android-compiler-plugin/testData/codegen/android/multiFile/0.kt +++ b/plugins/android-compiler-plugin/testData/codegen/android/multiFile/0.kt @@ -3,8 +3,8 @@ package com.myapp import android.app.Activity import android.view.View import android.widget.* -import kotlinx.android.synthetic.layout.* -import kotlinx.android.synthetic.layout1.* +import kotlinx.android.synthetic.main.layout.* +import kotlinx.android.synthetic.main.layout1.* class R { class id { diff --git a/plugins/android-compiler-plugin/testData/codegen/android/multiFile/1.kt b/plugins/android-compiler-plugin/testData/codegen/android/multiFile/1.kt index 8d106bf25a7..9eafc87cfcb 100644 --- a/plugins/android-compiler-plugin/testData/codegen/android/multiFile/1.kt +++ b/plugins/android-compiler-plugin/testData/codegen/android/multiFile/1.kt @@ -3,8 +3,8 @@ package com.myapp import android.app.Activity import android.view.View import android.widget.* -import kotlinx.android.synthetic.layout.* -import kotlinx.android.synthetic.layout1.* +import kotlinx.android.synthetic.main.layout.* +import kotlinx.android.synthetic.main.layout1.* class R { class id { diff --git a/plugins/android-compiler-plugin/testData/codegen/android/singleFile/0.kt b/plugins/android-compiler-plugin/testData/codegen/android/singleFile/0.kt index 7b42897ea77..1746f08801d 100644 --- a/plugins/android-compiler-plugin/testData/codegen/android/singleFile/0.kt +++ b/plugins/android-compiler-plugin/testData/codegen/android/singleFile/0.kt @@ -3,7 +3,7 @@ package com.myapp import android.app.Activity import android.view.View import android.widget.* -import kotlinx.android.synthetic.layout.* +import kotlinx.android.synthetic.main.layout.* class R { class id { diff --git a/plugins/android-compiler-plugin/testData/codegen/android/singleFile/1.kt b/plugins/android-compiler-plugin/testData/codegen/android/singleFile/1.kt index c09b727e11e..a4f3e044625 100644 --- a/plugins/android-compiler-plugin/testData/codegen/android/singleFile/1.kt +++ b/plugins/android-compiler-plugin/testData/codegen/android/singleFile/1.kt @@ -3,7 +3,7 @@ package com.myapp import android.app.Activity import android.view.View import android.widget.* -import kotlinx.android.synthetic.layout.* +import kotlinx.android.synthetic.main.layout.* class R { class id { diff --git a/plugins/android-compiler-plugin/testData/codegen/android/view/0.kt b/plugins/android-compiler-plugin/testData/codegen/android/view/0.kt index 7071504ff93..c96510650048 100644 --- a/plugins/android-compiler-plugin/testData/codegen/android/view/0.kt +++ b/plugins/android-compiler-plugin/testData/codegen/android/view/0.kt @@ -3,8 +3,8 @@ 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.* +import kotlinx.android.synthetic.main.layout.* +import kotlinx.android.synthetic.main.layout.view.* class R { class id { diff --git a/plugins/android-compiler-plugin/testData/codegen/android/view/1.kt b/plugins/android-compiler-plugin/testData/codegen/android/view/1.kt index a31b20205b3..4c3bc6bfe06 100644 --- a/plugins/android-compiler-plugin/testData/codegen/android/view/1.kt +++ b/plugins/android-compiler-plugin/testData/codegen/android/view/1.kt @@ -3,8 +3,8 @@ 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.* +import kotlinx.android.synthetic.main.layout.* +import kotlinx.android.synthetic.main.layout.view.* class R { class id { diff --git a/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/baseClass/baseClass.kt b/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/baseClass/baseClass.kt index c56d293dca2..91f5670a8d4 100644 --- a/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/baseClass/baseClass.kt +++ b/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/baseClass/baseClass.kt @@ -1,7 +1,7 @@ package com.myapp import android.app.Activity -import kotlinx.android.synthetic.layout.* +import kotlinx.android.synthetic.main.layout.* fun Activity.a() { val x = login diff --git a/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/baseClassFragment/baseClassFragment.kt b/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/baseClassFragment/baseClassFragment.kt index c42ecd99000..36cdeade2f8 100644 --- a/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/baseClassFragment/baseClassFragment.kt +++ b/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/baseClassFragment/baseClassFragment.kt @@ -1,7 +1,7 @@ package com.myapp import android.app.Fragment -import kotlinx.android.synthetic.layout.* +import kotlinx.android.synthetic.main.layout.* fun Fragment.a() { val x = login diff --git a/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/extensionFunctions/extensionFunctions.kt b/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/extensionFunctions/extensionFunctions.kt index 3ed457e41bd..487f847ba95 100644 --- a/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/extensionFunctions/extensionFunctions.kt +++ b/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/extensionFunctions/extensionFunctions.kt @@ -3,7 +3,7 @@ package com.myapp import android.app.Activity import android.os.Bundle import java.io.File -import kotlinx.android.synthetic.layout.* +import kotlinx.android.synthetic.main.layout.* public class MyActivity : Activity() { diff --git a/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/extensionFunctionsFragment/extensionFunctionsFragment.kt b/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/extensionFunctionsFragment/extensionFunctionsFragment.kt index 8ced6a9ad1b..3062bb7c056 100644 --- a/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/extensionFunctionsFragment/extensionFunctionsFragment.kt +++ b/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/extensionFunctionsFragment/extensionFunctionsFragment.kt @@ -3,7 +3,7 @@ package com.myapp import android.app.Fragment import android.os.Bundle import java.io.File -import kotlinx.android.synthetic.layout.* +import kotlinx.android.synthetic.main.layout.* public class MyFragment : Fragment() diff --git a/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/extensionFunctionsView/extensionFunctionsView.kt b/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/extensionFunctionsView/extensionFunctionsView.kt index 35c5238a85a..aaf06527fd5 100644 --- a/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/extensionFunctionsView/extensionFunctionsView.kt +++ b/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/extensionFunctionsView/extensionFunctionsView.kt @@ -1,7 +1,7 @@ package com.myapp import android.view.View -import kotlinx.android.synthetic.layout.view.* +import kotlinx.android.synthetic.main.layout.view.* fun View.a() { val x = login diff --git a/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/fqNameInAttr/fqNameInAttr.kt b/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/fqNameInAttr/fqNameInAttr.kt index 34c0d483e40..b5c92823a98 100644 --- a/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/fqNameInAttr/fqNameInAttr.kt +++ b/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/fqNameInAttr/fqNameInAttr.kt @@ -1,7 +1,7 @@ package com.myapp import android.app.Activity -import kotlinx.android.synthetic.layout.* +import kotlinx.android.synthetic.main.layout.* class MyActivity: Activity() { val button = this.MyButton diff --git a/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/fqNameInAttrFragment/fqNameInAttrFragment.kt b/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/fqNameInAttrFragment/fqNameInAttrFragment.kt index 92fe5a19eb7..99dee66d2a3 100644 --- a/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/fqNameInAttrFragment/fqNameInAttrFragment.kt +++ b/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/fqNameInAttrFragment/fqNameInAttrFragment.kt @@ -1,7 +1,7 @@ package com.myapp import android.app.Fragment -import kotlinx.android.synthetic.layout.* +import kotlinx.android.synthetic.main.layout.* class MyFragment: Fragment() { val button = this.MyButton diff --git a/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/fqNameInTag/fqNameInTag.kt b/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/fqNameInTag/fqNameInTag.kt index 34c0d483e40..b5c92823a98 100644 --- a/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/fqNameInTag/fqNameInTag.kt +++ b/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/fqNameInTag/fqNameInTag.kt @@ -1,7 +1,7 @@ package com.myapp import android.app.Activity -import kotlinx.android.synthetic.layout.* +import kotlinx.android.synthetic.main.layout.* class MyActivity: Activity() { val button = this.MyButton diff --git a/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/fqNameInTagFragment/fqNameInTagFragment.kt b/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/fqNameInTagFragment/fqNameInTagFragment.kt index 92fe5a19eb7..99dee66d2a3 100644 --- a/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/fqNameInTagFragment/fqNameInTagFragment.kt +++ b/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/fqNameInTagFragment/fqNameInTagFragment.kt @@ -1,7 +1,7 @@ package com.myapp import android.app.Fragment -import kotlinx.android.synthetic.layout.* +import kotlinx.android.synthetic.main.layout.* class MyFragment: Fragment() { val button = this.MyButton diff --git a/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/multiFile/multiFile.kt b/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/multiFile/multiFile.kt index 1ab62d2f1bb..0aab1960810 100644 --- a/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/multiFile/multiFile.kt +++ b/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/multiFile/multiFile.kt @@ -1,8 +1,8 @@ package com.myapp import android.app.Activity -import kotlinx.android.synthetic.layout.* -import kotlinx.android.synthetic.layout1.* +import kotlinx.android.synthetic.main.layout.* +import kotlinx.android.synthetic.main.layout1.* class MyActivity: Activity() { val button = this.login diff --git a/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/multiFileFragment/multiFileFragment.kt b/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/multiFileFragment/multiFileFragment.kt index 5c0d87bff9b..35a86cf0af8 100644 --- a/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/multiFileFragment/multiFileFragment.kt +++ b/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/multiFileFragment/multiFileFragment.kt @@ -2,8 +2,8 @@ package com.myapp import android.app.Activity import android.app.Fragment -import kotlinx.android.synthetic.layout.* -import kotlinx.android.synthetic.layout1.* +import kotlinx.android.synthetic.main.layout.* +import kotlinx.android.synthetic.main.layout1.* class MyActivity: Activity() { val button = this.login diff --git a/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/onDestroyFragment/onDestroyFragment.kt b/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/onDestroyFragment/onDestroyFragment.kt index fb412e7994a..896b7cd62f2 100644 --- a/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/onDestroyFragment/onDestroyFragment.kt +++ b/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/onDestroyFragment/onDestroyFragment.kt @@ -2,7 +2,7 @@ package com.myapp import android.app.Fragment import java.io.File -import kotlinx.android.synthetic.layout.* +import kotlinx.android.synthetic.main.layout.* public class MyFragment : Fragment() { init {login} diff --git a/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/simple/simple.kt b/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/simple/simple.kt index ef30a2dfc6c..2202b27882e 100644 --- a/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/simple/simple.kt +++ b/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/simple/simple.kt @@ -3,7 +3,7 @@ package com.myapp import android.app.Activity import android.os.Bundle import java.io.File -import kotlinx.android.synthetic.layout.* +import kotlinx.android.synthetic.main.layout.* public class MyActivity : Activity() { init {login} diff --git a/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/simpleFragment/simpleFragment.kt b/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/simpleFragment/simpleFragment.kt index fc040a81304..224e122771b 100644 --- a/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/simpleFragment/simpleFragment.kt +++ b/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/simpleFragment/simpleFragment.kt @@ -2,7 +2,7 @@ package com.myapp import android.app.Fragment import java.io.File -import kotlinx.android.synthetic.layout.* +import kotlinx.android.synthetic.main.layout.* public class MyFragment : Fragment() { init {login} diff --git a/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/simpleFragmentProperty/simpleFragmentProperty.kt b/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/simpleFragmentProperty/simpleFragmentProperty.kt index 1db097c78b6..7c0e94109be 100644 --- a/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/simpleFragmentProperty/simpleFragmentProperty.kt +++ b/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/simpleFragmentProperty/simpleFragmentProperty.kt @@ -4,7 +4,7 @@ import android.app.Activity import android.app.Fragment import android.os.Bundle import java.io.File -import kotlinx.android.synthetic.layout.* +import kotlinx.android.synthetic.main.layout.* public class MyActivity : Activity() { init { fragm } diff --git a/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/simpleView/simpleView.kt b/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/simpleView/simpleView.kt index 72ae25a8746..dabe8d44a6d 100644 --- a/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/simpleView/simpleView.kt +++ b/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/simpleView/simpleView.kt @@ -2,7 +2,7 @@ package com.myapp import android.view.View import android.app.Activity -import kotlinx.android.synthetic.layout.view.* +import kotlinx.android.synthetic.main.layout.view.* public class MyActivity : Activity() { init { View(this).login } diff --git a/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/supportExtensionFunctionsFragment/supportExtensionFunctionsFragment.kt b/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/supportExtensionFunctionsFragment/supportExtensionFunctionsFragment.kt index 73607ccae7b..b77bdfba0bc 100644 --- a/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/supportExtensionFunctionsFragment/supportExtensionFunctionsFragment.kt +++ b/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/supportExtensionFunctionsFragment/supportExtensionFunctionsFragment.kt @@ -4,7 +4,7 @@ import android.app.Activity import android.view.View import android.os.Bundle import java.io.File -import kotlinx.android.synthetic.layout.* +import kotlinx.android.synthetic.main.layout.* open class Fragment { open fun getActivity(): Activity = throw Exception("Function getActivity() is not overridden") diff --git a/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/supportSimpleFragment/supportSimpleFragment.kt b/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/supportSimpleFragment/supportSimpleFragment.kt index aeb9865ecb1..c133e697e6e 100644 --- a/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/supportSimpleFragment/supportSimpleFragment.kt +++ b/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/supportSimpleFragment/supportSimpleFragment.kt @@ -3,7 +3,7 @@ package android.support.v4.app import android.app.Activity import android.view.View import java.io.File -import kotlinx.android.synthetic.layout.* +import kotlinx.android.synthetic.main.layout.* open class Fragment { open fun getActivity(): Activity = throw Exception("Function getActivity() is not overridden") diff --git a/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/supportSimpleFragmentProperty/supportSimpleFragmentProperty.kt b/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/supportSimpleFragmentProperty/supportSimpleFragmentProperty.kt index 19a80118407..6bc31286e4b 100644 --- a/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/supportSimpleFragmentProperty/supportSimpleFragmentProperty.kt +++ b/plugins/android-compiler-plugin/testData/codegen/bytecodeShape/supportSimpleFragmentProperty/supportSimpleFragmentProperty.kt @@ -3,7 +3,7 @@ package android.support.v4.app import android.app.Activity import android.os.Bundle import java.io.File -import kotlinx.android.synthetic.layout.* +import kotlinx.android.synthetic.main.layout.* open class FragmentManager { open fun findFragmentById(id: Int): Fragment = throw Exception("Function getFragmentById() is not overriden") diff --git a/plugins/android-compiler-plugin/tests/org/jetbrains/kotlin/lang/resolve/android/test/AbstractAndroidXml2KConversionTest.kt b/plugins/android-compiler-plugin/tests/org/jetbrains/kotlin/lang/resolve/android/test/AbstractAndroidXml2KConversionTest.kt index a6a5f3b1553..cc670bced3a 100644 --- a/plugins/android-compiler-plugin/tests/org/jetbrains/kotlin/lang/resolve/android/test/AbstractAndroidXml2KConversionTest.kt +++ b/plugins/android-compiler-plugin/tests/org/jetbrains/kotlin/lang/resolve/android/test/AbstractAndroidXml2KConversionTest.kt @@ -24,9 +24,7 @@ import org.jetbrains.kotlin.test.ConfigurationKind import org.jetbrains.kotlin.test.KotlinTestUtils import org.jetbrains.kotlin.test.TestJdkKind import java.io.File -import kotlin.test.assertEquals import kotlin.test.assertNotNull -import kotlin.test.fail public abstract class AbstractAndroidXml2KConversionTest : UsefulTestCase() { @@ -39,13 +37,21 @@ public abstract class AbstractAndroidXml2KConversionTest : UsefulTestCase() { val parser = CliSyntheticFileGeneratorForConversionTest( jetCoreEnvironment.project, File(testDirectory.parentFile, "AndroidManifest.xml").path, layoutPaths, supportV4) - val actual = parser.gen().toMap { it.name } + val actual = parser.gen().toMapBy { it.name } val expectedLayoutFiles = testDirectory .listFiles { it.isFile && it.name.endsWith(".kt") } - ?.toMap { it.name.substringBefore(".kt") } ?: mapOf() + ?.toMapBy { it.name.substringBefore(".kt") } ?: mapOf() - assertEquals(expectedLayoutFiles.size(), actual.size()) + if (expectedLayoutFiles.size == 0 && actual.size > 0) { + for (file in actual) { + val syntheticFile = file.value + File(testDirectory, syntheticFile.name + ".kt").writeText(syntheticFile.contents) + } + fail("No expected synthetic .kt files found, generated from actual") + } + + assertEquals(expectedLayoutFiles.size, actual.size) for ((name, file) in expectedLayoutFiles) { val actualContents = actual[name] diff --git a/plugins/android-compiler-plugin/tests/org/jetbrains/kotlin/lang/resolve/android/test/CompilerTestUtils.kt b/plugins/android-compiler-plugin/tests/org/jetbrains/kotlin/lang/resolve/android/test/CompilerTestUtils.kt index da2e4eafd59..f0eac577578 100644 --- a/plugins/android-compiler-plugin/tests/org/jetbrains/kotlin/lang/resolve/android/test/CompilerTestUtils.kt +++ b/plugins/android-compiler-plugin/tests/org/jetbrains/kotlin/lang/resolve/android/test/CompilerTestUtils.kt @@ -24,6 +24,7 @@ import org.jetbrains.kotlin.android.synthetic.AndroidExtensionPropertiesComponen import org.jetbrains.kotlin.android.synthetic.codegen.AndroidExpressionCodegenExtension import org.jetbrains.kotlin.android.synthetic.codegen.AndroidOnDestroyClassBuilderInterceptorExtension import org.jetbrains.kotlin.android.synthetic.res.AndroidSyntheticFile +import org.jetbrains.kotlin.android.synthetic.res.AndroidVariant import org.jetbrains.kotlin.android.synthetic.res.CliSyntheticFileGenerator import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment @@ -52,7 +53,7 @@ class CliSyntheticFileGeneratorForConversionTest( manifestPath: String, resDirectories: List, private val supportV4: Boolean -) : CliSyntheticFileGenerator(project, manifestPath, resDirectories) { +) : CliSyntheticFileGenerator(project, manifestPath, listOf(AndroidVariant.createMainVariant(resDirectories))) { fun gen() = generateSyntheticFiles(false, supportV4) @@ -67,8 +68,8 @@ fun UsefulTestCase.createAndroidTestEnvironment( manifestPath: String, supportV4: Boolean ): KotlinCoreEnvironment { - configuration.put(AndroidConfigurationKeys.ANDROID_RES_PATH, resPaths) - configuration.put(AndroidConfigurationKeys.ANDROID_MANIFEST, manifestPath) + configuration.put(AndroidConfigurationKeys.VARIANT, resPaths) + configuration.put(AndroidConfigurationKeys.PACKAGE, manifestPath) val myEnvironment = KotlinCoreEnvironment.createForTests(testRootDisposable, configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES) val project = myEnvironment.project