[NI] Refactor: extract method to run candidate completion out
This commit is contained in:
+21
-23
@@ -38,29 +38,7 @@ class KotlinCallCompleter(
|
|||||||
val candidate = prepareCandidateForCompletion(factory, candidates, resolutionCallbacks)
|
val candidate = prepareCandidateForCompletion(factory, candidates, resolutionCallbacks)
|
||||||
val completionType = candidate.prepareForCompletion(expectedType, resolutionCallbacks)
|
val completionType = candidate.prepareForCompletion(expectedType, resolutionCallbacks)
|
||||||
|
|
||||||
if (ErrorUtils.isError(candidate.resolvedCall.candidateDescriptor) ||
|
return candidate.runCompletion(completionType, diagnosticHolder, resolutionCallbacks)
|
||||||
candidate.csBuilder.hasContradiction
|
|
||||||
) {
|
|
||||||
runCompletion(
|
|
||||||
candidate.resolvedCall,
|
|
||||||
ConstraintSystemCompletionMode.FULL,
|
|
||||||
diagnosticHolder,
|
|
||||||
candidate.getSystem(),
|
|
||||||
resolutionCallbacks
|
|
||||||
)
|
|
||||||
|
|
||||||
return candidate.asCallResolutionResult(CallResolutionResult.Type.ERROR, diagnosticHolder)
|
|
||||||
}
|
|
||||||
|
|
||||||
val constraintSystem = candidate.getSystem()
|
|
||||||
runCompletion(candidate.resolvedCall, completionType, diagnosticHolder, constraintSystem, resolutionCallbacks)
|
|
||||||
|
|
||||||
val callResolutionType = if (completionType == ConstraintSystemCompletionMode.FULL)
|
|
||||||
CallResolutionResult.Type.COMPLETED
|
|
||||||
else
|
|
||||||
CallResolutionResult.Type.PARTIAL
|
|
||||||
|
|
||||||
return candidate.asCallResolutionResult(callResolutionType, diagnosticHolder)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun createAllCandidatesResult(
|
fun createAllCandidatesResult(
|
||||||
@@ -83,6 +61,26 @@ class KotlinCallCompleter(
|
|||||||
return CallResolutionResult(CallResolutionResult.Type.ALL_CANDIDATES, null, emptyList(), ConstraintStorage.Empty, candidates)
|
return CallResolutionResult(CallResolutionResult.Type.ALL_CANDIDATES, null, emptyList(), ConstraintStorage.Empty, candidates)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun KotlinResolutionCandidate.runCompletion(
|
||||||
|
completionType: ConstraintSystemCompletionMode,
|
||||||
|
diagnosticHolder: KotlinDiagnosticsHolder.SimpleHolder,
|
||||||
|
resolutionCallbacks: KotlinResolutionCallbacks
|
||||||
|
): CallResolutionResult {
|
||||||
|
if (ErrorUtils.isError(resolvedCall.candidateDescriptor) || csBuilder.hasContradiction) {
|
||||||
|
runCompletion(resolvedCall, ConstraintSystemCompletionMode.FULL, diagnosticHolder, getSystem(), resolutionCallbacks)
|
||||||
|
return asCallResolutionResult(CallResolutionResult.Type.ERROR, diagnosticHolder)
|
||||||
|
}
|
||||||
|
|
||||||
|
runCompletion(resolvedCall, completionType, diagnosticHolder, getSystem(), resolutionCallbacks)
|
||||||
|
|
||||||
|
val callResolutionType = if (completionType == ConstraintSystemCompletionMode.FULL)
|
||||||
|
CallResolutionResult.Type.COMPLETED
|
||||||
|
else
|
||||||
|
CallResolutionResult.Type.PARTIAL
|
||||||
|
|
||||||
|
return asCallResolutionResult(callResolutionType, diagnosticHolder)
|
||||||
|
}
|
||||||
|
|
||||||
private fun runCompletion(
|
private fun runCompletion(
|
||||||
resolvedCallAtom: ResolvedCallAtom,
|
resolvedCallAtom: ResolvedCallAtom,
|
||||||
completionMode: ConstraintSystemCompletionMode,
|
completionMode: ConstraintSystemCompletionMode,
|
||||||
|
|||||||
Reference in New Issue
Block a user