mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 14:23:28 +07:00
[Kotlin] drop k2-fe10-bindings module
This is obsolete code for experiments around reusing K1 implementations in K2 plugin ^KTIJ-30339 Fixed GitOrigin-RevId: 528eba596d911d3f784c3be5b6ead2f122c170ec
This commit is contained in:
committed by
intellij-monorepo-bot
parent
9d89c2d7a4
commit
01f8311767
1
.idea/modules.xml
generated
1
.idea/modules.xml
generated
@@ -1120,7 +1120,6 @@
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/kotlin/jvm-debugger/test/k2/kotlin.jvm-debugger.test.k2.iml" filepath="$PROJECT_DIR$/plugins/kotlin/jvm-debugger/test/k2/kotlin.jvm-debugger.test.k2.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/kotlin/jvm-debugger/util/kotlin.jvm-debugger.util.iml" filepath="$PROJECT_DIR$/plugins/kotlin/jvm-debugger/util/kotlin.jvm-debugger.util.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/kotlin/jvm-decompiler/kotlin.jvm-decompiler.iml" filepath="$PROJECT_DIR$/plugins/kotlin/jvm-decompiler/kotlin.jvm-decompiler.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/kotlin/k2-fe10-bindings/kotlin.k2.fe10-bindings.iml" filepath="$PROJECT_DIR$/plugins/kotlin/k2-fe10-bindings/kotlin.k2.fe10-bindings.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/kotlin/kotlin.lombok.tests/kotlin.k2.lombok.tests.iml" filepath="$PROJECT_DIR$/plugins/kotlin/kotlin.lombok.tests/kotlin.k2.lombok.tests.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/kotlin/maven/kotlin.maven.iml" filepath="$PROJECT_DIR$/plugins/kotlin/maven/kotlin.maven.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/kotlin/maven/tests/kotlin.maven.tests.iml" filepath="$PROJECT_DIR$/plugins/kotlin/maven/tests/kotlin.maven.tests.iml" />
|
||||
|
||||
@@ -370,12 +370,8 @@ org.jetbrains.kotlin.idea.k2.*
|
||||
org.jetbrains.kotlin.idea.*.k2.*
|
||||
org.jetbrains.kotlin.idea.*.k2
|
||||
org.jetbrains.fir.uast.test.*
|
||||
-org.jetbrains.kotlin.idea.k2.fe10bindings.*
|
||||
org.jetbrains.kotlin.j2k.k2.*
|
||||
|
||||
[KOTLIN_K2_FE10_BINDINGS_TESTS]
|
||||
org.jetbrains.kotlin.idea.k2.fe10bindings.*
|
||||
|
||||
[TARGETS_API_INTEGRATION_TESTS]
|
||||
com.intellij.tests.targets.integration.*
|
||||
|
||||
|
||||
@@ -34,7 +34,6 @@ import org.jetbrains.kotlin.util.OperatorNameConventions
|
||||
* Tests:
|
||||
* [org.jetbrains.kotlin.idea.quickfix.QuickFixMultiModuleTestGenerated.CanSealedSubClassBeObject]
|
||||
* [org.jetbrains.kotlin.idea.inspections.LocalInspectionTestGenerated.ConvertSealedSubClassToObject]
|
||||
* [org.jetbrains.kotlin.idea.k2.fe10bindings.inspections.Fe10BindingLocalInspectionTestGenerated.ConvertSealedSubClassToObject]
|
||||
*/
|
||||
class CanSealedSubClassBeObjectInspection : AbstractKotlinInspection() {
|
||||
override fun buildVisitor(holder: ProblemsHolder, isOnTheFly: Boolean, session: LocalInspectionToolSession): PsiElementVisitor {
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="FacetManager">
|
||||
<facet type="kotlin-language" name="Kotlin">
|
||||
<configuration version="5" platform="JVM 17" allPlatforms="JVM [17]" useProjectSettings="false">
|
||||
<compilerSettings>
|
||||
<option name="additionalArguments" value="-Xjvm-default=all -opt-in=com.intellij.openapi.util.IntellijInternalApi -opt-in=org.jetbrains.kotlin.utils.addToStdlib.UnsafeCastFunction -opt-in=org.jetbrains.kotlin.analysis.api.permissions.KaAllowProhibitedAnalyzeFromWriteAction" />
|
||||
</compilerSettings>
|
||||
<compilerArguments>
|
||||
<stringArguments>
|
||||
<stringArg name="jvmTarget" arg="17" />
|
||||
<stringArg name="apiVersion" arg="1.9" />
|
||||
<stringArg name="languageVersion" arg="1.9" />
|
||||
</stringArguments>
|
||||
</compilerArguments>
|
||||
</configuration>
|
||||
</facet>
|
||||
</component>
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/resources" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="kotlin.plugin.k2" scope="TEST" />
|
||||
<orderEntry type="library" name="kotlin-stdlib" level="project" />
|
||||
<orderEntry type="library" name="kotlinc.kotlin-compiler-common" level="project" />
|
||||
<orderEntry type="library" name="kotlinc.kotlin-compiler-fe10" level="project" />
|
||||
<orderEntry type="library" name="kotlinc.kotlin-compiler-ir" level="project" />
|
||||
<orderEntry type="library" name="kotlinc.kotlin-compiler-fir" level="project" />
|
||||
<orderEntry type="library" name="kotlinc.analysis-api" level="project" />
|
||||
<orderEntry type="library" name="kotlinc.analysis-api-k2" level="project" />
|
||||
<orderEntry type="library" name="kotlinc.low-level-api-fir" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="kotlinc.kotlin-compiler-tests" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="JUnit4" level="project" />
|
||||
<orderEntry type="library" name="Guava" level="project" />
|
||||
<orderEntry type="module" module-name="kotlin.base.util" />
|
||||
<orderEntry type="module" module-name="kotlin.base.project-structure" />
|
||||
<orderEntry type="module" module-name="kotlin.base.analysis" />
|
||||
<orderEntry type="module" module-name="kotlin.base.fe10.analysis" />
|
||||
<orderEntry type="module" module-name="kotlin.tests-common" scope="TEST" />
|
||||
<orderEntry type="module" module-name="kotlin.idea.tests" scope="TEST" />
|
||||
<orderEntry type="module" module-name="kotlin.core" />
|
||||
<orderEntry type="module" module-name="kotlin.fir.tests" scope="TEST" />
|
||||
<orderEntry type="module" module-name="intellij.platform.core" />
|
||||
<orderEntry type="module" module-name="intellij.platform.analysis" />
|
||||
<orderEntry type="module" module-name="intellij.platform.core.impl" />
|
||||
<orderEntry type="module" module-name="intellij.java.psi" />
|
||||
<orderEntry type="library" name="kotlinc.analysis-api-platform-interface" level="project" />
|
||||
<orderEntry type="library" name="kotlinc.analysis-project-structure" level="project" />
|
||||
<orderEntry type="module" module-name="kotlin.code-insight.api" scope="TEST" />
|
||||
<orderEntry type="module" module-name="kotlin.highlighting.k2" scope="TEST" />
|
||||
<orderEntry type="module" module-name="kotlin.base.plugin" scope="TEST" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -1,259 +0,0 @@
|
||||
<idea-plugin>
|
||||
<extensions defaultExtensionNs="com.intellij">
|
||||
|
||||
<projectService serviceInterface="org.jetbrains.kotlin.caches.resolve.KotlinCacheService"
|
||||
serviceImplementation="org.jetbrains.kotlin.idea.fir.fe10.KtSymbolBasedKotlinCacheServiceImpl"/>
|
||||
|
||||
<!-- Supported Intentions -->
|
||||
<intentionAction>
|
||||
<language>kotlin</language>
|
||||
<className>org.jetbrains.kotlin.idea.intentions.conventionNameCalls.ReplaceContainsIntention</className>
|
||||
<bundleName>messages.KotlinBundle</bundleName>
|
||||
<categoryKey>group.names.kotlin</categoryKey>
|
||||
</intentionAction>
|
||||
|
||||
<intentionAction>
|
||||
<language>kotlin</language>
|
||||
<className>org.jetbrains.kotlin.idea.intentions.conventionNameCalls.ReplaceInvokeIntention</className>
|
||||
<bundleName>messages.KotlinBundle</bundleName>
|
||||
<categoryKey>group.names.kotlin</categoryKey>
|
||||
</intentionAction>
|
||||
|
||||
<intentionAction>
|
||||
<language>kotlin</language>
|
||||
<className>org.jetbrains.kotlin.idea.intentions.conventionNameCalls.ReplaceCallWithUnaryOperatorIntention</className>
|
||||
<bundleName>messages.KotlinBundle</bundleName>
|
||||
<categoryKey>group.names.kotlin</categoryKey>
|
||||
</intentionAction>
|
||||
|
||||
<intentionAction>
|
||||
<language>kotlin</language>
|
||||
<className>org.jetbrains.kotlin.idea.intentions.ConvertSecondaryConstructorToPrimaryIntention</className>
|
||||
<bundleName>messages.KotlinBundle</bundleName>
|
||||
<categoryKey>group.names.kotlin</categoryKey>
|
||||
</intentionAction>
|
||||
|
||||
<intentionAction>
|
||||
<language>kotlin</language>
|
||||
<className>org.jetbrains.kotlin.idea.intentions.ConvertToStringTemplateIntention</className>
|
||||
<bundleName>messages.KotlinBundle</bundleName>
|
||||
<categoryKey>group.names.kotlin</categoryKey>
|
||||
</intentionAction>
|
||||
|
||||
<localInspection implementationClass="org.jetbrains.kotlin.idea.inspections.AddOperatorModifierInspection"
|
||||
groupPath="Kotlin"
|
||||
groupBundle="messages.KotlinBundle" groupKey="group.names.style.issues"
|
||||
enabledByDefault="true"
|
||||
level="INFORMATION"
|
||||
language="kotlin"
|
||||
key="inspection.add.operator.modifier.display.name" bundle="messages.KotlinBundle"/>
|
||||
|
||||
<localInspection implementationClass="org.jetbrains.kotlin.idea.inspections.AddVarianceModifierInspection"
|
||||
groupPath="Kotlin"
|
||||
groupBundle="messages.KotlinBundle" groupKey="group.names.style.issues"
|
||||
enabledByDefault="true"
|
||||
level="INFORMATION"
|
||||
language="kotlin"
|
||||
key="inspection.add.variance.modifier.display.name" bundle="messages.KotlinBundle"/>
|
||||
|
||||
<localInspection implementationClass="org.jetbrains.kotlin.idea.inspections.BooleanLiteralArgumentInspection"
|
||||
groupPath="Kotlin"
|
||||
groupBundle="messages.KotlinBundle" groupKey="group.names.style.issues"
|
||||
enabledByDefault="true"
|
||||
level="WEAK WARNING"
|
||||
language="kotlin"
|
||||
key="inspection.boolean.literal.argument.display.name" bundle="messages.KotlinBundle"/>
|
||||
|
||||
|
||||
<localInspection implementationClass="org.jetbrains.kotlin.idea.inspections.CanSealedSubClassBeObjectInspection"
|
||||
groupPath="Kotlin"
|
||||
groupBundle="messages.KotlinBundle" groupKey="group.names.probable.bugs"
|
||||
enabledByDefault="true"
|
||||
level="WEAK WARNING"
|
||||
language="kotlin"
|
||||
key="inspection.can.sealed.subclass.be.object.display.name" bundle="messages.KotlinBundle"/>
|
||||
|
||||
<localInspection implementationClass="org.jetbrains.kotlin.idea.inspections.CascadeIfInspection"
|
||||
groupPath="Kotlin"
|
||||
groupBundle="messages.KotlinBundle" groupKey="group.names.style.issues"
|
||||
enabledByDefault="true"
|
||||
level="WEAK WARNING"
|
||||
language="kotlin"
|
||||
key="inspection.cascade.if.display.name" bundle="messages.KotlinBundle"/>
|
||||
|
||||
<localInspection implementationClass="org.jetbrains.kotlin.idea.inspections.collections.ConvertCallChainIntoSequenceInspection"
|
||||
groupPath="Kotlin"
|
||||
groupBundle="messages.KotlinBundle" groupKey="group.names.style.issues"
|
||||
enabledByDefault="true"
|
||||
level="WEAK WARNING"
|
||||
language="kotlin"
|
||||
key="inspection.convert.call.chain.into.sequence.display.name" bundle="messages.KotlinBundle"/>
|
||||
|
||||
<localInspection implementationClass="org.jetbrains.kotlin.idea.inspections.ConvertNaNEqualityInspection"
|
||||
groupPath="Kotlin"
|
||||
groupBundle="messages.KotlinBundle" groupKey="group.names.probable.bugs"
|
||||
enabledByDefault="true"
|
||||
level="WARNING"
|
||||
language="kotlin"
|
||||
key="inspection.convert.na.n.equality.display.name" bundle="messages.KotlinBundle"/>
|
||||
|
||||
<localInspection implementationClass="org.jetbrains.kotlin.idea.inspections.ConvertPairConstructorToToFunctionInspection"
|
||||
groupPath="Kotlin"
|
||||
groupBundle="messages.KotlinBundle" groupKey="group.names.style.issues"
|
||||
enabledByDefault="true"
|
||||
level="INFORMATION"
|
||||
language="kotlin"
|
||||
key="inspection.convert.pair.constructor.to.to.function.display.name" bundle="messages.KotlinBundle"/>
|
||||
|
||||
<localInspection implementationClass="org.jetbrains.kotlin.idea.intentions.ConvertSecondaryConstructorToPrimaryInspection"
|
||||
groupPath="Kotlin"
|
||||
groupBundle="messages.KotlinBundle" groupKey="group.names.style.issues"
|
||||
enabledByDefault="true"
|
||||
level="WARNING"
|
||||
language="kotlin"
|
||||
key="inspection.convert.secondary.constructor.to.primary.display.name" bundle="messages.KotlinBundle"/>
|
||||
|
||||
<localInspection implementationClass="org.jetbrains.kotlin.idea.intentions.ConvertToStringTemplateInspection"
|
||||
groupPath="Kotlin"
|
||||
groupBundle="messages.KotlinBundle" groupKey="group.names.style.issues"
|
||||
enabledByDefault="true"
|
||||
level="INFO"
|
||||
language="kotlin"
|
||||
key="inspection.convert.to.string.template.display.name" bundle="messages.KotlinBundle"/>
|
||||
|
||||
<localInspection implementationClass="org.jetbrains.kotlin.idea.intentions.ConvertTryFinallyToUseCallInspection"
|
||||
groupPath="Kotlin"
|
||||
groupBundle="messages.KotlinBundle" groupKey="group.names.style.issues"
|
||||
enabledByDefault="true"
|
||||
cleanupTool="true"
|
||||
level="WEAK WARNING"
|
||||
language="kotlin"
|
||||
key="inspection.convert.try.finally.to.use.call.display.name" bundle="messages.KotlinBundle"/>
|
||||
|
||||
<localInspection implementationClass="org.jetbrains.kotlin.idea.inspections.CopyWithoutNamedArgumentsInspection"
|
||||
groupPath="Kotlin"
|
||||
groupBundle="messages.KotlinBundle" groupKey="group.names.style.issues"
|
||||
enabledByDefault="true"
|
||||
cleanupTool="true"
|
||||
level="WEAK WARNING"
|
||||
language="kotlin"
|
||||
key="inspection.copy.without.named.arguments.display.name" bundle="messages.KotlinBundle"/>
|
||||
|
||||
<localInspection implementationClass="org.jetbrains.kotlin.idea.inspections.branchedTransformations.IntroduceWhenSubjectInspection"
|
||||
groupPath="Kotlin"
|
||||
groupBundle="messages.KotlinBundle" groupKey="group.names.style.issues"
|
||||
enabledByDefault="true"
|
||||
cleanupTool="true"
|
||||
level="WEAK WARNING"
|
||||
language="kotlin"
|
||||
key="inspection.introduce.when.subject.display.name" bundle="messages.KotlinBundle"/>
|
||||
|
||||
<localInspection implementationClass="org.jetbrains.kotlin.idea.inspections.kdoc.KDocMissingDocumentationInspection"
|
||||
groupPath="Kotlin"
|
||||
groupBundle="messages.KotlinBundle" groupKey="group.names.other.problems"
|
||||
enabledByDefault="false"
|
||||
level="WARNING"
|
||||
language="kotlin"
|
||||
runForWholeFile="true"
|
||||
key="inspection.k.doc.missing.documentation.display.name" bundle="messages.KotlinBundle"/>
|
||||
|
||||
<localInspection implementationClass="org.jetbrains.kotlin.idea.inspections.ForEachParameterNotUsedInspection"
|
||||
groupPath="Kotlin"
|
||||
groupBundle="messages.KotlinBundle" groupKey="group.names.probable.bugs"
|
||||
enabledByDefault="true"
|
||||
level="WEAK WARNING"
|
||||
language="kotlin"
|
||||
key="inspection.for.each.parameter.not.used.display.name" bundle="messages.KotlinBundle"/>
|
||||
|
||||
<localInspection implementationClass="org.jetbrains.kotlin.idea.inspections.KotlinCovariantEqualsInspection"
|
||||
groupPath="Kotlin"
|
||||
groupBundle="messages.KotlinBundle" groupKey="group.names.probable.bugs"
|
||||
enabledByDefault="true"
|
||||
level="WARNING"
|
||||
language="kotlin"
|
||||
suppressId="CovariantEquals"
|
||||
key="inspection.kotlin.covariant.equals.display.name" bundle="messages.KotlinBundle"/>
|
||||
|
||||
<localInspection implementationClass="org.jetbrains.kotlin.idea.inspections.LateinitVarOverridesLateinitVarInspection"
|
||||
groupPath="Kotlin"
|
||||
groupBundle="messages.KotlinBundle" groupKey="group.names.probable.bugs"
|
||||
enabledByDefault="true"
|
||||
level="WARNING"
|
||||
language="kotlin"
|
||||
key="inspection.lateinit.var.overrides.lateinit.var.display.name" bundle="messages.KotlinBundle"/>
|
||||
|
||||
<localInspection implementationClass="org.jetbrains.kotlin.idea.inspections.FoldInitializerAndIfToElvisInspection"
|
||||
groupPath="Kotlin"
|
||||
groupBundle="messages.KotlinBundle" groupKey="group.names.style.issues"
|
||||
enabledByDefault="true"
|
||||
level="WEAK WARNING"
|
||||
language="kotlin"
|
||||
key="inspection.fold.initializer.and.if.to.elvis.display.name" bundle="messages.KotlinBundle"/>
|
||||
|
||||
<localInspection implementationClass="org.jetbrains.kotlin.idea.inspections.MapGetWithNotNullAssertionOperatorInspection"
|
||||
groupPath="Kotlin"
|
||||
groupBundle="messages.KotlinBundle" groupKey="group.names.style.issues"
|
||||
enabledByDefault="true"
|
||||
level="INFORMATION"
|
||||
language="kotlin"
|
||||
key="inspection.map.get.with.not.null.assertion.operator.display.name" bundle="messages.KotlinBundle"/>
|
||||
|
||||
<localInspection implementationClass="org.jetbrains.kotlin.idea.inspections.MemberVisibilityCanBePrivateInspection"
|
||||
groupPath="Kotlin"
|
||||
groupBundle="messages.KotlinBundle" groupKey="group.names.style.issues"
|
||||
enabledByDefault="true"
|
||||
level="WEAK WARNING"
|
||||
language="kotlin"
|
||||
runForWholeFile="true"
|
||||
key="inspection.member.visibility.can.be.private.display.name" bundle="messages.KotlinBundle"/>
|
||||
|
||||
<localInspection implementationClass="org.jetbrains.kotlin.idea.inspections.RedundantObjectTypeCheckInspection"
|
||||
groupPath="Kotlin"
|
||||
groupBundle="messages.KotlinBundle" groupKey="group.names.style.issues"
|
||||
enabledByDefault="true"
|
||||
level="INFORMATION"
|
||||
language="kotlin"
|
||||
key="inspection.redundant.object.type.check.display.name" bundle="messages.KotlinBundle"/>
|
||||
|
||||
<localInspection implementationClass="org.jetbrains.kotlin.idea.inspections.RedundantExplicitTypeInspection"
|
||||
groupPath="Kotlin"
|
||||
groupBundle="messages.KotlinBundle" groupKey="group.names.redundant.constructs"
|
||||
enabledByDefault="true"
|
||||
level="WARNING"
|
||||
language="kotlin" editorAttributes="NOT_USED_ELEMENT_ATTRIBUTES"
|
||||
key="inspection.redundant.explicit.type.display.name" bundle="messages.KotlinBundle"/>
|
||||
|
||||
<localInspection implementationClass="org.jetbrains.kotlin.idea.intentions.RemoveRedundantCallsOfConversionMethodsInspection"
|
||||
groupPath="Kotlin"
|
||||
groupBundle="messages.KotlinBundle" groupKey="group.names.redundant.constructs"
|
||||
enabledByDefault="true"
|
||||
level="WARNING"
|
||||
language="kotlin" editorAttributes="NOT_USED_ELEMENT_ATTRIBUTES"
|
||||
key="inspection.remove.redundant.calls.of.conversion.methods.display.name" bundle="messages.KotlinBundle"/>
|
||||
|
||||
<localInspection implementationClass="org.jetbrains.kotlin.idea.inspections.ReplaceArrayEqualityOpWithArraysEqualsInspection"
|
||||
groupPath="Kotlin"
|
||||
groupBundle="messages.KotlinBundle" groupKey="group.names.probable.bugs"
|
||||
enabledByDefault="true"
|
||||
level="WARNING"
|
||||
language="kotlin"
|
||||
key="inspection.replace.array.equality.op.with.arrays.equals.display.name" bundle="messages.KotlinBundle"/>
|
||||
|
||||
<localInspection implementationClass="org.jetbrains.kotlin.idea.inspections.ReplaceAssociateFunctionInspection"
|
||||
groupPath="Kotlin"
|
||||
groupBundle="messages.KotlinBundle" groupKey="group.names.style.issues"
|
||||
enabledByDefault="true"
|
||||
level="WEAK WARNING"
|
||||
language="kotlin"
|
||||
key="inspection.replace.associate.function.display.name" bundle="messages.KotlinBundle"/>
|
||||
|
||||
<localInspection implementationClass="org.jetbrains.kotlin.idea.inspections.ReplaceIsEmptyWithIfEmptyInspection"
|
||||
groupPath="Kotlin"
|
||||
groupBundle="messages.KotlinBundle" groupKey="group.names.style.issues"
|
||||
enabledByDefault="true"
|
||||
level="WEAK WARNING"
|
||||
language="kotlin"
|
||||
key="inspection.replace.isempty.with.ifempty.display.name" bundle="messages.KotlinBundle"/>
|
||||
|
||||
</extensions>
|
||||
</idea-plugin>
|
||||
@@ -1,5 +0,0 @@
|
||||
<idea-plugin xmlns:xi="http://www.w3.org/2001/XInclude" implementation-detail="true">
|
||||
<id>org.jetbrains.kotlin.fe10-binding</id>
|
||||
<vendor>JetBrains</vendor>
|
||||
<xi:include href="fe10Binding.xml"/>
|
||||
</idea-plugin>
|
||||
@@ -1,916 +0,0 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
|
||||
package org.jetbrains.kotlin.idea.fir.fe10
|
||||
|
||||
import org.jetbrains.kotlin.analysis.api.KaConstantInitializerValue
|
||||
import org.jetbrains.kotlin.analysis.api.annotations.*
|
||||
import org.jetbrains.kotlin.analysis.api.base.KaConstantValue
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.*
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KtSymbolOrigin.*
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.markers.KaAnnotatedSymbol
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.markers.KaNamedSymbol
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.markers.KaSymbolWithTypeParameters
|
||||
import org.jetbrains.kotlin.analysis.api.types.KtNonErrorClassType
|
||||
import org.jetbrains.kotlin.analysis.api.types.KtType
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.descriptors.impl.AbstractReceiverParameterDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.impl.ReceiverParameterDescriptorImpl
|
||||
import org.jetbrains.kotlin.descriptors.impl.TypeAliasConstructorDescriptor
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.name.SpecialNames
|
||||
import org.jetbrains.kotlin.name.StandardClassIds
|
||||
import org.jetbrains.kotlin.psi.KtPureElement
|
||||
import org.jetbrains.kotlin.resolve.constants.*
|
||||
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ExtensionReceiver
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ImplicitClassReceiver
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
||||
import org.jetbrains.kotlin.resolve.source.toSourceElement
|
||||
import org.jetbrains.kotlin.storage.StorageManager
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
|
||||
|
||||
|
||||
/**
|
||||
* List of known problems/not-implemented:
|
||||
* - getOrigin return itself all the time. Formally it should return "unsubstituted" version of itself, but it isn't clear,
|
||||
* if we really needed that nor how to implemented it. Btw, it is relevant only to member functions/properties (unlikely, but may be to
|
||||
* inner classes) and not for "resulting descriptor". I.e. only class/interface type parameters could be substituted in FIR,
|
||||
* there is no "resulting descriptor" and type arguments are passed together with the target function.
|
||||
* - equals on descriptors and type constructors. It isn't clear what type of equality we should implement,
|
||||
* will figure that later o real cases.
|
||||
* See the functions below
|
||||
*/
|
||||
|
||||
internal fun Fe10WrapperContext.containerDeclarationImplementationPostponed(): Nothing =
|
||||
implementationPostponed("It isn't clear what we really need and how to implement it")
|
||||
|
||||
interface KtSymbolBasedNamed : Named {
|
||||
val ktSymbol: KaNamedSymbol
|
||||
override fun getName(): Name = ktSymbol.name
|
||||
}
|
||||
|
||||
private fun Visibility.toDescriptorVisibility(): DescriptorVisibility =
|
||||
when (this) {
|
||||
Visibilities.Public -> DescriptorVisibilities.PUBLIC
|
||||
Visibilities.Private -> DescriptorVisibilities.PRIVATE
|
||||
Visibilities.PrivateToThis -> DescriptorVisibilities.PRIVATE_TO_THIS
|
||||
Visibilities.Protected -> DescriptorVisibilities.PROTECTED
|
||||
Visibilities.Internal -> DescriptorVisibilities.INTERNAL
|
||||
Visibilities.Local -> DescriptorVisibilities.LOCAL
|
||||
else -> error("Unknown visibility: $this")
|
||||
}
|
||||
|
||||
private fun KaClassKind.toDescriptorKlassKind(): ClassKind =
|
||||
when (this) {
|
||||
KaClassKind.CLASS -> ClassKind.CLASS
|
||||
KaClassKind.ENUM_CLASS -> ClassKind.ENUM_CLASS
|
||||
KaClassKind.ANNOTATION_CLASS -> ClassKind.ANNOTATION_CLASS
|
||||
KaClassKind.OBJECT, KaClassKind.COMPANION_OBJECT, KaClassKind.ANONYMOUS_OBJECT -> ClassKind.OBJECT
|
||||
KaClassKind.INTERFACE -> ClassKind.INTERFACE
|
||||
}
|
||||
|
||||
private fun KtSymbolOrigin.toCallableDescriptorKind(): CallableMemberDescriptor.Kind = when (this) {
|
||||
DELEGATED -> CallableMemberDescriptor.Kind.DELEGATION
|
||||
SUBSTITUTION_OVERRIDE, INTERSECTION_OVERRIDE -> CallableMemberDescriptor.Kind.FAKE_OVERRIDE
|
||||
SOURCE_MEMBER_GENERATED -> CallableMemberDescriptor.Kind.SYNTHESIZED
|
||||
else -> CallableMemberDescriptor.Kind.DECLARATION
|
||||
}
|
||||
|
||||
private fun KtAnnotationValue.toConstantValue(context: Fe10WrapperContext): ConstantValue<*> {
|
||||
return when (this) {
|
||||
is KtUnsupportedAnnotationValue -> ErrorValue.create("Unsupported annotation value")
|
||||
is KtArrayAnnotationValue -> ArrayValue(values.map { it.toConstantValue(context) }) { TODO() }
|
||||
is KtAnnotationApplicationValue -> TODO()
|
||||
is KtKClassAnnotationValue -> context.withAnalysisSession {
|
||||
when (val type = type) {
|
||||
is KtNonErrorClassType -> {
|
||||
val classId = type.classId
|
||||
if (classId.isLocal) {
|
||||
KClassValue(KClassValue.Value.LocalClass(type.toKotlinType(context)))
|
||||
} else {
|
||||
var unwrappedType: KtNonErrorClassType = type
|
||||
var arrayDimensions = 0
|
||||
while (unwrappedType.classId == StandardClassIds.Array) {
|
||||
val elementType = unwrappedType.getArrayElementType()?.lowerBoundIfFlexible() as? KtNonErrorClassType ?: break
|
||||
unwrappedType = elementType
|
||||
arrayDimensions += 1
|
||||
}
|
||||
KClassValue(unwrappedType.classId, arrayDimensions)
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
ErrorValue.create("Unresolved class")
|
||||
}
|
||||
}
|
||||
}
|
||||
is KtEnumEntryAnnotationValue -> {
|
||||
val callableId = callableId ?: return ErrorValue.create("Unresolved enum entry")
|
||||
val classId = callableId.classId ?: return ErrorValue.create("Unresolved enum entry")
|
||||
EnumValue(classId, callableId.callableName)
|
||||
}
|
||||
|
||||
is KtConstantAnnotationValue -> constantValue.toConstantValue()
|
||||
}
|
||||
}
|
||||
|
||||
internal fun KaConstantValue.toConstantValue(): ConstantValue<*> =
|
||||
when (this) {
|
||||
is KaConstantValue.KaErrorConstantValue -> ErrorValue.create(errorMessage)
|
||||
else -> when (constantValueKind) {
|
||||
ConstantValueKind.Null -> NullValue()
|
||||
ConstantValueKind.Boolean -> BooleanValue(value as Boolean)
|
||||
ConstantValueKind.Char -> CharValue(value as Char)
|
||||
ConstantValueKind.Byte -> ByteValue(value as Byte)
|
||||
ConstantValueKind.Short -> ShortValue(value as Short)
|
||||
ConstantValueKind.Int -> IntValue(value as Int)
|
||||
ConstantValueKind.Long -> LongValue(value as Long)
|
||||
ConstantValueKind.String -> StringValue(value as String)
|
||||
ConstantValueKind.Float -> FloatValue(value as Float)
|
||||
ConstantValueKind.Double -> DoubleValue(value as Double)
|
||||
ConstantValueKind.UnsignedByte -> UByteValue(value as Byte)
|
||||
ConstantValueKind.UnsignedShort -> UShortValue(value as Short)
|
||||
ConstantValueKind.UnsignedInt -> UIntValue(value as Int)
|
||||
ConstantValueKind.UnsignedLong -> ULongValue(value as Long)
|
||||
else -> error("Unexpected constant KtSimpleConstantValue: $value (class: ${value?.javaClass}")
|
||||
}
|
||||
}
|
||||
|
||||
abstract class KtSymbolBasedDeclarationDescriptor(val context: Fe10WrapperContext) : DeclarationDescriptorWithSource {
|
||||
abstract val ktSymbol: KtSymbol
|
||||
override val annotations: Annotations
|
||||
get() {
|
||||
val ktAnnotations = (ktSymbol as? KaAnnotatedSymbol)?.annotations ?: return Annotations.EMPTY
|
||||
return Annotations.create(ktAnnotations.map { KtSymbolBasedAnnotationDescriptor(it, context) })
|
||||
}
|
||||
|
||||
override fun getSource(): SourceElement = ktSymbol.psi.safeAs<KtPureElement>().toSourceElement()
|
||||
|
||||
override fun getContainingDeclaration(): DeclarationDescriptor {
|
||||
val containerSymbol = context.withAnalysisSession {
|
||||
ktSymbol.getContainingSymbol()
|
||||
}
|
||||
if (containerSymbol != null)
|
||||
return containerSymbol.toDeclarationDescriptor(context)
|
||||
|
||||
// i.e. declaration is top-level
|
||||
return KtSymbolBasedPackageFragmentDescriptor(getPackageFqNameIfTopLevel(), context)
|
||||
}
|
||||
|
||||
protected abstract fun getPackageFqNameIfTopLevel(): FqName
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (other === this) return true
|
||||
if (other !is KtSymbolBasedDeclarationDescriptor) return false
|
||||
|
||||
ktSymbol.psi?.let {
|
||||
return other.ktSymbol.psi == it
|
||||
}
|
||||
|
||||
return ktSymbol == other.ktSymbol
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
ktSymbol.psi?.let { return it.hashCode() }
|
||||
return ktSymbol.hashCode()
|
||||
}
|
||||
|
||||
override fun <R : Any?, D : Any?> accept(visitor: DeclarationDescriptorVisitor<R, D>?, data: D): R = noImplementation()
|
||||
override fun acceptVoid(visitor: DeclarationDescriptorVisitor<Void, Void>?): Unit = noImplementation()
|
||||
|
||||
// stub for automatic Substitutable<T> implementation for all relevant subclasses
|
||||
fun substitute(substitutor: TypeSubstitutor): Nothing = noImplementation()
|
||||
|
||||
protected fun noImplementation(): Nothing = context.noImplementation("ktSymbol = $ktSymbol")
|
||||
protected fun implementationPostponed(): Nothing = context.implementationPostponed("ktSymbol = $ktSymbol")
|
||||
protected fun implementationPlanned(): Nothing = context.implementationPlanned("ktSymbol = $ktSymbol")
|
||||
|
||||
override fun toString(): String = this.javaClass.simpleName + " " + this.name
|
||||
}
|
||||
|
||||
class KtSymbolBasedAnnotationDescriptor(
|
||||
private val ktAnnotationCall: KtAnnotationApplicationWithArgumentsInfo,
|
||||
val context: Fe10WrapperContext,
|
||||
) : AnnotationDescriptor {
|
||||
override val type: KotlinType
|
||||
get() = context.implementationPlanned("ktAnnotationCall = $ktAnnotationCall")
|
||||
|
||||
override val fqName: FqName?
|
||||
get() = ktAnnotationCall.classId?.asSingleFqName()
|
||||
|
||||
override val allValueArguments: Map<Name, ConstantValue<*>> =
|
||||
ktAnnotationCall.arguments.associate { it.name to it.expression.toConstantValue(context) }
|
||||
|
||||
override val source: SourceElement
|
||||
get() = ktAnnotationCall.psi.toSourceElement()
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Should be created only for this class receiver and extension receiver
|
||||
*
|
||||
* We are using custom equals/hashCode because in Fe10Binding all the descriptors are created multiple times,
|
||||
* so identityEquals for ReceiverParameters as in ReceiverParameterDescriptorImpl works incorrectly
|
||||
*/
|
||||
class Fe10BindingReceiverParameterDescriptorImpl(
|
||||
containingDeclaration: DeclarationDescriptor,
|
||||
receiverValue: ReceiverValue,
|
||||
annotations: Annotations
|
||||
) : ReceiverParameterDescriptorImpl(containingDeclaration, receiverValue, annotations) {
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (other !is Fe10BindingReceiverParameterDescriptorImpl) return false
|
||||
if (other.containingDeclaration != containingDeclaration) return false
|
||||
|
||||
return other.value.type == value.type
|
||||
}
|
||||
|
||||
override fun hashCode(): Int = 31 * containingDeclaration.hashCode() + value.type.hashCode()
|
||||
}
|
||||
|
||||
class KtSymbolBasedClassDescriptor(override val ktSymbol: KaNamedClassOrObjectSymbol, context: Fe10WrapperContext) :
|
||||
KtSymbolBasedDeclarationDescriptor(context), KtSymbolBasedNamed, ClassDescriptor {
|
||||
|
||||
override fun isInner(): Boolean = ktSymbol.isInner
|
||||
override fun isCompanionObject(): Boolean = ktSymbol.classKind == KaClassKind.COMPANION_OBJECT
|
||||
override fun isData(): Boolean = ktSymbol.isData
|
||||
override fun isInline(): Boolean = ktSymbol.isInline // seems like th`is `flag should be removed in favor of isValue
|
||||
override fun isValue(): Boolean = ktSymbol.isInline
|
||||
override fun isFun(): Boolean = ktSymbol.isFun
|
||||
|
||||
override fun isExpect(): Boolean = ktSymbol.isExpect
|
||||
override fun isActual(): Boolean = ktSymbol.isActual
|
||||
override fun isExternal(): Boolean = ktSymbol.isExternal
|
||||
|
||||
override fun getVisibility(): DescriptorVisibility = ktSymbol.visibility.toDescriptorVisibility()
|
||||
override fun getModality(): Modality = ktSymbol.modality
|
||||
|
||||
override fun getKind(): ClassKind = ktSymbol.classKind.toDescriptorKlassKind()
|
||||
|
||||
override fun getCompanionObjectDescriptor(): ClassDescriptor? = ktSymbol.companionObject?.let {
|
||||
KtSymbolBasedClassDescriptor(it, context)
|
||||
}
|
||||
|
||||
override fun getTypeConstructor(): TypeConstructor = KtSymbolBasedClassTypeConstructor(this)
|
||||
|
||||
override fun getDeclaredTypeParameters(): List<TypeParameterDescriptor> = getTypeParameters(ktSymbol)
|
||||
|
||||
override fun getDefaultType(): SimpleType {
|
||||
val arguments = TypeUtils.getDefaultTypeProjections(typeConstructor.parameters)
|
||||
return KotlinTypeFactory.simpleTypeWithNonTrivialMemberScope(
|
||||
TypeAttributes.Empty, typeConstructor, arguments, false,
|
||||
MemberScopeForKtSymbolBasedDescriptors { "ktSymbol = $ktSymbol" }
|
||||
)
|
||||
}
|
||||
|
||||
override fun getThisAsReceiverParameter(): ReceiverParameterDescriptor =
|
||||
Fe10BindingReceiverParameterDescriptorImpl(this, ImplicitClassReceiver(this), Annotations.EMPTY)
|
||||
|
||||
override fun getContextReceivers(): List<ReceiverParameterDescriptor> = implementationPlanned()
|
||||
|
||||
override fun getOriginal(): ClassDescriptor = this
|
||||
|
||||
override fun getUnsubstitutedPrimaryConstructor(): ClassConstructorDescriptor? = context.withAnalysisSession {
|
||||
ktSymbol.getDeclaredMemberScope().getConstructors().firstOrNull { it.isPrimary }
|
||||
?.let { KtSymbolBasedConstructorDescriptor(it, this@KtSymbolBasedClassDescriptor) }
|
||||
}
|
||||
|
||||
override fun getConstructors(): Collection<ClassConstructorDescriptor> = context.withAnalysisSession {
|
||||
ktSymbol.getDeclaredMemberScope().getConstructors().map {
|
||||
KtSymbolBasedConstructorDescriptor(it, this@KtSymbolBasedClassDescriptor)
|
||||
}.toList()
|
||||
}
|
||||
|
||||
override fun getPackageFqNameIfTopLevel(): FqName = (ktSymbol.classId ?: error("should be top-level")).packageFqName
|
||||
|
||||
override fun getSealedSubclasses(): Collection<ClassDescriptor> = implementationPostponed()
|
||||
|
||||
override fun getValueClassRepresentation(): ValueClassRepresentation<SimpleType> = TODO("Not yet implemented")
|
||||
|
||||
override fun getMemberScope(typeArguments: List<TypeProjection>): MemberScope = noImplementation()
|
||||
override fun getMemberScope(typeSubstitution: TypeSubstitution): MemberScope = noImplementation()
|
||||
override fun getUnsubstitutedMemberScope(): MemberScope = noImplementation()
|
||||
override fun getUnsubstitutedInnerClassesScope(): MemberScope = noImplementation()
|
||||
override fun getStaticScope(): MemberScope = noImplementation()
|
||||
|
||||
override fun isDefinitelyNotSamInterface(): Boolean = noImplementation()
|
||||
override fun getDefaultFunctionTypeForSamInterface(): SimpleType = noImplementation()
|
||||
}
|
||||
|
||||
class KtSymbolBasedTypeParameterDescriptor(
|
||||
override val ktSymbol: KaTypeParameterSymbol, context: Fe10WrapperContext
|
||||
) : KtSymbolBasedDeclarationDescriptor(context), KtSymbolBasedNamed, TypeParameterDescriptor {
|
||||
override fun isReified(): Boolean = ktSymbol.isReified
|
||||
override fun getVariance(): Variance = ktSymbol.variance
|
||||
|
||||
override fun getTypeConstructor(): TypeConstructor = KtSymbolBasedTypeParameterTypeConstructor(this)
|
||||
|
||||
override fun getDefaultType(): SimpleType =
|
||||
KotlinTypeFactory.simpleTypeWithNonTrivialMemberScope(
|
||||
TypeAttributes.Empty, typeConstructor, emptyList(), false,
|
||||
MemberScopeForKtSymbolBasedDescriptors { "ktSymbol = $ktSymbol" }
|
||||
)
|
||||
|
||||
override fun getUpperBounds(): List<KotlinType> = ktSymbol.upperBounds.map { it.toKotlinType(context) }
|
||||
override fun getOriginal(): TypeParameterDescriptor = this
|
||||
|
||||
override fun getPackageFqNameIfTopLevel(): FqName = error("Should be called")
|
||||
|
||||
// there is no such thing in FIR, and it seems like it isn't really needed for IDE and could be bypassed on client site
|
||||
override fun getIndex(): Int = implementationPostponed()
|
||||
|
||||
override fun isCapturedFromOuterDeclaration(): Boolean = noImplementation()
|
||||
override fun getStorageManager(): StorageManager = noImplementation()
|
||||
}
|
||||
|
||||
abstract class KtSymbolBasedFunctionLikeDescriptor(context: Fe10WrapperContext) :
|
||||
KtSymbolBasedDeclarationDescriptor(context), FunctionDescriptor {
|
||||
abstract override val ktSymbol: KaFunctionLikeSymbol
|
||||
|
||||
override fun getReturnType(): KotlinType = ktSymbol.returnType.toKotlinType(context)
|
||||
|
||||
override fun getValueParameters(): List<ValueParameterDescriptor> = ktSymbol.valueParameters.mapIndexed { index, it ->
|
||||
KtSymbolBasedValueParameterDescriptor(it, context, this, index)
|
||||
}
|
||||
|
||||
override fun hasStableParameterNames(): Boolean = ktSymbol.hasStableParameterNames
|
||||
override fun hasSynthesizedParameterNames(): Boolean = implementationPostponed()
|
||||
|
||||
override fun getKind(): CallableMemberDescriptor.Kind = ktSymbol.origin.toCallableDescriptorKind()
|
||||
|
||||
override fun <V : Any?> getUserData(key: CallableDescriptor.UserDataKey<V>?): V? = null
|
||||
|
||||
override fun getOriginal(): FunctionDescriptor = this
|
||||
|
||||
override fun isHiddenForResolutionEverywhereBesideSupercalls(): Boolean = implementationPostponed()
|
||||
|
||||
override fun getInitialSignatureDescriptor(): FunctionDescriptor? = noImplementation()
|
||||
override fun isHiddenToOvercomeSignatureClash(): Boolean = noImplementation()
|
||||
|
||||
override fun setOverriddenDescriptors(overriddenDescriptors: MutableCollection<out CallableMemberDescriptor>) = noImplementation()
|
||||
override fun newCopyBuilder(): FunctionDescriptor.CopyBuilder<out FunctionDescriptor> = noImplementation()
|
||||
override fun copy(
|
||||
newOwner: DeclarationDescriptor?,
|
||||
modality: Modality?,
|
||||
visibility: DescriptorVisibility?,
|
||||
kind: CallableMemberDescriptor.Kind?,
|
||||
copyOverrides: Boolean
|
||||
): FunctionDescriptor = noImplementation()
|
||||
}
|
||||
|
||||
class KtSymbolBasedFunctionDescriptor(override val ktSymbol: KaFunctionSymbol, context: Fe10WrapperContext) :
|
||||
KtSymbolBasedFunctionLikeDescriptor(context),
|
||||
SimpleFunctionDescriptor,
|
||||
KtSymbolBasedNamed {
|
||||
override fun getExtensionReceiverParameter(): ReceiverParameterDescriptor? = getExtensionReceiverParameter(ktSymbol)
|
||||
override fun getDispatchReceiverParameter(): ReceiverParameterDescriptor? = getDispatchReceiverParameter(ktSymbol)
|
||||
override fun getContextReceiverParameters(): List<ReceiverParameterDescriptor> = implementationPlanned()
|
||||
|
||||
override fun getPackageFqNameIfTopLevel(): FqName = (ktSymbol.callableId ?: error("should be top-level")).packageName
|
||||
|
||||
override fun isSuspend(): Boolean = ktSymbol.isSuspend
|
||||
override fun isOperator(): Boolean = ktSymbol.isOperator
|
||||
override fun isExternal(): Boolean = ktSymbol.isExternal
|
||||
override fun isInline(): Boolean = ktSymbol.isInline
|
||||
override fun isInfix(): Boolean = implementationPostponed()
|
||||
override fun isTailrec(): Boolean = implementationPostponed()
|
||||
|
||||
override fun isExpect(): Boolean = context.incorrectImplementation { false }
|
||||
override fun isActual(): Boolean = context.incorrectImplementation { false }
|
||||
|
||||
override fun getVisibility(): DescriptorVisibility = ktSymbol.visibility.toDescriptorVisibility()
|
||||
override fun getModality(): Modality = ktSymbol.modality
|
||||
|
||||
override fun getTypeParameters(): List<TypeParameterDescriptor> = getTypeParameters(ktSymbol)
|
||||
|
||||
override fun getOverriddenDescriptors(): Collection<FunctionDescriptor> {
|
||||
val overriddenKtSymbols = context.withAnalysisSession {
|
||||
ktSymbol.getAllOverriddenSymbols()
|
||||
}
|
||||
|
||||
return overriddenKtSymbols.map { KtSymbolBasedFunctionDescriptor(it as KaFunctionSymbol, context) }
|
||||
}
|
||||
|
||||
override fun copy(
|
||||
newOwner: DeclarationDescriptor?,
|
||||
modality: Modality?,
|
||||
visibility: DescriptorVisibility?,
|
||||
kind: CallableMemberDescriptor.Kind?,
|
||||
copyOverrides: Boolean
|
||||
): SimpleFunctionDescriptor = context.noImplementation()
|
||||
|
||||
override fun getOriginal(): SimpleFunctionDescriptor = context.incorrectImplementation { this }
|
||||
|
||||
override fun newCopyBuilder(): FunctionDescriptor.CopyBuilder<out SimpleFunctionDescriptor> =
|
||||
context.noImplementation()
|
||||
}
|
||||
|
||||
class KtSymbolBasedConstructorDescriptor(
|
||||
override val ktSymbol: KaConstructorSymbol,
|
||||
private val ktSBClassDescriptor: KtSymbolBasedClassDescriptor
|
||||
) : KtSymbolBasedFunctionLikeDescriptor(ktSBClassDescriptor.context),
|
||||
ClassConstructorDescriptor {
|
||||
override fun getName(): Name = Name.special("<init>")
|
||||
|
||||
override fun getExtensionReceiverParameter(): ReceiverParameterDescriptor? = null
|
||||
override fun getDispatchReceiverParameter(): ReceiverParameterDescriptor? = getDispatchReceiverParameter(ktSymbol)
|
||||
override fun getContextReceiverParameters(): List<ReceiverParameterDescriptor> = ktSBClassDescriptor.contextReceivers
|
||||
|
||||
override fun getConstructedClass(): ClassDescriptor = ktSBClassDescriptor
|
||||
override fun getContainingDeclaration(): ClassDescriptor = ktSBClassDescriptor
|
||||
override fun getPackageFqNameIfTopLevel(): FqName = error("should not be called")
|
||||
|
||||
override fun isPrimary(): Boolean = ktSymbol.isPrimary
|
||||
|
||||
override fun getReturnType(): KotlinType = ktSBClassDescriptor.defaultType
|
||||
|
||||
override fun isSuspend(): Boolean = false
|
||||
override fun isOperator(): Boolean = false
|
||||
override fun isExternal(): Boolean = false
|
||||
override fun isInline(): Boolean = false
|
||||
override fun isInfix(): Boolean = false
|
||||
override fun isTailrec(): Boolean = false
|
||||
|
||||
override fun isExpect(): Boolean = implementationPostponed()
|
||||
override fun isActual(): Boolean = implementationPostponed()
|
||||
|
||||
override fun getVisibility(): DescriptorVisibility = ktSymbol.visibility.toDescriptorVisibility()
|
||||
override fun getModality(): Modality = Modality.FINAL
|
||||
|
||||
override fun getTypeParameters(): List<TypeParameterDescriptor> = getTypeParameters(ktSymbol)
|
||||
|
||||
override fun getOriginal(): ClassConstructorDescriptor = this
|
||||
|
||||
override fun getOverriddenDescriptors(): Collection<FunctionDescriptor> = emptyList()
|
||||
|
||||
override fun copy(
|
||||
newOwner: DeclarationDescriptor,
|
||||
modality: Modality,
|
||||
visibility: DescriptorVisibility,
|
||||
kind: CallableMemberDescriptor.Kind,
|
||||
copyOverrides: Boolean
|
||||
): ClassConstructorDescriptor = noImplementation()
|
||||
}
|
||||
|
||||
class KtSymbolBasedAnonymousFunctionDescriptor(
|
||||
override val ktSymbol: KaAnonymousFunctionSymbol,
|
||||
context: Fe10WrapperContext
|
||||
) : KtSymbolBasedFunctionLikeDescriptor(context), SimpleFunctionDescriptor {
|
||||
override fun getName(): Name = SpecialNames.ANONYMOUS
|
||||
|
||||
override fun getExtensionReceiverParameter(): ReceiverParameterDescriptor? = getExtensionReceiverParameter(ktSymbol)
|
||||
override fun getDispatchReceiverParameter(): ReceiverParameterDescriptor? = null
|
||||
override fun getContextReceiverParameters(): List<ReceiverParameterDescriptor> = implementationPlanned()
|
||||
|
||||
override fun getPackageFqNameIfTopLevel(): FqName = error("Impossible to be a top-level declaration")
|
||||
|
||||
override fun isOperator(): Boolean = false
|
||||
override fun isExternal(): Boolean = false
|
||||
override fun isInline(): Boolean = false
|
||||
override fun isInfix(): Boolean = false
|
||||
override fun isTailrec(): Boolean = false
|
||||
override fun isExpect(): Boolean = false
|
||||
override fun isActual(): Boolean = false
|
||||
|
||||
override fun getVisibility(): DescriptorVisibility = DescriptorVisibilities.LOCAL
|
||||
override fun getModality(): Modality = Modality.FINAL
|
||||
override fun getTypeParameters(): List<TypeParameterDescriptor> = emptyList()
|
||||
|
||||
// it doesn't seems like isSuspend are used in FIR for anonymous functions, but it used in FIR2IR so if we really need that
|
||||
// we could implement that later
|
||||
override fun isSuspend(): Boolean = implementationPostponed()
|
||||
|
||||
override fun getOverriddenDescriptors(): Collection<FunctionDescriptor> = emptyList()
|
||||
|
||||
override fun copy(
|
||||
newOwner: DeclarationDescriptor?,
|
||||
modality: Modality?,
|
||||
visibility: DescriptorVisibility?,
|
||||
kind: CallableMemberDescriptor.Kind?,
|
||||
copyOverrides: Boolean
|
||||
): SimpleFunctionDescriptor = noImplementation()
|
||||
|
||||
override fun getOriginal(): SimpleFunctionDescriptor = this
|
||||
|
||||
override fun newCopyBuilder(): FunctionDescriptor.CopyBuilder<out SimpleFunctionDescriptor> = noImplementation()
|
||||
}
|
||||
|
||||
private fun KtSymbolBasedDeclarationDescriptor.getDispatchReceiverParameter(ktSymbol: KaCallableSymbol): ReceiverParameterDescriptor? {
|
||||
val ktDispatchTypeAndAnnotations = context.withAnalysisSession { ktSymbol.getDispatchReceiverType() } ?: return null
|
||||
return KtSymbolStubDispatchReceiverParameterDescriptor(ktDispatchTypeAndAnnotations, context)
|
||||
}
|
||||
|
||||
private fun <T> T.getExtensionReceiverParameter(
|
||||
ktSymbol: KaCallableSymbol,
|
||||
): ReceiverParameterDescriptor? where T : KtSymbolBasedDeclarationDescriptor, T : CallableDescriptor {
|
||||
val receiverType = ktSymbol.receiverType ?: return null
|
||||
val receiverValue = ExtensionReceiver(this, receiverType.toKotlinType(context), null)
|
||||
return Fe10BindingReceiverParameterDescriptorImpl(this, receiverValue, receiverType.getDescriptorsAnnotations(context))
|
||||
}
|
||||
|
||||
private fun KtSymbolBasedDeclarationDescriptor.getTypeParameters(ktSymbol: KaSymbolWithTypeParameters) =
|
||||
ktSymbol.typeParameters.map { KtSymbolBasedTypeParameterDescriptor(it, context) }
|
||||
|
||||
private class KtSymbolBasedReceiverValue(val ktType: KtType, val context: Fe10WrapperContext) : ReceiverValue {
|
||||
override fun getType(): KotlinType = ktType.toKotlinType(context)
|
||||
|
||||
override fun replaceType(newType: KotlinType): ReceiverValue = context.noImplementation("Should be called from IDE")
|
||||
override fun getOriginal(): ReceiverValue = this
|
||||
}
|
||||
|
||||
// Don't think that annotation is important here, because containingDeclaration used way more then annotation and they are not supported here
|
||||
private class KtSymbolStubDispatchReceiverParameterDescriptor(
|
||||
val receiverType: KtType,
|
||||
val context: Fe10WrapperContext
|
||||
) : AbstractReceiverParameterDescriptor(Annotations.EMPTY) {
|
||||
override fun getContainingDeclaration(): DeclarationDescriptor = context.containerDeclarationImplementationPostponed()
|
||||
|
||||
override fun getValue(): ReceiverValue = KtSymbolBasedReceiverValue(receiverType, context)
|
||||
|
||||
override fun copy(newOwner: DeclarationDescriptor): ReceiverParameterDescriptor =
|
||||
context.noImplementation("Copy should be called from IDE code")
|
||||
}
|
||||
|
||||
class KtSymbolBasedValueParameterDescriptor(
|
||||
override val ktSymbol: KaValueParameterSymbol,
|
||||
context: Fe10WrapperContext,
|
||||
val containingDeclaration: KtSymbolBasedFunctionLikeDescriptor,
|
||||
index: Int = -1,
|
||||
) : KtSymbolBasedDeclarationDescriptor(context), KtSymbolBasedNamed, ValueParameterDescriptor {
|
||||
override val index: Int
|
||||
|
||||
init {
|
||||
if (index != -1) {
|
||||
this.index = index
|
||||
} else {
|
||||
val containerSymbol = containingDeclaration.ktSymbol
|
||||
this.index = containerSymbol.valueParameters.indexOf(ktSymbol)
|
||||
check(this.index != -1) {
|
||||
"Parameter not found in container symbol = $containerSymbol"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun getExtensionReceiverParameter(): ReceiverParameterDescriptor? = null
|
||||
override fun getDispatchReceiverParameter(): ReceiverParameterDescriptor? = null
|
||||
override fun getContextReceiverParameters(): List<ReceiverParameterDescriptor> = emptyList()
|
||||
|
||||
override fun getTypeParameters(): List<TypeParameterDescriptor> = emptyList()
|
||||
|
||||
override fun getReturnType(): KotlinType = this.type
|
||||
|
||||
override fun getValueParameters(): List<ValueParameterDescriptor> = emptyList()
|
||||
override fun hasStableParameterNames(): Boolean = false
|
||||
override fun hasSynthesizedParameterNames(): Boolean = false
|
||||
|
||||
override fun <V : Any?> getUserData(key: CallableDescriptor.UserDataKey<V>?): V? = null
|
||||
|
||||
override fun getVisibility(): DescriptorVisibility = DescriptorVisibilities.LOCAL
|
||||
|
||||
// for old FE it should return ArrayType in case of vararg
|
||||
override fun getType(): KotlinType {
|
||||
val elementType = ktSymbol.returnType.toKotlinType(context)
|
||||
if (!ktSymbol.isVararg) return elementType
|
||||
|
||||
// copy from org.jetbrains.kotlin.resolve.DescriptorResolver.getVarargParameterType
|
||||
val primitiveArrayType = context.builtIns.getPrimitiveArrayKotlinTypeByPrimitiveKotlinType(elementType)
|
||||
return primitiveArrayType ?: context.builtIns.getArrayType(Variance.OUT_VARIANCE, elementType)
|
||||
}
|
||||
|
||||
override fun getContainingDeclaration(): CallableDescriptor = containingDeclaration
|
||||
override fun getPackageFqNameIfTopLevel(): FqName = error("Couldn't be top-level")
|
||||
|
||||
override fun declaresDefaultValue(): Boolean = ktSymbol.hasDefaultValue
|
||||
|
||||
override val varargElementType: KotlinType?
|
||||
get() {
|
||||
if (!ktSymbol.isVararg) return null
|
||||
return type
|
||||
}
|
||||
|
||||
override fun cleanCompileTimeInitializerCache() {}
|
||||
|
||||
override fun getOriginal(): ValueParameterDescriptor = context.incorrectImplementation { this }
|
||||
|
||||
override fun copy(newOwner: CallableDescriptor, newName: Name, newIndex: Int): ValueParameterDescriptor =
|
||||
context.noImplementation()
|
||||
|
||||
override fun getOverriddenDescriptors(): Collection<ValueParameterDescriptor> {
|
||||
return containingDeclaration.overriddenDescriptors.map { it.valueParameters[index] }
|
||||
}
|
||||
|
||||
override val isCrossinline: Boolean
|
||||
get() = implementationPostponed()
|
||||
override val isNoinline: Boolean
|
||||
get() = implementationPostponed()
|
||||
|
||||
override fun isVar(): Boolean = false
|
||||
override fun getCompileTimeInitializer(): ConstantValue<*>? = null
|
||||
override fun isConst(): Boolean = false
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (other === this) return true
|
||||
if (other !is KtSymbolBasedValueParameterDescriptor) return false
|
||||
return index == other.index && containingDeclaration == other.containingDeclaration
|
||||
}
|
||||
|
||||
override fun hashCode(): Int = containingDeclaration.hashCode() * 37 + index
|
||||
|
||||
}
|
||||
|
||||
abstract class AbstractKtSymbolBasedPropertyDescriptor(
|
||||
context: Fe10WrapperContext
|
||||
) : KtSymbolBasedDeclarationDescriptor(context), KtSymbolBasedNamed, PropertyDescriptor {
|
||||
abstract override val ktSymbol: KtVariableSymbol
|
||||
|
||||
override fun getPackageFqNameIfTopLevel(): FqName = (ktSymbol.callableId ?: error("should be top-level")).packageName
|
||||
override fun getOriginal(): PropertyDescriptor = context.incorrectImplementation { this }
|
||||
|
||||
|
||||
override fun getExtensionReceiverParameter(): ReceiverParameterDescriptor? = getExtensionReceiverParameter(ktSymbol)
|
||||
override fun getDispatchReceiverParameter(): ReceiverParameterDescriptor? = getDispatchReceiverParameter(ktSymbol)
|
||||
|
||||
override fun getContextReceiverParameters(): List<ReceiverParameterDescriptor> = implementationPlanned()
|
||||
|
||||
override fun getTypeParameters(): List<TypeParameterDescriptor> = getTypeParameters(ktSymbol)
|
||||
|
||||
override fun getReturnType(): KotlinType = ktSymbol.returnType.toKotlinType(context)
|
||||
|
||||
|
||||
override fun getValueParameters(): List<ValueParameterDescriptor> = emptyList()
|
||||
override fun hasStableParameterNames(): Boolean = false
|
||||
override fun hasSynthesizedParameterNames(): Boolean = false
|
||||
|
||||
override fun getOverriddenDescriptors(): Collection<PropertyDescriptor> {
|
||||
val overriddenKtSymbols = context.withAnalysisSession {
|
||||
ktSymbol.getAllOverriddenSymbols()
|
||||
}
|
||||
|
||||
return overriddenKtSymbols.map { it.toDeclarationDescriptor(context) as PropertyDescriptor }
|
||||
}
|
||||
|
||||
override fun <V : Any?> getUserData(key: CallableDescriptor.UserDataKey<V>?): V? = null
|
||||
|
||||
override fun getType(): KotlinType = ktSymbol.returnType.toKotlinType(context)
|
||||
|
||||
override fun isVar(): Boolean = !ktSymbol.isVal
|
||||
|
||||
override fun getAccessors(): List<PropertyAccessorDescriptor> = listOfNotNull(getter, setter)
|
||||
|
||||
override fun cleanCompileTimeInitializerCache() = noImplementation()
|
||||
|
||||
override fun isLateInit(): Boolean = ktSymbol is KtKotlinPropertySymbol && (ktSymbol as KtKotlinPropertySymbol).isLateInit
|
||||
|
||||
override fun getModality(): Modality = when (ktSymbol) {
|
||||
is KtJavaFieldSymbol -> (ktSymbol as KtJavaFieldSymbol).modality
|
||||
is KtPropertySymbol -> (ktSymbol as KtPropertySymbol).modality
|
||||
is KaLocalVariableSymbol -> Modality.FINAL
|
||||
}
|
||||
|
||||
override fun isExpect(): Boolean = implementationPostponed()
|
||||
override fun isActual(): Boolean = implementationPostponed()
|
||||
override fun isExternal(): Boolean = implementationPlanned()
|
||||
|
||||
override fun getInType(): KotlinType = implementationPostponed()
|
||||
|
||||
override fun setOverriddenDescriptors(overriddenDescriptors: MutableCollection<out CallableMemberDescriptor>) =
|
||||
noImplementation()
|
||||
|
||||
override fun getKind() = ktSymbol.origin.toCallableDescriptorKind()
|
||||
|
||||
override fun copy(
|
||||
newOwner: DeclarationDescriptor?,
|
||||
modality: Modality?,
|
||||
visibility: DescriptorVisibility?,
|
||||
kind: CallableMemberDescriptor.Kind?,
|
||||
copyOverrides: Boolean
|
||||
): CallableMemberDescriptor = noImplementation()
|
||||
|
||||
override fun newCopyBuilder(): CallableMemberDescriptor.CopyBuilder<out PropertyDescriptor> = noImplementation()
|
||||
|
||||
override fun isSetterProjectedOut(): Boolean = implementationPostponed()
|
||||
|
||||
override fun getBackingField(): FieldDescriptor = implementationPostponed()
|
||||
override fun getDelegateField(): FieldDescriptor = implementationPostponed()
|
||||
override val isDelegated: Boolean
|
||||
get() = implementationPostponed()
|
||||
}
|
||||
|
||||
|
||||
class KtSymbolBasedJavaPropertyDescriptor(
|
||||
override val ktSymbol: KtJavaFieldSymbol,
|
||||
context: Fe10WrapperContext
|
||||
) : AbstractKtSymbolBasedPropertyDescriptor(context), PropertyDescriptor {
|
||||
override fun getVisibility(): DescriptorVisibility = ktSymbol.visibility.toDescriptorVisibility()
|
||||
|
||||
override fun getCompileTimeInitializer(): ConstantValue<*>? = implementationPlanned()
|
||||
override fun isConst(): Boolean = implementationPlanned()
|
||||
|
||||
override val getter: PropertyGetterDescriptor?
|
||||
get() = null
|
||||
|
||||
override val setter: PropertySetterDescriptor?
|
||||
get() = null
|
||||
}
|
||||
|
||||
class KtSymbolBasedPropertyDescriptor(
|
||||
override val ktSymbol: KtPropertySymbol,
|
||||
context: Fe10WrapperContext
|
||||
) : AbstractKtSymbolBasedPropertyDescriptor(context), PropertyDescriptor {
|
||||
override fun getVisibility(): DescriptorVisibility = ktSymbol.visibility.toDescriptorVisibility()
|
||||
|
||||
override fun getCompileTimeInitializer(): ConstantValue<*>? {
|
||||
val constantInitializer = ktSymbol.initializer as? KaConstantInitializerValue ?: return null
|
||||
return constantInitializer.constant.toConstantValue()
|
||||
}
|
||||
|
||||
override fun isConst(): Boolean = ktSymbol.initializer != null
|
||||
|
||||
override val getter: PropertyGetterDescriptor?
|
||||
get() = ktSymbol.getter?.let { KtSymbolBasedPropertyGetterDescriptor(it, this) }
|
||||
|
||||
override val setter: PropertySetterDescriptor?
|
||||
get() = ktSymbol.setter?.let { KtSymbolBasedPropertySetterDescriptor(it, this) }
|
||||
}
|
||||
|
||||
class KtSymbolBasedLocalVariableDescriptor(
|
||||
override val ktSymbol: KaLocalVariableSymbol,
|
||||
context: Fe10WrapperContext
|
||||
) : AbstractKtSymbolBasedPropertyDescriptor(context), VariableDescriptorWithAccessors {
|
||||
|
||||
override fun getVisibility(): DescriptorVisibility = DescriptorVisibilities.LOCAL
|
||||
|
||||
override fun getCompileTimeInitializer(): ConstantValue<*>? = context.incorrectImplementation { null }
|
||||
|
||||
override fun isConst(): Boolean = false
|
||||
|
||||
override val getter: PropertyGetterDescriptor?
|
||||
get() = context.incorrectImplementation { null } // todo: add implementation for delegates
|
||||
|
||||
override val setter: PropertySetterDescriptor?
|
||||
get() = context.incorrectImplementation { null } // todo: add implementation for delegates
|
||||
}
|
||||
|
||||
abstract class KtSymbolBasedVariableAccessorDescriptor(
|
||||
val propertyDescriptor: KtSymbolBasedPropertyDescriptor
|
||||
) : KtSymbolBasedDeclarationDescriptor(propertyDescriptor.context), VariableAccessorDescriptor {
|
||||
abstract override val ktSymbol: KaPropertyAccessorSymbol
|
||||
|
||||
override fun getPackageFqNameIfTopLevel(): FqName = error("should be called")
|
||||
override fun getContainingDeclaration(): DeclarationDescriptor = propertyDescriptor
|
||||
override val correspondingVariable: VariableDescriptorWithAccessors
|
||||
get() = propertyDescriptor
|
||||
|
||||
override fun getExtensionReceiverParameter(): ReceiverParameterDescriptor? = propertyDescriptor.extensionReceiverParameter
|
||||
override fun getDispatchReceiverParameter(): ReceiverParameterDescriptor? = propertyDescriptor.dispatchReceiverParameter
|
||||
override fun getContextReceiverParameters(): List<ReceiverParameterDescriptor> = propertyDescriptor.contextReceiverParameters
|
||||
|
||||
override fun getTypeParameters(): List<TypeParameterDescriptor> = emptyList()
|
||||
|
||||
override fun getValueParameters(): List<ValueParameterDescriptor> = emptyList()
|
||||
override fun hasStableParameterNames(): Boolean = false
|
||||
override fun hasSynthesizedParameterNames(): Boolean = false
|
||||
override fun <V : Any?> getUserData(key: CallableDescriptor.UserDataKey<V>?): V? = null
|
||||
|
||||
override fun setOverriddenDescriptors(overriddenDescriptors: MutableCollection<out CallableMemberDescriptor>) =
|
||||
noImplementation()
|
||||
|
||||
override fun getKind(): CallableMemberDescriptor.Kind = propertyDescriptor.kind
|
||||
override fun getVisibility(): DescriptorVisibility = propertyDescriptor.visibility
|
||||
|
||||
override fun getInitialSignatureDescriptor(): FunctionDescriptor? =
|
||||
noImplementation()
|
||||
|
||||
override fun isHiddenToOvercomeSignatureClash(): Boolean = false
|
||||
|
||||
override fun isOperator(): Boolean = false
|
||||
|
||||
override fun isInfix(): Boolean = false
|
||||
|
||||
override fun isInline(): Boolean = ktSymbol.isInline
|
||||
|
||||
override fun isTailrec(): Boolean = false
|
||||
|
||||
override fun isHiddenForResolutionEverywhereBesideSupercalls(): Boolean =
|
||||
implementationPostponed()
|
||||
|
||||
override fun isSuspend(): Boolean = false
|
||||
|
||||
override fun newCopyBuilder(): FunctionDescriptor.CopyBuilder<out FunctionDescriptor> =
|
||||
noImplementation()
|
||||
|
||||
override fun getModality(): Modality = implementationPlanned()
|
||||
|
||||
override fun isExpect(): Boolean = implementationPostponed()
|
||||
override fun isActual(): Boolean = implementationPostponed()
|
||||
override fun isExternal(): Boolean = implementationPostponed()
|
||||
}
|
||||
|
||||
class KtSymbolBasedPropertyGetterDescriptor(
|
||||
override val ktSymbol: KaPropertyGetterSymbol,
|
||||
propertyDescriptor: KtSymbolBasedPropertyDescriptor
|
||||
) : KtSymbolBasedVariableAccessorDescriptor(propertyDescriptor), PropertyGetterDescriptor {
|
||||
override fun getReturnType(): KotlinType = propertyDescriptor.returnType
|
||||
|
||||
override fun getName(): Name = Name.special("<get-${propertyDescriptor.name}>")
|
||||
override fun isDefault(): Boolean = ktSymbol.isDefault
|
||||
|
||||
override fun getCorrespondingProperty(): PropertyDescriptor = propertyDescriptor
|
||||
|
||||
override fun copy(
|
||||
newOwner: DeclarationDescriptor?,
|
||||
modality: Modality?,
|
||||
visibility: DescriptorVisibility?,
|
||||
kind: CallableMemberDescriptor.Kind?,
|
||||
copyOverrides: Boolean
|
||||
): PropertyAccessorDescriptor = noImplementation()
|
||||
|
||||
override fun getOriginal(): PropertyGetterDescriptor = context.incorrectImplementation { this }
|
||||
override fun getOverriddenDescriptors(): Collection<PropertyGetterDescriptor> = implementationPostponed()
|
||||
}
|
||||
|
||||
class KtSymbolBasedPropertySetterDescriptor(
|
||||
override val ktSymbol: KaPropertySetterSymbol,
|
||||
propertyDescriptor: KtSymbolBasedPropertyDescriptor
|
||||
) : KtSymbolBasedVariableAccessorDescriptor(propertyDescriptor), PropertySetterDescriptor {
|
||||
override fun getReturnType(): KotlinType = propertyDescriptor.returnType
|
||||
|
||||
override fun getName(): Name = Name.special("<set-${propertyDescriptor.name}>")
|
||||
override fun isDefault(): Boolean = ktSymbol.isDefault
|
||||
|
||||
override fun getCorrespondingProperty(): PropertyDescriptor = propertyDescriptor
|
||||
|
||||
override fun copy(
|
||||
newOwner: DeclarationDescriptor?,
|
||||
modality: Modality?,
|
||||
visibility: DescriptorVisibility?,
|
||||
kind: CallableMemberDescriptor.Kind?,
|
||||
copyOverrides: Boolean
|
||||
): PropertyAccessorDescriptor = noImplementation()
|
||||
|
||||
override fun getOriginal(): PropertySetterDescriptor = context.incorrectImplementation { this }
|
||||
override fun getOverriddenDescriptors(): Collection<PropertySetterDescriptor> = implementationPostponed()
|
||||
}
|
||||
|
||||
class KtSymbolBasedPackageFragmentDescriptor(
|
||||
override val fqName: FqName,
|
||||
val context: Fe10WrapperContext
|
||||
) : PackageFragmentDescriptor {
|
||||
|
||||
override fun getName(): Name = fqName.shortName()
|
||||
|
||||
override fun getOriginal(): DeclarationDescriptorWithSource = this
|
||||
|
||||
override fun getSource(): SourceElement = SourceElement.NO_SOURCE
|
||||
|
||||
override val annotations: Annotations
|
||||
get() = Annotations.EMPTY
|
||||
|
||||
override fun getContainingDeclaration(): ModuleDescriptor = context.moduleDescriptor
|
||||
|
||||
override fun getMemberScope(): MemberScope = context.noImplementation()
|
||||
|
||||
override fun <R : Any?, D : Any?> accept(visitor: DeclarationDescriptorVisitor<R, D>?, data: D): R =
|
||||
context.noImplementation("IDE shouldn't use visitor on descriptors")
|
||||
|
||||
override fun acceptVoid(visitor: DeclarationDescriptorVisitor<Void, Void>?) =
|
||||
context.noImplementation("IDE shouldn't use visitor on descriptors")
|
||||
}
|
||||
|
||||
class KtSymbolBasedTypeAliasDescriptor(
|
||||
override val ktSymbol: KaTypeAliasSymbol,
|
||||
context: Fe10WrapperContext
|
||||
) : KtSymbolBasedDeclarationDescriptor(context), KtSymbolBasedNamed, TypeAliasDescriptor {
|
||||
override val classDescriptor: ClassDescriptor?
|
||||
get() = context.implementationPostponed()
|
||||
|
||||
override val constructors: Collection<TypeAliasConstructorDescriptor>
|
||||
get() = context.implementationPostponed()
|
||||
|
||||
override val expandedType: SimpleType
|
||||
get() = ktSymbol.expandedType.toKotlinType(context, annotations) as SimpleType
|
||||
|
||||
override val underlyingType: SimpleType
|
||||
get() = context.implementationPostponed()
|
||||
|
||||
override fun getDeclaredTypeParameters(): List<TypeParameterDescriptor> = context.implementationPostponed()
|
||||
|
||||
override fun getDefaultType(): SimpleType = expandedType
|
||||
|
||||
override fun getModality(): Modality = Modality.FINAL
|
||||
|
||||
override fun getPackageFqNameIfTopLevel(): FqName = (ktSymbol.classId ?: error("should be top-level")).packageFqName
|
||||
|
||||
override fun getOriginal(): TypeAliasDescriptor = this
|
||||
|
||||
override fun getTypeConstructor(): TypeConstructor = context.implementationPostponed()
|
||||
|
||||
override fun getVisibility(): DescriptorVisibility = ktSymbol.visibility.toDescriptorVisibility()
|
||||
override fun isInner(): Boolean = false
|
||||
|
||||
override fun isActual(): Boolean = context.implementationPostponed()
|
||||
override fun isExpect(): Boolean = context.implementationPostponed()
|
||||
override fun isExternal(): Boolean = context.implementationPostponed()
|
||||
}
|
||||
@@ -1,99 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
package org.jetbrains.kotlin.idea.fir.fe10
|
||||
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KaTypeParameterSymbol
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.checker.SimpleClassicTypeSystemContext.getVariance
|
||||
import org.jetbrains.kotlin.types.model.TypeVariance
|
||||
import org.jetbrains.kotlin.types.typeUtil.makeNullable
|
||||
|
||||
class Fe10BindingSimpleTypeSubstitutor private constructor(
|
||||
private val map: Map<KaTypeParameterSymbol, TypeProjection>
|
||||
) {
|
||||
private fun substitute(kotlinType: KotlinType): KotlinType? {
|
||||
when (val unwrappedType = kotlinType.unwrap()) {
|
||||
is SimpleType -> return substitute(unwrappedType)
|
||||
is FlexibleType -> {
|
||||
val lower = substitute(unwrappedType.lowerBound)?.lowerIfFlexible()
|
||||
val upper = substitute(unwrappedType.upperBound)?.upperIfFlexible()
|
||||
if (lower == null && upper == null) return null
|
||||
|
||||
|
||||
return KotlinTypeFactory.flexibleType(
|
||||
lower ?: unwrappedType.lowerBound,
|
||||
upper ?: unwrappedType.upperBound
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun substitute(simpleType: SimpleType): UnwrappedType? {
|
||||
val replacement = simpleType.constructor.replacement()
|
||||
if (replacement != null) {
|
||||
assert(replacement.getVariance() == TypeVariance.INV)
|
||||
if (simpleType.isMarkedNullable) {
|
||||
return replacement.type.makeNullable().unwrap()
|
||||
} else {
|
||||
return replacement.type.unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
var hasNotNull = false
|
||||
|
||||
val substitutedArguments = simpleType.arguments.map {
|
||||
val newArguments = substituteArgument(it)
|
||||
if (newArguments != null) hasNotNull = true
|
||||
newArguments ?: it
|
||||
}
|
||||
if (!hasNotNull) return null
|
||||
|
||||
return KotlinTypeFactory.simpleTypeWithNonTrivialMemberScope(
|
||||
simpleType.attributes, simpleType.constructor, substitutedArguments, simpleType.isMarkedNullable,
|
||||
simpleType.memberScope
|
||||
)
|
||||
}
|
||||
|
||||
private fun substituteArgument(argument: TypeProjection): TypeProjection? {
|
||||
if (argument.isStarProjection) return null
|
||||
|
||||
val type = argument.type.unwrap()
|
||||
val replacement = type.constructor.replacement()
|
||||
if (replacement != null && replacement.getVariance() != TypeVariance.INV) {
|
||||
if (replacement.isStarProjection) return replacement
|
||||
|
||||
when (type) {
|
||||
is SimpleType -> {
|
||||
if (type.isMarkedNullable) {
|
||||
return TypeProjectionImpl(replacement.projectionKind, replacement.type.makeNullable())
|
||||
} else {
|
||||
return replacement
|
||||
}
|
||||
}
|
||||
// T..T?
|
||||
is FlexibleType -> {
|
||||
val newType = FlexibleTypeImpl(replacement.type.lowerIfFlexible(), replacement.type.makeNullable().upperIfFlexible())
|
||||
return TypeProjectionImpl(replacement.projectionKind, newType)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
val newType = substitute(type) ?: return null
|
||||
return TypeProjectionImpl(argument.projectionKind, newType)
|
||||
}
|
||||
|
||||
private fun TypeConstructor.replacement(): TypeProjection? {
|
||||
if (this !is KtSymbolBasedTypeParameterTypeConstructor) return null
|
||||
return map[this.ktSBDescriptor.ktSymbol]
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun substitute(map: Map<KaTypeParameterSymbol, TypeProjection>, type: UnwrappedType) : UnwrappedType {
|
||||
if (map.isEmpty()) return type
|
||||
return Fe10BindingSimpleTypeSubstitutor(map).substitute(type)?.unwrap() ?: type
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,231 +0,0 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
|
||||
package org.jetbrains.kotlin.idea.fir.fe10
|
||||
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.util.ModificationTracker
|
||||
import org.jetbrains.kotlin.analysis.api.KaSession
|
||||
import org.jetbrains.kotlin.analysis.api.analyze
|
||||
import org.jetbrains.kotlin.analysis.api.lifetime.KtLifetimeToken
|
||||
import org.jetbrains.kotlin.analysis.api.lifetime.KtLifetimeTokenFactory
|
||||
import org.jetbrains.kotlin.analysis.api.permissions.KaAllowAnalysisFromWriteAction
|
||||
import org.jetbrains.kotlin.analysis.api.permissions.KaAllowAnalysisOnEdt
|
||||
import org.jetbrains.kotlin.analysis.api.permissions.allowAnalysisFromWriteAction
|
||||
import org.jetbrains.kotlin.analysis.api.permissions.allowAnalysisOnEdt
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.*
|
||||
import org.jetbrains.kotlin.analysis.project.structure.KtModule
|
||||
import org.jetbrains.kotlin.analysis.project.structure.KtSourceModule
|
||||
import org.jetbrains.kotlin.analysis.project.structure.ProjectStructureProvider
|
||||
import org.jetbrains.kotlin.builtins.DefaultBuiltIns
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.idea.base.projectStructure.moduleInfo
|
||||
import org.jetbrains.kotlin.idea.base.util.Frontend10ApiUsage
|
||||
import org.jetbrains.kotlin.idea.fir.fe10.binding.KtSymbolBasedBindingContext
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.platform.TargetPlatform
|
||||
import org.jetbrains.kotlin.psi.KtElement
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
|
||||
interface Fe10WrapperContext {
|
||||
val builtIns: KotlinBuiltIns
|
||||
val moduleDescriptor: ModuleDescriptor
|
||||
val languageVersionSettings: LanguageVersionSettings
|
||||
val bindingContext: BindingContext
|
||||
|
||||
// This property used to disable some logic used locally for debug purposes
|
||||
val enableLogging: Boolean get() = false
|
||||
|
||||
fun <R> withAnalysisSession(f: KaSession.() -> R): R
|
||||
|
||||
/**
|
||||
* Legend:
|
||||
* - where was decided, that KtSymbolBased descriptor is not support method, noImplementation() method is called.
|
||||
* - where the implementation planned, but not yet here: implementationPlanned()
|
||||
* - if there is no simple implementation and it isn't clear if it really needed -- implementationPostponed()
|
||||
* - if there were no investigation -- autogenerated TODO("not implemented") called
|
||||
* - if we could implement it right now, but not entirely correct -- wrap it into incorrect implementation
|
||||
* - if some error situation should be handled later -- use errorHandling
|
||||
*/
|
||||
fun noImplementation(additionalInfo: String = ""): Nothing
|
||||
fun implementationPostponed(additionalInfo: String = ""): Nothing
|
||||
fun implementationPlanned(additionalInfo: String = ""): Nothing
|
||||
fun errorHandling(additionalInfo: String = ""): Nothing
|
||||
|
||||
fun <R> incorrectImplementation(block: () -> R) = block()
|
||||
}
|
||||
|
||||
fun KtSymbol.toDeclarationDescriptor(context: Fe10WrapperContext): DeclarationDescriptor =
|
||||
when (this) {
|
||||
is KaNamedClassOrObjectSymbol -> toDeclarationDescriptor(context)
|
||||
is KaFunctionLikeSymbol -> toDeclarationDescriptor(context)
|
||||
is KtVariableLikeSymbol -> toDeclarationDescriptor(context)
|
||||
is KaReceiverParameterSymbol -> toDeclarationDescriptor(context)
|
||||
is KaTypeAliasSymbol -> toDeclarationDescriptor(context)
|
||||
else -> context.implementationPlanned(this::class.qualifiedName ?: "")
|
||||
}
|
||||
|
||||
fun KaReceiverParameterSymbol.toDeclarationDescriptor(context: Fe10WrapperContext): DeclarationDescriptor =
|
||||
when (val owner = owningCallableSymbol.toDeclarationDescriptor(context)) {
|
||||
is CallableDescriptor -> owner.extensionReceiverParameter ?: context.errorHandling("no receiver for $owner but expected")
|
||||
else -> context.errorHandling("Unexpected type of owner: $owner")
|
||||
}
|
||||
|
||||
fun KaClassOrObjectSymbol.toDeclarationDescriptor(context: Fe10WrapperContext): ClassDescriptor =
|
||||
when (this) {
|
||||
is KaNamedClassOrObjectSymbol -> KtSymbolBasedClassDescriptor(this, context)
|
||||
is KaAnonymousObjectSymbol -> context.implementationPlanned("KaAnonymousObjectSymbol")
|
||||
}
|
||||
|
||||
fun KaFunctionLikeSymbol.toDeclarationDescriptor(context: Fe10WrapperContext): KtSymbolBasedFunctionLikeDescriptor =
|
||||
when (this) {
|
||||
is KaFunctionSymbol -> KtSymbolBasedFunctionDescriptor(this, context)
|
||||
is KaAnonymousFunctionSymbol -> KtSymbolBasedAnonymousFunctionDescriptor(this, context)
|
||||
is KaConstructorSymbol -> {
|
||||
val ktConstructorSymbol = this
|
||||
val ktClassOrObject = context.withAnalysisSession { ktConstructorSymbol.getContainingSymbol() as KaNamedClassOrObjectSymbol }
|
||||
KtSymbolBasedConstructorDescriptor(ktConstructorSymbol, KtSymbolBasedClassDescriptor(ktClassOrObject, context))
|
||||
}
|
||||
else -> error("Unexpected kind of KaFunctionLikeSymbol: ${this.javaClass}")
|
||||
}
|
||||
|
||||
fun KaValueParameterSymbol.toDeclarationDescriptor(context: Fe10WrapperContext): KtSymbolBasedValueParameterDescriptor {
|
||||
val containingSymbol = context.withAnalysisSession { this@toDeclarationDescriptor.getContainingSymbol() }
|
||||
check(containingSymbol is KaFunctionLikeSymbol) {
|
||||
"Unexpected containing symbol = $containingSymbol"
|
||||
}
|
||||
return KtSymbolBasedValueParameterDescriptor(this, context, containingSymbol.toDeclarationDescriptor(context))
|
||||
}
|
||||
|
||||
|
||||
fun KtVariableLikeSymbol.toDeclarationDescriptor(context: Fe10WrapperContext): VariableDescriptor =
|
||||
when (this) {
|
||||
is KaValueParameterSymbol -> toDeclarationDescriptor(context)
|
||||
is KtPropertySymbol -> KtSymbolBasedPropertyDescriptor(this, context)
|
||||
is KtJavaFieldSymbol -> KtSymbolBasedJavaPropertyDescriptor(this, context)
|
||||
is KaLocalVariableSymbol -> KtSymbolBasedLocalVariableDescriptor(this, context)
|
||||
else -> context.implementationPlanned(this::class.toString())
|
||||
}
|
||||
|
||||
fun KaTypeAliasSymbol.toDeclarationDescriptor(context: Fe10WrapperContext) = KtSymbolBasedTypeAliasDescriptor(this, context)
|
||||
|
||||
class Fe10WrapperContextImpl(
|
||||
project: Project,
|
||||
private val ktElement: KtElement
|
||||
) : Fe10WrapperContext {
|
||||
private val module: KtModule = ProjectStructureProvider.getModule(project, ktElement, null)
|
||||
|
||||
@OptIn(KaAllowAnalysisOnEdt::class, KaAllowAnalysisFromWriteAction::class)
|
||||
override fun <R> withAnalysisSession(f: KaSession.() -> R): R {
|
||||
return allowAnalysisOnEdt {
|
||||
allowAnalysisFromWriteAction {
|
||||
analyze(ktElement, f)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override val moduleDescriptor: ModuleDescriptor = withAnalysisSession {
|
||||
KtSymbolBasedModuleDescriptorImpl(this@Fe10WrapperContextImpl, module, token)
|
||||
}
|
||||
|
||||
override val builtIns: KotlinBuiltIns
|
||||
get() = incorrectImplementation { DefaultBuiltIns.Instance }
|
||||
|
||||
override val languageVersionSettings: LanguageVersionSettings
|
||||
get() = withAnalysisSession { (useSiteModule as KtSourceModule).languageVersionSettings }
|
||||
|
||||
override val bindingContext: BindingContext = KtSymbolBasedBindingContext(this)
|
||||
|
||||
override fun noImplementation(additionalInfo: String): Nothing =
|
||||
error("This method should not be called for wrappers. $additionalInfo")
|
||||
|
||||
override fun implementationPostponed(additionalInfo: String): Nothing =
|
||||
TODO("InvestigateLater and implement if needed. $additionalInfo")
|
||||
|
||||
override fun implementationPlanned(additionalInfo: String): Nothing =
|
||||
TODO("SE_to_implement. $additionalInfo")
|
||||
|
||||
override fun errorHandling(additionalInfo: String): Nothing =
|
||||
TODO("Some incorrect situation/parser error/resolution error. $additionalInfo")
|
||||
|
||||
}
|
||||
|
||||
@Suppress("unused")
|
||||
internal class KtLifetimeTokenForKtSymbolBasedWrappers(
|
||||
private val project: Project,
|
||||
) : KtLifetimeToken() {
|
||||
|
||||
/**
|
||||
* This is quite strange code, isn't it?
|
||||
* Well... Unfortunately in old FE we don't do any checks regarding of the validity of the descriptors.
|
||||
* Moreover, it was a common practice to ask BindingContext for something and do modification of the PSI at the same time.
|
||||
* Yes, that is not great at all, and it is unclear what will happen in that case.
|
||||
* See [org.jetbrains.kotlin.idea.intentions.ConvertSecondaryConstructorToPrimaryIntention.applyTo] as an example.
|
||||
*
|
||||
* One potential solution will be -- disable Fe10Wrapper for the Intentions/inspections that do this
|
||||
*/
|
||||
override fun isValid(): Boolean = true
|
||||
override fun getInvalidationReason(): String = error("Getting invalidation reason for valid validity token")
|
||||
|
||||
override fun isAccessible(): Boolean = true
|
||||
override fun getInaccessibilityReason(): String = error("Getting inaccessibility reason for validity token when it is accessible")
|
||||
|
||||
override val factory = KtLifetimeTokenForKtSymbolBasedWrappersFactory(this)
|
||||
}
|
||||
|
||||
|
||||
internal class KtLifetimeTokenForKtSymbolBasedWrappersFactory(
|
||||
private val token: KtLifetimeTokenForKtSymbolBasedWrappers
|
||||
) : KtLifetimeTokenFactory() {
|
||||
override val identifier = KtLifetimeTokenForKtSymbolBasedWrappers::class
|
||||
|
||||
override fun create(project: Project, modificationTracker: ModificationTracker): KtLifetimeTokenForKtSymbolBasedWrappers = token
|
||||
}
|
||||
|
||||
private class KtSymbolBasedModuleDescriptorImpl(
|
||||
val context: Fe10WrapperContext,
|
||||
val module: KtModule,
|
||||
val token: KtLifetimeToken
|
||||
) : ModuleDescriptor {
|
||||
override val builtIns: KotlinBuiltIns
|
||||
get() = context.builtIns
|
||||
|
||||
override val stableName: Name
|
||||
get() = context.noImplementation()
|
||||
override val platform: TargetPlatform
|
||||
get() = module.platform
|
||||
|
||||
override fun shouldSeeInternalsOf(targetModule: ModuleDescriptor): Boolean = context.noImplementation()
|
||||
override fun getPackage(fqName: FqName): PackageViewDescriptor = context.noImplementation()
|
||||
override fun getSubPackagesOf(fqName: FqName, nameFilter: (Name) -> Boolean): Collection<FqName> = context.noImplementation()
|
||||
|
||||
override val allDependencyModules: List<ModuleDescriptor>
|
||||
get() = context.implementationPostponed()
|
||||
override val expectedByModules: List<ModuleDescriptor>
|
||||
get() = context.implementationPostponed()
|
||||
override val allExpectedByModules: Set<ModuleDescriptor>
|
||||
get() = context.implementationPostponed()
|
||||
|
||||
override fun <T> getCapability(capability: ModuleCapability<T>): T? = null
|
||||
|
||||
override val isValid: Boolean
|
||||
get() = token.isValid()
|
||||
|
||||
override fun assertValid() {
|
||||
assert(token.isValid())
|
||||
}
|
||||
|
||||
@OptIn(Frontend10ApiUsage::class)
|
||||
override fun getName(): Name = module.moduleInfo.name
|
||||
|
||||
override fun getOriginal(): DeclarationDescriptor = this
|
||||
|
||||
override fun acceptVoid(visitor: DeclarationDescriptorVisitor<Void, Void>?) = context.noImplementation()
|
||||
|
||||
override val annotations: Annotations
|
||||
get() = context.incorrectImplementation { Annotations.EMPTY }
|
||||
|
||||
}
|
||||
@@ -1,171 +0,0 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
|
||||
package org.jetbrains.kotlin.idea.fir.fe10
|
||||
|
||||
import org.jetbrains.kotlin.analysis.api.KaAnalysisNonPublicApi
|
||||
import org.jetbrains.kotlin.analysis.api.KtStarTypeProjection
|
||||
import org.jetbrains.kotlin.analysis.api.KtTypeArgumentWithVariance
|
||||
import org.jetbrains.kotlin.analysis.api.KtTypeProjection
|
||||
import org.jetbrains.kotlin.analysis.api.annotations.annotations
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KaAnonymousObjectSymbol
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KaNamedClassOrObjectSymbol
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KaTypeAliasSymbol
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KaTypeParameterSymbol
|
||||
import org.jetbrains.kotlin.analysis.api.types.*
|
||||
import org.jetbrains.kotlin.builtins.DefaultBuiltIns
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.incremental.components.LookupLocation
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
||||
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.checker.KotlinTypeRefiner
|
||||
import org.jetbrains.kotlin.types.error.ErrorTypeKind
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||
import org.jetbrains.kotlin.utils.Printer
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
|
||||
|
||||
abstract class KtSymbolBasedAbstractTypeConstructor<T> internal constructor(
|
||||
val ktSBDescriptor: T
|
||||
) : ClassifierBasedTypeConstructor() where T : KtSymbolBasedDeclarationDescriptor, T : ClassifierDescriptor {
|
||||
override fun getDeclarationDescriptor(): ClassifierDescriptor = ktSBDescriptor
|
||||
|
||||
// TODO: captured types
|
||||
override fun isDenotable(): Boolean = true
|
||||
|
||||
// for Intention|inspection it shouldn't be important what to use.
|
||||
override fun getBuiltIns(): KotlinBuiltIns = DefaultBuiltIns.Instance
|
||||
|
||||
// I don't think that we need to implement this method
|
||||
override fun isFinal(): Boolean = ktSBDescriptor.context.implementationPostponed("ktSBDescriptor = $ktSBDescriptor")
|
||||
|
||||
@TypeRefinement
|
||||
override fun refine(kotlinTypeRefiner: KotlinTypeRefiner): TypeConstructor =
|
||||
ktSBDescriptor.context.noImplementation("ktSBDescriptor = $ktSBDescriptor")
|
||||
}
|
||||
|
||||
class KtSymbolBasedClassTypeConstructor(ktSBDescriptor: KtSymbolBasedClassDescriptor) :
|
||||
KtSymbolBasedAbstractTypeConstructor<KtSymbolBasedClassDescriptor>(ktSBDescriptor) {
|
||||
override fun getParameters(): List<TypeParameterDescriptor> =
|
||||
ktSBDescriptor.ktSymbol.typeParameters.map { KtSymbolBasedTypeParameterDescriptor(it, ktSBDescriptor.context) }
|
||||
|
||||
override fun getSupertypes(): Collection<KotlinType> =
|
||||
ktSBDescriptor.ktSymbol.superTypes.map { it.toKotlinType(ktSBDescriptor.context) }
|
||||
|
||||
override fun isSameClassifier(classifier: ClassifierDescriptor): Boolean {
|
||||
return classifier is ClassDescriptor && areFqNamesEqual(declarationDescriptor, classifier)
|
||||
}
|
||||
|
||||
override fun toString() = DescriptorUtils.getFqName(ktSBDescriptor).asString()
|
||||
}
|
||||
|
||||
class KtSymbolBasedTypeParameterTypeConstructor(ktSBDescriptor: KtSymbolBasedTypeParameterDescriptor) :
|
||||
KtSymbolBasedAbstractTypeConstructor<KtSymbolBasedTypeParameterDescriptor>(ktSBDescriptor) {
|
||||
override fun getParameters(): List<TypeParameterDescriptor> = emptyList()
|
||||
|
||||
override fun getSupertypes(): Collection<KotlinType> =
|
||||
ktSBDescriptor.ktSymbol.upperBounds.map { it.toKotlinType(ktSBDescriptor.context) }
|
||||
|
||||
// TODO overrides: see AbstractTypeParameterDescriptor.TypeParameterTypeConstructor.isSameClassifier
|
||||
override fun isSameClassifier(classifier: ClassifierDescriptor): Boolean = ktSBDescriptor == classifier
|
||||
|
||||
override fun toString(): String = ktSBDescriptor.name.asString()
|
||||
}
|
||||
|
||||
// This class is not suppose to be used as "is instance of" because scopes could be wrapped into other scopes
|
||||
// so generally it isn't a good idea
|
||||
internal class MemberScopeForKtSymbolBasedDescriptors(lazyDebugInfo: () -> String) : MemberScope {
|
||||
private val additionalInfo by lazy(lazyDebugInfo)
|
||||
|
||||
private fun noImplementation(): Nothing =
|
||||
error("Scope for descriptors based on KtSymbols should not be used, additional info: $additionalInfo")
|
||||
|
||||
override fun getContributedVariables(name: Name, location: LookupLocation): Collection<PropertyDescriptor> = noImplementation()
|
||||
override fun getContributedFunctions(name: Name, location: LookupLocation): Collection<SimpleFunctionDescriptor> = noImplementation()
|
||||
override fun getFunctionNames(): Set<Name> = noImplementation()
|
||||
override fun getVariableNames(): Set<Name> = noImplementation()
|
||||
override fun getClassifierNames(): Set<Name> = noImplementation()
|
||||
override fun printScopeStructure(p: Printer): Unit = noImplementation()
|
||||
override fun getContributedClassifier(name: Name, location: LookupLocation): ClassifierDescriptor = noImplementation()
|
||||
|
||||
override fun getContributedDescriptors(
|
||||
kindFilter: DescriptorKindFilter,
|
||||
nameFilter: (Name) -> Boolean
|
||||
): Collection<DeclarationDescriptor> = noImplementation()
|
||||
}
|
||||
|
||||
fun KtType.getDescriptorsAnnotations(context: Fe10WrapperContext): Annotations =
|
||||
Annotations.create(annotations.map { KtSymbolBasedAnnotationDescriptor(it, context) })
|
||||
|
||||
fun KtTypeProjection.toTypeProjection(context: Fe10WrapperContext): TypeProjection =
|
||||
when (this) {
|
||||
is KtStarTypeProjection -> StarProjectionForAbsentTypeParameter(context.builtIns)
|
||||
is KtTypeArgumentWithVariance -> TypeProjectionImpl(variance, type.toKotlinType(context))
|
||||
}
|
||||
|
||||
@OptIn(KaAnalysisNonPublicApi::class)
|
||||
fun KtType.toKotlinType(context: Fe10WrapperContext, annotations: Annotations = getDescriptorsAnnotations(context)): UnwrappedType {
|
||||
val typeConstructor: TypeConstructor = when (this) {
|
||||
is KtTypeParameterType -> KtSymbolBasedTypeParameterDescriptor(this.symbol, context).typeConstructor
|
||||
is KtNonErrorClassType -> when (val classLikeSymbol = symbol) {
|
||||
is KaTypeAliasSymbol -> return classLikeSymbol.toExpandedKotlinType(context, ownTypeArguments, annotations)
|
||||
is KaNamedClassOrObjectSymbol -> KtSymbolBasedClassDescriptor(classLikeSymbol, context).typeConstructor
|
||||
is KaAnonymousObjectSymbol -> context.implementationPostponed()
|
||||
}
|
||||
is KtErrorType -> ErrorUtils.createErrorTypeConstructor(ErrorTypeKind.TYPE_FOR_ERROR_TYPE_CONSTRUCTOR, errorMessage)
|
||||
is KtFlexibleType -> {
|
||||
return KotlinTypeFactory.flexibleType(
|
||||
lowerBound.toKotlinType(context, annotations) as SimpleType,
|
||||
upperBound.toKotlinType(context, annotations) as SimpleType
|
||||
)
|
||||
}
|
||||
|
||||
is KtIntersectionType -> {
|
||||
// most likely it isn't correct and intersectTypes(List<UnwrappedType>) should be used,
|
||||
// but I don't think that we will have the real problem with that implementation
|
||||
return IntersectionTypeConstructor(conjuncts.map { it.toKotlinType(context) }).createType()
|
||||
}
|
||||
is KtDefinitelyNotNullType -> {
|
||||
val kotlinType = original.toKotlinType(context, annotations)
|
||||
return DefinitelyNotNullType.makeDefinitelyNotNull(kotlinType) ?: kotlinType
|
||||
}
|
||||
is KtDynamicType -> {
|
||||
return createDynamicType(context.builtIns)
|
||||
}
|
||||
else -> error("Unexpected subclass: ${this.javaClass}")
|
||||
}
|
||||
|
||||
val ktTypeArguments = this.safeAs<KtNonErrorClassType>()?.ownTypeArguments ?: emptyList()
|
||||
|
||||
val markedAsNullable = this.nullability == KtTypeNullability.NULLABLE
|
||||
|
||||
return KotlinTypeFactory.simpleTypeWithNonTrivialMemberScope(
|
||||
annotations.toDefaultAttributes(), typeConstructor, ktTypeArguments.map { it.toTypeProjection(context) }, markedAsNullable,
|
||||
MemberScopeForKtSymbolBasedDescriptors { this.toString() }
|
||||
)
|
||||
}
|
||||
|
||||
fun KaTypeAliasSymbol.toExpandedKotlinType(
|
||||
context: Fe10WrapperContext,
|
||||
arguments: List<KtTypeProjection>,
|
||||
annotations: Annotations
|
||||
): UnwrappedType {
|
||||
check(arguments.size == typeParameters.size) {
|
||||
"${arguments.size} != ${typeParameters.size}"
|
||||
}
|
||||
|
||||
val expandedUnsubstitutedType = expandedType.toKotlinType(context, annotations)
|
||||
if (typeParameters.isEmpty()) return expandedUnsubstitutedType
|
||||
|
||||
// KtSubstitutor isn't able to substitute TypeProjections KT-53095
|
||||
val map = mutableMapOf<KaTypeParameterSymbol, TypeProjection>()
|
||||
|
||||
typeParameters.forEachIndexed { index, ktTypeParameterSymbol ->
|
||||
map[ktTypeParameterSymbol] = arguments[index].toTypeProjection(context)
|
||||
}
|
||||
|
||||
return Fe10BindingSimpleTypeSubstitutor.substitute(map, expandedUnsubstitutedType)
|
||||
}
|
||||
@@ -1,116 +0,0 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
|
||||
package org.jetbrains.kotlin.idea.fir.fe10
|
||||
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.PsiFile
|
||||
import org.jetbrains.kotlin.analyzer.AnalysisResult
|
||||
import org.jetbrains.kotlin.analyzer.ModuleInfo
|
||||
import org.jetbrains.kotlin.analyzer.ResolverForProject
|
||||
import org.jetbrains.kotlin.caches.resolve.KotlinCacheService
|
||||
import org.jetbrains.kotlin.caches.resolve.PlatformAnalysisSettings
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||
import org.jetbrains.kotlin.diagnostics.DiagnosticSink
|
||||
import org.jetbrains.kotlin.idea.FrontendInternals
|
||||
import org.jetbrains.kotlin.idea.base.projectStructure.moduleInfo.IdeaModuleInfo
|
||||
import org.jetbrains.kotlin.idea.resolve.ResolutionFacade
|
||||
import org.jetbrains.kotlin.platform.TargetPlatform
|
||||
import org.jetbrains.kotlin.psi.KtDeclaration
|
||||
import org.jetbrains.kotlin.psi.KtElement
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.diagnostics.BindingContextSuppressCache
|
||||
import org.jetbrains.kotlin.resolve.diagnostics.KotlinSuppressCache
|
||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
|
||||
|
||||
|
||||
class KtSymbolBasedResolutionFacade(
|
||||
override val project: Project,
|
||||
val context: Fe10WrapperContext
|
||||
) : ResolutionFacade {
|
||||
override fun analyze(element: KtElement, bodyResolveMode: BodyResolveMode): BindingContext = context.bindingContext
|
||||
|
||||
override fun analyze(elements: Collection<KtElement>, bodyResolveMode: BodyResolveMode): BindingContext =
|
||||
context.bindingContext
|
||||
|
||||
override fun analyzeWithAllCompilerChecks(elements: Collection<KtElement>, callback: DiagnosticSink.DiagnosticsCallback?): AnalysisResult {
|
||||
return AnalysisResult.success(context.bindingContext, context.moduleDescriptor)
|
||||
}
|
||||
|
||||
override fun resolveToDescriptor(declaration: KtDeclaration, bodyResolveMode: BodyResolveMode): DeclarationDescriptor {
|
||||
val ktSymbol = context.withAnalysisSession {
|
||||
declaration.getSymbol()
|
||||
}
|
||||
return ktSymbol.toDeclarationDescriptor(context)
|
||||
}
|
||||
|
||||
override val moduleDescriptor: ModuleDescriptor
|
||||
get() = context.moduleDescriptor
|
||||
|
||||
@FrontendInternals
|
||||
override fun <T : Any> getFrontendService(serviceClass: Class<T>): T {
|
||||
if (serviceClass == LanguageVersionSettings::class.java) {
|
||||
return context.languageVersionSettings as T
|
||||
}
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
@FrontendInternals
|
||||
override fun <T : Any> getFrontendService(element: PsiElement, serviceClass: Class<T>): T {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
@FrontendInternals
|
||||
override fun <T : Any> getFrontendService(moduleDescriptor: ModuleDescriptor, serviceClass: Class<T>): T {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
override fun <T : Any> getIdeService(serviceClass: Class<T>): T {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
@FrontendInternals
|
||||
override fun <T : Any> tryGetFrontendService(element: PsiElement, serviceClass: Class<T>): T? {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
override fun getResolverForProject(): ResolverForProject<out ModuleInfo> {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class KtSymbolBasedKotlinCacheServiceImpl(private val project: Project) : KotlinCacheService {
|
||||
override fun getResolutionFacadeWithForcedPlatform(elements: List<KtElement>, platform: TargetPlatform): ResolutionFacade {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
override fun getResolutionFacade(element: KtElement): ResolutionFacade {
|
||||
return getResolutionFacade(listOf(element))
|
||||
}
|
||||
|
||||
override fun getResolutionFacade(elements: List<KtElement>): ResolutionFacade =
|
||||
KtSymbolBasedResolutionFacade(project, Fe10WrapperContextImpl(project, elements.first().containingKtFile))
|
||||
|
||||
override fun getResolutionFacadeByFile(file: PsiFile, platform: TargetPlatform): ResolutionFacade? =
|
||||
file.safeAs<KtFile>()?.let { KtSymbolBasedResolutionFacade(project, Fe10WrapperContextImpl(project, it)) }
|
||||
|
||||
override fun getSuppressionCache(): KotlinSuppressCache {
|
||||
return BindingContextSuppressCache(BindingContext.EMPTY)
|
||||
}
|
||||
|
||||
override fun getResolutionFacadeByModuleInfo(moduleInfo: ModuleInfo, platform: TargetPlatform): ResolutionFacade =
|
||||
TODO("Not yet implemented")
|
||||
|
||||
override fun getResolutionFacadeByModuleInfo(moduleInfo: IdeaModuleInfo, platform: TargetPlatform): ResolutionFacade {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
override fun getResolutionFacadeByModuleInfo(moduleInfo: ModuleInfo, settings: PlatformAnalysisSettings): ResolutionFacade? {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
}
|
||||
@@ -1,163 +0,0 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
|
||||
package org.jetbrains.kotlin.idea.fir.fe10.binding
|
||||
|
||||
import com.intellij.lang.ASTNode
|
||||
import org.jetbrains.kotlin.analysis.api.resolution.*
|
||||
import org.jetbrains.kotlin.analysis.api.diagnostics.KtDiagnostic
|
||||
import org.jetbrains.kotlin.descriptors.ConstructorDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.idea.fir.fe10.Fe10WrapperContext
|
||||
import org.jetbrains.kotlin.idea.fir.fe10.KtSymbolBasedConstructorDescriptor
|
||||
import org.jetbrains.kotlin.idea.fir.fe10.toDeclarationDescriptor
|
||||
import org.jetbrains.kotlin.idea.fir.fe10.toKotlinType
|
||||
import org.jetbrains.kotlin.idea.references.mainReference
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.calls.util.CallMaker
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.Receiver
|
||||
import org.jetbrains.kotlin.types.expressions.ControlStructureTypingUtils
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
|
||||
|
||||
|
||||
class CallAndResolverCallWrappers(bindingContext: KtSymbolBasedBindingContext) {
|
||||
private val context = bindingContext.context
|
||||
|
||||
init {
|
||||
bindingContext.registerGetterByKey(BindingContext.CALL, this::getCall)
|
||||
bindingContext.registerGetterByKey(BindingContext.RESOLVED_CALL, this::getResolvedCall)
|
||||
bindingContext.registerGetterByKey(BindingContext.CONSTRUCTOR_RESOLVED_DELEGATION_CALL, this::getConstructorResolvedDelegationCall)
|
||||
bindingContext.registerGetterByKey(BindingContext.REFERENCE_TARGET, this::getReferenceTarget)
|
||||
}
|
||||
|
||||
private fun getCall(element: KtElement): Call? {
|
||||
val call = createCall(element) ?: return null
|
||||
|
||||
/**
|
||||
* In FE10 [org.jetbrains.kotlin.resolve.calls.tasks.TracingStrategyImpl.bindCall] happening to the calleeExpression
|
||||
*/
|
||||
check(call.calleeExpression == element) {
|
||||
"${call.calleeExpression} != $element"
|
||||
}
|
||||
return call
|
||||
}
|
||||
|
||||
private fun createCall(element: KtElement): Call? {
|
||||
val parent = element.parent
|
||||
if (parent is KtCallElement) {
|
||||
val callParent = parent.parent
|
||||
val callOperationNode: ASTNode?
|
||||
val receiver: Receiver?
|
||||
if (callParent is KtQualifiedExpression) {
|
||||
callOperationNode = callParent.operationTokenNode
|
||||
receiver = callParent.receiverExpression.toExpressionReceiverValue(context)
|
||||
} else {
|
||||
callOperationNode = null
|
||||
receiver = null
|
||||
}
|
||||
|
||||
return CallMaker.makeCall(receiver, callOperationNode, parent)
|
||||
}
|
||||
|
||||
if (element is KtSimpleNameExpression && element !is KtOperationReferenceExpression) {
|
||||
if (parent is KtQualifiedExpression) {
|
||||
val receiver = parent.receiverExpression.toExpressionReceiverValue(context)
|
||||
return CallMaker.makePropertyCall(receiver, parent.operationTokenNode, element)
|
||||
}
|
||||
|
||||
return CallMaker.makePropertyCall(null, null, element)
|
||||
}
|
||||
|
||||
if (element is KtArrayAccessExpression) {
|
||||
val receiver = element.arrayExpression?.toExpressionReceiverValue(context) ?: return null
|
||||
return CallMaker.makeArrayGetCall(receiver, element, Call.CallType.ARRAY_GET_METHOD)
|
||||
}
|
||||
|
||||
when (parent) {
|
||||
is KtBinaryExpression -> {
|
||||
val receiver = parent.left?.toExpressionReceiverValue(context) ?: context.errorHandling()
|
||||
return CallMaker.makeCall(receiver, parent)
|
||||
}
|
||||
is KtUnaryExpression -> {
|
||||
if (element is KtOperationReferenceExpression && element.getReferencedNameElementType() == KtTokens.EXCLEXCL) {
|
||||
return ControlStructureTypingUtils.createCallForSpecialConstruction(parent, element, listOf(parent.baseExpression))
|
||||
}
|
||||
|
||||
val receiver = parent.baseExpression?.toExpressionReceiverValue(context) ?: context.errorHandling()
|
||||
return CallMaker.makeCall(receiver, parent)
|
||||
}
|
||||
}
|
||||
|
||||
// todo support array get/set calls
|
||||
return null
|
||||
}
|
||||
|
||||
private fun KtExpression.toExpressionReceiverValue(context: Fe10WrapperContext): ExpressionReceiver {
|
||||
val ktType = context.withAnalysisSession {
|
||||
this@toExpressionReceiverValue.getKtType() ?: context.implementationPostponed()
|
||||
}
|
||||
|
||||
// TODO: implement THIS_TYPE_FOR_SUPER_EXPRESSION Binding slice
|
||||
return ExpressionReceiver.create(this, ktType.toKotlinType(context), context.bindingContext)
|
||||
}
|
||||
|
||||
private fun getResolvedCall(call: Call): ResolvedCall<*>? {
|
||||
val ktElement = call.calleeExpression ?: call.callElement
|
||||
|
||||
val ktCallInfo = context.withAnalysisSession { ktElement.resolveCallOld() }
|
||||
val diagnostic: KtDiagnostic?
|
||||
val ktCall: KaCall = when (ktCallInfo) {
|
||||
null -> return null
|
||||
is KaSuccessCallInfo -> {
|
||||
diagnostic = null
|
||||
ktCallInfo.call
|
||||
}
|
||||
is KaErrorCallInfo -> {
|
||||
diagnostic = ktCallInfo.diagnostic
|
||||
ktCallInfo.candidateCalls.singleOrNull() ?: return null
|
||||
}
|
||||
}
|
||||
|
||||
when (ktCall) {
|
||||
is KaFunctionCall<*> -> {
|
||||
if (ktCall.safeAs<KaSimpleFunctionCall>()?.isImplicitInvoke == true) {
|
||||
context.implementationPostponed("Variable + invoke resolved call")
|
||||
}
|
||||
return FunctionFe10WrapperResolvedCall(call, ktCall, diagnostic, context)
|
||||
}
|
||||
|
||||
is KaVariableAccessCall -> {
|
||||
return VariableFe10WrapperResolvedCall(call, ktCall, diagnostic, context)
|
||||
}
|
||||
|
||||
else -> context.implementationPostponed(ktCall.javaClass.canonicalName)
|
||||
}
|
||||
}
|
||||
|
||||
private fun getConstructorResolvedDelegationCall(constructor: ConstructorDescriptor): ResolvedCall<ConstructorDescriptor>? {
|
||||
when (val constructorPSI = constructor.safeAs<KtSymbolBasedConstructorDescriptor>()?.ktSymbol?.psi) {
|
||||
is KtSecondaryConstructor -> {
|
||||
val delegationCall = constructorPSI.getDelegationCall()
|
||||
val ktCallInfo = context.withAnalysisSession { delegationCall.resolveCallOld() }
|
||||
val diagnostic = ktCallInfo.safeAs<KaErrorCallInfo>()?.diagnostic
|
||||
val constructorCall = ktCallInfo?.calls?.singleOrNull() ?: return null
|
||||
|
||||
if (constructorCall !is KaFunctionCall<*>) context.errorHandling(constructorCall::class.toString())
|
||||
val psiCall = CallMaker.makeCall(null, null, delegationCall)
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return FunctionFe10WrapperResolvedCall(psiCall, constructorCall, diagnostic, context) as ResolvedCall<ConstructorDescriptor>
|
||||
}
|
||||
null -> return null
|
||||
else -> if (constructorPSI is KtPrimaryConstructor && !constructorPSI.hasBody()) return null else context.implementationPlanned() // todo: Primary Constructor delegated call
|
||||
}
|
||||
}
|
||||
|
||||
private fun getReferenceTarget(key: KtReferenceExpression): DeclarationDescriptor? {
|
||||
val ktSymbol = context.withAnalysisSession { key.mainReference.resolveToSymbols().singleOrNull() } ?: return null
|
||||
return ktSymbol.toDeclarationDescriptor(context)
|
||||
}
|
||||
}
|
||||
@@ -1,218 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
package org.jetbrains.kotlin.idea.fir.fe10.binding
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.*
|
||||
import org.jetbrains.kotlin.analysis.api.types.KtNonErrorClassType
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.idea.fir.fe10.Fe10WrapperContext
|
||||
import org.jetbrains.kotlin.idea.fir.fe10.toDeclarationDescriptor
|
||||
import org.jetbrains.kotlin.incremental.components.LookupLocation
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.scopes.*
|
||||
import org.jetbrains.kotlin.utils.Printer
|
||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
|
||||
|
||||
class Fe10BindingScopeProvider(bindingContext: KtSymbolBasedBindingContext) {
|
||||
private val context = bindingContext.context
|
||||
|
||||
init {
|
||||
bindingContext.registerGetterByKey(BindingContext.LEXICAL_SCOPE, this::getLexicalScope)
|
||||
}
|
||||
|
||||
private fun getLexicalScope(element: KtElement): LexicalScope? {
|
||||
return context.getLexicalScope(element)
|
||||
}
|
||||
}
|
||||
|
||||
private fun Fe10WrapperContext.getLexicalScope(element: PsiElement): LexicalScope? {
|
||||
val ktDeclaration = KtStubbedPsiUtil.getPsiOrStubParent(element, KtDeclaration::class.java, false) ?: return null
|
||||
|
||||
return when (ktDeclaration) {
|
||||
is KtPropertyAccessor -> {
|
||||
val propertyDeclaration = KtStubbedPsiUtil.getContainingDeclaration(ktDeclaration, KtDeclaration::class.java) ?: return null
|
||||
|
||||
val parent = Fe10BindingLexicalScopeForCallableDeclaration(propertyDeclaration, withReceivers = true, this)
|
||||
val propertyDescriptor = parent.ownerDescriptor.safeAs<PropertyDescriptor>() ?: return null
|
||||
|
||||
val accessorDescriptor = (if (ktDeclaration.isGetter) propertyDescriptor.getter else propertyDescriptor.setter) ?: return parent
|
||||
|
||||
Fe10BindingLexicalScopeForAccessors(parent, accessorDescriptor, this)
|
||||
}
|
||||
// i.e. we inside initializer --> no implicit receiver
|
||||
is KtProperty -> Fe10BindingLexicalScopeForCallableDeclaration(ktDeclaration, withReceivers = false, this)
|
||||
is KtFunction -> Fe10BindingLexicalScopeForCallableDeclaration(ktDeclaration, withReceivers = true, this)
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* based on [org.jetbrains.kotlin.resolve.lazy.DeclarationScopeProviderImpl.getResolutionScopeForDeclaration]
|
||||
*/
|
||||
private fun Fe10WrapperContext.getResolutionScopeForDeclaration(declaration: KtDeclaration): LexicalScope {
|
||||
val ktDeclaration = KtStubbedPsiUtil.getPsiOrStubParent(declaration, KtDeclaration::class.java, false) ?: return fileScope()
|
||||
|
||||
var parentDeclaration = KtStubbedPsiUtil.getContainingDeclaration(ktDeclaration)
|
||||
|
||||
if (ktDeclaration is KtPropertyAccessor) {
|
||||
parentDeclaration = KtStubbedPsiUtil.getContainingDeclaration(parentDeclaration!!, KtDeclaration::class.java)
|
||||
}
|
||||
|
||||
if (parentDeclaration is KtClassOrObject) {
|
||||
val classScopeKind =
|
||||
if (ktDeclaration is KtAnonymousInitializer || ktDeclaration is KtProperty) {
|
||||
// scopeForInitializerResolution, actually should contain primary constructor also
|
||||
Fe10BindingLexicalScopeForClassLikeElement.Kind.ME_AND_COMPANIONS
|
||||
} else if (ktDeclaration is KtObjectDeclaration && ktDeclaration.isCompanion()) {
|
||||
// scopeForCompanionObjectHeaderResolution
|
||||
Fe10BindingLexicalScopeForClassLikeElement.Kind.SCOPE_FOR_COMPANION
|
||||
} else if (ktDeclaration is KtObjectDeclaration || (ktDeclaration is KtClass && !ktDeclaration.isInner())) {
|
||||
Fe10BindingLexicalScopeForClassLikeElement.Kind.MY_STATIC_SCOPE
|
||||
} else Fe10BindingLexicalScopeForClassLikeElement.Kind.ME_AND_COMPANIONS
|
||||
return Fe10BindingLexicalScopeForClassLikeElement(parentDeclaration, classScopeKind, this)
|
||||
}
|
||||
|
||||
// i.e. ~declaration is local
|
||||
if (parentDeclaration != null) {
|
||||
return getLexicalScope(parentDeclaration) ?: fileScope()
|
||||
}
|
||||
|
||||
return fileScope()
|
||||
}
|
||||
|
||||
|
||||
private fun Fe10WrapperContext.fileScope() = LexicalScope.Base(ImportingScope.Empty, moduleDescriptor)
|
||||
|
||||
private sealed class Fe10BindingLexicalScope(val context: Fe10WrapperContext) : LexicalScope {
|
||||
private fun noImplementation(): Nothing = context.noImplementation("LexicalScope wrappers has very limited functionally")
|
||||
|
||||
override val isOwnerDescriptorAccessibleByLabel: Boolean
|
||||
get() = noImplementation()
|
||||
override val kind: LexicalScopeKind
|
||||
get() = noImplementation()
|
||||
|
||||
override fun getContributedClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? = noImplementation()
|
||||
|
||||
override fun getContributedDescriptors(
|
||||
kindFilter: DescriptorKindFilter,
|
||||
nameFilter: (Name) -> Boolean
|
||||
): Collection<DeclarationDescriptor> = noImplementation()
|
||||
|
||||
override fun getContributedFunctions(name: Name, location: LookupLocation): Collection<FunctionDescriptor> = noImplementation()
|
||||
|
||||
override fun getContributedVariables(name: Name, location: LookupLocation): Collection<VariableDescriptor> = noImplementation()
|
||||
override fun printStructure(p: Printer) = noImplementation()
|
||||
}
|
||||
|
||||
private class Fe10BindingLexicalScopeForCompanionObjectReceivers(
|
||||
override val implicitReceiver: ReceiverParameterDescriptor?,
|
||||
override val ownerDescriptor: DeclarationDescriptor,
|
||||
override val parent: LexicalScope,
|
||||
context: Fe10WrapperContext
|
||||
): Fe10BindingLexicalScope(context) {
|
||||
/**
|
||||
* see [org.jetbrains.kotlin.resolve.lazy.descriptors.ClassResolutionScopesSupport.createInheritanceScope]
|
||||
*/
|
||||
override val contextReceiversGroup: List<ReceiverParameterDescriptor>
|
||||
get() = emptyList()
|
||||
}
|
||||
|
||||
private class Fe10BindingLexicalScopeForAccessors(
|
||||
override val parent: Fe10BindingLexicalScopeForCallableDeclaration,
|
||||
override val ownerDescriptor: DeclarationDescriptor,
|
||||
context: Fe10WrapperContext,
|
||||
): Fe10BindingLexicalScope(context) {
|
||||
override val contextReceiversGroup: List<ReceiverParameterDescriptor>
|
||||
get() = emptyList()
|
||||
|
||||
override val implicitReceiver: ReceiverParameterDescriptor?
|
||||
get() = null
|
||||
}
|
||||
|
||||
private class Fe10BindingLexicalScopeForCallableDeclaration(
|
||||
private val ktDeclaration: KtDeclaration,
|
||||
private val withReceivers: Boolean,
|
||||
context: Fe10WrapperContext
|
||||
): Fe10BindingLexicalScope(context) {
|
||||
override val ownerDescriptor: CallableDescriptor = run {
|
||||
context.withAnalysisSession { ktDeclaration.getSymbol() }.toDeclarationDescriptor(context) as CallableDescriptor
|
||||
}
|
||||
|
||||
override val parent: HierarchicalScope
|
||||
get() = context.getResolutionScopeForDeclaration(ktDeclaration)
|
||||
|
||||
override val implicitReceiver: ReceiverParameterDescriptor?
|
||||
get() = ownerDescriptor.extensionReceiverParameter.takeIf { withReceivers }
|
||||
|
||||
override val contextReceiversGroup: List<ReceiverParameterDescriptor>
|
||||
get() = ownerDescriptor.contextReceiverParameters
|
||||
}
|
||||
|
||||
private class Fe10BindingLexicalScopeForClassLikeElement(
|
||||
val ktClassOrObject: KtClassOrObject,
|
||||
val myKind: Kind,
|
||||
context: Fe10WrapperContext
|
||||
) : Fe10BindingLexicalScope(context) {
|
||||
enum class Kind {
|
||||
OUTER_CLASS, // without receiver, only owner class, parent class is parent scope
|
||||
ME_AND_COMPANIONS, // this receiver, parent -- all companion objects and the last one -- same class with OUTER_CLASS
|
||||
MY_STATIC_SCOPE, // me -- only if object, parent -- all companion objects and the last one -- same class with OUTER_CLASS
|
||||
SCOPE_FOR_COMPANION // all companion objects except mine and the last one -- same class with OUTER_CLASS
|
||||
}
|
||||
|
||||
private val ktClassSymbol = context.withAnalysisSession { ktClassOrObject.getSymbol() } as KaClassOrObjectSymbol
|
||||
|
||||
override val ownerDescriptor: ClassDescriptor = ktClassSymbol.toDeclarationDescriptor(context)
|
||||
|
||||
override val implicitReceiver: ReceiverParameterDescriptor?
|
||||
get() = when (myKind) {
|
||||
Kind.OUTER_CLASS, Kind.SCOPE_FOR_COMPANION -> null
|
||||
Kind.ME_AND_COMPANIONS -> ownerDescriptor.thisAsReceiverParameter
|
||||
Kind.MY_STATIC_SCOPE -> ownerDescriptor.thisAsReceiverParameter.takeIf { ownerDescriptor.kind.isSingleton }
|
||||
}
|
||||
|
||||
override val contextReceiversGroup: List<ReceiverParameterDescriptor>
|
||||
get() = ownerDescriptor.contextReceivers.takeIf { myKind == Kind.ME_AND_COMPANIONS } ?: emptyList()
|
||||
|
||||
override val parent: HierarchicalScope
|
||||
get() = when (myKind) {
|
||||
Kind.OUTER_CLASS -> context.getResolutionScopeForDeclaration(ktClassOrObject)
|
||||
Kind.ME_AND_COMPANIONS, Kind.MY_STATIC_SCOPE, Kind.SCOPE_FOR_COMPANION -> {
|
||||
val topLevelMe = Fe10BindingLexicalScopeForClassLikeElement(ktClassOrObject, Kind.OUTER_CLASS, context)
|
||||
collectAllCompanionObjects(skipMine = myKind == Kind.SCOPE_FOR_COMPANION).reversed().fold<_, Fe10BindingLexicalScope>(topLevelMe) {
|
||||
parent, companion ->
|
||||
val implicitReceiver = companion.toDeclarationDescriptor(context).thisAsReceiverParameter
|
||||
Fe10BindingLexicalScopeForCompanionObjectReceivers(implicitReceiver, ownerDescriptor, parent, context)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun collectAllCompanionObjects(skipMine: Boolean): List<KaNamedClassOrObjectSymbol> = buildList {
|
||||
var current = ktClassSymbol
|
||||
mainLoop@ while (true) {
|
||||
if (current is KaNamedClassOrObjectSymbol && (current !== ktClassSymbol || !skipMine)) {
|
||||
addIfNotNull(current.companionObject)
|
||||
}
|
||||
|
||||
superTypeLoop@ for (superType in current.superTypes) {
|
||||
if (superType !is KtNonErrorClassType) continue@superTypeLoop
|
||||
val classOrObjectSymbol: KaClassOrObjectSymbol = when (val typeSymbol = superType.symbol) {
|
||||
is KaClassOrObjectSymbol -> typeSymbol
|
||||
is KaTypeAliasSymbol -> typeSymbol.expandedType.safeAs<KtNonErrorClassType>()?.classSymbol.safeAs<KaClassOrObjectSymbol>()
|
||||
?: continue@superTypeLoop
|
||||
}
|
||||
if (classOrObjectSymbol.classKind == KaClassKind.CLASS) {
|
||||
current = classOrObjectSymbol
|
||||
continue@mainLoop
|
||||
}
|
||||
}
|
||||
break@mainLoop
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
|
||||
package org.jetbrains.kotlin.idea.fir.fe10.binding
|
||||
|
||||
import com.google.common.collect.ImmutableMap
|
||||
import com.intellij.openapi.diagnostic.Logger
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.idea.fir.fe10.Fe10WrapperContext
|
||||
import org.jetbrains.kotlin.idea.fir.fe10.toKotlinType
|
||||
import org.jetbrains.kotlin.psi.KtExpression
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.BindingTrace
|
||||
import org.jetbrains.kotlin.resolve.diagnostics.Diagnostics
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.util.slicedMap.ReadOnlySlice
|
||||
import org.jetbrains.kotlin.util.slicedMap.WritableSlice
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
|
||||
|
||||
class KtSymbolBasedBindingContext(val context: Fe10WrapperContext) : BindingContext {
|
||||
private val LOG = Logger.getInstance(KtSymbolBasedBindingContext::class.java)
|
||||
|
||||
private val getterBySlice: MutableMap<ReadOnlySlice<*, *>, (Nothing) -> Any?> = hashMapOf()
|
||||
|
||||
init {
|
||||
CallAndResolverCallWrappers(this)
|
||||
ToDescriptorBindingContextValueProviders(this)
|
||||
MiscBindingContextValueProvider(this)
|
||||
Fe10BindingScopeProvider(this)
|
||||
}
|
||||
|
||||
fun <K, V> registerGetterByKey(slice: ReadOnlySlice<K, V>, getter: (K) -> V?) {
|
||||
check(!getterBySlice.containsKey(slice)) {
|
||||
"Key $slice already registered: ${getterBySlice[slice]}"
|
||||
}
|
||||
getterBySlice[slice] = getter
|
||||
}
|
||||
|
||||
override fun getDiagnostics(): Diagnostics = context.incorrectImplementation { Diagnostics.EMPTY }
|
||||
|
||||
override fun getProject(): Project? {
|
||||
return context.bindingContext.project
|
||||
}
|
||||
|
||||
override fun <K : Any?, V : Any?> get(slice: ReadOnlySlice<K, V>, key: K): V? {
|
||||
val getter = getterBySlice[slice]
|
||||
if (getter == null) {
|
||||
if (context.enableLogging) LOG.warn("Key not registered: $slice")
|
||||
return null
|
||||
}
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
val v = if (key == null) null else (getter as (K) -> V?)(key)
|
||||
|
||||
if (context.enableLogging) {
|
||||
val psiText = key.safeAs<PsiElement>()?.text ?: key
|
||||
println("$slice: $psiText -> $v")
|
||||
}
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
override fun getType(expression: KtExpression): KotlinType? =
|
||||
context.withAnalysisSession {
|
||||
expression.getKtType()?.toKotlinType(context)
|
||||
}
|
||||
|
||||
override fun <K : Any?, V : Any?> getKeys(slice: WritableSlice<K, V>?): Collection<K> =
|
||||
context.noImplementation()
|
||||
|
||||
override fun <K : Any?, V : Any?> getSliceContents(slice: ReadOnlySlice<K, V>): ImmutableMap<K, V> =
|
||||
context.noImplementation()
|
||||
|
||||
override fun addOwnDataTo(trace: BindingTrace, commitDiagnostics: Boolean) =
|
||||
context.noImplementation()
|
||||
}
|
||||
@@ -1,94 +0,0 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package org.jetbrains.kotlin.idea.fir.fe10.binding
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KaCallableSymbol
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KaFunctionLikeSymbol
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KtSymbolOrigin
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.idea.fir.fe10.KtSymbolBasedClassDescriptor
|
||||
import org.jetbrains.kotlin.idea.fir.fe10.toConstantValue
|
||||
import org.jetbrains.kotlin.idea.fir.fe10.toDeclarationDescriptor
|
||||
import org.jetbrains.kotlin.idea.fir.fe10.toKotlinType
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.psi.KtExpression
|
||||
import org.jetbrains.kotlin.psi.KtReferenceExpression
|
||||
import org.jetbrains.kotlin.psi.KtReturnExpression
|
||||
import org.jetbrains.kotlin.psi.KtSuperExpression
|
||||
import org.jetbrains.kotlin.psi.KtTypeReference
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant
|
||||
import org.jetbrains.kotlin.resolve.constants.TypedCompileTimeConstant
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
|
||||
|
||||
class MiscBindingContextValueProvider(bindingContext: KtSymbolBasedBindingContext) {
|
||||
private val context = bindingContext.context
|
||||
|
||||
init {
|
||||
bindingContext.registerGetterByKey(BindingContext.TYPE, this::getType)
|
||||
bindingContext.registerGetterByKey(BindingContext.THIS_TYPE_FOR_SUPER_EXPRESSION, this::getThisTypeForSuperExpression)
|
||||
bindingContext.registerGetterByKey(BindingContext.COMPILE_TIME_VALUE, this::getCompileTimeValue)
|
||||
bindingContext.registerGetterByKey(BindingContext.DATA_CLASS_COPY_FUNCTION, this::getDataClassCopyFunction)
|
||||
bindingContext.registerGetterByKey(BindingContext.EXPECTED_EXPRESSION_TYPE, this::getExpectedExpressionType)
|
||||
bindingContext.registerGetterByKey(BindingContext.LABEL_TARGET, this::getLabelTarget)
|
||||
}
|
||||
|
||||
private fun getType(ktTypeReference: KtTypeReference): KotlinType {
|
||||
return context.withAnalysisSession {
|
||||
ktTypeReference.getKtType()
|
||||
}.toKotlinType(context)
|
||||
}
|
||||
|
||||
private fun getThisTypeForSuperExpression(superExpression: KtSuperExpression): KotlinType =
|
||||
context.withAnalysisSession { superExpression.getKtType() }?.toKotlinType(context) ?: context.errorHandling()
|
||||
|
||||
private fun getCompileTimeValue(key: KtExpression): CompileTimeConstant<*>? {
|
||||
val kaConstantValue = context.withAnalysisSession { key.evaluate() }
|
||||
?: return null
|
||||
val constantValue = kaConstantValue.toConstantValue()
|
||||
// only usesNonConstValAsConstant seems to be used in IDE code
|
||||
val parameters = CompileTimeConstant.Parameters(
|
||||
canBeUsedInAnnotation = false,
|
||||
isPure = false,
|
||||
isUnsignedNumberLiteral = false,
|
||||
isUnsignedLongNumberLiteral = false,
|
||||
usesVariableAsConstant = false,
|
||||
usesNonConstValAsConstant = false,
|
||||
isConvertableConstVal = false
|
||||
)
|
||||
return TypedCompileTimeConstant(constantValue, context.moduleDescriptor, parameters)
|
||||
}
|
||||
|
||||
// copy function could be only generated, and DATA_CLASS_COPY_FUNCTION works only for function from sources
|
||||
private fun getDataClassCopyFunction(classDescriptor: ClassDescriptor): FunctionDescriptor? {
|
||||
if (classDescriptor !is KtSymbolBasedClassDescriptor) return null
|
||||
val classSymbol = classDescriptor.ktSymbol
|
||||
|
||||
val copyFunction: KaCallableSymbol? = context.withAnalysisSession {
|
||||
classSymbol.getMemberScope().getCallableSymbols(Name.identifier("copy")).singleOrNull {
|
||||
it.origin == KtSymbolOrigin.SOURCE_MEMBER_GENERATED
|
||||
}
|
||||
}
|
||||
|
||||
return copyFunction.safeAs<KaFunctionLikeSymbol>()?.toDeclarationDescriptor(context)
|
||||
}
|
||||
|
||||
private fun getExpectedExpressionType(ktExpression: KtExpression): KotlinType? =
|
||||
context.withAnalysisSession {
|
||||
ktExpression.getExpectedType()
|
||||
}?.toKotlinType(context)
|
||||
|
||||
private fun getLabelTarget(ktExpression: KtReferenceExpression): PsiElement? {
|
||||
val potentiallyParentReturn = ktExpression.parent.parent
|
||||
if (potentiallyParentReturn is KtReturnExpression) {
|
||||
return context.withAnalysisSession {
|
||||
potentiallyParentReturn.getReturnTargetSymbol()?.psi
|
||||
}
|
||||
}
|
||||
|
||||
// other cases
|
||||
return context.incorrectImplementation { null }
|
||||
}
|
||||
}
|
||||
@@ -1,192 +0,0 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package org.jetbrains.kotlin.idea.fir.fe10.binding
|
||||
|
||||
import org.jetbrains.kotlin.analysis.api.resolution.*
|
||||
import org.jetbrains.kotlin.analysis.api.diagnostics.KtDiagnostic
|
||||
import org.jetbrains.kotlin.analysis.api.fir.diagnostics.KaFirDiagnostic
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KaFunctionLikeSymbol
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KaReceiverParameterSymbol
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KaValueParameterSymbol
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KtVariableLikeSymbol
|
||||
import org.jetbrains.kotlin.analysis.api.types.KtType
|
||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
|
||||
import org.jetbrains.kotlin.idea.fir.fe10.Fe10WrapperContext
|
||||
import org.jetbrains.kotlin.idea.fir.fe10.toDeclarationDescriptor
|
||||
import org.jetbrains.kotlin.idea.fir.fe10.toKotlinType
|
||||
import org.jetbrains.kotlin.psi.Call
|
||||
import org.jetbrains.kotlin.psi.ValueArgument
|
||||
import org.jetbrains.kotlin.resolve.calls.model.*
|
||||
import org.jetbrains.kotlin.resolve.calls.results.ResolutionStatus
|
||||
import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.CastImplicitClassReceiver
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ImplicitClassReceiver
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
|
||||
|
||||
|
||||
internal abstract class Fe10WrapperResolvedCall<C : KaCallableMemberCall<*, *>>(
|
||||
private val psiCall: Call,
|
||||
protected val ktCall: C,
|
||||
private val diagnostic: KtDiagnostic?,
|
||||
protected val context: Fe10WrapperContext,
|
||||
) : ResolvedCall<CallableDescriptor> {
|
||||
private val _typeArguments: Map<TypeParameterDescriptor, KotlinType> by lazy(LazyThreadSafetyMode.PUBLICATION) {
|
||||
val ktTypeParameters = ktCall.partiallyAppliedSymbol.symbol.typeParameters
|
||||
if (ktTypeParameters.isEmpty()) return@lazy emptyMap()
|
||||
|
||||
val inferredTypeParametersByIndex: List<KtType?> = ktTypeParameters.map { ktCall.typeArgumentsMapping[it] }
|
||||
if (inferredTypeParametersByIndex.size != candidateDescriptor.typeParameters.size) {
|
||||
context.errorHandling("${inferredTypeParametersByIndex.size} != ${candidateDescriptor.typeParameters.size}")
|
||||
}
|
||||
|
||||
val typeArguments = linkedMapOf<TypeParameterDescriptor, KotlinType>()
|
||||
for ((index, parameter) in candidateDescriptor.typeParameters.withIndex()) {
|
||||
// If inference failed, old FE don't add anything into map
|
||||
val kotlinType = inferredTypeParametersByIndex[index]?.toKotlinType(context) ?: continue
|
||||
typeArguments[parameter] = kotlinType
|
||||
}
|
||||
typeArguments
|
||||
}
|
||||
|
||||
override fun getCall(): Call = psiCall
|
||||
|
||||
override fun getExtensionReceiver(): ReceiverValue? = ktCall.partiallyAppliedSymbol.extensionReceiver?.asFe10ReceiverValue(context)
|
||||
|
||||
override fun getDispatchReceiver(): ReceiverValue? = ktCall.partiallyAppliedSymbol.dispatchReceiver?.asFe10ReceiverValue(context)
|
||||
|
||||
override fun getExplicitReceiverKind() =
|
||||
if (extensionReceiver is ExpressionReceiver) {
|
||||
if (dispatchReceiver is ExpressionReceiver) ExplicitReceiverKind.BOTH_RECEIVERS else ExplicitReceiverKind.EXTENSION_RECEIVER
|
||||
} else {
|
||||
if (dispatchReceiver is ExpressionReceiver) ExplicitReceiverKind.DISPATCH_RECEIVER else ExplicitReceiverKind.NO_EXPLICIT_RECEIVER
|
||||
}
|
||||
|
||||
override fun getStatus(): ResolutionStatus {
|
||||
if (diagnostic == null) return ResolutionStatus.SUCCESS
|
||||
return when (diagnostic) {
|
||||
is KaFirDiagnostic.NamedArgumentsNotAllowed,
|
||||
is KaFirDiagnostic.NonVarargSpread,
|
||||
is KaFirDiagnostic.ArgumentPassedTwice,
|
||||
is KaFirDiagnostic.TooManyArguments,
|
||||
is KaFirDiagnostic.NoValueForParameter,
|
||||
is KaFirDiagnostic.NamedParameterNotFound,
|
||||
is KaFirDiagnostic.NameForAmbiguousParameter
|
||||
-> ResolutionStatus.ARGUMENTS_MAPPING_ERROR
|
||||
|
||||
else -> context.implementationPostponed(diagnostic.toString())
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun getTypeArguments(): Map<TypeParameterDescriptor, KotlinType> = _typeArguments
|
||||
|
||||
override fun getContextReceivers(): List<ReceiverValue> = context.implementationPlanned()
|
||||
override fun getDataFlowInfoForArguments(): DataFlowInfoForArguments = context.noImplementation()
|
||||
override fun getSmartCastDispatchReceiverType(): KotlinType? = context.noImplementation()
|
||||
}
|
||||
|
||||
internal class FunctionFe10WrapperResolvedCall(psiCall: Call, call: KaFunctionCall<*>, diagnostic: KtDiagnostic?, context: Fe10WrapperContext) :
|
||||
Fe10WrapperResolvedCall<KaFunctionCall<*>>(psiCall, call, diagnostic, context) {
|
||||
private val ktFunctionSymbol: KaFunctionLikeSymbol = ktCall.partiallyAppliedSymbol.symbol
|
||||
|
||||
private val argumentsMap: Map<ValueParameterDescriptor, ResolvedValueArgument> by lazy(LazyThreadSafetyMode.PUBLICATION) {
|
||||
val allArguments: List<ValueArgument> = psiCall.valueArguments + psiCall.functionLiteralArguments
|
||||
val ktParameterToResolvedValueArgument = hashMapOf<KaValueParameterSymbol, MutableList<ValueArgument>>()
|
||||
|
||||
for (argument in allArguments) {
|
||||
val parameter: KaValueParameterSymbol =
|
||||
ktCall.argumentMapping[argument.getArgumentExpression()]?.symbol ?: context.errorHandling()
|
||||
|
||||
ktParameterToResolvedValueArgument.getOrPut(parameter) { arrayListOf() }.add(argument)
|
||||
}
|
||||
|
||||
// linkedMap is important -- used in getValueArgumentsByIndex
|
||||
val arguments = linkedMapOf<ValueParameterDescriptor, ResolvedValueArgument>()
|
||||
for ((parameterIndex, parameter) in ktFunctionSymbol.valueParameters.withIndex()) {
|
||||
val argumentsForThisParameter: List<ValueArgument> = ktParameterToResolvedValueArgument[parameter] ?: emptyList()
|
||||
val resolvedValueArgument = when(argumentsForThisParameter.size) {
|
||||
0 -> DefaultValueArgument.DEFAULT
|
||||
1 -> ExpressionValueArgument(argumentsForThisParameter.single())
|
||||
else -> VarargValueArgument(argumentsForThisParameter)
|
||||
}
|
||||
arguments[resultingDescriptor.valueParameters[parameterIndex]] = resolvedValueArgument
|
||||
}
|
||||
arguments
|
||||
}
|
||||
|
||||
// For List<String>.add("") call ktFunctionSymbol is List<T>.add(T) i.e. we should substitute types from dispatch receiver
|
||||
override fun getCandidateDescriptor(): CallableDescriptor =
|
||||
context.incorrectImplementation { ktFunctionSymbol.toDeclarationDescriptor(context) }
|
||||
|
||||
// type arguments should be substituted
|
||||
override fun getResultingDescriptor(): CallableDescriptor = context.incorrectImplementation { candidateDescriptor }
|
||||
|
||||
override fun getValueArguments(): Map<ValueParameterDescriptor, ResolvedValueArgument> = argumentsMap
|
||||
|
||||
override fun getValueArgumentsByIndex(): List<ResolvedValueArgument> = valueArguments.values.toList()
|
||||
|
||||
override fun getArgumentMapping(valueArgument: ValueArgument): ArgumentMapping {
|
||||
val ktParameter = ktCall.argumentMapping.get(valueArgument.getArgumentExpression())?.symbol
|
||||
if (ktParameter == null) return ArgumentUnmapped
|
||||
|
||||
val parameterIndex = ktFunctionSymbol.valueParameters.indexOf(ktParameter)
|
||||
if (parameterIndex == -1) context.errorHandling("$ktParameter not found in $ktFunctionSymbol")
|
||||
|
||||
val parameterDescriptor = resultingDescriptor.valueParameters.getOrNull(parameterIndex) ?: context.errorHandling()
|
||||
val argumentMatch = ArgumentMatchImpl(parameterDescriptor)
|
||||
context.incorrectImplementation {
|
||||
// I'm not sure, when we should have not success status
|
||||
argumentMatch.recordMatchStatus(ArgumentMatchStatus.SUCCESS)
|
||||
}
|
||||
return argumentMatch
|
||||
}
|
||||
}
|
||||
|
||||
internal class VariableFe10WrapperResolvedCall(psiCall: Call, call: KaVariableAccessCall, diagnostic: KtDiagnostic?, context: Fe10WrapperContext) :
|
||||
Fe10WrapperResolvedCall<KaVariableAccessCall>(psiCall, call, diagnostic, context) {
|
||||
|
||||
private val ktVariableSymbol: KtVariableLikeSymbol = ktCall.partiallyAppliedSymbol.symbol
|
||||
|
||||
override fun getCandidateDescriptor(): CallableDescriptor = ktVariableSymbol.toDeclarationDescriptor(context) as CallableDescriptor
|
||||
|
||||
// type arguments should be substituted
|
||||
override fun getResultingDescriptor(): CallableDescriptor = context.incorrectImplementation { candidateDescriptor }
|
||||
|
||||
override fun getValueArguments(): Map<ValueParameterDescriptor, ResolvedValueArgument> = emptyMap()
|
||||
override fun getValueArgumentsByIndex(): List<ResolvedValueArgument> = emptyList()
|
||||
override fun getArgumentMapping(valueArgument: ValueArgument): ArgumentMapping =
|
||||
error("Variable call has no arguments. ktVariableSymbol: $ktVariableSymbol, valueArgument = $valueArgument")
|
||||
}
|
||||
|
||||
private fun KaReceiverValue.asFe10ReceiverValue(context: Fe10WrapperContext, smartCastType: KotlinType? = null): ReceiverValue {
|
||||
return when (this) {
|
||||
is KaSmartCastedReceiverValue -> original.asFe10ReceiverValue(context, this.type.toKotlinType(context))
|
||||
is KaExplicitReceiverValue -> ExpressionReceiver.create(
|
||||
expression,
|
||||
smartCastType ?: this.type.toKotlinType(context),
|
||||
context.bindingContext
|
||||
)
|
||||
|
||||
is KaImplicitReceiverValue -> {
|
||||
val ktDeclaration = symbol.safeAs<KaReceiverParameterSymbol>()?.owningCallableSymbol ?: symbol
|
||||
when (val descriptor = ktDeclaration.toDeclarationDescriptor(context)) {
|
||||
is ClassDescriptor ->
|
||||
if (smartCastType != null) {
|
||||
CastImplicitClassReceiver(descriptor, smartCastType)
|
||||
} else {
|
||||
ImplicitClassReceiver(descriptor)
|
||||
}
|
||||
|
||||
is CallableDescriptor -> descriptor.extensionReceiverParameter?.value
|
||||
?: context.errorHandling("$descriptor should have extension receiver")
|
||||
|
||||
else -> context.errorHandling("Unexpected descriptor: $descriptor")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,111 +0,0 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
|
||||
package org.jetbrains.kotlin.idea.fir.fe10.binding
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KaConstructorSymbol
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KaFunctionLikeSymbol
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KaNamedClassOrObjectSymbol
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KaValueParameterSymbol
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.idea.fir.fe10.*
|
||||
import org.jetbrains.kotlin.idea.references.FE10_BINDING_RESOLVE_TO_DESCRIPTORS
|
||||
import org.jetbrains.kotlin.idea.references.KtReference
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.util.slicedMap.ReadOnlySlice
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
|
||||
|
||||
internal class ToDescriptorBindingContextValueProviders(bindingContext: KtSymbolBasedBindingContext) {
|
||||
private val context = bindingContext.context
|
||||
private val declarationToDescriptorGetters = mutableListOf<(PsiElement) -> DeclarationDescriptor?>()
|
||||
|
||||
private inline fun <reified K : PsiElement, V : DeclarationDescriptor> KtSymbolBasedBindingContext.registerDeclarationToDescriptorByKey(
|
||||
slice: ReadOnlySlice<K, V>,
|
||||
crossinline getter: (K) -> V?
|
||||
) {
|
||||
declarationToDescriptorGetters.add {
|
||||
if (it is K) getter(it) else null
|
||||
}
|
||||
registerGetterByKey(slice, { getter(it) })
|
||||
}
|
||||
|
||||
init {
|
||||
bindingContext.registerDeclarationToDescriptorByKey(BindingContext.CLASS, this::getClass)
|
||||
bindingContext.registerDeclarationToDescriptorByKey(BindingContext.TYPE_PARAMETER, this::getTypeParameter)
|
||||
bindingContext.registerDeclarationToDescriptorByKey(BindingContext.FUNCTION, this::getFunction)
|
||||
bindingContext.registerDeclarationToDescriptorByKey(BindingContext.CONSTRUCTOR, this::getConstructor)
|
||||
bindingContext.registerDeclarationToDescriptorByKey(BindingContext.VARIABLE, this::getVariable)
|
||||
bindingContext.registerDeclarationToDescriptorByKey(BindingContext.VALUE_PARAMETER, this::getValueParameter)
|
||||
bindingContext.registerDeclarationToDescriptorByKey(BindingContext.PRIMARY_CONSTRUCTOR_PARAMETER, this::getPrimaryConstructorParameter)
|
||||
|
||||
bindingContext.registerGetterByKey(FE10_BINDING_RESOLVE_TO_DESCRIPTORS, this::resolveToDescriptors)
|
||||
bindingContext.registerGetterByKey(BindingContext.DECLARATION_TO_DESCRIPTOR, this::getDeclarationToDescriptor)
|
||||
}
|
||||
|
||||
private inline fun <reified T : Any> PsiElement.getKtSymbolOfTypeOrNull(): T? =
|
||||
this@ToDescriptorBindingContextValueProviders.context.withAnalysisSession {
|
||||
this@getKtSymbolOfTypeOrNull.safeAs<KtDeclaration>()?.getSymbol().safeAs<T>()
|
||||
}
|
||||
|
||||
private fun getClass(key: PsiElement): ClassDescriptor? {
|
||||
val ktClassSymbol = key.getKtSymbolOfTypeOrNull<KaNamedClassOrObjectSymbol>() ?: return null
|
||||
|
||||
return KtSymbolBasedClassDescriptor(ktClassSymbol, context)
|
||||
}
|
||||
|
||||
private fun getTypeParameter(key: KtTypeParameter): TypeParameterDescriptor {
|
||||
val ktTypeParameterSymbol = context.withAnalysisSession { key.getTypeParameterSymbol() }
|
||||
return KtSymbolBasedTypeParameterDescriptor(ktTypeParameterSymbol, context)
|
||||
}
|
||||
|
||||
private fun getFunction(key: PsiElement): SimpleFunctionDescriptor? {
|
||||
val ktFunctionLikeSymbol = key.getKtSymbolOfTypeOrNull<KaFunctionLikeSymbol>() ?: return null
|
||||
return ktFunctionLikeSymbol.toDeclarationDescriptor(context) as? SimpleFunctionDescriptor
|
||||
}
|
||||
|
||||
private fun getConstructor(key: PsiElement): ConstructorDescriptor? {
|
||||
val ktConstructorSymbol = key.getKtSymbolOfTypeOrNull<KaConstructorSymbol>() ?: return null
|
||||
val containerClass = context.withAnalysisSession { ktConstructorSymbol.getContainingSymbol() }
|
||||
check(containerClass is KaNamedClassOrObjectSymbol) {
|
||||
"Unexpected contained for Constructor symbol: $containerClass, ktConstructorSymbol = $ktConstructorSymbol"
|
||||
}
|
||||
|
||||
return KtSymbolBasedConstructorDescriptor(ktConstructorSymbol, KtSymbolBasedClassDescriptor(containerClass, context))
|
||||
}
|
||||
|
||||
private fun getVariable(key: PsiElement): VariableDescriptor? {
|
||||
if (key !is KtVariableDeclaration) return null
|
||||
|
||||
if (key is KtProperty) {
|
||||
val symbol = context.withAnalysisSession { key.getVariableSymbol() }
|
||||
return symbol.toDeclarationDescriptor(context)
|
||||
} else {
|
||||
context.implementationPostponed("Destruction declaration is not supported yet: $key")
|
||||
}
|
||||
}
|
||||
|
||||
private fun getValueParameter(key: KtParameter): VariableDescriptor? {
|
||||
val symbol = context.withAnalysisSession { key.getParameterSymbol() }.safeAs<KaValueParameterSymbol>() ?: return null
|
||||
return symbol.toDeclarationDescriptor(context)
|
||||
}
|
||||
|
||||
private fun getPrimaryConstructorParameter(key: PsiElement): PropertyDescriptor? {
|
||||
val parameter = key.safeAs<KtParameter>() ?: return null
|
||||
val parameterSymbol = context.withAnalysisSession { parameter.getParameterSymbol() }
|
||||
val propertySymbol = parameterSymbol.safeAs<KaValueParameterSymbol>()?.generatedPrimaryConstructorProperty ?: return null
|
||||
return KtSymbolBasedPropertyDescriptor(propertySymbol, context)
|
||||
}
|
||||
|
||||
private fun getDeclarationToDescriptor(key: PsiElement): DeclarationDescriptor? {
|
||||
for (getter in declarationToDescriptorGetters) {
|
||||
getter(key)?.let { return it }
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
private fun resolveToDescriptors(ktReference: KtReference): Collection<DeclarationDescriptor>? {
|
||||
val symbols = context.withAnalysisSession { ktReference.resolveToSymbols() }
|
||||
return symbols.map { it.toDeclarationDescriptor(context) }
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
|
||||
package org.jetbrains.kotlin.idea.k2.fe10bindings.inspections
|
||||
|
||||
import com.intellij.codeInsight.intention.IntentionAction
|
||||
import com.intellij.psi.PsiFile
|
||||
import com.intellij.util.ThrowableRunnable
|
||||
import org.jetbrains.kotlin.idea.base.test.IgnoreTests
|
||||
import org.jetbrains.kotlin.idea.fir.invalidateCaches
|
||||
import org.jetbrains.kotlin.idea.intentions.AbstractIntentionTestBase
|
||||
import org.jetbrains.kotlin.idea.test.KotlinLightProjectDescriptor
|
||||
import org.jetbrains.kotlin.idea.test.KotlinWithJdkAndRuntimeLightProjectDescriptor
|
||||
import org.jetbrains.kotlin.idea.test.runAll
|
||||
import java.io.File
|
||||
|
||||
abstract class AbstractFe10BindingIntentionTest : AbstractIntentionTestBase() {
|
||||
|
||||
override fun getDefaultProjectDescriptor(): KotlinLightProjectDescriptor {
|
||||
return KotlinWithJdkAndRuntimeLightProjectDescriptor.getInstance()
|
||||
}
|
||||
|
||||
// left empty because error reporting in FIR and old FE is different
|
||||
override fun checkForErrorsBefore(fileText: String) {}
|
||||
override fun checkForErrorsAfter(fileText: String) {}
|
||||
|
||||
override fun setUp() {
|
||||
super.setUp()
|
||||
project.registerLifetimeTokenFactoryForFe10Binding(myFixture.testRootDisposable)
|
||||
}
|
||||
|
||||
override fun tearDown() {
|
||||
runAll(
|
||||
ThrowableRunnable { project.invalidateCaches() },
|
||||
ThrowableRunnable { super.tearDown() }
|
||||
)
|
||||
}
|
||||
|
||||
override fun doTestFor(mainFile: File, pathToFiles: Map<String, PsiFile>, intentionAction: IntentionAction, fileText: String) {
|
||||
IgnoreTests.runTestIfNotDisabledByFileDirective(mainFile.toPath(), IgnoreTests.DIRECTIVES.IGNORE_FE10_BINDING_BY_FIR, "after") {
|
||||
super.doTestFor(mainFile, pathToFiles, intentionAction, fileText)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package org.jetbrains.kotlin.idea.k2.fe10bindings.inspections
|
||||
|
||||
import com.intellij.codeInspection.LocalInspectionTool
|
||||
import org.jetbrains.kotlin.idea.base.test.IgnoreTests
|
||||
import org.jetbrains.kotlin.idea.fir.invalidateCaches
|
||||
import org.jetbrains.kotlin.idea.inspections.AbstractLocalInspectionTest
|
||||
import org.jetbrains.kotlin.idea.test.KotlinLightProjectDescriptor
|
||||
import org.jetbrains.kotlin.idea.test.KotlinWithJdkAndRuntimeLightProjectDescriptor
|
||||
import org.jetbrains.kotlin.idea.test.runAll
|
||||
import java.io.File
|
||||
|
||||
abstract class AbstractFe10BindingLocalInspectionTest : AbstractLocalInspectionTest() {
|
||||
|
||||
override fun getDefaultProjectDescriptor(): KotlinLightProjectDescriptor {
|
||||
return KotlinWithJdkAndRuntimeLightProjectDescriptor.getInstance()
|
||||
}
|
||||
|
||||
override fun checkForUnexpectedErrors(fileText: String) {}
|
||||
|
||||
override fun setUp() {
|
||||
super.setUp()
|
||||
project.registerLifetimeTokenFactoryForFe10Binding(myFixture.testRootDisposable)
|
||||
}
|
||||
|
||||
override fun tearDown() {
|
||||
runAll(
|
||||
{ project.invalidateCaches() },
|
||||
{ super.tearDown() },
|
||||
)
|
||||
}
|
||||
|
||||
override fun doTestFor(mainFile: File, inspection: LocalInspectionTool, fileText: String) {
|
||||
IgnoreTests.runTestIfNotDisabledByFileDirective(mainFile.toPath(), IgnoreTests.DIRECTIVES.IGNORE_FE10_BINDING_BY_FIR, "after") {
|
||||
doTestForInternal(mainFile, inspection, fileText)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package org.jetbrains.kotlin.idea.k2.fe10bindings.inspections
|
||||
|
||||
import com.intellij.codeInsight.intention.IntentionAction
|
||||
import com.intellij.testFramework.runInEdtAndWait
|
||||
import org.jetbrains.kotlin.idea.base.test.IgnoreTests
|
||||
import org.jetbrains.kotlin.idea.fir.invalidateCaches
|
||||
import org.jetbrains.kotlin.idea.quickfix.AbstractQuickFixTest
|
||||
import org.jetbrains.kotlin.idea.test.KotlinLightProjectDescriptor
|
||||
import org.jetbrains.kotlin.idea.test.KotlinWithJdkAndRuntimeLightProjectDescriptor
|
||||
import org.jetbrains.kotlin.idea.test.runAll
|
||||
|
||||
abstract class AbstractFe10BindingQuickFixTest : AbstractQuickFixTest() {
|
||||
|
||||
override fun getDefaultProjectDescriptor(): KotlinLightProjectDescriptor {
|
||||
return KotlinWithJdkAndRuntimeLightProjectDescriptor.getInstance()
|
||||
}
|
||||
|
||||
override val disableTestDirective: String get() = IgnoreTests.DIRECTIVES.IGNORE_FE10_BINDING_BY_FIR
|
||||
|
||||
override fun setUp() {
|
||||
super.setUp()
|
||||
project.registerLifetimeTokenFactoryForFe10Binding(myFixture.testRootDisposable)
|
||||
}
|
||||
|
||||
override fun tearDown() {
|
||||
runAll(
|
||||
{ runInEdtAndWait { project.invalidateCaches() } },
|
||||
{ super.tearDown() },
|
||||
)
|
||||
}
|
||||
|
||||
// TODO: Enable these as more actions/inspections are enabled, and/or add more FIR-specific directives
|
||||
override fun checkForUnexpectedErrors() {}
|
||||
override fun checkAvailableActionsAreExpected(actions: List<IntentionAction>) {}
|
||||
}
|
||||
@@ -1,963 +0,0 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
|
||||
package org.jetbrains.kotlin.idea.k2.fe10bindings.inspections;
|
||||
|
||||
import com.intellij.testFramework.TestDataPath;
|
||||
import org.jetbrains.kotlin.idea.base.plugin.KotlinPluginMode;
|
||||
import org.jetbrains.kotlin.idea.base.test.TestRoot;
|
||||
import org.jetbrains.kotlin.idea.test.JUnit3RunnerWithInners;
|
||||
import org.jetbrains.kotlin.idea.test.KotlinTestUtils;
|
||||
import org.jetbrains.kotlin.test.TestMetadata;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
/**
|
||||
* This class is generated by {@link org.jetbrains.kotlin.testGenerator.generator.TestGenerator}.
|
||||
* DO NOT MODIFY MANUALLY.
|
||||
*/
|
||||
@SuppressWarnings("all")
|
||||
@TestRoot("k2-fe10-bindings")
|
||||
@TestDataPath("$CONTENT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public abstract class Fe10BindingIntentionTestGenerated extends AbstractFe10BindingIntentionTest {
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
@TestMetadata("../idea/tests/testData/intentions/conventionNameCalls")
|
||||
public abstract static class ConventionNameCalls extends AbstractFe10BindingIntentionTest {
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
@TestMetadata("../idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator")
|
||||
public static class ReplaceCallWithUnaryOperator extends AbstractFe10BindingIntentionTest {
|
||||
@java.lang.Override
|
||||
@org.jetbrains.annotations.NotNull
|
||||
public final KotlinPluginMode getPluginMode() {
|
||||
return KotlinPluginMode.K2;
|
||||
}
|
||||
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
|
||||
}
|
||||
|
||||
@TestMetadata("complexPlus.kt")
|
||||
public void testComplexPlus() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/complexPlus.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("dec.kt")
|
||||
public void testDec() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/dec.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("extensionFunction.kt")
|
||||
public void testExtensionFunction() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/extensionFunction.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("functionLiteralArgument.kt")
|
||||
public void testFunctionLiteralArgument() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/functionLiteralArgument.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inc.kt")
|
||||
public void testInc() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/inc.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("minusSanityTest.kt")
|
||||
public void testMinusSanityTest() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/minusSanityTest.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("namedValueArgument.kt")
|
||||
public void testNamedValueArgument() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/namedValueArgument.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("notSanityTest.kt")
|
||||
public void testNotSanityTest() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/notSanityTest.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("plusPlus.kt")
|
||||
public void testPlusPlus() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/plusPlus.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("plusSanityTest.kt")
|
||||
public void testPlusSanityTest() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/plusSanityTest.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("qualifier.kt")
|
||||
public void testQualifier() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/qualifier.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("super.kt")
|
||||
public void testSuper() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/super.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("typeArguments.kt")
|
||||
public void testTypeArguments() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/typeArguments.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("unacceptableVararg.kt")
|
||||
public void testUnacceptableVararg() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/unacceptableVararg.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("valueArgument.kt")
|
||||
public void testValueArgument() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/valueArgument.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
@TestMetadata("../idea/tests/testData/intentions/conventionNameCalls/replaceContains")
|
||||
public static class ReplaceContains extends AbstractFe10BindingIntentionTest {
|
||||
@java.lang.Override
|
||||
@org.jetbrains.annotations.NotNull
|
||||
public final KotlinPluginMode getPluginMode() {
|
||||
return KotlinPluginMode.K2;
|
||||
}
|
||||
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
|
||||
}
|
||||
|
||||
@TestMetadata("containsFromJava.kt")
|
||||
public void testContainsFromJava() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/conventionNameCalls/replaceContains/containsFromJava.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("containsInExpression.kt")
|
||||
public void testContainsInExpression() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/conventionNameCalls/replaceContains/containsInExpression.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("extensionFunction.kt")
|
||||
public void testExtensionFunction() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/conventionNameCalls/replaceContains/extensionFunction.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("functionLiteralArgument.kt")
|
||||
public void testFunctionLiteralArgument() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/conventionNameCalls/replaceContains/functionLiteralArgument.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("functionLiteralArgumentAfterSemicolon.kt")
|
||||
public void testFunctionLiteralArgumentAfterSemicolon() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/conventionNameCalls/replaceContains/functionLiteralArgumentAfterSemicolon.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("functionLiteralArgumentAtStartOfBlock.kt")
|
||||
public void testFunctionLiteralArgumentAtStartOfBlock() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/conventionNameCalls/replaceContains/functionLiteralArgumentAtStartOfBlock.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("functionLiteralArgumentInExpression.kt")
|
||||
public void testFunctionLiteralArgumentInExpression() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/conventionNameCalls/replaceContains/functionLiteralArgumentInExpression.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("invalidArgument.kt")
|
||||
public void testInvalidArgument() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/conventionNameCalls/replaceContains/invalidArgument.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("missingArgument.kt")
|
||||
public void testMissingArgument() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/conventionNameCalls/replaceContains/missingArgument.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("missingDefaultArgument.kt")
|
||||
public void testMissingDefaultArgument() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/conventionNameCalls/replaceContains/missingDefaultArgument.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("multipleArguments.kt")
|
||||
public void testMultipleArguments() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/conventionNameCalls/replaceContains/multipleArguments.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("notContains.kt")
|
||||
public void testNotContains() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/conventionNameCalls/replaceContains/notContains.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("qualifier.kt")
|
||||
public void testQualifier() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/conventionNameCalls/replaceContains/qualifier.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("simpleArgument.kt")
|
||||
public void testSimpleArgument() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/conventionNameCalls/replaceContains/simpleArgument.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("simpleStringLiteral.kt")
|
||||
public void testSimpleStringLiteral() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/conventionNameCalls/replaceContains/simpleStringLiteral.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("super.kt")
|
||||
public void testSuper() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/conventionNameCalls/replaceContains/super.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("twoArgsContainsFromJava.kt")
|
||||
public void testTwoArgsContainsFromJava() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/conventionNameCalls/replaceContains/twoArgsContainsFromJava.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("typeArguments.kt")
|
||||
public void testTypeArguments() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/conventionNameCalls/replaceContains/typeArguments.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("unacceptableVararg1.kt")
|
||||
public void testUnacceptableVararg1() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/conventionNameCalls/replaceContains/unacceptableVararg1.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("unacceptableVararg2.kt")
|
||||
public void testUnacceptableVararg2() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/conventionNameCalls/replaceContains/unacceptableVararg2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("withoutOperatorModifier.kt")
|
||||
public void testWithoutOperatorModifier() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/conventionNameCalls/replaceContains/withoutOperatorModifier.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
@TestMetadata("../idea/tests/testData/intentions/conventionNameCalls/replaceInvoke")
|
||||
public static class ReplaceInvoke extends AbstractFe10BindingIntentionTest {
|
||||
@java.lang.Override
|
||||
@org.jetbrains.annotations.NotNull
|
||||
public final KotlinPluginMode getPluginMode() {
|
||||
return KotlinPluginMode.K2;
|
||||
}
|
||||
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
|
||||
}
|
||||
|
||||
@TestMetadata("dotQualifiedReceiver.kt")
|
||||
public void testDotQualifiedReceiver() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/conventionNameCalls/replaceInvoke/dotQualifiedReceiver.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("dotQualifiedReceiver2.kt")
|
||||
public void testDotQualifiedReceiver2() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/conventionNameCalls/replaceInvoke/dotQualifiedReceiver2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("dotQualifiedReceiver3.kt")
|
||||
public void testDotQualifiedReceiver3() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/conventionNameCalls/replaceInvoke/dotQualifiedReceiver3.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("expressionReceiver.kt")
|
||||
public void testExpressionReceiver() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/conventionNameCalls/replaceInvoke/expressionReceiver.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("extensionFunction.kt")
|
||||
public void testExtensionFunction() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/conventionNameCalls/replaceInvoke/extensionFunction.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("functionLiteralInvoke.kt")
|
||||
public void testFunctionLiteralInvoke() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/conventionNameCalls/replaceInvoke/functionLiteralInvoke.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("invokeInExpression.kt")
|
||||
public void testInvokeInExpression() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/conventionNameCalls/replaceInvoke/invokeInExpression.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("invokeVariable.kt")
|
||||
public void testInvokeVariable() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/conventionNameCalls/replaceInvoke/invokeVariable.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("java.kt")
|
||||
public void testJava() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/conventionNameCalls/replaceInvoke/java.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("namedArgumentInvoke.kt")
|
||||
public void testNamedArgumentInvoke() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/conventionNameCalls/replaceInvoke/namedArgumentInvoke.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("noArgumentInvoke.kt")
|
||||
public void testNoArgumentInvoke() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/conventionNameCalls/replaceInvoke/noArgumentInvoke.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("notOperator.kt")
|
||||
public void testNotOperator() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/conventionNameCalls/replaceInvoke/notOperator.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("typeAndValueArgument.kt")
|
||||
public void testTypeAndValueArgument() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/conventionNameCalls/replaceInvoke/typeAndValueArgument.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("typeArgumentAndFunctionLiteral.kt")
|
||||
public void testTypeArgumentAndFunctionLiteral() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/conventionNameCalls/replaceInvoke/typeArgumentAndFunctionLiteral.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("valueAndFunctionLiteralInvoke.kt")
|
||||
public void testValueAndFunctionLiteralInvoke() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/conventionNameCalls/replaceInvoke/valueAndFunctionLiteralInvoke.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("valueArgumentInvoke.kt")
|
||||
public void testValueArgumentInvoke() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/conventionNameCalls/replaceInvoke/valueArgumentInvoke.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("varargInvoke.kt")
|
||||
public void testVarargInvoke() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/conventionNameCalls/replaceInvoke/varargInvoke.kt");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
@TestMetadata("../idea/tests/testData/intentions/convertSecondaryConstructorToPrimary")
|
||||
public static class ConvertSecondaryConstructorToPrimary extends AbstractFe10BindingIntentionTest {
|
||||
@java.lang.Override
|
||||
@org.jetbrains.annotations.NotNull
|
||||
public final KotlinPluginMode getPluginMode() {
|
||||
return KotlinPluginMode.K2;
|
||||
}
|
||||
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
|
||||
}
|
||||
|
||||
@TestMetadata("assignmentToGlobalVariable.kt")
|
||||
public void testAssignmentToGlobalVariable() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertSecondaryConstructorToPrimary/assignmentToGlobalVariable.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("defaultValueChain.kt")
|
||||
public void testDefaultValueChain() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertSecondaryConstructorToPrimary/defaultValueChain.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("init.kt")
|
||||
public void testInit() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertSecondaryConstructorToPrimary/init.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("initAndParams.kt")
|
||||
public void testInitAndParams() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertSecondaryConstructorToPrimary/initAndParams.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nonReachable.kt")
|
||||
public void testNonReachable() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertSecondaryConstructorToPrimary/nonReachable.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nonReachableLoop.kt")
|
||||
public void testNonReachableLoop() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertSecondaryConstructorToPrimary/nonReachableLoop.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("propertyWithGetter.kt")
|
||||
public void testPropertyWithGetter() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertSecondaryConstructorToPrimary/propertyWithGetter.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("propertyWithSetter.kt")
|
||||
public void testPropertyWithSetter() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertSecondaryConstructorToPrimary/propertyWithSetter.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("protectedConstructor.kt")
|
||||
public void testProtectedConstructor() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertSecondaryConstructorToPrimary/protectedConstructor.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("simple.kt")
|
||||
public void testSimple() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertSecondaryConstructorToPrimary/simple.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("useParam.kt")
|
||||
public void testUseParam() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertSecondaryConstructorToPrimary/useParam.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("varArg.kt")
|
||||
public void testVarArg() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertSecondaryConstructorToPrimary/varArg.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("varargVal.kt")
|
||||
public void testVarargVal() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertSecondaryConstructorToPrimary/varargVal.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("withBaseAliasImplicit.kt")
|
||||
public void testWithBaseAliasImplicit() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertSecondaryConstructorToPrimary/withBaseAliasImplicit.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("withBaseClass.kt")
|
||||
public void testWithBaseClass() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertSecondaryConstructorToPrimary/withBaseClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("withBaseClassImplicit.kt")
|
||||
public void testWithBaseClassImplicit() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertSecondaryConstructorToPrimary/withBaseClassImplicit.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("withBaseClassNoArgs.kt")
|
||||
public void testWithBaseClassNoArgs() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertSecondaryConstructorToPrimary/withBaseClassNoArgs.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("withComments.kt")
|
||||
public void testWithComments() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertSecondaryConstructorToPrimary/withComments.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("withComposedModifiers.kt")
|
||||
public void testWithComposedModifiers() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertSecondaryConstructorToPrimary/withComposedModifiers.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("withDelegation.kt")
|
||||
public void testWithDelegation() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertSecondaryConstructorToPrimary/withDelegation.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("withDifferentTypeProperty.kt")
|
||||
public void testWithDifferentTypeProperty() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertSecondaryConstructorToPrimary/withDifferentTypeProperty.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("withInterfaceAlias.kt")
|
||||
public void testWithInterfaceAlias() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertSecondaryConstructorToPrimary/withInterfaceAlias.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("withModifiers.kt")
|
||||
public void testWithModifiers() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertSecondaryConstructorToPrimary/withModifiers.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("withParameters.kt")
|
||||
public void testWithParameters() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertSecondaryConstructorToPrimary/withParameters.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("withPrimary.kt")
|
||||
public void testWithPrimary() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertSecondaryConstructorToPrimary/withPrimary.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("withProperties.kt")
|
||||
public void testWithProperties() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertSecondaryConstructorToPrimary/withProperties.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
@TestMetadata("../idea/tests/testData/intentions/convertToStringTemplate")
|
||||
public static class ConvertToStringTemplate extends AbstractFe10BindingIntentionTest {
|
||||
@java.lang.Override
|
||||
@org.jetbrains.annotations.NotNull
|
||||
public final KotlinPluginMode getPluginMode() {
|
||||
return KotlinPluginMode.K2;
|
||||
}
|
||||
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
|
||||
}
|
||||
|
||||
@TestMetadata("backslashNMultilineString.kt")
|
||||
public void testBackslashNMultilineString() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertToStringTemplate/backslashNMultilineString.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("combineEmptyStrings.kt")
|
||||
public void testCombineEmptyStrings() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertToStringTemplate/combineEmptyStrings.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("combinesNonStringsAsStrings.kt")
|
||||
public void testCombinesNonStringsAsStrings() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertToStringTemplate/combinesNonStringsAsStrings.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("combinesNonStringsAsStrings2.kt")
|
||||
public void testCombinesNonStringsAsStrings2() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertToStringTemplate/combinesNonStringsAsStrings2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("comment.kt")
|
||||
public void testComment() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertToStringTemplate/comment.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("consecutiveNewlines.kt")
|
||||
public void testConsecutiveNewlines() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertToStringTemplate/consecutiveNewlines.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("doesNotCorruptExistingTemplate.kt")
|
||||
public void testDoesNotCorruptExistingTemplate() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertToStringTemplate/doesNotCorruptExistingTemplate.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("doesNotCorruptExistingTemplateWithBraces.kt")
|
||||
public void testDoesNotCorruptExistingTemplateWithBraces() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertToStringTemplate/doesNotCorruptExistingTemplateWithBraces.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("dollarSignBeforeLeftBrace.kt")
|
||||
public void testDollarSignBeforeLeftBrace() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertToStringTemplate/dollarSignBeforeLeftBrace.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("dollarSignBeforeRightBrace.kt")
|
||||
public void testDollarSignBeforeRightBrace() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertToStringTemplate/dollarSignBeforeRightBrace.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("dollarSignChar.kt")
|
||||
public void testDollarSignChar() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertToStringTemplate/dollarSignChar.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("endOfLineComment.kt")
|
||||
public void testEndOfLineComment() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertToStringTemplate/endOfLineComment.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("escapedQuote.kt")
|
||||
public void testEscapedQuote() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertToStringTemplate/escapedQuote.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("escapedQuote2.kt")
|
||||
public void testEscapedQuote2() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertToStringTemplate/escapedQuote2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("insertBracesForSimpleNamedExpression.kt")
|
||||
public void testInsertBracesForSimpleNamedExpression() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertToStringTemplate/insertBracesForSimpleNamedExpression.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("intToString.kt")
|
||||
public void testIntToString() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertToStringTemplate/intToString.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("interpolate2StringConstants.kt")
|
||||
public void testInterpolate2StringConstants() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertToStringTemplate/interpolate2StringConstants.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("interpolate2Vals.kt")
|
||||
public void testInterpolate2Vals() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertToStringTemplate/interpolate2Vals.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("interpolate3Left.kt")
|
||||
public void testInterpolate3Left() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertToStringTemplate/interpolate3Left.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("interpolate3Right.kt")
|
||||
public void testInterpolate3Right() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertToStringTemplate/interpolate3Right.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("interpolateChar.kt")
|
||||
public void testInterpolateChar() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertToStringTemplate/interpolateChar.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("interpolateDollarSign.kt")
|
||||
public void testInterpolateDollarSign() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertToStringTemplate/interpolateDollarSign.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("interpolateMapAccess.kt")
|
||||
public void testInterpolateMapAccess() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertToStringTemplate/interpolateMapAccess.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("interpolateMethodInvoke.kt")
|
||||
public void testInterpolateMethodInvoke() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertToStringTemplate/interpolateMethodInvoke.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("interpolateMultiline.kt")
|
||||
public void testInterpolateMultiline() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertToStringTemplate/interpolateMultiline.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("interpolateStringWithFloat.kt")
|
||||
public void testInterpolateStringWithFloat() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertToStringTemplate/interpolateStringWithFloat.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("interpolateStringWithInt.kt")
|
||||
public void testInterpolateStringWithInt() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertToStringTemplate/interpolateStringWithInt.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("invalidChar.kt")
|
||||
public void testInvalidChar() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertToStringTemplate/invalidChar.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt11295.kt")
|
||||
public void testKt11295() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertToStringTemplate/kt11295.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("lambdaInParentheses.kt")
|
||||
public void testLambdaInParentheses() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertToStringTemplate/lambdaInParentheses.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("lambdaWithLabel.kt")
|
||||
public void testLambdaWithLabel() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertToStringTemplate/lambdaWithLabel.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("lambdaWithLabelInParentheses.kt")
|
||||
public void testLambdaWithLabelInParentheses() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertToStringTemplate/lambdaWithLabelInParentheses.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("longTemplatePlusStringLiteral.kt")
|
||||
public void testLongTemplatePlusStringLiteral() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertToStringTemplate/longTemplatePlusStringLiteral.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("multilineString.kt")
|
||||
public void testMultilineString() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertToStringTemplate/multilineString.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("newLine.kt")
|
||||
public void testNewLine() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertToStringTemplate/newLine.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("noBracesForLastSimpleExpression.kt")
|
||||
public void testNoBracesForLastSimpleExpression() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertToStringTemplate/noBracesForLastSimpleExpression.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("noBracesSimpleFollowedByDot.kt")
|
||||
public void testNoBracesSimpleFollowedByDot() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertToStringTemplate/noBracesSimpleFollowedByDot.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("notApplicableForErrorElement.kt")
|
||||
public void testNotApplicableForErrorElement() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertToStringTemplate/notApplicableForErrorElement.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("numberLiterals.kt")
|
||||
public void testNumberLiterals() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertToStringTemplate/numberLiterals.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("onMultipleLines.kt")
|
||||
public void testOnMultipleLines() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertToStringTemplate/onMultipleLines.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("onlyForConcat.kt")
|
||||
public void testOnlyForConcat() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertToStringTemplate/onlyForConcat.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("onlyForStrings.kt")
|
||||
public void testOnlyForStrings() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertToStringTemplate/onlyForStrings.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("plusOperatorReturnsString.kt")
|
||||
public void testPlusOperatorReturnsString() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertToStringTemplate/plusOperatorReturnsString.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("requiresPlusOperator.kt")
|
||||
public void testRequiresPlusOperator() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertToStringTemplate/requiresPlusOperator.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("simple.kt")
|
||||
public void testSimple() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertToStringTemplate/simple.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("specialCharsInCharLiteral.kt")
|
||||
public void testSpecialCharsInCharLiteral() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertToStringTemplate/specialCharsInCharLiteral.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("startsWithNullableVariable.kt")
|
||||
public void testStartsWithNullableVariable() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertToStringTemplate/startsWithNullableVariable.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("stringPlusStringLiteral.kt")
|
||||
public void testStringPlusStringLiteral() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertToStringTemplate/stringPlusStringLiteral.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("superToString.kt")
|
||||
public void testSuperToString() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertToStringTemplate/superToString.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("templatePlusStringLiteral.kt")
|
||||
public void testTemplatePlusStringLiteral() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertToStringTemplate/templatePlusStringLiteral.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("this.kt")
|
||||
public void testThis() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertToStringTemplate/this.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("this2.kt")
|
||||
public void testThis2() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertToStringTemplate/this2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("this3.kt")
|
||||
public void testThis3() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertToStringTemplate/this3.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("toString.kt")
|
||||
public void testToString() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertToStringTemplate/toString.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("tricky.kt")
|
||||
public void testTricky() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertToStringTemplate/tricky.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("unescapeSingleQuote.kt")
|
||||
public void testUnescapeSingleQuote() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertToStringTemplate/unescapeSingleQuote.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
@TestMetadata("../idea/tests/testData/intentions/convertTryFinallyToUseCall")
|
||||
public static class ConvertTryFinallyToUseCall extends AbstractFe10BindingIntentionTest {
|
||||
@java.lang.Override
|
||||
@org.jetbrains.annotations.NotNull
|
||||
public final KotlinPluginMode getPluginMode() {
|
||||
return KotlinPluginMode.K2;
|
||||
}
|
||||
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
|
||||
}
|
||||
|
||||
@TestMetadata("catch.kt")
|
||||
public void testCatch() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertTryFinallyToUseCall/catch.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("example.kt")
|
||||
public void testExample() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertTryFinallyToUseCall/example.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("implicitReceiver.kt")
|
||||
public void testImplicitReceiver() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertTryFinallyToUseCall/implicitReceiver.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("notClose.kt")
|
||||
public void testNotClose() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertTryFinallyToUseCall/notClose.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("notCloseableClose.kt")
|
||||
public void testNotCloseableClose() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertTryFinallyToUseCall/notCloseableClose.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("notCloseableClose2.kt")
|
||||
public void testNotCloseableClose2() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertTryFinallyToUseCall/notCloseableClose2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("notOnlyClose.kt")
|
||||
public void testNotOnlyClose() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertTryFinallyToUseCall/notOnlyClose.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("parameter.kt")
|
||||
public void testParameter() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertTryFinallyToUseCall/parameter.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("safeCall.kt")
|
||||
public void testSafeCall() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertTryFinallyToUseCall/safeCall.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("simple.kt")
|
||||
public void testSimple() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertTryFinallyToUseCall/simple.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("this.kt")
|
||||
public void testThis() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertTryFinallyToUseCall/this.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("thisLabeled.kt")
|
||||
public void testThisLabeled() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertTryFinallyToUseCall/thisLabeled.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("triple.kt")
|
||||
public void testTriple() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertTryFinallyToUseCall/triple.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("wrongCaret.kt")
|
||||
public void testWrongCaret() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/convertTryFinallyToUseCall/wrongCaret.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
@TestMetadata("../idea/tests/testData/intentions/removeRedundantCallsOfConversionMethods")
|
||||
public static class RemoveRedundantCallsOfConversionMethods extends AbstractFe10BindingIntentionTest {
|
||||
@java.lang.Override
|
||||
@org.jetbrains.annotations.NotNull
|
||||
public final KotlinPluginMode getPluginMode() {
|
||||
return KotlinPluginMode.K2;
|
||||
}
|
||||
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
|
||||
}
|
||||
|
||||
@TestMetadata("booleanToInt.kt")
|
||||
public void testBooleanToInt() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/removeRedundantCallsOfConversionMethods/booleanToInt.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("byte.kt")
|
||||
public void testByte() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/removeRedundantCallsOfConversionMethods/byte.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("char.kt")
|
||||
public void testChar() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/removeRedundantCallsOfConversionMethods/char.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("double.kt")
|
||||
public void testDouble() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/removeRedundantCallsOfConversionMethods/double.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("float.kt")
|
||||
public void testFloat() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/removeRedundantCallsOfConversionMethods/float.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("int.kt")
|
||||
public void testInt() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/removeRedundantCallsOfConversionMethods/int.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("long.kt")
|
||||
public void testLong() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/removeRedundantCallsOfConversionMethods/long.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nullable.kt")
|
||||
public void testNullable() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/removeRedundantCallsOfConversionMethods/nullable.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nullable2.kt")
|
||||
public void testNullable2() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/removeRedundantCallsOfConversionMethods/nullable2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("safeString.kt")
|
||||
public void testSafeString() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/removeRedundantCallsOfConversionMethods/safeString.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("safeString2.kt")
|
||||
public void testSafeString2() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/removeRedundantCallsOfConversionMethods/safeString2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("short.kt")
|
||||
public void testShort() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/removeRedundantCallsOfConversionMethods/short.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("string.kt")
|
||||
public void testString() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/removeRedundantCallsOfConversionMethods/string.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("toOtherType.kt")
|
||||
public void testToOtherType() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/removeRedundantCallsOfConversionMethods/toOtherType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("uByte.kt")
|
||||
public void testUByte() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/removeRedundantCallsOfConversionMethods/uByte.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("uInt.kt")
|
||||
public void testUInt() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/removeRedundantCallsOfConversionMethods/uInt.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("uLong.kt")
|
||||
public void testULong() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/removeRedundantCallsOfConversionMethods/uLong.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("uShort.kt")
|
||||
public void testUShort() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/removeRedundantCallsOfConversionMethods/uShort.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("variable.kt")
|
||||
public void testVariable() throws Exception {
|
||||
runTest("../idea/tests/testData/intentions/removeRedundantCallsOfConversionMethods/variable.kt");
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,113 +0,0 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
|
||||
package org.jetbrains.kotlin.idea.k2.fe10bindings.inspections;
|
||||
|
||||
import com.intellij.testFramework.TestDataPath;
|
||||
import org.jetbrains.kotlin.idea.base.plugin.KotlinPluginMode;
|
||||
import org.jetbrains.kotlin.idea.base.test.TestRoot;
|
||||
import org.jetbrains.kotlin.idea.test.JUnit3RunnerWithInners;
|
||||
import org.jetbrains.kotlin.idea.test.KotlinTestUtils;
|
||||
import org.jetbrains.kotlin.test.TestMetadata;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
/**
|
||||
* This class is generated by {@link org.jetbrains.kotlin.testGenerator.generator.TestGenerator}.
|
||||
* DO NOT MODIFY MANUALLY.
|
||||
*/
|
||||
@SuppressWarnings("all")
|
||||
@TestRoot("k2-fe10-bindings")
|
||||
@TestDataPath("$CONTENT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public abstract class Fe10BindingQuickFixTestGenerated extends AbstractFe10BindingQuickFixTest {
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
@TestMetadata("../idea/tests/testData/quickfix/addVarianceModifier")
|
||||
public static class AddVarianceModifier extends AbstractFe10BindingQuickFixTest {
|
||||
@java.lang.Override
|
||||
@org.jetbrains.annotations.NotNull
|
||||
public final KotlinPluginMode getPluginMode() {
|
||||
return KotlinPluginMode.K2;
|
||||
}
|
||||
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
|
||||
}
|
||||
|
||||
@TestMetadata("abstractIn.kt")
|
||||
public void testAbstractIn() throws Exception {
|
||||
runTest("../idea/tests/testData/quickfix/addVarianceModifier/abstractIn.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("abstractOut.kt")
|
||||
public void testAbstractOut() throws Exception {
|
||||
runTest("../idea/tests/testData/quickfix/addVarianceModifier/abstractOut.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("emptyTest.kt")
|
||||
public void testEmptyTest() throws Exception {
|
||||
runTest("../idea/tests/testData/quickfix/addVarianceModifier/emptyTest.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
@TestMetadata("../idea/tests/testData/quickfix/kdocMissingDocumentation")
|
||||
public static class KdocMissingDocumentation extends AbstractFe10BindingQuickFixTest {
|
||||
@java.lang.Override
|
||||
@org.jetbrains.annotations.NotNull
|
||||
public final KotlinPluginMode getPluginMode() {
|
||||
return KotlinPluginMode.K2;
|
||||
}
|
||||
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
|
||||
}
|
||||
|
||||
@TestMetadata("simple.kt")
|
||||
public void testSimple() throws Exception {
|
||||
runTest("../idea/tests/testData/quickfix/kdocMissingDocumentation/simple.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("withIndentation.kt")
|
||||
public void testWithIndentation() throws Exception {
|
||||
runTest("../idea/tests/testData/quickfix/kdocMissingDocumentation/withIndentation.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
@TestMetadata("../idea/tests/testData/quickfix/memberVisibilityCanBePrivate")
|
||||
public static class MemberVisibilityCanBePrivate extends AbstractFe10BindingQuickFixTest {
|
||||
@java.lang.Override
|
||||
@org.jetbrains.annotations.NotNull
|
||||
public final KotlinPluginMode getPluginMode() {
|
||||
return KotlinPluginMode.K2;
|
||||
}
|
||||
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
|
||||
}
|
||||
|
||||
@TestMetadata("constructorParam.kt")
|
||||
public void testConstructorParam() throws Exception {
|
||||
runTest("../idea/tests/testData/quickfix/memberVisibilityCanBePrivate/constructorParam.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("internal.kt")
|
||||
public void testInternal() throws Exception {
|
||||
runTest("../idea/tests/testData/quickfix/memberVisibilityCanBePrivate/internal.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("noModifier.kt")
|
||||
public void testNoModifier() throws Exception {
|
||||
runTest("../idea/tests/testData/quickfix/memberVisibilityCanBePrivate/noModifier.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("protected.kt")
|
||||
public void testProtected() throws Exception {
|
||||
runTest("../idea/tests/testData/quickfix/memberVisibilityCanBePrivate/protected.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("public.kt")
|
||||
public void testPublic() throws Exception {
|
||||
runTest("../idea/tests/testData/quickfix/memberVisibilityCanBePrivate/public.kt");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package org.jetbrains.kotlin.idea.k2.fe10bindings.inspections
|
||||
|
||||
import com.intellij.openapi.Disposable
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.testFramework.registerOrReplaceServiceInstance
|
||||
import org.jetbrains.kotlin.analysis.api.KtAnalysisApiInternals
|
||||
import org.jetbrains.kotlin.analysis.api.platform.lifetime.KotlinLifetimeTokenProvider
|
||||
import org.jetbrains.kotlin.idea.fir.fe10.KtLifetimeTokenForKtSymbolBasedWrappers
|
||||
import org.jetbrains.kotlin.idea.fir.fe10.KtLifetimeTokenForKtSymbolBasedWrappersFactory
|
||||
|
||||
@OptIn(KtAnalysisApiInternals::class)
|
||||
internal fun Project.registerLifetimeTokenFactoryForFe10Binding(disposable: Disposable) {
|
||||
val token = KtLifetimeTokenForKtSymbolBasedWrappers(this)
|
||||
val factory = KtLifetimeTokenForKtSymbolBasedWrappersFactory(token)
|
||||
registerOrReplaceServiceInstance(
|
||||
KotlinLifetimeTokenProvider::class.java,
|
||||
object : KotlinLifetimeTokenProvider() {
|
||||
override fun getLifetimeTokenFactory() = factory
|
||||
},
|
||||
parentDisposable = disposable
|
||||
)
|
||||
}
|
||||
@@ -43,7 +43,6 @@
|
||||
<orderEntry type="module" module-name="kotlin.project-wizard.tests" scope="TEST" />
|
||||
<orderEntry type="module" module-name="kotlin.j2k.k1.new.tests" scope="TEST" />
|
||||
<orderEntry type="module" module-name="kotlin.j2k.k2.tests" scope="TEST" />
|
||||
<orderEntry type="module" module-name="kotlin.k2.fe10-bindings" scope="TEST" />
|
||||
<orderEntry type="module" module-name="kotlin.fir.fir-low-level-api-ide-impl" scope="TEST" />
|
||||
<orderEntry type="module" module-name="kotlin.uast.uast-kotlin.k2.tests" scope="TEST" />
|
||||
<orderEntry type="module" module-name="kotlin.tests-common" scope="TEST" />
|
||||
|
||||
@@ -76,7 +76,6 @@ fun generateK2Tests(isUpToDateCheck: Boolean = false) {
|
||||
|
||||
private fun assembleWorkspace(): TWorkspace = workspace(KotlinPluginMode.K2) {
|
||||
generateK2CodeInsightTests()
|
||||
generateK2Fe10BindingsTests()
|
||||
generateK2NavigationTests()
|
||||
generateK2DebuggerTests()
|
||||
generateK2HighlighterTests()
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package org.jetbrains.kotlin.fir.testGenerator
|
||||
|
||||
import org.jetbrains.kotlin.idea.k2.fe10bindings.inspections.AbstractFe10BindingIntentionTest
|
||||
import org.jetbrains.kotlin.idea.k2.fe10bindings.inspections.AbstractFe10BindingLocalInspectionTest
|
||||
import org.jetbrains.kotlin.idea.k2.fe10bindings.inspections.AbstractFe10BindingQuickFixTest
|
||||
import org.jetbrains.kotlin.testGenerator.model.*
|
||||
import org.jetbrains.kotlin.testGenerator.model.GroupCategory.*
|
||||
|
||||
internal fun MutableTWorkspace.generateK2Fe10BindingsTests() {
|
||||
testGroup("k2-fe10-bindings", testDataPath = "../idea/tests", category = INTENTIONS) {
|
||||
testClass<AbstractFe10BindingIntentionTest> {
|
||||
val pattern = Patterns.forRegex("^([\\w\\-_]+)\\.(kt|kts)$")
|
||||
model("testData/intentions/conventionNameCalls", pattern = pattern)
|
||||
model("testData/intentions/convertSecondaryConstructorToPrimary", pattern = pattern)
|
||||
model("testData/intentions/convertToStringTemplate", pattern = pattern)
|
||||
model("testData/intentions/convertTryFinallyToUseCall", pattern = pattern)
|
||||
model("testData/intentions/removeRedundantCallsOfConversionMethods", pattern = pattern)
|
||||
}
|
||||
}
|
||||
|
||||
testGroup("k2-fe10-bindings", testDataPath = "../idea/tests", category = INSPECTIONS) {
|
||||
testClass<AbstractFe10BindingLocalInspectionTest> {
|
||||
val pattern = Patterns.forRegex("^([\\w\\-_]+)\\.(kt|kts)$")
|
||||
model("testData/inspectionsLocal/addOperatorModifier", pattern = pattern)
|
||||
model("testData/inspectionsLocal/booleanLiteralArgument", pattern = pattern)
|
||||
model("testData/inspectionsLocal/convertSealedSubClassToObject", pattern = pattern)
|
||||
model("testData/inspectionsLocal/cascadeIf", pattern = pattern)
|
||||
model("testData/inspectionsLocal/collections/convertCallChainIntoSequence", pattern = pattern)
|
||||
model("testData/inspectionsLocal/convertNaNEquality", pattern = pattern)
|
||||
model("testData/inspectionsLocal/convertPairConstructorToToFunction", pattern = pattern)
|
||||
model("testData/inspectionsLocal/copyWithoutNamedArguments", pattern = pattern)
|
||||
model("testData/inspectionsLocal/branched/introduceWhenSubject", pattern = pattern)
|
||||
model("testData/inspectionsLocal/kdocMissingDocumentation", pattern = pattern)
|
||||
model("testData/inspectionsLocal/forEachParameterNotUsed", pattern = pattern)
|
||||
model("testData/inspectionsLocal/covariantEquals", pattern = pattern)
|
||||
model("testData/inspectionsLocal/lateinitVarOverridesLateinitVar", pattern = pattern)
|
||||
model("testData/inspectionsLocal/foldInitializerAndIfToElvis", pattern = pattern)
|
||||
model("testData/inspectionsLocal/mapGetWithNotNullAssertionOperator", pattern = pattern)
|
||||
model("testData/inspectionsLocal/memberVisibilityCanBePrivate", pattern = pattern)
|
||||
model("testData/inspectionsLocal/redundantObjectTypeCheck", pattern = pattern)
|
||||
model("testData/inspectionsLocal/redundantExplicitType", pattern = pattern)
|
||||
model("testData/inspectionsLocal/replaceArrayEqualityOpWithArraysEquals", pattern = pattern)
|
||||
model("testData/inspectionsLocal/replaceAssociateFunction", pattern = pattern)
|
||||
model("testData/inspectionsLocal/replaceIsEmptyWithIfEmpty", pattern = pattern)
|
||||
}
|
||||
}
|
||||
|
||||
testGroup("k2-fe10-bindings", testDataPath = "../idea/tests", category = QUICKFIXES) {
|
||||
testClass<AbstractFe10BindingQuickFixTest> {
|
||||
val pattern = Patterns.forRegex("^([\\w\\-_]+)\\.kt$")
|
||||
model("testData/quickfix/addVarianceModifier", pattern = pattern)
|
||||
model("testData/quickfix/kdocMissingDocumentation", pattern = pattern)
|
||||
model("testData/quickfix/memberVisibilityCanBePrivate", pattern = pattern)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user