Cleanup Android Extensions code
This commit is contained in:
+3
-3
@@ -23,11 +23,11 @@ import java.util.HashMap
|
||||
class AndroidXmlHandler(private val elementCallback: (String, String) -> Unit) : DefaultHandler() {
|
||||
|
||||
override fun startDocument() {
|
||||
super<DefaultHandler>.startDocument()
|
||||
super.startDocument()
|
||||
}
|
||||
|
||||
override fun endDocument() {
|
||||
super<DefaultHandler>.endDocument()
|
||||
super.endDocument()
|
||||
}
|
||||
|
||||
override fun startElement(uri: String, localName: String, qName: String, attributes: Attributes) {
|
||||
@@ -47,7 +47,7 @@ class AndroidXmlHandler(private val elementCallback: (String, String) -> Unit) :
|
||||
|
||||
public fun Attributes.toMap(): HashMap<String, String> {
|
||||
val res = HashMap<String, String>()
|
||||
for (index in 0..getLength() - 1) {
|
||||
for (index in 0..length - 1) {
|
||||
val attrName = getLocalName(index)!!
|
||||
val attrVal = getValue(index)!!
|
||||
res[attrName] = attrVal
|
||||
|
||||
@@ -67,12 +67,6 @@ open class Context(val buffer: StringBuffer = StringBuffer(), private var indent
|
||||
return child
|
||||
}
|
||||
|
||||
public fun adopt<T : Context>(c: T, inheritIndent: Boolean = true): T {
|
||||
children.add(c)
|
||||
if (inheritIndent) c.currentIndent = currentIndent
|
||||
return c
|
||||
}
|
||||
|
||||
public fun absorbChildren(noIndent: Boolean = true) {
|
||||
for (child in children) {
|
||||
child.absorbChildren()
|
||||
|
||||
+1
-1
@@ -45,7 +45,7 @@ public class AndroidOnDestroyClassBuilderInterceptorExtension : ClassBuilderInte
|
||||
return AndroidOnDestroyCollectorClassBuilder(delegateFactory.newClassBuilder(origin), bindingContext)
|
||||
}
|
||||
|
||||
override fun getClassBuilderMode() = delegateFactory.getClassBuilderMode()
|
||||
override fun getClassBuilderMode() = delegateFactory.classBuilderMode
|
||||
|
||||
override fun asText(builder: ClassBuilder?): String? {
|
||||
return delegateFactory.asText((builder as AndroidOnDestroyCollectorClassBuilder).delegateClassBuilder)
|
||||
|
||||
-3
@@ -16,9 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.android.synthetic.diagnostic
|
||||
|
||||
import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.kotlin.android.synthetic.AndroidConst
|
||||
import org.jetbrains.kotlin.android.synthetic.CliAndroidDeclarationsProvider
|
||||
import org.jetbrains.kotlin.android.synthetic.res.SyntheticFileGenerator
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.resolve.calls.checkers.CallChecker
|
||||
@@ -26,7 +24,6 @@ import org.jetbrains.kotlin.resolve.calls.context.BasicCallResolutionContext
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.constants.StringValue
|
||||
import org.jetbrains.kotlin.android.synthetic.diagnostic.ErrorsAndroid.*
|
||||
import org.jetbrains.kotlin.extensions.ExternalDeclarationsProvider
|
||||
|
||||
public class AndroidExtensionPropertiesCallChecker : CallChecker {
|
||||
override fun <F : CallableDescriptor> check(resolvedCall: ResolvedCall<F>, context: BasicCallResolutionContext) {
|
||||
|
||||
+5
-5
@@ -65,17 +65,17 @@ public abstract class AndroidLayoutXmlFileManager(val project: Project) {
|
||||
list
|
||||
}
|
||||
|
||||
val layoutNameToXmls = allLayoutPsiFiles
|
||||
val layoutNameToXmlFiles = allLayoutPsiFiles
|
||||
.groupBy { it.name.substringBeforeLast('.') }
|
||||
.mapValues { it.getValue().sortedBy { it.parent!!.name.length() } }
|
||||
|
||||
return layoutNameToXmls
|
||||
return layoutNameToXmlFiles
|
||||
}
|
||||
|
||||
companion object {
|
||||
public fun getInstance(module: Module): AndroidLayoutXmlFileManager {
|
||||
val service = ModuleServiceManager.getService(module, javaClass<AndroidLayoutXmlFileManager>())
|
||||
return service ?: module.getComponent(javaClass<AndroidLayoutXmlFileManager>())!!
|
||||
public fun getInstance(module: Module): AndroidLayoutXmlFileManager? {
|
||||
val service = ModuleServiceManager.getService(module, AndroidLayoutXmlFileManager::class.java)
|
||||
return service ?: module.getComponent(AndroidLayoutXmlFileManager::class.java)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -85,7 +85,7 @@ public open class CliSyntheticFileGenerator(
|
||||
}
|
||||
|
||||
private companion object {
|
||||
private val LOG: Logger = Logger.getInstance(javaClass)
|
||||
private val LOG: Logger = Logger.getInstance(CliSyntheticFileGenerator::class.java)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -41,7 +41,7 @@ public abstract class AbstractAndroidBoxTest : AbstractBlackBoxCodegenTest() {
|
||||
}
|
||||
|
||||
private fun createEnvironmentForConfiguration(configuration: CompilerConfiguration, path: String) {
|
||||
val layoutPaths = File(path).listFiles { it.name.startsWith("layout") && it.isDirectory() }!!.map { "$path${it.name}/" }
|
||||
val layoutPaths = File(path).listFiles { it.name.startsWith("layout") && it.isDirectory }!!.map { "$path${it.name}/" }
|
||||
val manifestPath = path + "AndroidManifest.xml"
|
||||
val supportV4 = File(path).name.startsWith("support")
|
||||
myEnvironment = createAndroidTestEnvironment(configuration, layoutPaths, manifestPath, supportV4)
|
||||
@@ -83,7 +83,7 @@ public abstract class AbstractAndroidBoxTest : AbstractBlackBoxCodegenTest() {
|
||||
if (additionalFiles != null) files.add(relativePath(file))
|
||||
}
|
||||
else -> {
|
||||
if (file.getName().endsWith(".kt")) files.add(relativePath(file))
|
||||
if (file.name.endsWith(".kt")) files.add(relativePath(file))
|
||||
}
|
||||
}
|
||||
return true
|
||||
|
||||
+5
-6
@@ -41,9 +41,9 @@ public abstract class AbstractAndroidXml2KConversionTest : UsefulTestCase() {
|
||||
|
||||
val actual = parser.gen().toMap { it.name }
|
||||
|
||||
val expectedLayoutFiles = testDirectory.listFiles {
|
||||
it.isFile() && it.name.endsWith(".kt")
|
||||
}?.toMap { it.name.substringBefore(".kt") } ?: mapOf()
|
||||
val expectedLayoutFiles = testDirectory
|
||||
.listFiles { it.isFile && it.name.endsWith(".kt") }
|
||||
?.toMap { it.name.substringBefore(".kt") } ?: mapOf()
|
||||
|
||||
assertEquals(expectedLayoutFiles.size(), actual.size())
|
||||
|
||||
@@ -59,12 +59,11 @@ public abstract class AbstractAndroidXml2KConversionTest : UsefulTestCase() {
|
||||
doTest(path)
|
||||
fail("NoAndroidManifestFound not thrown")
|
||||
}
|
||||
catch (e: SyntheticFileGenerator.NoAndroidManifestFound) {
|
||||
}
|
||||
catch (e: SyntheticFileGenerator.NoAndroidManifestFound) {}
|
||||
}
|
||||
|
||||
private fun getEnvironment(): KotlinCoreEnvironment {
|
||||
val configuration = KotlinTestUtils.compilerConfigurationForTests(ConfigurationKind.ALL, TestJdkKind.ANDROID_API)
|
||||
return KotlinCoreEnvironment.createForTests(getTestRootDisposable()!!, configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES)
|
||||
return KotlinCoreEnvironment.createForTests(testRootDisposable, configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user