Cleanup: fix some compiler warnings (mostly deprecations, javaClass)

This commit is contained in:
Mikhail Glukhikh
2017-02-21 17:38:43 +03:00
parent d0cc1635db
commit b121bf8802
445 changed files with 773 additions and 949 deletions
@@ -84,7 +84,7 @@ class AndroidSyntheticPackageFragmentDescriptor(
override fun getContributedVariables(name: Name, location: LookupLocation) = properties().filter { it.name == name }
override fun printScopeStructure(p: Printer) {
p.println(javaClass.simpleName)
p.println(this::class.java.simpleName)
}
}
}
@@ -55,7 +55,7 @@ class PredefinedPackageFragmentDescriptor(
calculatedFunctions().filter { nameFilter(it.name) && kindFilter.accepts(it) }
override fun printScopeStructure(p: Printer) {
p.println(javaClass.simpleName)
p.println(this::class.java.simpleName)
}
}
}
@@ -48,7 +48,7 @@ class ResourceIdentifier(val name: String, val packageName: String?) {
// Without packageName
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other?.javaClass != javaClass) return false
if (other == null || other::class.java != this::class.java) return false
other as ResourceIdentifier
@@ -47,7 +47,7 @@ class AndroidXmlVisitor(val elementCallback: (ResourceIdentifier, String, XmlAtt
if (idAttribute != null) {
val idAttributeValue = idAttribute.value
if (idAttributeValue != null) {
val xmlType = tag?.getAttribute(AndroidConst.CLASS_ATTRIBUTE_NO_NAMESPACE)?.value ?: localName
val xmlType = tag.getAttribute(AndroidConst.CLASS_ATTRIBUTE_NO_NAMESPACE)?.value ?: localName
val name = androidIdToName(idAttributeValue)
if (name != null) elementCallback(name, xmlType, idAttribute)
}
@@ -83,7 +83,7 @@ class IDEAndroidLayoutXmlFileManager(val module: Module) : AndroidLayoutXmlFileM
val propertyName = propertyDescriptor.name.asString()
val attributes = arrayListOf<PsiElement>()
val visitor = AndroidXmlVisitor { retId, wClass, valueElement ->
val visitor = AndroidXmlVisitor { retId, _, valueElement ->
if (retId.name == propertyName) attributes.add(valueElement)
}
@@ -114,7 +114,7 @@ class IDEAndroidLayoutXmlFileManager(val module: Module) : AndroidLayoutXmlFileM
if (applicationPackage != null) {
val mainVariant = mainSourceProvider.toVariant()
val method = try { javaClass.getMethod("getFlavorSourceProviders") } catch (e: NoSuchMethodException) { null }
val method = try { this::class.java.getMethod("getFlavorSourceProviders") } catch (e: NoSuchMethodException) { null }
val variants: List<AndroidVariant>? = if (method != null) {
val sourceProviders = method.invoke(this) as List<SourceProvider>?
sourceProviders?.map { it.toVariant() } ?: listOf()
@@ -48,7 +48,7 @@ abstract class AbstractAndroidGotoTest : KotlinAndroidTestCase() {
val targetElement = GotoDeclarationAction.findTargetElement(f.project, f.editor, f.caretOffset)!!
assert(targetElement is XmlAttributeValue) { "XmlAttributeValue expected, got ${targetElement.javaClass}" }
assert(targetElement is XmlAttributeValue) { "XmlAttributeValue expected, got ${targetElement::class.java}" }
assertEquals("@+id/${property.name}", (targetElement as XmlAttributeValue).value)
}
}
@@ -62,16 +62,16 @@ class KotlinAndroidJpsPlugin : KotlinJpsCompilerArgumentsProvider {
val module = moduleBuildTarget.module
if (!hasAndroidJpsPlugin() || !isAndroidModuleWithoutGradle(module)) return emptyList()
val inJar = File(PathUtil.getJarPathForClass(javaClass)).isFile
val inJar = File(PathUtil.getJarPathForClass(this::class.java)).isFile
val manifestFile = getAndroidManifest(moduleBuildTarget.module)
return if (manifestFile != null) {
listOf(
if (inJar) {
val libDirectory = File(PathUtil.getJarPathForClass(javaClass)).parentFile.parentFile
val libDirectory = File(PathUtil.getJarPathForClass(this::class.java)).parentFile.parentFile
File(libDirectory, JAR_FILE_NAME).absolutePath
} else {
// We're in tests now (in out/production/android-extensions/android-extensions-jps)
val kotlinProjectDirectory = File(PathUtil.getJarPathForClass(javaClass)).parentFile.parentFile.parentFile
val kotlinProjectDirectory = File(PathUtil.getJarPathForClass(this::class.java)).parentFile.parentFile.parentFile
File(kotlinProjectDirectory, "dist/kotlinc/lib/$JAR_FILE_NAME").absolutePath
})
}