[NI] Refactoring: extract method to create resolution result out
This commit is contained in:
+22
-24
@@ -49,8 +49,6 @@ class KotlinCallCompleter(
|
|||||||
// this is needed at least for non-local return checker, because when we analyze lambda we should already bind descriptor for outer call
|
// this is needed at least for non-local return checker, because when we analyze lambda we should already bind descriptor for outer call
|
||||||
candidate?.resolvedCall?.let { resolutionCallbacks.bindStubResolvedCallForCandidate(it) }
|
candidate?.resolvedCall?.let { resolutionCallbacks.bindStubResolvedCallForCandidate(it) }
|
||||||
|
|
||||||
val diagnosticsFromResolutionParts = candidate?.diagnosticsFromResolutionParts ?: emptyList<KotlinCallDiagnostic>()
|
|
||||||
|
|
||||||
if (candidate == null || candidate.csBuilder.hasContradiction) {
|
if (candidate == null || candidate.csBuilder.hasContradiction) {
|
||||||
val candidateForCompletion = candidate ?: factory.createErrorCandidate().forceResolution()
|
val candidateForCompletion = candidate ?: factory.createErrorCandidate().forceResolution()
|
||||||
candidateForCompletion.prepareForCompletion(expectedType, resolutionCallbacks)
|
candidateForCompletion.prepareForCompletion(expectedType, resolutionCallbacks)
|
||||||
@@ -62,34 +60,19 @@ class KotlinCallCompleter(
|
|||||||
resolutionCallbacks
|
resolutionCallbacks
|
||||||
)
|
)
|
||||||
|
|
||||||
val systemStorage = candidate?.getSystem()?.asReadOnlyStorage() ?: ConstraintStorage.Empty
|
return candidate.asCallResolutionResult(CallResolutionResult.Type.ERROR, diagnosticHolder)
|
||||||
return CallResolutionResult(
|
|
||||||
CallResolutionResult.Type.ERROR,
|
|
||||||
candidate?.resolvedCall,
|
|
||||||
diagnosticHolder.getDiagnostics() + diagnosticsFromResolutionParts,
|
|
||||||
systemStorage
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val completionType = candidate.prepareForCompletion(expectedType, resolutionCallbacks)
|
val completionType = candidate.prepareForCompletion(expectedType, resolutionCallbacks)
|
||||||
val constraintSystem = candidate.getSystem()
|
val constraintSystem = candidate.getSystem()
|
||||||
runCompletion(candidate.resolvedCall, completionType, diagnosticHolder, constraintSystem, resolutionCallbacks)
|
runCompletion(candidate.resolvedCall, completionType, diagnosticHolder, constraintSystem, resolutionCallbacks)
|
||||||
|
|
||||||
return if (completionType == ConstraintSystemCompletionMode.FULL) {
|
val callResolutionType = if (completionType == ConstraintSystemCompletionMode.FULL)
|
||||||
CallResolutionResult(
|
CallResolutionResult.Type.COMPLETED
|
||||||
CallResolutionResult.Type.COMPLETED,
|
else
|
||||||
candidate.resolvedCall,
|
CallResolutionResult.Type.PARTIAL
|
||||||
diagnosticHolder.getDiagnostics() + diagnosticsFromResolutionParts,
|
|
||||||
constraintSystem.asReadOnlyStorage()
|
return candidate.asCallResolutionResult(callResolutionType, diagnosticHolder)
|
||||||
)
|
|
||||||
} else {
|
|
||||||
CallResolutionResult(
|
|
||||||
CallResolutionResult.Type.PARTIAL,
|
|
||||||
candidate.resolvedCall,
|
|
||||||
diagnosticHolder.getDiagnostics() + diagnosticsFromResolutionParts,
|
|
||||||
constraintSystem.asReadOnlyStorage()
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun createAllCandidatesResult(
|
fun createAllCandidatesResult(
|
||||||
@@ -165,4 +148,19 @@ class KotlinCallCompleter(
|
|||||||
ConstraintSystemCompletionMode.PARTIAL
|
ConstraintSystemCompletionMode.PARTIAL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun KotlinResolutionCandidate?.asCallResolutionResult(
|
||||||
|
type: CallResolutionResult.Type,
|
||||||
|
diagnosticsHolder: KotlinDiagnosticsHolder.SimpleHolder
|
||||||
|
): CallResolutionResult {
|
||||||
|
val diagnosticsFromResolutionParts = this?.diagnosticsFromResolutionParts ?: emptyList<KotlinCallDiagnostic>()
|
||||||
|
val systemStorage = this?.getSystem()?.asReadOnlyStorage() ?: ConstraintStorage.Empty
|
||||||
|
|
||||||
|
return CallResolutionResult(
|
||||||
|
type,
|
||||||
|
this?.resolvedCall,
|
||||||
|
diagnosticsHolder.getDiagnostics() + diagnosticsFromResolutionParts,
|
||||||
|
systemStorage
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user