Reformat and cleanup in asJava/elements
This commit is contained in:
+5
-6
@@ -29,10 +29,10 @@ import org.jetbrains.kotlin.name.FqName
|
|||||||
import org.jetbrains.kotlin.psi.KtFile
|
import org.jetbrains.kotlin.psi.KtFile
|
||||||
|
|
||||||
open class FakeFileForLightClass(
|
open class FakeFileForLightClass(
|
||||||
val ktFile: KtFile,
|
val ktFile: KtFile,
|
||||||
private val lightClass: () -> KtLightClass,
|
private val lightClass: () -> KtLightClass,
|
||||||
private val stub: () -> PsiClassHolderFileStub<*>,
|
private val stub: () -> PsiClassHolderFileStub<*>,
|
||||||
private val packageFqName: FqName = ktFile.packageFqName
|
private val packageFqName: FqName = ktFile.packageFqName
|
||||||
) : ClsFileImpl(ktFile.viewProvider) {
|
) : ClsFileImpl(ktFile.viewProvider) {
|
||||||
|
|
||||||
override fun getVirtualFile(): VirtualFile =
|
override fun getVirtualFile(): VirtualFile =
|
||||||
@@ -78,8 +78,7 @@ open class FakeFileForLightClass(
|
|||||||
override fun setPackageName(packageName: String) {
|
override fun setPackageName(packageName: String) {
|
||||||
if (lightClass() is KtLightClassForFacade) {
|
if (lightClass() is KtLightClassForFacade) {
|
||||||
ktFile.packageDirective?.fqName = FqName(packageName)
|
ktFile.packageDirective?.fqName = FqName(packageName)
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
super.setPackageName(packageName)
|
super.setPackageName(packageName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-1
@@ -26,7 +26,12 @@ import org.jetbrains.kotlin.idea.KotlinLanguage
|
|||||||
|
|
||||||
class KotlinLightTypeParameterListBuilder(private val owner: PsiTypeParameterListOwner) :
|
class KotlinLightTypeParameterListBuilder(private val owner: PsiTypeParameterListOwner) :
|
||||||
LightTypeParameterListBuilder(owner.manager, KotlinLanguage.INSTANCE) {
|
LightTypeParameterListBuilder(owner.manager, KotlinLanguage.INSTANCE) {
|
||||||
override fun processDeclarations(processor: PsiScopeProcessor, state: ResolveState, lastParent: PsiElement?, place: PsiElement): Boolean {
|
override fun processDeclarations(
|
||||||
|
processor: PsiScopeProcessor,
|
||||||
|
state: ResolveState,
|
||||||
|
lastParent: PsiElement?,
|
||||||
|
place: PsiElement
|
||||||
|
): Boolean {
|
||||||
return typeParameters.all { processor.execute(it, state) }
|
return typeParameters.all { processor.execute(it, state) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -23,7 +23,7 @@ import com.intellij.psi.impl.light.LightElement
|
|||||||
import org.jetbrains.kotlin.idea.KotlinLanguage
|
import org.jetbrains.kotlin.idea.KotlinLanguage
|
||||||
import org.jetbrains.kotlin.psi.KtElement
|
import org.jetbrains.kotlin.psi.KtElement
|
||||||
|
|
||||||
abstract class KtLightElementBase(private val parent: PsiElement): LightElement(parent.manager, KotlinLanguage.INSTANCE) {
|
abstract class KtLightElementBase(private val parent: PsiElement) : LightElement(parent.manager, KotlinLanguage.INSTANCE) {
|
||||||
override fun toString() = "${this.javaClass.simpleName} of $parent"
|
override fun toString() = "${this.javaClass.simpleName} of $parent"
|
||||||
override fun getParent(): PsiElement = parent
|
override fun getParent(): PsiElement = parent
|
||||||
|
|
||||||
|
|||||||
+23
-20
@@ -27,13 +27,12 @@ import org.jetbrains.kotlin.asJava.classes.cannotModify
|
|||||||
import org.jetbrains.kotlin.asJava.classes.lazyPub
|
import org.jetbrains.kotlin.asJava.classes.lazyPub
|
||||||
import org.jetbrains.kotlin.psi.KtEnumEntry
|
import org.jetbrains.kotlin.psi.KtEnumEntry
|
||||||
import org.jetbrains.kotlin.psi.KtNamedDeclaration
|
import org.jetbrains.kotlin.psi.KtNamedDeclaration
|
||||||
import java.lang.UnsupportedOperationException
|
|
||||||
|
|
||||||
sealed class KtLightFieldImpl<D : PsiField>(
|
sealed class KtLightFieldImpl<D : PsiField>(
|
||||||
override val lightMemberOrigin: LightMemberOrigin?,
|
override val lightMemberOrigin: LightMemberOrigin?,
|
||||||
computeRealDelegate: () -> D,
|
computeRealDelegate: () -> D,
|
||||||
containingClass: KtLightClass,
|
containingClass: KtLightClass,
|
||||||
dummyDelegate: PsiField?
|
dummyDelegate: PsiField?
|
||||||
) : KtLightMemberImpl<PsiField>(computeRealDelegate, lightMemberOrigin, containingClass, dummyDelegate), KtLightField {
|
) : KtLightMemberImpl<PsiField>(computeRealDelegate, lightMemberOrigin, containingClass, dummyDelegate), KtLightField {
|
||||||
|
|
||||||
override val clsDelegate: D
|
override val clsDelegate: D
|
||||||
@@ -60,10 +59,10 @@ sealed class KtLightFieldImpl<D : PsiField>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun equals(other: Any?): Boolean =
|
override fun equals(other: Any?): Boolean =
|
||||||
this === other ||
|
this === other ||
|
||||||
(other is KtLightFieldImpl<*> &&
|
(other is KtLightFieldImpl<*> &&
|
||||||
this.name == other.name &&
|
this.name == other.name &&
|
||||||
this.containingClass == other.containingClass)
|
this.containingClass == other.containingClass)
|
||||||
|
|
||||||
override fun hashCode() = 31 * containingClass.hashCode() + name.hashCode()
|
override fun hashCode() = 31 * containingClass.hashCode() + name.hashCode()
|
||||||
|
|
||||||
@@ -75,17 +74,16 @@ sealed class KtLightFieldImpl<D : PsiField>(
|
|||||||
|
|
||||||
|
|
||||||
class KtLightEnumConstant(
|
class KtLightEnumConstant(
|
||||||
origin: LightMemberOrigin?,
|
origin: LightMemberOrigin?,
|
||||||
computeDelegate: () -> PsiEnumConstant,
|
computeDelegate: () -> PsiEnumConstant,
|
||||||
containingClass: KtLightClass,
|
containingClass: KtLightClass,
|
||||||
dummyDelegate: PsiField?
|
dummyDelegate: PsiField?
|
||||||
) : KtLightFieldImpl<PsiEnumConstant>(origin, computeDelegate, containingClass, dummyDelegate), PsiEnumConstant {
|
) : KtLightFieldImpl<PsiEnumConstant>(origin, computeDelegate, containingClass, dummyDelegate), PsiEnumConstant {
|
||||||
private val initializingClass by lazyPub {
|
private val initializingClass by lazyPub {
|
||||||
val kotlinEnumEntry = (lightMemberOrigin as? LightMemberOriginForDeclaration)?.originalElement as? KtEnumEntry
|
val kotlinEnumEntry = (lightMemberOrigin as? LightMemberOriginForDeclaration)?.originalElement as? KtEnumEntry
|
||||||
if (kotlinEnumEntry != null && kotlinEnumEntry.declarations.isNotEmpty()) {
|
if (kotlinEnumEntry != null && kotlinEnumEntry.declarations.isNotEmpty()) {
|
||||||
KtLightClassForEnumEntry(kotlinEnumEntry, clsDelegate)
|
KtLightClassForEnumEntry(kotlinEnumEntry, clsDelegate)
|
||||||
}
|
} else null
|
||||||
else null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: we don't use "delegation by" because the compiler would generate method calls to ALL of PsiEnumConstant members,
|
// NOTE: we don't use "delegation by" because the compiler would generate method calls to ALL of PsiEnumConstant members,
|
||||||
@@ -102,7 +100,12 @@ sealed class KtLightFieldImpl<D : PsiField>(
|
|||||||
override fun resolveMethodGenerics() = clsDelegate.resolveMethodGenerics()
|
override fun resolveMethodGenerics() = clsDelegate.resolveMethodGenerics()
|
||||||
}
|
}
|
||||||
|
|
||||||
class KtLightFieldForSourceDeclaration(origin: LightMemberOrigin?, computeDelegate: () -> PsiField, containingClass: KtLightClass, dummyDelegate: PsiField?) :
|
class KtLightFieldForSourceDeclaration(
|
||||||
|
origin: LightMemberOrigin?,
|
||||||
|
computeDelegate: () -> PsiField,
|
||||||
|
containingClass: KtLightClass,
|
||||||
|
dummyDelegate: PsiField?
|
||||||
|
) :
|
||||||
KtLightFieldImpl<PsiField>(origin, computeDelegate, containingClass, dummyDelegate),
|
KtLightFieldImpl<PsiField>(origin, computeDelegate, containingClass, dummyDelegate),
|
||||||
KtLightFieldForSourceDeclarationSupport
|
KtLightFieldForSourceDeclarationSupport
|
||||||
|
|
||||||
@@ -113,10 +116,10 @@ sealed class KtLightFieldImpl<D : PsiField>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun lazy(
|
fun lazy(
|
||||||
dummyDelegate: PsiField,
|
dummyDelegate: PsiField,
|
||||||
origin: LightMemberOriginForDeclaration?,
|
origin: LightMemberOriginForDeclaration?,
|
||||||
containingClass: KtLightClass,
|
containingClass: KtLightClass,
|
||||||
computeRealDelegate: () -> PsiField
|
computeRealDelegate: () -> PsiField
|
||||||
): KtLightField {
|
): KtLightField {
|
||||||
if (dummyDelegate is PsiEnumConstant) {
|
if (dummyDelegate is PsiEnumConstant) {
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
|
|||||||
+2
-2
@@ -35,8 +35,8 @@ open class KtLightIdentifier(
|
|||||||
get() = when (ktDeclaration) {
|
get() = when (ktDeclaration) {
|
||||||
is KtSecondaryConstructor -> ktDeclaration.getConstructorKeyword()
|
is KtSecondaryConstructor -> ktDeclaration.getConstructorKeyword()
|
||||||
is KtPrimaryConstructor -> ktDeclaration.getConstructorKeyword()
|
is KtPrimaryConstructor -> ktDeclaration.getConstructorKeyword()
|
||||||
?: ktDeclaration.valueParameterList
|
?: ktDeclaration.valueParameterList
|
||||||
?: ktDeclaration.containingClassOrObject?.nameIdentifier
|
?: ktDeclaration.containingClassOrObject?.nameIdentifier
|
||||||
else -> ktDeclaration?.nameIdentifier
|
else -> ktDeclaration?.nameIdentifier
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+13
-12
@@ -33,10 +33,10 @@ import org.jetbrains.kotlin.psi.KtNamedDeclaration
|
|||||||
import org.jetbrains.kotlin.psi.psiUtil.hasBody
|
import org.jetbrains.kotlin.psi.psiUtil.hasBody
|
||||||
|
|
||||||
abstract class KtLightMemberImpl<out D : PsiMember>(
|
abstract class KtLightMemberImpl<out D : PsiMember>(
|
||||||
computeRealDelegate: () -> D,
|
computeRealDelegate: () -> D,
|
||||||
override val lightMemberOrigin: LightMemberOrigin?,
|
override val lightMemberOrigin: LightMemberOrigin?,
|
||||||
private val containingClass: KtLightClass,
|
private val containingClass: KtLightClass,
|
||||||
private val dummyDelegate: D?
|
private val dummyDelegate: D?
|
||||||
) : KtLightElementBase(containingClass), PsiMember, KtLightMember<D> {
|
) : KtLightElementBase(containingClass), PsiMember, KtLightMember<D> {
|
||||||
override val clsDelegate by lazyPub(computeRealDelegate)
|
override val clsDelegate by lazyPub(computeRealDelegate)
|
||||||
private val lightIdentifier by lazyPub { KtLightIdentifier(this, kotlinOrigin as? KtNamedDeclaration) }
|
private val lightIdentifier by lazyPub { KtLightIdentifier(this, kotlinOrigin as? KtNamedDeclaration) }
|
||||||
@@ -73,8 +73,8 @@ abstract class KtLightMemberImpl<out D : PsiMember>(
|
|||||||
if (lightMemberOrigin?.originalElement?.isEquivalentTo(another) == true) return true
|
if (lightMemberOrigin?.originalElement?.isEquivalentTo(another) == true) return true
|
||||||
|
|
||||||
val isEquivalentByOrigin =
|
val isEquivalentByOrigin =
|
||||||
another is KtLightMember<*> &&
|
another is KtLightMember<*> &&
|
||||||
lightMemberOrigin?.isEquivalentTo(another.lightMemberOrigin) == true
|
lightMemberOrigin?.isEquivalentTo(another.lightMemberOrigin) == true
|
||||||
|
|
||||||
return isEquivalentByOrigin || this == another
|
return isEquivalentByOrigin || this == another
|
||||||
}
|
}
|
||||||
@@ -91,13 +91,14 @@ internal fun getMemberOrigin(member: PsiMember): LightMemberOriginForDeclaration
|
|||||||
private val visibilityModifiers = arrayOf(PsiModifier.PRIVATE, PsiModifier.PACKAGE_LOCAL, PsiModifier.PROTECTED, PsiModifier.PUBLIC)
|
private val visibilityModifiers = arrayOf(PsiModifier.PRIVATE, PsiModifier.PACKAGE_LOCAL, PsiModifier.PROTECTED, PsiModifier.PUBLIC)
|
||||||
|
|
||||||
private class KtLightMemberModifierList(
|
private class KtLightMemberModifierList(
|
||||||
owner: KtLightMember<*>, private val dummyDelegate: PsiModifierList?
|
owner: KtLightMember<*>, private val dummyDelegate: PsiModifierList?
|
||||||
) : KtLightModifierList<KtLightMember<*>>(owner) {
|
) : KtLightModifierList<KtLightMember<*>>(owner) {
|
||||||
override fun hasModifierProperty(name: String) = when {
|
override fun hasModifierProperty(name: String) = when {
|
||||||
name == PsiModifier.ABSTRACT && isImplementationInInterface() -> false
|
name == PsiModifier.ABSTRACT && isImplementationInInterface() -> false
|
||||||
// pretend this method behaves like a default method
|
// pretend this method behaves like a default method
|
||||||
name == PsiModifier.DEFAULT && isImplementationInInterface() -> true
|
name == PsiModifier.DEFAULT && isImplementationInInterface() -> true
|
||||||
name == PsiModifier.FINAL && ((owner.containingClass as? KtLightClassForSourceDeclaration)?.isPossiblyAffectedByAllOpen() ?: false) ->
|
name == PsiModifier.FINAL && ((owner.containingClass as? KtLightClassForSourceDeclaration)?.isPossiblyAffectedByAllOpen()
|
||||||
|
?: false) ->
|
||||||
clsDelegate.hasModifierProperty(name)
|
clsDelegate.hasModifierProperty(name)
|
||||||
dummyDelegate != null -> {
|
dummyDelegate != null -> {
|
||||||
when {
|
when {
|
||||||
@@ -110,13 +111,13 @@ private class KtLightMemberModifierList(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun hasExplicitModifier(name: String) =
|
override fun hasExplicitModifier(name: String) =
|
||||||
// kotlin methods can't be truly default atm, that way we can avoid being reported on by diagnostics, namely android lint
|
// kotlin methods can't be truly default atm, that way we can avoid being reported on by diagnostics, namely android lint
|
||||||
if (name == PsiModifier.DEFAULT) false else super.hasExplicitModifier(name)
|
if (name == PsiModifier.DEFAULT) false else super.hasExplicitModifier(name)
|
||||||
|
|
||||||
private fun isMethodOverride() = owner is KtLightMethod && owner.kotlinOrigin?.hasModifier(KtTokens.OVERRIDE_KEYWORD) ?: false
|
private fun isMethodOverride() = owner is KtLightMethod && owner.kotlinOrigin?.hasModifier(KtTokens.OVERRIDE_KEYWORD) ?: false
|
||||||
|
|
||||||
private fun isImplementationInInterface()
|
private fun isImplementationInInterface() =
|
||||||
= owner.containingClass.isInterface && owner is KtLightMethod && owner.kotlinOrigin?.hasBody() ?: false
|
owner.containingClass.isInterface && owner is KtLightMethod && owner.kotlinOrigin?.hasBody() ?: false
|
||||||
|
|
||||||
override fun copy() = KtLightMemberModifierList(owner, dummyDelegate)
|
override fun copy() = KtLightMemberModifierList(owner, dummyDelegate)
|
||||||
}
|
}
|
||||||
|
|||||||
+30
-26
@@ -40,10 +40,10 @@ import org.jetbrains.kotlin.resolve.DescriptorUtils
|
|||||||
import org.jetbrains.kotlin.resolve.jvm.KotlinJavaPsiFacade
|
import org.jetbrains.kotlin.resolve.jvm.KotlinJavaPsiFacade
|
||||||
|
|
||||||
open class KtLightMethodImpl protected constructor(
|
open class KtLightMethodImpl protected constructor(
|
||||||
computeRealDelegate: () -> PsiMethod,
|
computeRealDelegate: () -> PsiMethod,
|
||||||
lightMemberOrigin: LightMemberOrigin?,
|
lightMemberOrigin: LightMemberOrigin?,
|
||||||
containingClass: KtLightClass,
|
containingClass: KtLightClass,
|
||||||
private val dummyDelegate: PsiMethod? = null
|
private val dummyDelegate: PsiMethod? = null
|
||||||
) : KtLightMemberImpl<PsiMethod>(computeRealDelegate, lightMemberOrigin, containingClass, dummyDelegate), KtLightMethod {
|
) : KtLightMemberImpl<PsiMethod>(computeRealDelegate, lightMemberOrigin, containingClass, dummyDelegate), KtLightMethod {
|
||||||
private val returnTypeElem by lazyPub {
|
private val returnTypeElem by lazyPub {
|
||||||
val delegateTypeElement = clsDelegate.returnTypeElement as? ClsTypeElementImpl
|
val delegateTypeElement = clsDelegate.returnTypeElement as? ClsTypeElementImpl
|
||||||
@@ -84,8 +84,7 @@ open class KtLightMethodImpl protected constructor(
|
|||||||
override fun accept(visitor: PsiElementVisitor) {
|
override fun accept(visitor: PsiElementVisitor) {
|
||||||
if (visitor is JavaElementVisitor) {
|
if (visitor is JavaElementVisitor) {
|
||||||
visitor.visitMethod(this)
|
visitor.visitMethod(this)
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
visitor.visitElement(this)
|
visitor.visitElement(this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -108,8 +107,7 @@ open class KtLightMethodImpl protected constructor(
|
|||||||
val nameExpression = jvmNameAnnotation?.findAttributeValue("name")?.unwrapped as? KtStringTemplateExpression
|
val nameExpression = jvmNameAnnotation?.findAttributeValue("name")?.unwrapped as? KtStringTemplateExpression
|
||||||
if (nameExpression != null) {
|
if (nameExpression != null) {
|
||||||
nameExpression.replace(KtPsiFactory(this).createStringTemplate(name))
|
nameExpression.replace(KtPsiFactory(this).createStringTemplate(name))
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
val toRename = kotlinOrigin as? PsiNamedElement ?: cannotModify()
|
val toRename = kotlinOrigin as? PsiNamedElement ?: cannotModify()
|
||||||
toRename.setName(newNameForOrigin)
|
toRename.setName(newNameForOrigin)
|
||||||
}
|
}
|
||||||
@@ -136,7 +134,7 @@ open class KtLightMethodImpl protected constructor(
|
|||||||
override fun getTypeParameterList() = typeParamsList
|
override fun getTypeParameterList() = typeParamsList
|
||||||
|
|
||||||
override fun getTypeParameters(): Array<PsiTypeParameter> =
|
override fun getTypeParameters(): Array<PsiTypeParameter> =
|
||||||
typeParameterList?.typeParameters ?: PsiTypeParameter.EMPTY_ARRAY
|
typeParameterList?.typeParameters ?: PsiTypeParameter.EMPTY_ARRAY
|
||||||
|
|
||||||
override fun hasTypeParameters() = typeParameters.isNotEmpty()
|
override fun hasTypeParameters() = typeParameters.isNotEmpty()
|
||||||
|
|
||||||
@@ -151,7 +149,12 @@ open class KtLightMethodImpl protected constructor(
|
|||||||
return Factory.create(clsDelegate, lightMemberOrigin?.copy(), containingClass)
|
return Factory.create(clsDelegate, lightMemberOrigin?.copy(), containingClass)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun processDeclarations(processor: PsiScopeProcessor, state: ResolveState, lastParent: PsiElement?, place: PsiElement): Boolean {
|
override fun processDeclarations(
|
||||||
|
processor: PsiScopeProcessor,
|
||||||
|
state: ResolveState,
|
||||||
|
lastParent: PsiElement?,
|
||||||
|
place: PsiElement
|
||||||
|
): Boolean {
|
||||||
return typeParameters.all { processor.execute(it, state) }
|
return typeParameters.all { processor.execute(it, state) }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,14 +166,15 @@ open class KtLightMethodImpl protected constructor(
|
|||||||
for source elements index is unique to each member
|
for source elements index is unique to each member
|
||||||
*/
|
*/
|
||||||
override fun equals(other: Any?): Boolean =
|
override fun equals(other: Any?): Boolean =
|
||||||
this === other ||
|
this === other ||
|
||||||
(other is KtLightMethodImpl &&
|
(other is KtLightMethodImpl &&
|
||||||
this.name == other.name &&
|
this.name == other.name &&
|
||||||
this.containingClass == other.containingClass &&
|
this.containingClass == other.containingClass &&
|
||||||
this.lightMemberOrigin == other.lightMemberOrigin &&
|
this.lightMemberOrigin == other.lightMemberOrigin &&
|
||||||
this.memberIndex == other.memberIndex)
|
this.memberIndex == other.memberIndex)
|
||||||
|
|
||||||
override fun hashCode(): Int = ((getName().hashCode() * 31 + (lightMemberOrigin?.hashCode() ?: 0)) * 31 + containingClass.hashCode()) * 31 + (memberIndex?.hashCode() ?: 0)
|
override fun hashCode(): Int = ((name.hashCode() * 31 + (lightMemberOrigin?.hashCode()
|
||||||
|
?: 0)) * 31 + containingClass.hashCode()) * 31 + (memberIndex?.hashCode() ?: 0)
|
||||||
|
|
||||||
override fun getDefaultValue() = (clsDelegate as? PsiAnnotationMethod)?.defaultValue
|
override fun getDefaultValue() = (clsDelegate as? PsiAnnotationMethod)?.defaultValue
|
||||||
|
|
||||||
@@ -182,8 +186,7 @@ open class KtLightMethodImpl protected constructor(
|
|||||||
calculatingReturnType.set(true)
|
calculatingReturnType.set(true)
|
||||||
try {
|
try {
|
||||||
return returnTypeElement?.type
|
return returnTypeElement?.type
|
||||||
}
|
} finally {
|
||||||
finally {
|
|
||||||
calculatingReturnType.set(false)
|
calculatingReturnType.set(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -220,16 +223,16 @@ open class KtLightMethodImpl protected constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun create(
|
fun create(
|
||||||
delegate: PsiMethod, origin: LightMemberOrigin?, containingClass: KtLightClass
|
delegate: PsiMethod, origin: LightMemberOrigin?, containingClass: KtLightClass
|
||||||
): KtLightMethodImpl {
|
): KtLightMethodImpl {
|
||||||
return KtLightMethodImpl({ delegate}, origin, containingClass)
|
return KtLightMethodImpl({ delegate }, origin, containingClass)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun lazy(
|
fun lazy(
|
||||||
dummyDelegate: PsiMethod?,
|
dummyDelegate: PsiMethod?,
|
||||||
containingClass: KtLightClass,
|
containingClass: KtLightClass,
|
||||||
origin: LightMemberOriginForDeclaration?,
|
origin: LightMemberOriginForDeclaration?,
|
||||||
computeRealDelegate: () -> PsiMethod
|
computeRealDelegate: () -> PsiMethod
|
||||||
): KtLightMethodImpl {
|
): KtLightMethodImpl {
|
||||||
return KtLightMethodImpl(computeRealDelegate, origin, containingClass, dummyDelegate)
|
return KtLightMethodImpl(computeRealDelegate, origin, containingClass, dummyDelegate)
|
||||||
}
|
}
|
||||||
@@ -249,7 +252,8 @@ open class KtLightMethodImpl protected constructor(
|
|||||||
|
|
||||||
override fun getHierarchicalMethodSignature() = clsDelegate.hierarchicalMethodSignature
|
override fun getHierarchicalMethodSignature() = clsDelegate.hierarchicalMethodSignature
|
||||||
|
|
||||||
override fun findSuperMethodSignaturesIncludingStatic(checkAccess: Boolean) = clsDelegate.findSuperMethodSignaturesIncludingStatic(checkAccess)
|
override fun findSuperMethodSignaturesIncludingStatic(checkAccess: Boolean) =
|
||||||
|
clsDelegate.findSuperMethodSignaturesIncludingStatic(checkAccess)
|
||||||
|
|
||||||
override fun getBody() = null
|
override fun getBody() = null
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ class KtLightParameter(
|
|||||||
private val index: Int,
|
private val index: Int,
|
||||||
method: KtLightMethod
|
method: KtLightMethod
|
||||||
) : LightParameter(dummyDelegate.name ?: "p$index", dummyDelegate.type, method, KotlinLanguage.INSTANCE),
|
) : LightParameter(dummyDelegate.name ?: "p$index", dummyDelegate.type, method, KotlinLanguage.INSTANCE),
|
||||||
KtLightDeclaration<KtParameter, PsiParameter> {
|
KtLightDeclaration<KtParameter, PsiParameter> {
|
||||||
|
|
||||||
private val lazyDelegate by lazyPub { clsDelegateProvider() ?: dummyDelegate }
|
private val lazyDelegate by lazyPub { clsDelegateProvider() ?: dummyDelegate }
|
||||||
|
|
||||||
@@ -106,8 +106,7 @@ class KtLightParameter(
|
|||||||
|
|
||||||
if (another is KtLightParameter && kotlinOrigin != null) {
|
if (another is KtLightParameter && kotlinOrigin != null) {
|
||||||
kotlinOrigin == another.kotlinOrigin && clsDelegate == another.clsDelegate
|
kotlinOrigin == another.kotlinOrigin && clsDelegate == another.clsDelegate
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
+3
-3
@@ -25,9 +25,9 @@ import org.jetbrains.kotlin.psi.KtElement
|
|||||||
import org.jetbrains.kotlin.psi.KtFunction
|
import org.jetbrains.kotlin.psi.KtFunction
|
||||||
|
|
||||||
class KtLightParameterList(
|
class KtLightParameterList(
|
||||||
private val parent: KtLightMethod,
|
private val parent: KtLightMethod,
|
||||||
private val parametersCount: Int,
|
private val parametersCount: Int,
|
||||||
computeParameters: () -> List<PsiParameter>
|
computeParameters: () -> List<PsiParameter>
|
||||||
) : KtLightElementBase(parent), PsiParameterList {
|
) : KtLightElementBase(parent), PsiParameterList {
|
||||||
|
|
||||||
override val kotlinOrigin: KtElement?
|
override val kotlinOrigin: KtElement?
|
||||||
|
|||||||
+2
-5
@@ -20,16 +20,13 @@ import com.intellij.openapi.util.TextRange
|
|||||||
import com.intellij.psi.PsiElement
|
import com.intellij.psi.PsiElement
|
||||||
import com.intellij.psi.PsiJavaCodeReferenceElement
|
import com.intellij.psi.PsiJavaCodeReferenceElement
|
||||||
import com.intellij.psi.PsiReferenceList
|
import com.intellij.psi.PsiReferenceList
|
||||||
import com.intellij.psi.PsiReferenceList.Role
|
|
||||||
import org.jetbrains.kotlin.asJava.LightClassGenerationSupport
|
|
||||||
import org.jetbrains.kotlin.asJava.classes.KtLightClass
|
import org.jetbrains.kotlin.asJava.classes.KtLightClass
|
||||||
import org.jetbrains.kotlin.asJava.classes.addSuperTypeEntry
|
import org.jetbrains.kotlin.asJava.classes.addSuperTypeEntry
|
||||||
import org.jetbrains.kotlin.asJava.classes.findEntry
|
import org.jetbrains.kotlin.asJava.classes.findEntry
|
||||||
import org.jetbrains.kotlin.asJava.classes.lazyPub
|
import org.jetbrains.kotlin.asJava.classes.lazyPub
|
||||||
import org.jetbrains.kotlin.psi.*
|
import org.jetbrains.kotlin.psi.KtSuperTypeList
|
||||||
|
import org.jetbrains.kotlin.psi.KtSuperTypeListEntry
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.getElementTextWithContext
|
import org.jetbrains.kotlin.psi.psiUtil.getElementTextWithContext
|
||||||
import org.jetbrains.kotlin.resolve.BindingContext
|
|
||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameUnsafe
|
|
||||||
|
|
||||||
class KtLightPsiReferenceList(
|
class KtLightPsiReferenceList(
|
||||||
override val clsDelegate: PsiReferenceList,
|
override val clsDelegate: PsiReferenceList,
|
||||||
|
|||||||
+2
-1
@@ -39,7 +39,8 @@ public class KtLightTypeParameter
|
|||||||
public KtLightTypeParameter(
|
public KtLightTypeParameter(
|
||||||
@NotNull PsiTypeParameterListOwner owner,
|
@NotNull PsiTypeParameterListOwner owner,
|
||||||
int index,
|
int index,
|
||||||
@NotNull String name) {
|
@NotNull String name
|
||||||
|
) {
|
||||||
super(owner.getManager(), KotlinLanguage.INSTANCE);
|
super(owner.getManager(), KotlinLanguage.INSTANCE);
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
this.index = index;
|
this.index = index;
|
||||||
|
|||||||
@@ -32,7 +32,13 @@ public class LightParameter extends LightVariableBuilder implements PsiParameter
|
|||||||
this(name, type, declarationScope, language, type instanceof PsiEllipsisType);
|
this(name, type, declarationScope, language, type instanceof PsiEllipsisType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public LightParameter(@NotNull String name, @NotNull PsiType type, @NotNull KtLightMethod declarationScope, Language language, boolean isVarArgs) {
|
public LightParameter(
|
||||||
|
@NotNull String name,
|
||||||
|
@NotNull PsiType type,
|
||||||
|
@NotNull KtLightMethod declarationScope,
|
||||||
|
Language language,
|
||||||
|
boolean isVarArgs
|
||||||
|
) {
|
||||||
super(declarationScope.getManager(), name, type, language);
|
super(declarationScope.getManager(), name, type, language);
|
||||||
myName = name;
|
myName = name;
|
||||||
myDeclarationScope = declarationScope;
|
myDeclarationScope = declarationScope;
|
||||||
@@ -52,7 +58,7 @@ public class LightParameter extends LightVariableBuilder implements PsiParameter
|
|||||||
@Override
|
@Override
|
||||||
public void accept(@NotNull PsiElementVisitor visitor) {
|
public void accept(@NotNull PsiElementVisitor visitor) {
|
||||||
if (visitor instanceof JavaElementVisitor) {
|
if (visitor instanceof JavaElementVisitor) {
|
||||||
((JavaElementVisitor)visitor).visitParameter(this);
|
((JavaElementVisitor) visitor).visitParameter(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ class KtLightAnnotationForSourceEntry(
|
|||||||
|
|
||||||
override fun getParameterList(): PsiAnnotationParameterList = ktLightAnnotationParameterList
|
override fun getParameterList(): PsiAnnotationParameterList = ktLightAnnotationParameterList
|
||||||
|
|
||||||
inner class KtLightAnnotationParameterList() : KtLightElementBase(this),
|
inner class KtLightAnnotationParameterList : KtLightElementBase(this),
|
||||||
PsiAnnotationParameterList {
|
PsiAnnotationParameterList {
|
||||||
override val kotlinOrigin: KtElement? get() = null
|
override val kotlinOrigin: KtElement? get() = null
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user