Fix deprecated Kotlin constructs and remove unused code in Android plugins
This commit is contained in:
+1
-1
@@ -35,7 +35,7 @@ open class Context(val buffer: StringBuffer = StringBuffer(), private var indent
|
|||||||
indentDepth--
|
indentDepth--
|
||||||
if (indentDepth < 0)
|
if (indentDepth < 0)
|
||||||
throw InvalidIndent(indentDepth)
|
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) {
|
public open fun write(what: String) {
|
||||||
|
|||||||
-22
@@ -26,28 +26,6 @@ class KotlinStringWriter : KotlinWriter {
|
|||||||
private val imports = ctx.fork()
|
private val imports = ctx.fork()
|
||||||
private val body = ctx.fork()
|
private val body = ctx.fork()
|
||||||
|
|
||||||
fun writeFunction(name: String,
|
|
||||||
args: Collection<String>?,
|
|
||||||
retType: String,
|
|
||||||
statements: Collection<String>) {
|
|
||||||
val returnTerm = if (retType == "" || retType == "Unit") "" else ": $retType"
|
|
||||||
val argStr = if (args != null) args.join(", ") else ""
|
|
||||||
body.writeln("fun $name($argStr)$returnTerm {")
|
|
||||||
body.incIndent()
|
|
||||||
for (stmt in statements)
|
|
||||||
body.writeln(stmt)
|
|
||||||
body.decIndent()
|
|
||||||
body.writeln("}")
|
|
||||||
}
|
|
||||||
|
|
||||||
fun writeExtensionFunction(receiver: String,
|
|
||||||
name: String,
|
|
||||||
args: Collection<String>?,
|
|
||||||
retType: String,
|
|
||||||
body: Collection<String>) {
|
|
||||||
writeFunction("$receiver.$name", args, retType, body)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun writeImmutableProperty(name: String,
|
fun writeImmutableProperty(name: String,
|
||||||
retType: String,
|
retType: String,
|
||||||
getterBody: Collection<String>) {
|
getterBody: Collection<String>) {
|
||||||
|
|||||||
+1
-1
@@ -63,7 +63,7 @@ public abstract class AbstractAndroidBoxTest : AbstractBlackBoxCodegenTest() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun needsInvocationTest(path: String): Boolean {
|
private fun needsInvocationTest(path: String): Boolean {
|
||||||
return !FileUtil.findFilesByMask(Pattern.compile("^0.kt$"), File(path)).empty
|
return !FileUtil.findFilesByMask(Pattern.compile("^0.kt$"), File(path)).isEmpty()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun codegenTestBasePath(): String {
|
override fun codegenTestBasePath(): String {
|
||||||
|
|||||||
-4
@@ -28,10 +28,6 @@ public abstract class AbstractAndroidBytecodeShapeTest : AbstractBytecodeTextTes
|
|||||||
return createEnvironmentForConfiguration(JetTestUtils.compilerConfigurationForTests(ConfigurationKind.ALL, TestJdkKind.ANDROID_API), path)
|
return createEnvironmentForConfiguration(JetTestUtils.compilerConfigurationForTests(ConfigurationKind.ALL, TestJdkKind.ANDROID_API), path)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createFakeAndroidEnvironment(path: String) {
|
|
||||||
return createEnvironmentForConfiguration(JetTestUtils.compilerConfigurationForTests(ConfigurationKind.ALL, TestJdkKind.MOCK_JDK), path)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun createEnvironmentForConfiguration(configuration: CompilerConfiguration, path: String) {
|
private fun createEnvironmentForConfiguration(configuration: CompilerConfiguration, path: String) {
|
||||||
val resPath = path + "res/layout/"
|
val resPath = path + "res/layout/"
|
||||||
val manifestPath = path + "../AndroidManifest.xml"
|
val manifestPath = path + "../AndroidManifest.xml"
|
||||||
|
|||||||
+1
-8
@@ -40,14 +40,7 @@ public abstract class AbstractParserResultEqualityTest : KotlinAndroidTestCase()
|
|||||||
|
|
||||||
assertEquals(cliResult, ideResult)
|
assertEquals(cliResult, ideResult)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getEnvironment(testPath: String): KotlinCoreEnvironment {
|
|
||||||
val configuration = JetTestUtils.compilerConfigurationForTests(ConfigurationKind.ALL, TestJdkKind.MOCK_JDK)
|
|
||||||
configuration.put<String>(AndroidConfigurationKeys.ANDROID_RES_PATH, testPath + "/layout")
|
|
||||||
configuration.put<String>(AndroidConfigurationKeys.ANDROID_MANIFEST, testPath + "/AndroidManifest.xml")
|
|
||||||
return KotlinCoreEnvironment.createForTests(getTestRootDisposable()!!, configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getTestDataPath(): String? {
|
override fun getTestDataPath(): String? {
|
||||||
return KotlinAndroidTestCaseBase.getPluginTestDataPathBase() + "/parserResultEquality/" + getTestName(true) + "/"
|
return KotlinAndroidTestCaseBase.getPluginTestDataPathBase() + "/parserResultEquality/" + getTestName(true) + "/"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user