Use javaClass instead of getClass()

This commit is contained in:
Alexander Udalov
2014-07-22 00:35:36 +04:00
parent 8c13a76805
commit bea740b478
13 changed files with 23 additions and 23 deletions
@@ -85,7 +85,7 @@ private object DebugTextBuildingVisitor : JetVisitor<String, Unit>() {
override fun visitJetElement(element: JetElement, data: Unit?): String? {
if (element is JetElementImplStub<*>) {
LOG.error("getDebugText() is not defined for ${element.getClass()}")
LOG.error("getDebugText() is not defined for ${element.javaClass}")
}
return element.getText()
}
@@ -203,7 +203,7 @@ public fun PsiElement.deleteElementAndCleanParent() {
JetPsiUtil.deleteElementWithDelimiters(this)
[suppress("UNCHECKED_CAST")]
JetPsiUtil.deleteChildlessElement(parent, this.getClass() as Class<PsiElement>)
JetPsiUtil.deleteChildlessElement(parent, this.javaClass as Class<PsiElement>)
}
public fun PsiElement.parameterIndex(): Int {
@@ -329,4 +329,4 @@ public fun JetElement.getCalleeExpressionIfAny(): JetExpression? {
}
}
public fun JetElement.getTextWithLocation(): String = "'${this.getText()}' at ${DiagnosticUtils.atLocation(this)}"
public fun JetElement.getTextWithLocation(): String = "'${this.getText()}' at ${DiagnosticUtils.atLocation(this)}"
@@ -30,7 +30,7 @@ import java.util.ArrayList
public open class JetStubBaseImpl<T : JetElementImplStub<*>>(parent: StubElement<*>?, elementType: IStubElementType<*, *>) : StubBase<T>(parent, elementType) {
override fun toString(): String {
val stubInterface = this.getClass().getInterfaces().first()
val stubInterface = this.javaClass.getInterfaces().first()
val propertiesValues = renderPropertyValues(stubInterface)
if (propertiesValues.isEmpty()) {
return ""
@@ -37,6 +37,6 @@ public class ExceptionTracker : ModificationTracker, LockBasedStorageManager.Exc
}
override fun toString(): String {
return getClass().getName() + ": " + getModificationCount()
return javaClass.getName() + ": " + getModificationCount()
}
}
@@ -77,6 +77,6 @@ public class SyntheticKotlinBlock(
}
}
return getClass().getName() + ": " + textRange
return javaClass.getName() + ": " + textRange
}
}
@@ -88,7 +88,7 @@ private fun buildDecompiledText(packageFqName: FqName, descriptors: List<Declara
fun appendDescriptor(descriptor: DeclarationDescriptor, indent: String) {
if (descriptor is MissingDependencyErrorClass) {
throw IllegalStateException("${descriptor.getClass().getSimpleName()} cannot be rendered. FqName: ${descriptor.fullFqName}")
throw IllegalStateException("${descriptor.javaClass.getSimpleName()} cannot be rendered. FqName: ${descriptor.fullFqName}")
}
val startOffset = builder.length()
val header = if (isEnumEntry(descriptor))
@@ -160,4 +160,4 @@ private fun buildDecompiledText(packageFqName: FqName, descriptors: List<Declara
}
return DecompiledText(builder.toString(), renderedDescriptorsToRange)
}
}
@@ -223,7 +223,7 @@ public class MoveKotlinTopLevelDeclarationsProcessor(project: Project, val optio
override fun performRefactoring(usages: Array<out UsageInfo>?) {
fun moveDeclaration(declaration: JetNamedDeclaration, moveTarget: KotlinMoveTarget): JetNamedDeclaration? {
val file = declaration.getContainingFile() as? JetFile
assert (file != null, "${declaration.getClass()}: ${declaration.getText()}")
assert (file != null, "${declaration.javaClass}: ${declaration.getText()}")
val targetPsi = moveTarget.getOrCreateTargetPsi(declaration)
val targetFile =
@@ -238,7 +238,7 @@ public class MoveKotlinTopLevelDeclarationsProcessor(project: Project, val optio
}
else targetPsi
assert(targetFile is JetFile, "Couldn't create Koltin file for: ${declaration.getClass()}: ${declaration.getText()}")
assert(targetFile is JetFile, "Couldn't create Koltin file for: ${declaration.javaClass}: ${declaration.getText()}")
val newPackageFqName = (targetFile as JetFile).getPackageFqName()
@@ -35,7 +35,7 @@ public abstract class AbstractDecompiledTextTest() : JetLightCodeInsightFixtureT
val classFile = NavigateToDecompiledLibraryTest.getClassFile("test", getTestName(false), myModule!!)
val clsFileForClassFile = PsiManager.getInstance(getProject()!!).findFile(classFile)
assertNotNull(clsFileForClassFile)
assertTrue("Expecting java class file, was: " + clsFileForClassFile!!.getClass(), clsFileForClassFile is ClsFileImpl)
assertTrue("Expecting java class file, was: " + clsFileForClassFile.javaClass, clsFileForClassFile is ClsFileImpl)
val decompiledPsiFile = (clsFileForClassFile as ClsFileImpl).getDecompiledPsiFile()
assertNotNull(decompiledPsiFile)
assertSameLinesWithFile(path.substring(0, path.length - 1) + ".expected.kt", decompiledPsiFile!!.getText())
@@ -62,11 +62,11 @@ public class InternalCompiledClassesTest : JetLightCodeInsightFixtureTestCase()
val psiFile = PsiManager.getInstance(project).findFile(this)
Assert.assertTrue("Should not be kotlin file",
psiFile !is JetClsFile)
Assert.assertTrue("Should be java file, was ${psiFile!!.getClass().getSimpleName()}",
Assert.assertTrue("Should be java file, was ${psiFile.javaClass.getSimpleName()}",
psiFile is ClsFileImpl)
val decompiledPsiFile = (psiFile as PsiCompiledFile).getDecompiledPsiFile()!!
Assert.assertTrue("Should be java decompiled file, was ${decompiledPsiFile.getClass().getSimpleName()}",
Assert.assertTrue("Should be java decompiled file, was ${decompiledPsiFile.javaClass.getSimpleName()}",
decompiledPsiFile is PsiJavaFile)
val classes = (decompiledPsiFile as PsiJavaFile).getClasses()
Assert.assertTrue("Should have some decompiled text",
@@ -93,7 +93,7 @@ private fun ReceiverParameterDescriptor.getNameForCapturedReceiver(): String {
val containingDeclaration = this.getContainingDeclaration()
assert(containingDeclaration is MemberDescriptor) {
"Unsupported descriptor type: ${containingDeclaration.getClass()}, " +
"Unsupported descriptor type: ${containingDeclaration.javaClass}, " +
"receiverDescriptor = $this, " +"containingDeclaration = $containingDeclaration"
}
@@ -102,4 +102,4 @@ private fun ReceiverParameterDescriptor.getNameForCapturedReceiver(): String {
}
return containingDeclaration.getNameForCapturedDescriptor()
}
}
@@ -125,7 +125,7 @@ open class KotlinPlugin [Inject] (val scriptHandler: ScriptHandler): Plugin<Proj
open class KotlinAndroidPlugin [Inject] (val scriptHandler: ScriptHandler): Plugin<Project> {
val log = Logging.getLogger(getClass())
val log = Logging.getLogger(this.javaClass)
public override fun apply(p0: Project) {
@@ -35,8 +35,8 @@ public open class KotlinCompile(): AbstractCompile() {
val srcDirsRoots = HashSet<File>()
val compiler = K2JVMCompiler()
private val _logger = Logging.getLogger(getClass())
override fun getLogger() = _logger
private val logger = Logging.getLogger(this.javaClass)
override fun getLogger() = logger
public var kotlinOptions: K2JVMCompilerArguments = K2JVMCompilerArguments();
@@ -148,8 +148,8 @@ public open class KotlinCompile(): AbstractCompile() {
public open class KDoc(): SourceTask() {
private val _logger = Logging.getLogger(getClass())
override fun getLogger() = _logger
private val logger = Logging.getLogger(this.javaClass)
override fun getLogger() = logger
public var kdocArgs: KDocArguments = KDocArguments()
@@ -15,7 +15,7 @@ import org.gradle.api.initialization.dsl.ScriptHandler
abstract class KotlinBasePluginWrapper: Plugin<Project> {
val log = Logging.getLogger(getClass())
val log = Logging.getLogger(this.javaClass)
public override fun apply(project: Project) {
val sourceBuildScript = findSourceBuildScript(project);
@@ -30,7 +30,7 @@ abstract class KotlinBasePluginWrapper: Plugin<Project> {
log.debug("Loading version information")
val props = Properties()
val propFileName = "project.properties"
val inputStream = getClass().getClassLoader()!!.getResourceAsStream(propFileName)
val inputStream = this.javaClass.getClassLoader()!!.getResourceAsStream(propFileName)
if (inputStream == null) {
throw FileNotFoundException("property file '" + propFileName + "' not found in the classpath")
@@ -51,7 +51,7 @@ abstract class KotlinBasePluginWrapper: Plugin<Project> {
val kotlinPluginDependencies : List<URL> = configuration.getResolvedConfiguration().getFiles(KSpec({ dep -> true }))!!.map({(f: File):URL -> f.toURI().toURL() })
log.debug("Resolved files: [" + kotlinPluginDependencies.toString() + "]")
log.debug("Load plugin in parent-last URL classloader")
val kotlinPluginClassloader = ParentLastURLClassLoader(kotlinPluginDependencies, getClass().getClassLoader())
val kotlinPluginClassloader = ParentLastURLClassLoader(kotlinPluginDependencies, this.javaClass.getClassLoader())
log.debug("Class loader created")
val cls = Class.forName(getPluginClassName(), true, kotlinPluginClassloader)
log.debug("Plugin class loaded")