Revert "[light classes] drop old light classes and backend: iteration #2"
This reverts commit 97ce502cbe.
This commit is contained in:
+2
-1
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -18,6 +18,7 @@ import org.jetbrains.kotlin.psi.KtClassOrObject
|
|||||||
class FirFakeFileImpl(private val classOrObject: KtClassOrObject, ktClass: KtLightClass) : FakeFileForLightClass(
|
class FirFakeFileImpl(private val classOrObject: KtClassOrObject, ktClass: KtLightClass) : FakeFileForLightClass(
|
||||||
classOrObject.containingKtFile,
|
classOrObject.containingKtFile,
|
||||||
{ if (classOrObject.isTopLevel()) ktClass else getOrCreateFirLightClass(getOutermostClassOrObject(classOrObject))!! },
|
{ if (classOrObject.isTopLevel()) ktClass else getOrCreateFirLightClass(getOutermostClassOrObject(classOrObject))!! },
|
||||||
|
{ null }
|
||||||
) {
|
) {
|
||||||
|
|
||||||
override fun findReferenceAt(offset: Int) = ktFile.findReferenceAt(offset)
|
override fun findReferenceAt(offset: Int) = ktFile.findReferenceAt(offset)
|
||||||
|
|||||||
+1
@@ -172,6 +172,7 @@ class FirLightClassForFacade(
|
|||||||
private val packageClsFile = FakeFileForLightClass(
|
private val packageClsFile = FakeFileForLightClass(
|
||||||
firstFileInFacade,
|
firstFileInFacade,
|
||||||
lightClass = { this },
|
lightClass = { this },
|
||||||
|
stub = { null },
|
||||||
packageFqName = packageFqName
|
packageFqName = packageFqName
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
+6
-6
@@ -97,21 +97,21 @@ class CliLightClassGenerationSupport(
|
|||||||
//force resolve companion for light class generation
|
//force resolve companion for light class generation
|
||||||
traceHolder.bindingContext.get(BindingContext.CLASS, classOrObject)?.companionObjectDescriptor
|
traceHolder.bindingContext.get(BindingContext.CLASS, classOrObject)?.companionObjectDescriptor
|
||||||
|
|
||||||
val (_, bindingContext, diagnostics) = builder(getContext())
|
val (stub, bindingContext, diagnostics) = builder(getContext())
|
||||||
|
|
||||||
bindingContext.get(BindingContext.CLASS, classOrObject) ?: return InvalidLightClassDataHolder
|
bindingContext.get(BindingContext.CLASS, classOrObject) ?: return InvalidLightClassDataHolder
|
||||||
|
|
||||||
return LightClassDataHolderImpl(diagnostics)
|
return LightClassDataHolderImpl(stub, diagnostics)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun createDataHolderForFacade(files: Collection<KtFile>, builder: LightClassBuilder): LightClassDataHolder.ForFacade {
|
override fun createDataHolderForFacade(files: Collection<KtFile>, builder: LightClassBuilder): LightClassDataHolder.ForFacade {
|
||||||
val (_, _, diagnostics) = builder(getContext())
|
val (stub, _, diagnostics) = builder(getContext())
|
||||||
return LightClassDataHolderImpl(diagnostics)
|
return LightClassDataHolderImpl(stub, diagnostics)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun createDataHolderForScript(script: KtScript, builder: LightClassBuilder): LightClassDataHolder.ForScript {
|
override fun createDataHolderForScript(script: KtScript, builder: LightClassBuilder): LightClassDataHolder.ForScript {
|
||||||
val (_, _, diagnostics) = builder(getContext())
|
val (stub, _, diagnostics) = builder(getContext())
|
||||||
return LightClassDataHolderImpl(diagnostics)
|
return LightClassDataHolderImpl(stub, diagnostics)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getContext(): LightClassConstructionContext =
|
private fun getContext(): LightClassConstructionContext =
|
||||||
|
|||||||
+8
-1
@@ -5,9 +5,11 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.asJava.builder
|
package org.jetbrains.kotlin.asJava.builder
|
||||||
|
|
||||||
|
import com.intellij.psi.impl.java.stubs.PsiJavaFileStub
|
||||||
import org.jetbrains.kotlin.resolve.diagnostics.Diagnostics
|
import org.jetbrains.kotlin.resolve.diagnostics.Diagnostics
|
||||||
|
|
||||||
interface LightClassDataHolder {
|
interface LightClassDataHolder {
|
||||||
|
val javaFileStub: PsiJavaFileStub
|
||||||
val extraDiagnostics: Diagnostics
|
val extraDiagnostics: Diagnostics
|
||||||
|
|
||||||
interface ForClass : LightClassDataHolder
|
interface ForClass : LightClassDataHolder
|
||||||
@@ -16,11 +18,16 @@ interface LightClassDataHolder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
object InvalidLightClassDataHolder : LightClassDataHolder.ForClass {
|
object InvalidLightClassDataHolder : LightClassDataHolder.ForClass {
|
||||||
override val extraDiagnostics: Diagnostics get() = shouldNotBeCalled()
|
override val javaFileStub: PsiJavaFileStub
|
||||||
|
get() = shouldNotBeCalled()
|
||||||
|
|
||||||
|
override val extraDiagnostics: Diagnostics
|
||||||
|
get() = shouldNotBeCalled()
|
||||||
|
|
||||||
private fun shouldNotBeCalled(): Nothing = throw UnsupportedOperationException("Should not be called")
|
private fun shouldNotBeCalled(): Nothing = throw UnsupportedOperationException("Should not be called")
|
||||||
}
|
}
|
||||||
|
|
||||||
class LightClassDataHolderImpl(
|
class LightClassDataHolderImpl(
|
||||||
|
override val javaFileStub: PsiJavaFileStub,
|
||||||
override val extraDiagnostics: Diagnostics
|
override val extraDiagnostics: Diagnostics
|
||||||
) : LightClassDataHolder.ForClass, LightClassDataHolder.ForFacade, LightClassDataHolder.ForScript
|
) : LightClassDataHolder.ForClass, LightClassDataHolder.ForFacade, LightClassDataHolder.ForScript
|
||||||
|
|||||||
+1
@@ -47,6 +47,7 @@ abstract class KtLightClassForFacadeImpl constructor(
|
|||||||
FakeFileForLightClass(
|
FakeFileForLightClass(
|
||||||
firstFileInFacade,
|
firstFileInFacade,
|
||||||
lightClass = { this },
|
lightClass = { this },
|
||||||
|
stub = { null },
|
||||||
packageFqName = facadeClassFqName.parent()
|
packageFqName = facadeClassFqName.parent()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
+1
@@ -43,6 +43,7 @@ abstract class KtLightClassForScript(val script: KtScript) : KtLazyLightClass(sc
|
|||||||
FakeFileForLightClass(
|
FakeFileForLightClass(
|
||||||
script.containingKtFile,
|
script.containingKtFile,
|
||||||
lightClass = { this },
|
lightClass = { this },
|
||||||
|
stub = { null },
|
||||||
packageFqName = fqName.parent(),
|
packageFqName = fqName.parent(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
+13
@@ -12,6 +12,7 @@ import com.intellij.openapi.util.Key
|
|||||||
import com.intellij.openapi.util.TextRange
|
import com.intellij.openapi.util.TextRange
|
||||||
import com.intellij.psi.*
|
import com.intellij.psi.*
|
||||||
import com.intellij.psi.impl.InheritanceImplUtil
|
import com.intellij.psi.impl.InheritanceImplUtil
|
||||||
|
import com.intellij.psi.impl.java.stubs.PsiJavaFileStub
|
||||||
import com.intellij.psi.impl.source.PsiImmediateClassType
|
import com.intellij.psi.impl.source.PsiImmediateClassType
|
||||||
import com.intellij.psi.impl.source.tree.TreeUtil
|
import com.intellij.psi.impl.source.tree.TreeUtil
|
||||||
import com.intellij.psi.scope.PsiScopeProcessor
|
import com.intellij.psi.scope.PsiScopeProcessor
|
||||||
@@ -43,6 +44,7 @@ import org.jetbrains.kotlin.load.java.structure.LightClassOriginKind
|
|||||||
import org.jetbrains.kotlin.name.FqNameUnsafe
|
import org.jetbrains.kotlin.name.FqNameUnsafe
|
||||||
import org.jetbrains.kotlin.psi.*
|
import org.jetbrains.kotlin.psi.*
|
||||||
import org.jetbrains.kotlin.psi.debugText.getDebugText
|
import org.jetbrains.kotlin.psi.debugText.getDebugText
|
||||||
|
import org.jetbrains.kotlin.psi.psiUtil.getElementTextWithContext
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.hasExpectModifier
|
import org.jetbrains.kotlin.psi.psiUtil.hasExpectModifier
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.parentsWithSelf
|
import org.jetbrains.kotlin.psi.psiUtil.parentsWithSelf
|
||||||
import org.jetbrains.kotlin.psi.stubs.KotlinClassOrObjectStub
|
import org.jetbrains.kotlin.psi.stubs.KotlinClassOrObjectStub
|
||||||
@@ -97,13 +99,24 @@ abstract class KtLightClassForSourceDeclaration(
|
|||||||
abstract override fun getParent(): PsiElement?
|
abstract override fun getParent(): PsiElement?
|
||||||
abstract override fun getQualifiedName(): String?
|
abstract override fun getQualifiedName(): String?
|
||||||
|
|
||||||
|
private fun getJavaFileStub(): PsiJavaFileStub = getLightClassDataHolder().javaFileStub
|
||||||
|
|
||||||
fun getDescriptor() =
|
fun getDescriptor() =
|
||||||
LightClassGenerationSupport.getInstance(project).resolveToDescriptor(classOrObject) as? ClassDescriptor
|
LightClassGenerationSupport.getInstance(project).resolveToDescriptor(classOrObject) as? ClassDescriptor
|
||||||
|
|
||||||
|
protected fun getLightClassDataHolder(): LightClassDataHolder.ForClass {
|
||||||
|
val lightClassData = getLightClassDataHolder(classOrObject)
|
||||||
|
if (lightClassData is InvalidLightClassDataHolder) {
|
||||||
|
LOG.error("Invalid light class data for existing light class:\n$lightClassData\n${classOrObject.getElementTextWithContext()}")
|
||||||
|
}
|
||||||
|
return lightClassData
|
||||||
|
}
|
||||||
|
|
||||||
private val _containingFile: PsiFile by lazyPub {
|
private val _containingFile: PsiFile by lazyPub {
|
||||||
object : FakeFileForLightClass(
|
object : FakeFileForLightClass(
|
||||||
classOrObject.containingKtFile,
|
classOrObject.containingKtFile,
|
||||||
{ if (classOrObject.isTopLevel()) this else create(getOutermostClassOrObject(classOrObject))!! },
|
{ if (classOrObject.isTopLevel()) this else create(getOutermostClassOrObject(classOrObject))!! },
|
||||||
|
{ getJavaFileStub() }
|
||||||
) {
|
) {
|
||||||
override fun findReferenceAt(offset: Int) = ktFile.findReferenceAt(offset)
|
override fun findReferenceAt(offset: Int) = ktFile.findReferenceAt(offset)
|
||||||
|
|
||||||
|
|||||||
+1
-6
@@ -7,7 +7,6 @@ package org.jetbrains.kotlin.asJava.classes
|
|||||||
|
|
||||||
import com.intellij.psi.*
|
import com.intellij.psi.*
|
||||||
import com.intellij.psi.impl.PsiImplUtil
|
import com.intellij.psi.impl.PsiImplUtil
|
||||||
import com.intellij.psi.impl.compiled.ClsJavaCodeReferenceElementImpl
|
|
||||||
import com.intellij.psi.impl.light.LightIdentifier
|
import com.intellij.psi.impl.light.LightIdentifier
|
||||||
import org.jetbrains.kotlin.asJava.elements.KtLightAbstractAnnotation
|
import org.jetbrains.kotlin.asJava.elements.KtLightAbstractAnnotation
|
||||||
import org.jetbrains.kotlin.asJava.elements.KtLightElementBase
|
import org.jetbrains.kotlin.asJava.elements.KtLightElementBase
|
||||||
@@ -48,11 +47,7 @@ class KtUltraLightSimpleAnnotation(
|
|||||||
parent: PsiElement,
|
parent: PsiElement,
|
||||||
private val nameReferenceElementProvider: (() -> PsiJavaCodeReferenceElement?)? = null,
|
private val nameReferenceElementProvider: (() -> PsiJavaCodeReferenceElement?)? = null,
|
||||||
) : KtLightAbstractAnnotation(parent) {
|
) : KtLightAbstractAnnotation(parent) {
|
||||||
private val _nameReferenceElement: PsiJavaCodeReferenceElement? by lazyPub {
|
override fun getNameReferenceElement(): PsiJavaCodeReferenceElement? = nameReferenceElementProvider?.invoke()
|
||||||
nameReferenceElementProvider?.invoke() ?: annotationFqName?.let { ClsJavaCodeReferenceElementImpl(parent, it) }
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getNameReferenceElement(): PsiJavaCodeReferenceElement? = _nameReferenceElement
|
|
||||||
|
|
||||||
private val parameterList = ParameterListImpl()
|
private val parameterList = ParameterListImpl()
|
||||||
|
|
||||||
|
|||||||
@@ -69,6 +69,9 @@ internal class KtUltraLightFieldForSourceDeclaration(
|
|||||||
private val lightIdentifier = KtLightIdentifier(this, declaration)
|
private val lightIdentifier = KtLightIdentifier(this, declaration)
|
||||||
|
|
||||||
override fun getNameIdentifier(): PsiIdentifier = lightIdentifier
|
override fun getNameIdentifier(): PsiIdentifier = lightIdentifier
|
||||||
|
override fun getText(): String? = kotlinOrigin.text
|
||||||
|
override fun getTextRange(): TextRange = kotlinOrigin.textRange
|
||||||
|
override fun getTextOffset(): Int = kotlinOrigin.textOffset
|
||||||
override fun getStartOffsetInParent(): Int = kotlinOrigin.startOffsetInParent
|
override fun getStartOffsetInParent(): Int = kotlinOrigin.startOffsetInParent
|
||||||
override fun isWritable(): Boolean = kotlinOrigin.isWritable
|
override fun isWritable(): Boolean = kotlinOrigin.isWritable
|
||||||
override fun getNavigationElement(): PsiElement = kotlinOrigin.navigationElement ?: this
|
override fun getNavigationElement(): PsiElement = kotlinOrigin.navigationElement ?: this
|
||||||
@@ -103,10 +106,6 @@ internal open class KtUltraLightFieldImpl protected constructor(
|
|||||||
|
|
||||||
override fun getLanguage(): Language = KotlinLanguage.INSTANCE
|
override fun getLanguage(): Language = KotlinLanguage.INSTANCE
|
||||||
|
|
||||||
override fun getText(): String? = kotlinOrigin.text
|
|
||||||
override fun getTextRange(): TextRange? = kotlinOrigin.textRange
|
|
||||||
override fun getTextOffset(): Int = kotlinOrigin.textOffset
|
|
||||||
|
|
||||||
private val variableDescriptor: VariableDescriptor?
|
private val variableDescriptor: VariableDescriptor?
|
||||||
get() = declaration.resolve()
|
get() = declaration.resolve()
|
||||||
?.let { it as? PropertyDescriptor ?: it as? ValueParameterDescriptor }
|
?.let { it as? PropertyDescriptor ?: it as? ValueParameterDescriptor }
|
||||||
@@ -117,14 +116,11 @@ internal open class KtUltraLightFieldImpl protected constructor(
|
|||||||
declaration.delegateExpression?.let {
|
declaration.delegateExpression?.let {
|
||||||
LightClassGenerationSupport.getInstance(project).analyze(it).getType(it)
|
LightClassGenerationSupport.getInstance(project).analyze(it).getType(it)
|
||||||
}
|
}
|
||||||
|
|
||||||
declaration is KtObjectDeclaration ->
|
declaration is KtObjectDeclaration ->
|
||||||
(declaration.resolve() as? ClassDescriptor)?.defaultType
|
(declaration.resolve() as? ClassDescriptor)?.defaultType
|
||||||
|
|
||||||
declaration is KtEnumEntry -> {
|
declaration is KtEnumEntry -> {
|
||||||
(containingClass.kotlinOrigin?.resolve() as? ClassDescriptor)?.defaultType
|
(containingClass.kotlinOrigin?.resolve() as? ClassDescriptor)?.defaultType
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> {
|
else -> {
|
||||||
declaration.getKotlinType()
|
declaration.getKotlinType()
|
||||||
}
|
}
|
||||||
@@ -149,7 +145,6 @@ internal open class KtUltraLightFieldImpl protected constructor(
|
|||||||
kotlinType?.asPsiType(support, TypeMappingMode.DEFAULT, this)
|
kotlinType?.asPsiType(support, TypeMappingMode.DEFAULT, this)
|
||||||
?.let(TypeConversionUtil::erasure)
|
?.let(TypeConversionUtil::erasure)
|
||||||
?: nonExistent()
|
?: nonExistent()
|
||||||
|
|
||||||
else -> {
|
else -> {
|
||||||
val kotlinType = declaration.getKotlinType() ?: return@lazyPub PsiType.NULL
|
val kotlinType = declaration.getKotlinType() ?: return@lazyPub PsiType.NULL
|
||||||
val descriptor = variableDescriptor ?: return@lazyPub PsiType.NULL
|
val descriptor = variableDescriptor ?: return@lazyPub PsiType.NULL
|
||||||
|
|||||||
+5
-7
@@ -90,9 +90,8 @@ internal abstract class KtUltraLightParameter(
|
|||||||
ultraLightMethod,
|
ultraLightMethod,
|
||||||
ultraLightMethod.language
|
ultraLightMethod.language
|
||||||
), KtUltraLightElementWithNullabilityAnnotation<KtParameter, PsiParameter>, KtLightParameter {
|
), KtUltraLightElementWithNullabilityAnnotation<KtParameter, PsiParameter>, KtLightParameter {
|
||||||
override fun isEquivalentTo(another: PsiElement?): Boolean {
|
|
||||||
return another is KtParameter && kotlinOrigin?.isEquivalentTo(another) == true || this == another
|
override fun isEquivalentTo(another: PsiElement?): Boolean = kotlinOrigin == another
|
||||||
}
|
|
||||||
|
|
||||||
private val lightModifierList by lazyPub { KtLightSimpleModifierList(this, emptySet()) }
|
private val lightModifierList by lazyPub { KtLightSimpleModifierList(this, emptySet()) }
|
||||||
|
|
||||||
@@ -101,10 +100,6 @@ internal abstract class KtUltraLightParameter(
|
|||||||
override fun getNavigationElement(): PsiElement = kotlinOrigin ?: method.navigationElement
|
override fun getNavigationElement(): PsiElement = kotlinOrigin ?: method.navigationElement
|
||||||
override fun getUseScope(): SearchScope = kotlinOrigin?.useScope ?: LocalSearchScope(this)
|
override fun getUseScope(): SearchScope = kotlinOrigin?.useScope ?: LocalSearchScope(this)
|
||||||
|
|
||||||
override fun getText(): String? = kotlinOrigin?.text.orEmpty()
|
|
||||||
override fun getTextRange(): TextRange? = kotlinOrigin?.textRange
|
|
||||||
override fun getTextOffset(): Int = kotlinOrigin?.textOffset ?: super.getTextOffset()
|
|
||||||
|
|
||||||
override fun isValid() = parent.isValid
|
override fun isValid() = parent.isValid
|
||||||
|
|
||||||
override fun computeQualifiedNameForNullabilityAnnotation(kotlinType: KotlinType?): String? {
|
override fun computeQualifiedNameForNullabilityAnnotation(kotlinType: KotlinType?): String? {
|
||||||
@@ -203,6 +198,9 @@ internal class KtUltraLightParameterForSource(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun getText(): String? = kotlinOrigin.text
|
||||||
|
override fun getTextRange(): TextRange = kotlinOrigin.textRange
|
||||||
|
override fun getTextOffset(): Int = kotlinOrigin.textOffset
|
||||||
override fun getStartOffsetInParent(): Int = kotlinOrigin.startOffsetInParent
|
override fun getStartOffsetInParent(): Int = kotlinOrigin.startOffsetInParent
|
||||||
override fun isWritable(): Boolean = kotlinOrigin.isWritable
|
override fun isWritable(): Boolean = kotlinOrigin.isWritable
|
||||||
override fun getNavigationElement(): PsiElement = kotlinOrigin.navigationElement
|
override fun getNavigationElement(): PsiElement = kotlinOrigin.navigationElement
|
||||||
|
|||||||
+4
-2
@@ -19,6 +19,7 @@ import com.intellij.psi.impl.java.stubs.impl.PsiJavaFileStubImpl
|
|||||||
import com.intellij.psi.impl.source.PsiFileImpl
|
import com.intellij.psi.impl.source.PsiFileImpl
|
||||||
import com.intellij.psi.impl.source.SourceTreeToPsiMap
|
import com.intellij.psi.impl.source.SourceTreeToPsiMap
|
||||||
import com.intellij.psi.impl.source.tree.TreeElement
|
import com.intellij.psi.impl.source.tree.TreeElement
|
||||||
|
import com.intellij.psi.stubs.PsiClassHolderFileStub
|
||||||
import com.intellij.psi.util.PsiUtil
|
import com.intellij.psi.util.PsiUtil
|
||||||
import com.intellij.reference.SoftReference
|
import com.intellij.reference.SoftReference
|
||||||
import com.intellij.util.AstLoadingFilter
|
import com.intellij.util.AstLoadingFilter
|
||||||
@@ -32,7 +33,8 @@ import java.lang.ref.Reference
|
|||||||
open class FakeFileForLightClass(
|
open class FakeFileForLightClass(
|
||||||
val ktFile: KtFile,
|
val ktFile: KtFile,
|
||||||
private val lightClass: () -> KtLightClass,
|
private val lightClass: () -> KtLightClass,
|
||||||
private val packageFqName: FqName = ktFile.packageFqName,
|
private val stub: () -> PsiClassHolderFileStub<*>?,
|
||||||
|
private val packageFqName: FqName = ktFile.packageFqName
|
||||||
) : ClsFileImpl(ktFile.viewProvider) {
|
) : ClsFileImpl(ktFile.viewProvider) {
|
||||||
|
|
||||||
override fun getVirtualFile(): VirtualFile =
|
override fun getVirtualFile(): VirtualFile =
|
||||||
@@ -47,7 +49,7 @@ open class FakeFileForLightClass(
|
|||||||
return javaFileStub
|
return javaFileStub
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getStub() = createFakeJavaFileStub()
|
override fun getStub() = stub() ?: createFakeJavaFileStub()
|
||||||
|
|
||||||
override fun getClasses() = arrayOf(lightClass())
|
override fun getClasses() = arrayOf(lightClass())
|
||||||
|
|
||||||
|
|||||||
+6
-17
@@ -20,7 +20,6 @@ import org.jetbrains.kotlin.psi.KtAnnotationEntry
|
|||||||
import org.jetbrains.kotlin.psi.KtClass
|
import org.jetbrains.kotlin.psi.KtClass
|
||||||
import org.jetbrains.kotlin.psi.KtModifierListOwner
|
import org.jetbrains.kotlin.psi.KtModifierListOwner
|
||||||
import org.jetbrains.kotlin.resolve.constants.ArrayValue
|
import org.jetbrains.kotlin.resolve.constants.ArrayValue
|
||||||
import org.jetbrains.kotlin.resolve.constants.ConstantValue
|
|
||||||
import org.jetbrains.kotlin.resolve.constants.EnumValue
|
import org.jetbrains.kotlin.resolve.constants.EnumValue
|
||||||
import org.jetbrains.kotlin.resolve.constants.KClassValue
|
import org.jetbrains.kotlin.resolve.constants.KClassValue
|
||||||
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
|
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
|
||||||
@@ -92,10 +91,11 @@ internal fun PsiAnnotation.tryConvertAsTarget(support: KtUltraLightSupport): KtL
|
|||||||
|
|
||||||
val targetAttributes = "value" to ArrayValue(convertedValues) { module -> module.builtIns.array.defaultType }
|
val targetAttributes = "value" to ArrayValue(convertedValues) { module -> module.builtIns.array.defaultType }
|
||||||
|
|
||||||
return asUltraLightSimpleAnnotation(
|
return KtUltraLightSimpleAnnotation(
|
||||||
JAVA_LANG_ANNOTATION_TARGET,
|
JAVA_LANG_ANNOTATION_TARGET,
|
||||||
listOf(targetAttributes),
|
listOf(targetAttributes),
|
||||||
support,
|
support,
|
||||||
|
parent
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,28 +111,17 @@ internal fun createRetentionRuntimeAnnotation(support: KtUltraLightSupport, pare
|
|||||||
JAVA_LANG_ANNOTATION_RETENTION,
|
JAVA_LANG_ANNOTATION_RETENTION,
|
||||||
listOf("value" to retentionMapping["kotlin.annotation.AnnotationRetention.RUNTIME"]!!),
|
listOf("value" to retentionMapping["kotlin.annotation.AnnotationRetention.RUNTIME"]!!),
|
||||||
support,
|
support,
|
||||||
parent,
|
parent
|
||||||
)
|
|
||||||
|
|
||||||
internal fun PsiAnnotation.asUltraLightSimpleAnnotation(
|
|
||||||
qualifier: String,
|
|
||||||
argumentsList: List<Pair<String, ConstantValue<*>>>,
|
|
||||||
ultraLightSupport: KtUltraLightSupport,
|
|
||||||
): KtLightAbstractAnnotation = KtUltraLightSimpleAnnotation(
|
|
||||||
annotationFqName = qualifier,
|
|
||||||
argumentsList = argumentsList,
|
|
||||||
ultraLightSupport = ultraLightSupport,
|
|
||||||
parent = parent,
|
|
||||||
nameReferenceElementProvider = { nameReferenceElement }
|
|
||||||
)
|
)
|
||||||
|
|
||||||
internal fun PsiAnnotation.tryConvertAsRetention(support: KtUltraLightSupport): KtLightAbstractAnnotation? {
|
internal fun PsiAnnotation.tryConvertAsRetention(support: KtUltraLightSupport): KtLightAbstractAnnotation? {
|
||||||
if (FqNames.retention.asString() != qualifiedName) return null
|
if (FqNames.retention.asString() != qualifiedName) return null
|
||||||
val convertedValue = extractAnnotationFqName("value")?.let { retentionMapping[it] } ?: return null
|
val convertedValue = extractAnnotationFqName("value")?.let { retentionMapping[it] } ?: return null
|
||||||
return asUltraLightSimpleAnnotation(
|
return KtUltraLightSimpleAnnotation(
|
||||||
JAVA_LANG_ANNOTATION_RETENTION,
|
JAVA_LANG_ANNOTATION_RETENTION,
|
||||||
listOf("value" to convertedValue),
|
listOf("value" to convertedValue),
|
||||||
support,
|
support,
|
||||||
|
parent
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -182,5 +171,5 @@ private fun PsiAnnotation.tryConvertAs(
|
|||||||
from: FqName,
|
from: FqName,
|
||||||
to: String,
|
to: String,
|
||||||
): KtLightAbstractAnnotation? = takeIf { from.asString() == qualifiedName }?.let {
|
): KtLightAbstractAnnotation? = takeIf { from.asString() == qualifiedName }?.let {
|
||||||
asUltraLightSimpleAnnotation(to, emptyList(), support)
|
KtUltraLightSimpleAnnotation(to, emptyList(), support, parent)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,3 +15,6 @@ class Test(@get:MyAnnotation @set:MyAnnotation2 @setparam:MyAnnotation3 @propert
|
|||||||
get() = Unit
|
get() = Unit
|
||||||
set(value) {}
|
set(value) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SKIP_SANITY_TEST
|
||||||
|
// SKIP_IDE_TEST
|
||||||
@@ -4,4 +4,6 @@
|
|||||||
package simple
|
package simple
|
||||||
|
|
||||||
@Repeatable
|
@Repeatable
|
||||||
annotation class One(val value: String)
|
annotation class One(val value: String)
|
||||||
|
// SKIP_SANITY_TEST
|
||||||
|
// SKIP_IDE_TEST
|
||||||
@@ -5,4 +5,5 @@ class Constructors(val valInPrimary: Int) {
|
|||||||
private constructor(): this(2)
|
private constructor(): this(2)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LAZINESS:NoLaziness
|
||||||
// FIR_COMPARISON
|
// FIR_COMPARISON
|
||||||
+2
@@ -16,3 +16,5 @@ class Wrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class G
|
class G
|
||||||
|
|
||||||
|
// LAZINESS:NoLaziness
|
||||||
|
|||||||
@@ -11,3 +11,5 @@ interface I {
|
|||||||
|
|
||||||
fun f()
|
fun f()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LAZINESS:NoLaziness
|
||||||
|
|||||||
@@ -9,3 +9,5 @@ interface I {
|
|||||||
|
|
||||||
fun f()
|
fun f()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LAZINESS:NoLaziness
|
||||||
|
|||||||
@@ -12,3 +12,7 @@ interface B: A {
|
|||||||
interface C : B {
|
interface C : B {
|
||||||
fun c() = "c"
|
fun c() = "c"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: could be lazy
|
||||||
|
// see KT-22819
|
||||||
|
// LAZINESS:NoLaziness
|
||||||
@@ -5,4 +5,5 @@ package a
|
|||||||
fun f() {
|
fun f() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// LAZINESS:NoLaziness
|
||||||
// FIR_COMPARISON
|
// FIR_COMPARISON
|
||||||
@@ -8,4 +8,5 @@ class A {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LAZINESS:NoLaziness
|
||||||
// FIR_COMPARISON
|
// FIR_COMPARISON
|
||||||
@@ -5,4 +5,5 @@ class OnlySecondaryConstructors {
|
|||||||
constructor(p: Int): this()
|
constructor(p: Int): this()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LAZINESS:NoLaziness
|
||||||
// FIR_COMPARISON
|
// FIR_COMPARISON
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
// Anno
|
// Anno
|
||||||
// FULL_JDK
|
// FULL_JDK
|
||||||
|
// SKIP_SANITY_TEST
|
||||||
|
// SKIP_IDE_TEST
|
||||||
|
|
||||||
@Retention(AnnotationRetention.SOURCE)
|
@Retention(AnnotationRetention.SOURCE)
|
||||||
@Target(AnnotationTarget.TYPE_PARAMETER, AnnotationTarget.TYPE)
|
@Target(AnnotationTarget.TYPE_PARAMETER, AnnotationTarget.TYPE)
|
||||||
|
|||||||
Vendored
+2
@@ -4,3 +4,5 @@
|
|||||||
package p
|
package p
|
||||||
|
|
||||||
actual typealias B = List<Int>
|
actual typealias B = List<Int>
|
||||||
|
|
||||||
|
// SKIP_IDE_TEST
|
||||||
@@ -6,3 +6,5 @@ package p
|
|||||||
fun f() {
|
fun f() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SKIP_IDE_TEST
|
||||||
+1
@@ -1,4 +1,5 @@
|
|||||||
// p.Annotations
|
// p.Annotations
|
||||||
|
// SKIP_SANITY_TEST
|
||||||
|
|
||||||
package p
|
package p
|
||||||
|
|
||||||
|
|||||||
@@ -32,3 +32,5 @@ class A {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LAZINESS:NoConsistency
|
||||||
@@ -5,3 +5,5 @@
|
|||||||
fun foo() {
|
fun foo() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SKIP_IDE_TEST
|
||||||
+2
@@ -23,4 +23,6 @@ class C {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LAZINESS:NoLaziness
|
||||||
|
// SKIP_SANITY_TEST
|
||||||
// COMPILATION_ERRORS
|
// COMPILATION_ERRORS
|
||||||
+2
-2
@@ -1,8 +1,8 @@
|
|||||||
public final class C /* p.C*/ extends p.A {
|
public final class C /* p.C*/ extends p.A {
|
||||||
public C();// .ctor()
|
public C();// .ctor()
|
||||||
|
|
||||||
public int af$light_idea_test_case();// af$light_idea_test_case()
|
public int af();// af$light_idea_test_case()
|
||||||
|
|
||||||
public int getAp$light_idea_test_case();// getAp$light_idea_test_case()
|
public int getAp();// getAp$light_idea_test_case()
|
||||||
|
|
||||||
}
|
}
|
||||||
+1
@@ -10,4 +10,5 @@ class C : A() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LAZINESS:NoConsistency
|
||||||
// COMPILATION_ERRORS
|
// COMPILATION_ERRORS
|
||||||
@@ -13,4 +13,5 @@ class C : A(), I {
|
|||||||
override fun if() = 5
|
override fun if() = 5
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LAZINESS:NoLaziness
|
||||||
// COMPILATION_ERRORS
|
// COMPILATION_ERRORS
|
||||||
@@ -10,4 +10,5 @@ class C : A() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LAZINESS:NoLaziness
|
||||||
// COMPILATION_ERRORS
|
// COMPILATION_ERRORS
|
||||||
+1
@@ -8,4 +8,5 @@ class C : Base {
|
|||||||
override fun foo(): Unit {}
|
override fun foo(): Unit {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LAZINESS:NoLaziness
|
||||||
// FIR_COMPARISON
|
// FIR_COMPARISON
|
||||||
+1
@@ -7,4 +7,5 @@ interface Base<T> {
|
|||||||
class C : Base<Unit> {
|
class C : Base<Unit> {
|
||||||
override fun foo(t: Unit) {}
|
override fun foo(t: Unit) {}
|
||||||
}
|
}
|
||||||
|
// LAZINESS:NoLaziness
|
||||||
// FIR_COMPARISON
|
// FIR_COMPARISON
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
// HelloWorld
|
// HelloWorld
|
||||||
|
|
||||||
println("Hello world!")
|
println("Hello world!")
|
||||||
|
|
||||||
|
// LAZINESS:NoLaziness
|
||||||
@@ -11,3 +11,5 @@ class Bar(val a: Int) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LAZINESS:NoLaziness
|
||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
public class HelloWorld /* HelloWorld*/ extends kotlin.script.templates.standard.ScriptTemplateWithArgs {
|
public class HelloWorld /* HelloWorld*/ extends kotlin.script.templates.standard.ScriptTemplateWithArgs {
|
||||||
public HelloWorld(java.lang.String[]);// .ctor(java.lang.String[])
|
public HelloWorld();// .ctor()
|
||||||
|
|
||||||
public static final void main(java.lang.String[]);// main(java.lang.String[])
|
public static final void main(java.lang.String[]);// main(java.lang.String[])
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
// HelloWorld
|
// HelloWorld
|
||||||
|
|
||||||
println("Hello world!")
|
println("Hello world!")
|
||||||
|
|
||||||
|
// LAZINESS:NoLaziness
|
||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
public class InnerClasses /* InnerClasses*/ extends kotlin.script.templates.standard.ScriptTemplateWithArgs {
|
public class InnerClasses /* InnerClasses*/ extends kotlin.script.templates.standard.ScriptTemplateWithArgs {
|
||||||
public InnerClasses(java.lang.String[]);// .ctor(java.lang.String[])
|
public InnerClasses();// .ctor()
|
||||||
|
|
||||||
public static final void main(java.lang.String[]);// main(java.lang.String[])
|
public static final void main(java.lang.String[]);// main(java.lang.String[])
|
||||||
|
|
||||||
@@ -23,4 +23,4 @@ public static final class Baz /* InnerClasses.Bar.Baz*/ {
|
|||||||
|
|
||||||
public final void doSomething();// doSomething()
|
public final void doSomething();// doSomething()
|
||||||
|
|
||||||
}}}
|
}}}
|
||||||
@@ -11,3 +11,5 @@ class Bar(val a: Int) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LAZINESS:NoLaziness
|
||||||
@@ -4,12 +4,6 @@ public enum Direction /* Direction*/ {
|
|||||||
WEST,
|
WEST,
|
||||||
EAST;
|
EAST;
|
||||||
|
|
||||||
@org.jetbrains.annotations.NotNull()
|
|
||||||
public static Direction valueOf(@org.jetbrains.annotations.NotNull() java.lang.String) throws java.lang.IllegalArgumentException;// valueOf(java.lang.String)
|
|
||||||
|
|
||||||
@org.jetbrains.annotations.NotNull()
|
|
||||||
public static Direction[] values();// values()
|
|
||||||
|
|
||||||
private Direction();// .ctor()
|
private Direction();// .ctor()
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -21,12 +15,6 @@ public enum Color /* Color*/ {
|
|||||||
|
|
||||||
private final int rgb;
|
private final int rgb;
|
||||||
|
|
||||||
@org.jetbrains.annotations.NotNull()
|
|
||||||
public static Color valueOf(@org.jetbrains.annotations.NotNull() java.lang.String) throws java.lang.IllegalArgumentException;// valueOf(java.lang.String)
|
|
||||||
|
|
||||||
@org.jetbrains.annotations.NotNull()
|
|
||||||
public static Color[] values();// values()
|
|
||||||
|
|
||||||
private Color(@org.jetbrains.annotations.NotNull() java.lang.String);// .ctor(java.lang.String)
|
private Color(@org.jetbrains.annotations.NotNull() java.lang.String);// .ctor(java.lang.String)
|
||||||
|
|
||||||
private Color(int);// .ctor(int)
|
private Color(int);// .ctor(int)
|
||||||
@@ -54,12 +42,6 @@ public enum ProtocolState /* ProtocolState*/ {
|
|||||||
@org.jetbrains.annotations.NotNull()
|
@org.jetbrains.annotations.NotNull()
|
||||||
public abstract ProtocolState signal();// signal()
|
public abstract ProtocolState signal();// signal()
|
||||||
|
|
||||||
@org.jetbrains.annotations.NotNull()
|
|
||||||
public static ProtocolState valueOf(@org.jetbrains.annotations.NotNull() java.lang.String) throws java.lang.IllegalArgumentException;// valueOf(java.lang.String)
|
|
||||||
|
|
||||||
@org.jetbrains.annotations.NotNull()
|
|
||||||
public static ProtocolState[] values();// values()
|
|
||||||
|
|
||||||
private ProtocolState();// .ctor()
|
private ProtocolState();// .ctor()
|
||||||
|
|
||||||
|
|
||||||
@@ -102,12 +84,6 @@ public enum IntArithmetics /* IntArithmetics*/ implements java.util.function.Bin
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@org.jetbrains.annotations.NotNull()
|
|
||||||
public static IntArithmetics valueOf(@org.jetbrains.annotations.NotNull() java.lang.String) throws java.lang.IllegalArgumentException;// valueOf(java.lang.String)
|
|
||||||
|
|
||||||
@org.jetbrains.annotations.NotNull()
|
|
||||||
public static IntArithmetics[] values();// values()
|
|
||||||
|
|
||||||
private IntArithmetics();// .ctor()
|
private IntArithmetics();// .ctor()
|
||||||
|
|
||||||
public int applyAsInt(int, int);// applyAsInt(int, int)
|
public int applyAsInt(int, int);// applyAsInt(int, int)
|
||||||
|
|||||||
Reference in New Issue
Block a user