[FE] Support analyzable files throughout all 'KtPsiFactory' API
Before, the only way of getting analyzable elements was to create an analyzable file by using 'createAnalyzableFile()'. So made all utilities available in 'KtPsiFactory' useless as they delegate to 'createFile()' that always set the 'doNotAnalyze' flag. The new behavior is to pass the 'analysisContext' instead if it is passed to the 'KtPsiFactory' constructor. The newly appeared API is going to be used in the Kotlin's UAST implementation.
This commit is contained in:
@@ -370,7 +370,7 @@ class DelegatedPropertyResolver(
|
||||
val hasThis = propertyDescriptor.extensionReceiverParameter != null || propertyDescriptor.dispatchReceiverParameter != null
|
||||
|
||||
val arguments = Lists.newArrayList<KtExpression>()
|
||||
val psiFactory = KtPsiFactory(delegateExpression, markGenerated = false)
|
||||
val psiFactory = KtPsiFactory(delegateExpression.project, markGenerated = false)
|
||||
arguments.add(psiFactory.createExpression(if (hasThis) "this" else "null"))
|
||||
arguments.add(psiFactory.createExpressionForProperty())
|
||||
|
||||
@@ -458,7 +458,7 @@ class DelegatedPropertyResolver(
|
||||
context: ExpressionTypingContext
|
||||
): OverloadResolutionResults<FunctionDescriptor> {
|
||||
val propertyHasReceiver = propertyDescriptor.dispatchReceiverParameter != null
|
||||
val arguments = KtPsiFactory(delegateExpression, markGenerated = false).run {
|
||||
val arguments = KtPsiFactory(delegateExpression.project, markGenerated = false).run {
|
||||
listOf(
|
||||
createExpression(if (propertyHasReceiver) "this" else "null"),
|
||||
createExpressionForProperty()
|
||||
|
||||
@@ -107,7 +107,7 @@ public class CallTransformer {
|
||||
this.explicitExtensionReceiver = explicitExtensionReceiver;
|
||||
this.calleeExpressionAsDispatchReceiver = calleeExpressionAsDispatchReceiver;
|
||||
this.fakeInvokeExpression =
|
||||
(KtSimpleNameExpression) KtPsiFactoryKt.KtPsiFactory(call.getCallElement(), false)
|
||||
(KtSimpleNameExpression) new KtPsiFactory(call.getCallElement().getProject(), false)
|
||||
.createExpression(OperatorNameConventions.INVOKE.asString());
|
||||
itIsVariableAsFunctionCall = functionCall;
|
||||
}
|
||||
|
||||
+1
-1
@@ -107,7 +107,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
|
||||
return getTypeInfoWhenOnlyOneBranchIsPresent(
|
||||
elseBranch, elseScope, elseInfo, thenInfo, context, ifExpression);
|
||||
}
|
||||
KtPsiFactory psiFactory = KtPsiFactoryKt.KtPsiFactory(ifExpression, false);
|
||||
KtPsiFactory psiFactory = new KtPsiFactory(ifExpression.getProject(), false);
|
||||
KtBlockExpression thenBlock = psiFactory.wrapInABlockWrapper(thenBranch);
|
||||
KtBlockExpression elseBlock = psiFactory.wrapInABlockWrapper(elseBranch);
|
||||
Call callForIf = createCallForSpecialConstruction(ifExpression, ifExpression, Lists.newArrayList(thenBlock, elseBlock));
|
||||
|
||||
+1
-1
@@ -271,7 +271,7 @@ class DoubleColonExpressionResolver(
|
||||
private fun KtQualifiedExpression.buildNewExpressionForReservedGenericPropertyCallChainResolution(): KtExpression? {
|
||||
val parts = this.getQualifierChainParts()?.map { it.getQualifiedNameStringPart() ?: return null } ?: return null
|
||||
val qualifiedExpressionText = parts.joinToString(separator = ".")
|
||||
return KtPsiFactory(this, markGenerated = false).createExpression(qualifiedExpressionText)
|
||||
return KtPsiFactory(project, markGenerated = false).createExpression(qualifiedExpressionText)
|
||||
}
|
||||
|
||||
private fun resolveReservedExpressionOnLHS(expression: KtExpression, c: ExpressionTypingContext): DoubleColonLHS.Expression? {
|
||||
|
||||
+1
-1
@@ -93,7 +93,7 @@ public class ExpressionTypingUtils {
|
||||
@NotNull String argumentName,
|
||||
@NotNull KotlinType argumentType
|
||||
) {
|
||||
KtExpression fakeExpression = KtPsiFactoryKt.KtPsiFactory(project, false).createExpression(argumentName);
|
||||
KtExpression fakeExpression = new KtPsiFactory(project, false).createExpression(argumentName);
|
||||
trace.recordType(fakeExpression, argumentType);
|
||||
trace.record(PROCESSED, fakeExpression);
|
||||
return fakeExpression;
|
||||
|
||||
+1
-1
@@ -334,7 +334,7 @@ class PatternMatchingTypingVisitor internal constructor(facade: ExpressionTyping
|
||||
}
|
||||
|
||||
private fun wrapWhenEntryExpressionsAsSpecialCallArguments(expression: KtWhenExpression): List<KtExpression> {
|
||||
val psiFactory = KtPsiFactory(expression)
|
||||
val psiFactory = KtPsiFactory(expression.project)
|
||||
return expression.entries.mapNotNull { whenEntry ->
|
||||
whenEntry.expression?.let { psiFactory.wrapInABlockWrapper(it) }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user