[NI] Provide diagnostics for candidates in "allCandidates" mode
This helps for completion as it use diagnostics to clip extra candidates
This commit is contained in:
@@ -189,9 +189,12 @@ class PSICallResolver(
|
||||
tracingStrategy: TracingStrategy
|
||||
): OverloadResolutionResults<D> {
|
||||
if (result is AllCandidatesResolutionResult) {
|
||||
val resolvedCalls = result.allCandidates.map {
|
||||
val resultingSubstitutor = it.getSystem().asReadOnlyStorage().buildResultingSubstitutor()
|
||||
kotlinToResolvedCallTransformer.transformToResolvedCall<D>(it.resolvedCall, null, resultingSubstitutor, result.diagnostics)
|
||||
val resolvedCalls = result.allCandidates.map { (candidate, diagnostics) ->
|
||||
val resultingSubstitutor = candidate.getSystem().asReadOnlyStorage().buildResultingSubstitutor()
|
||||
|
||||
kotlinToResolvedCallTransformer.transformToResolvedCall<D>(
|
||||
candidate.resolvedCall, null, resultingSubstitutor, diagnostics
|
||||
)
|
||||
}
|
||||
|
||||
return AllCandidates(resolvedCalls)
|
||||
|
||||
+6
-3
@@ -58,8 +58,9 @@ class KotlinCallCompleter(
|
||||
expectedType: UnwrappedType?,
|
||||
resolutionCallbacks: KotlinResolutionCallbacks
|
||||
): CallResolutionResult {
|
||||
val diagnosticsHolder = KotlinDiagnosticsHolder.SimpleHolder()
|
||||
for (candidate in candidates) {
|
||||
val completedCandidates = candidates.map { candidate ->
|
||||
val diagnosticsHolder = KotlinDiagnosticsHolder.SimpleHolder()
|
||||
|
||||
candidate.addExpectedTypeConstraint(
|
||||
candidate.returnTypeWithSmartCastInfo(resolutionCallbacks), expectedType, resolutionCallbacks
|
||||
)
|
||||
@@ -72,8 +73,10 @@ class KotlinCallCompleter(
|
||||
resolutionCallbacks,
|
||||
collectAllCandidatesMode = true
|
||||
)
|
||||
|
||||
CandidateWithDiagnostics(candidate, diagnosticsHolder.getDiagnostics() + candidate.diagnosticsFromResolutionParts)
|
||||
}
|
||||
return AllCandidatesResolutionResult(candidates)
|
||||
return AllCandidatesResolutionResult(completedCandidates)
|
||||
}
|
||||
|
||||
private fun KotlinResolutionCandidate.runCompletion(
|
||||
|
||||
@@ -203,9 +203,11 @@ class ErrorCallResolutionResult(
|
||||
) : SingleCallResolutionResult(resultCallAtom, diagnostics, constraintSystem)
|
||||
|
||||
class AllCandidatesResolutionResult(
|
||||
val allCandidates: Collection<KotlinResolutionCandidate>
|
||||
val allCandidates: Collection<CandidateWithDiagnostics>
|
||||
) : CallResolutionResult(null, emptyList(), ConstraintStorage.Empty)
|
||||
|
||||
data class CandidateWithDiagnostics(val candidate: KotlinResolutionCandidate, val diagnostics: List<KotlinCallDiagnostic>)
|
||||
|
||||
fun CallResolutionResult.resultCallAtom(): ResolvedCallAtom? =
|
||||
if (this is SingleCallResolutionResult) resultCallAtom else null
|
||||
|
||||
|
||||
Reference in New Issue
Block a user