From 108ed55ac28358baf46b02d5fdb99bbd053eab30 Mon Sep 17 00:00:00 2001 From: Chris Penner Date: Fri, 16 Aug 2024 17:59:18 -0700 Subject: [PATCH] Use similar leaf-node logic on other mismatches --- unison-cli/src/Unison/LSP/FileAnalysis.hs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/unison-cli/src/Unison/LSP/FileAnalysis.hs b/unison-cli/src/Unison/LSP/FileAnalysis.hs index ee3276743c..0463ff94c1 100644 --- a/unison-cli/src/Unison/LSP/FileAnalysis.hs +++ b/unison-cli/src/Unison/LSP/FileAnalysis.hs @@ -224,12 +224,9 @@ analyseNotes codebase fileUri ppe src notes = do Result.TypeError errNote@(Context.ErrorNote {cause}) -> do let typeErr = TypeError.typeErrorFromNote errNote ranges = case typeErr of - TypeError.Mismatch {mismatchSite} -> do - let locs = ABT.annotation <$> expressionLeafNodes mismatchSite - (r, rs) <- withNeighbours (locs >>= aToR) - pure (r, ("mismatch",) <$> rs) - TypeError.BooleanMismatch {mismatchSite} -> singleRange $ ABT.annotation mismatchSite - TypeError.ExistentialMismatch {mismatchSite} -> singleRange $ ABT.annotation mismatchSite + TypeError.Mismatch {mismatchSite} -> leafNodeRanges "mismatch" mismatchSite + TypeError.BooleanMismatch {mismatchSite} -> leafNodeRanges "mismatch" mismatchSite + TypeError.ExistentialMismatch {mismatchSite} -> leafNodeRanges "mismatch" mismatchSite TypeError.FunctionApplication {f} -> singleRange $ ABT.annotation f TypeError.NotFunctionApplication {f} -> singleRange $ ABT.annotation f TypeError.AbilityCheckFailure {abilityCheckFailureSite} -> singleRange abilityCheckFailureSite @@ -323,6 +320,10 @@ analyseNotes codebase fileUri ppe src notes = do Context.OtherBug _s -> todoAnnotation pure (noteDiagnostic note ranges, []) where + leafNodeRanges label mismatchSite = do + let locs = ABT.annotation <$> expressionLeafNodes mismatchSite + (r, rs) <- withNeighbours (locs >>= aToR) + pure (r, (label,) <$> rs) -- Diagnostics with this return value haven't been properly configured yet. todoAnnotation = [] singleRange :: Ann -> [(Range, [a])]