[FIR IDE] Initial descriptor-based implementation of the Analysis API
This commit is contained in:
committed by
teamcityserver
parent
e2c9be0932
commit
516dd825c2
+5
-7
@@ -19,25 +19,23 @@ package org.jetbrains.kotlin.descriptors.impl
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.PropertyAccessorDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.SourceElement
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.psi.KtProperty
|
||||
import org.jetbrains.kotlin.resolve.source.toSourceElement
|
||||
|
||||
class SyntheticFieldDescriptor private constructor(
|
||||
val propertyDescriptor: PropertyDescriptor,
|
||||
accessorDescriptor: PropertyAccessorDescriptor,
|
||||
property: KtProperty
|
||||
sourceElement: SourceElement
|
||||
) : LocalVariableDescriptor(
|
||||
accessorDescriptor, Annotations.EMPTY, SyntheticFieldDescriptor.NAME,
|
||||
propertyDescriptor.type, propertyDescriptor.isVar, false, false,
|
||||
property.toSourceElement()
|
||||
sourceElement
|
||||
) {
|
||||
|
||||
constructor(
|
||||
accessorDescriptor: PropertyAccessorDescriptor,
|
||||
property: KtProperty
|
||||
) : this(accessorDescriptor.correspondingProperty, accessorDescriptor, property)
|
||||
sourceElement: SourceElement
|
||||
) : this(accessorDescriptor.correspondingProperty, accessorDescriptor, sourceElement)
|
||||
|
||||
override fun getDispatchReceiverParameter() = null
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt;
|
||||
import org.jetbrains.kotlin.resolve.lazy.ForceResolveUtil;
|
||||
import org.jetbrains.kotlin.resolve.multiplatform.ExpectedActualResolver;
|
||||
import org.jetbrains.kotlin.resolve.scopes.*;
|
||||
import org.jetbrains.kotlin.resolve.source.KotlinSourceElementKt;
|
||||
import org.jetbrains.kotlin.types.*;
|
||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingContext;
|
||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingServices;
|
||||
@@ -1013,7 +1014,8 @@ public class BodyResolver {
|
||||
if (functionDescriptor instanceof PropertyAccessorDescriptor && functionDescriptor.getExtensionReceiverParameter() == null) {
|
||||
PropertyAccessorDescriptor accessorDescriptor = (PropertyAccessorDescriptor) functionDescriptor;
|
||||
KtProperty property = (KtProperty) function.getParent();
|
||||
SyntheticFieldDescriptor fieldDescriptor = new SyntheticFieldDescriptor(accessorDescriptor, property);
|
||||
SourceElement propertySourceElement = KotlinSourceElementKt.toSourceElement(property);
|
||||
SyntheticFieldDescriptor fieldDescriptor = new SyntheticFieldDescriptor(accessorDescriptor, propertySourceElement);
|
||||
innerScope = new LexicalScopeImpl(innerScope, functionDescriptor, true, null,
|
||||
LexicalScopeKind.PROPERTY_ACCESSOR_BODY,
|
||||
LocalRedeclarationChecker.DO_NOTHING.INSTANCE, handler -> {
|
||||
|
||||
@@ -591,6 +591,10 @@ public class KtPsiUtil {
|
||||
((KtBinaryExpression) element).getOperationToken().equals(KtTokens.EQ);
|
||||
}
|
||||
|
||||
public static boolean isCast(@NotNull KtBinaryExpressionWithTypeRHS expression) {
|
||||
return isSafeCast(expression) || isUnsafeCast(expression);
|
||||
}
|
||||
|
||||
public static boolean isSafeCast(@NotNull KtBinaryExpressionWithTypeRHS expression) {
|
||||
return expression.getOperationReference().getReferencedNameElementType() == KtTokens.AS_SAFE;
|
||||
}
|
||||
|
||||
+1
-1
@@ -88,7 +88,7 @@ object JvmResolveUtil {
|
||||
fun analyze(files: Collection<KtFile>, environment: KotlinCoreEnvironment, configuration: CompilerConfiguration): AnalysisResult =
|
||||
analyze(environment.project, files, configuration, environment::createPackagePartProvider)
|
||||
|
||||
private fun analyze(
|
||||
fun analyze(
|
||||
project: Project,
|
||||
files: Collection<KtFile>,
|
||||
configuration: CompilerConfiguration,
|
||||
|
||||
Reference in New Issue
Block a user