[light classes] drop old light classes and backend: iteration #2
drop javaFileStub and fix tests ^KT-48773
This commit is contained in:
+1
-2
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
* Copyright 2010-2022 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,7 +18,6 @@ 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,7 +172,6 @@ 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 (stub, bindingContext, diagnostics) = builder(getContext())
|
val (_, bindingContext, diagnostics) = builder(getContext())
|
||||||
|
|
||||||
bindingContext.get(BindingContext.CLASS, classOrObject) ?: return InvalidLightClassDataHolder
|
bindingContext.get(BindingContext.CLASS, classOrObject) ?: return InvalidLightClassDataHolder
|
||||||
|
|
||||||
return LightClassDataHolderImpl(stub, diagnostics)
|
return LightClassDataHolderImpl(diagnostics)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun createDataHolderForFacade(files: Collection<KtFile>, builder: LightClassBuilder): LightClassDataHolder.ForFacade {
|
override fun createDataHolderForFacade(files: Collection<KtFile>, builder: LightClassBuilder): LightClassDataHolder.ForFacade {
|
||||||
val (stub, _, diagnostics) = builder(getContext())
|
val (_, _, diagnostics) = builder(getContext())
|
||||||
return LightClassDataHolderImpl(stub, diagnostics)
|
return LightClassDataHolderImpl(diagnostics)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun createDataHolderForScript(script: KtScript, builder: LightClassBuilder): LightClassDataHolder.ForScript {
|
override fun createDataHolderForScript(script: KtScript, builder: LightClassBuilder): LightClassDataHolder.ForScript {
|
||||||
val (stub, _, diagnostics) = builder(getContext())
|
val (_, _, diagnostics) = builder(getContext())
|
||||||
return LightClassDataHolderImpl(stub, diagnostics)
|
return LightClassDataHolderImpl(diagnostics)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getContext(): LightClassConstructionContext =
|
private fun getContext(): LightClassConstructionContext =
|
||||||
|
|||||||
+1
-8
@@ -5,11 +5,9 @@
|
|||||||
|
|
||||||
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
|
||||||
@@ -18,16 +16,11 @@ interface LightClassDataHolder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
object InvalidLightClassDataHolder : LightClassDataHolder.ForClass {
|
object InvalidLightClassDataHolder : LightClassDataHolder.ForClass {
|
||||||
override val javaFileStub: PsiJavaFileStub
|
override val extraDiagnostics: Diagnostics get() = shouldNotBeCalled()
|
||||||
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,7 +47,6 @@ abstract class KtLightClassForFacadeImpl constructor(
|
|||||||
FakeFileForLightClass(
|
FakeFileForLightClass(
|
||||||
firstFileInFacade,
|
firstFileInFacade,
|
||||||
lightClass = { this },
|
lightClass = { this },
|
||||||
stub = { null },
|
|
||||||
packageFqName = facadeClassFqName.parent()
|
packageFqName = facadeClassFqName.parent()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
-1
@@ -43,7 +43,6 @@ 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,7 +12,6 @@ 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
|
||||||
@@ -44,7 +43,6 @@ 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
|
||||||
@@ -99,24 +97,13 @@ 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)
|
||||||
|
|
||||||
|
|||||||
+6
-1
@@ -7,6 +7,7 @@ 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
|
||||||
@@ -47,7 +48,11 @@ class KtUltraLightSimpleAnnotation(
|
|||||||
parent: PsiElement,
|
parent: PsiElement,
|
||||||
private val nameReferenceElementProvider: (() -> PsiJavaCodeReferenceElement?)? = null,
|
private val nameReferenceElementProvider: (() -> PsiJavaCodeReferenceElement?)? = null,
|
||||||
) : KtLightAbstractAnnotation(parent) {
|
) : KtLightAbstractAnnotation(parent) {
|
||||||
override fun getNameReferenceElement(): PsiJavaCodeReferenceElement? = nameReferenceElementProvider?.invoke()
|
private val _nameReferenceElement: PsiJavaCodeReferenceElement? by lazyPub {
|
||||||
|
nameReferenceElementProvider?.invoke() ?: annotationFqName?.let { ClsJavaCodeReferenceElementImpl(parent, it) }
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getNameReferenceElement(): PsiJavaCodeReferenceElement? = _nameReferenceElement
|
||||||
|
|
||||||
private val parameterList = ParameterListImpl()
|
private val parameterList = ParameterListImpl()
|
||||||
|
|
||||||
|
|||||||
@@ -69,9 +69,6 @@ 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
|
||||||
@@ -106,6 +103,10 @@ 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 }
|
||||||
@@ -116,11 +117,14 @@ 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()
|
||||||
}
|
}
|
||||||
@@ -145,6 +149,7 @@ 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
|
||||||
|
|||||||
+7
-5
@@ -90,8 +90,9 @@ internal abstract class KtUltraLightParameter(
|
|||||||
ultraLightMethod,
|
ultraLightMethod,
|
||||||
ultraLightMethod.language
|
ultraLightMethod.language
|
||||||
), KtUltraLightElementWithNullabilityAnnotation<KtParameter, PsiParameter>, KtLightParameter {
|
), KtUltraLightElementWithNullabilityAnnotation<KtParameter, PsiParameter>, KtLightParameter {
|
||||||
|
override fun isEquivalentTo(another: PsiElement?): Boolean {
|
||||||
override fun isEquivalentTo(another: PsiElement?): Boolean = kotlinOrigin == another
|
return another is KtParameter && kotlinOrigin?.isEquivalentTo(another) == true || this == another
|
||||||
|
}
|
||||||
|
|
||||||
private val lightModifierList by lazyPub { KtLightSimpleModifierList(this, emptySet()) }
|
private val lightModifierList by lazyPub { KtLightSimpleModifierList(this, emptySet()) }
|
||||||
|
|
||||||
@@ -100,6 +101,10 @@ 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? {
|
||||||
@@ -198,9 +203,6 @@ 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
|
||||||
|
|||||||
+2
-4
@@ -19,7 +19,6 @@ 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
|
||||||
@@ -33,8 +32,7 @@ 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 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 =
|
||||||
@@ -49,7 +47,7 @@ open class FakeFileForLightClass(
|
|||||||
return javaFileStub
|
return javaFileStub
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getStub() = stub() ?: createFakeJavaFileStub()
|
override fun getStub() = createFakeJavaFileStub()
|
||||||
|
|
||||||
override fun getClasses() = arrayOf(lightClass())
|
override fun getClasses() = arrayOf(lightClass())
|
||||||
|
|
||||||
|
|||||||
+17
-6
@@ -20,6 +20,7 @@ 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
|
||||||
@@ -91,11 +92,10 @@ 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 KtUltraLightSimpleAnnotation(
|
return asUltraLightSimpleAnnotation(
|
||||||
JAVA_LANG_ANNOTATION_TARGET,
|
JAVA_LANG_ANNOTATION_TARGET,
|
||||||
listOf(targetAttributes),
|
listOf(targetAttributes),
|
||||||
support,
|
support,
|
||||||
parent
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,17 +111,28 @@ 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 KtUltraLightSimpleAnnotation(
|
return asUltraLightSimpleAnnotation(
|
||||||
JAVA_LANG_ANNOTATION_RETENTION,
|
JAVA_LANG_ANNOTATION_RETENTION,
|
||||||
listOf("value" to convertedValue),
|
listOf("value" to convertedValue),
|
||||||
support,
|
support,
|
||||||
parent
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,5 +182,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 {
|
||||||
KtUltraLightSimpleAnnotation(to, emptyList(), support, parent)
|
asUltraLightSimpleAnnotation(to, emptyList(), support)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,3 @@ class Test(@get:MyAnnotation @set:MyAnnotation2 @setparam:MyAnnotation3 @propert
|
|||||||
get() = Unit
|
get() = Unit
|
||||||
set(value) {}
|
set(value) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
// SKIP_SANITY_TEST
|
|
||||||
// SKIP_IDE_TEST
|
|
||||||
@@ -4,6 +4,4 @@
|
|||||||
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,5 +5,4 @@ class Constructors(val valInPrimary: Int) {
|
|||||||
private constructor(): this(2)
|
private constructor(): this(2)
|
||||||
}
|
}
|
||||||
|
|
||||||
// LAZINESS:NoLaziness
|
|
||||||
// FIR_COMPARISON
|
// FIR_COMPARISON
|
||||||
-2
@@ -16,5 +16,3 @@ class Wrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class G
|
class G
|
||||||
|
|
||||||
// LAZINESS:NoLaziness
|
|
||||||
|
|||||||
@@ -11,5 +11,3 @@ interface I {
|
|||||||
|
|
||||||
fun f()
|
fun f()
|
||||||
}
|
}
|
||||||
|
|
||||||
// LAZINESS:NoLaziness
|
|
||||||
|
|||||||
@@ -9,5 +9,3 @@ interface I {
|
|||||||
|
|
||||||
fun f()
|
fun f()
|
||||||
}
|
}
|
||||||
|
|
||||||
// LAZINESS:NoLaziness
|
|
||||||
|
|||||||
@@ -12,7 +12,3 @@ 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,5 +5,4 @@ package a
|
|||||||
fun f() {
|
fun f() {
|
||||||
|
|
||||||
}
|
}
|
||||||
// LAZINESS:NoLaziness
|
|
||||||
// FIR_COMPARISON
|
// FIR_COMPARISON
|
||||||
@@ -8,5 +8,4 @@ class A {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// LAZINESS:NoLaziness
|
|
||||||
// FIR_COMPARISON
|
// FIR_COMPARISON
|
||||||
@@ -5,5 +5,4 @@ class OnlySecondaryConstructors {
|
|||||||
constructor(p: Int): this()
|
constructor(p: Int): this()
|
||||||
}
|
}
|
||||||
|
|
||||||
// LAZINESS:NoLaziness
|
|
||||||
// FIR_COMPARISON
|
// FIR_COMPARISON
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
// 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,5 +4,3 @@
|
|||||||
package p
|
package p
|
||||||
|
|
||||||
actual typealias B = List<Int>
|
actual typealias B = List<Int>
|
||||||
|
|
||||||
// SKIP_IDE_TEST
|
|
||||||
@@ -6,5 +6,3 @@ package p
|
|||||||
fun f() {
|
fun f() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// SKIP_IDE_TEST
|
|
||||||
-1
@@ -1,5 +1,4 @@
|
|||||||
// p.Annotations
|
// p.Annotations
|
||||||
// SKIP_SANITY_TEST
|
|
||||||
|
|
||||||
package p
|
package p
|
||||||
|
|
||||||
|
|||||||
@@ -32,5 +32,3 @@ class A {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// LAZINESS:NoConsistency
|
|
||||||
@@ -5,5 +5,3 @@
|
|||||||
fun foo() {
|
fun foo() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// SKIP_IDE_TEST
|
|
||||||
-2
@@ -23,6 +23,4 @@ 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();// af$light_idea_test_case()
|
public int af$light_idea_test_case();// af$light_idea_test_case()
|
||||||
|
|
||||||
public int getAp();// getAp$light_idea_test_case()
|
public int getAp$light_idea_test_case();// getAp$light_idea_test_case()
|
||||||
|
|
||||||
}
|
}
|
||||||
-1
@@ -10,5 +10,4 @@ class C : A() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// LAZINESS:NoConsistency
|
|
||||||
// COMPILATION_ERRORS
|
// COMPILATION_ERRORS
|
||||||
@@ -13,5 +13,4 @@ class C : A(), I {
|
|||||||
override fun if() = 5
|
override fun if() = 5
|
||||||
}
|
}
|
||||||
|
|
||||||
// LAZINESS:NoLaziness
|
|
||||||
// COMPILATION_ERRORS
|
// COMPILATION_ERRORS
|
||||||
@@ -10,5 +10,4 @@ class C : A() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// LAZINESS:NoLaziness
|
|
||||||
// COMPILATION_ERRORS
|
// COMPILATION_ERRORS
|
||||||
-1
@@ -8,5 +8,4 @@ class C : Base {
|
|||||||
override fun foo(): Unit {}
|
override fun foo(): Unit {}
|
||||||
}
|
}
|
||||||
|
|
||||||
// LAZINESS:NoLaziness
|
|
||||||
// FIR_COMPARISON
|
// FIR_COMPARISON
|
||||||
-1
@@ -7,5 +7,4 @@ 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,5 +1,3 @@
|
|||||||
// HelloWorld
|
// HelloWorld
|
||||||
|
|
||||||
println("Hello world!")
|
println("Hello world!")
|
||||||
|
|
||||||
// LAZINESS:NoLaziness
|
|
||||||
@@ -11,5 +11,3 @@ 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();// .ctor()
|
public HelloWorld(java.lang.String[]);// .ctor(java.lang.String[])
|
||||||
|
|
||||||
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,5 +1,3 @@
|
|||||||
// 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();// .ctor()
|
public InnerClasses(java.lang.String[]);// .ctor(java.lang.String[])
|
||||||
|
|
||||||
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,5 +11,3 @@ class Bar(val a: Int) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// LAZINESS:NoLaziness
|
|
||||||
@@ -4,6 +4,12 @@ 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()
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -15,6 +21,12 @@ 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)
|
||||||
@@ -42,6 +54,12 @@ 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()
|
||||||
|
|
||||||
|
|
||||||
@@ -84,6 +102,12 @@ 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