Refactor light elements

KtLightElement#delegate -> clsDelegate, KtLightElement#origin -> kotlinOrigin and make them properties
KtLightClassForDecompiledDeclaration stores KtClsFile
KtLightField stores LightMemberOrigin
This commit is contained in:
Pavel V. Talanov
2016-03-29 18:48:30 +03:00
parent 02543295f9
commit f40a04c5a2
46 changed files with 247 additions and 254 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2015 JetBrains s.r.o.
* Copyright 2010-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -326,7 +326,7 @@ class DefaultExpressionConverter : JavaElementVisitor(), ExpressionConverter {
val typeArguments = convertTypeArguments(expression)
if (target is KtLightMethod) {
val origin = target.getOrigin()
val origin = target.kotlinOrigin
val isTopLevel = origin?.getStrictParentOfType<KtClassOrObject>() == null
if (origin is KtProperty || origin is KtPropertyAccessor || origin is KtParameter) {
val property = if (origin is KtPropertyAccessor)
@@ -429,7 +429,7 @@ class DefaultExpressionConverter : JavaElementVisitor(), ExpressionConverter {
}
private fun KtLightMethod.isKotlinExtensionFunction(): Boolean {
val origin = this.getOrigin()
val origin = this.kotlinOrigin
if (origin != null) return origin.isExtensionDeclaration()
val parameters = parameterList.parameters
@@ -539,7 +539,7 @@ class DefaultExpressionConverter : JavaElementVisitor(), ExpressionConverter {
identifier = Identifier("size", isNullable).assignNoPrototype()
}
else if (qualifier != null) {
if (target is KtLightField && target.getOrigin() is KtObjectDeclaration) {
if (target is KtLightField && target.kotlinOrigin is KtObjectDeclaration) {
result = codeConverter.convertExpression(qualifier)
return
}
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2015 JetBrains s.r.o.
* Copyright 2010-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -380,7 +380,7 @@ class TypeConverter(val converter: Converter) {
override fun fromAnnotations(owner: PsiModifierListOwner): Mutability {
if (owner is KtLightElement<*, *>) {
val jetDeclaration = owner.getOrigin() as? KtCallableDeclaration ?: return Mutability.Default
val jetDeclaration = owner.kotlinOrigin as? KtCallableDeclaration ?: return Mutability.Default
val descriptor = converter.services.resolverForConverter.resolveToDescriptor(jetDeclaration) as? CallableDescriptor ?: return Mutability.Default
val type = descriptor.returnType ?: return Mutability.Default
val classDescriptor = TypeUtils.getClassDescriptor(type) ?: return Mutability.Default
+2 -2
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2015 JetBrains s.r.o.
* Copyright 2010-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -128,4 +128,4 @@ fun PsiMember.isImported(file: PsiJavaFile): Boolean {
fun PsiExpression.isNullLiteral() = this is PsiLiteralExpression && type == PsiType.NULL
// TODO: set origin for facade classes in library
fun isFacadeClassFromLibrary(element: PsiElement?) = element is KtLightClass && element.getOrigin() == null
fun isFacadeClassFromLibrary(element: PsiElement?) = element is KtLightClass && element.kotlinOrigin == null
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2015 JetBrains s.r.o.
* Copyright 2010-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -367,7 +367,7 @@ private class PropertyDetector(
return if (propertyInfo != null) SuperInfo.Property(propertyInfo.isVar, propertyInfo.name) else SuperInfo.Function
}
else if (superMethod is KtLightMethod) {
val origin = superMethod.getOrigin()
val origin = superMethod.kotlinOrigin
return if (origin is KtProperty) SuperInfo.Property(origin.isVar, origin.name ?: "") else SuperInfo.Function
}
else {