better rendering of conflicted names in todo

This commit is contained in:
Mitchell Rosen 2024-07-09 18:58:42 -04:00
parent 1e5b925bca
commit d78154d7c1
2 changed files with 17 additions and 14 deletions

View File

@ -2593,20 +2593,20 @@ unsafePrettyTermResultSig' ppe = \case
head (TypePrinter.prettySignaturesCT ppe [(r, name, typ)])
_ -> error "Don't pass Nothing"
renderNameConflicts :: PPE.PrettyPrintEnv -> Names -> Numbered Pretty
renderNameConflicts ppe conflictedNames = do
renderNameConflicts :: Int -> Names -> Numbered Pretty
renderNameConflicts hashLen conflictedNames = do
let conflictedTypeNames :: Map Name [HQ.HashQualified Name]
conflictedTypeNames =
conflictedNames
& Names.types
& R.domain
& fmap (foldMap (pure @[] . PPE.typeName ppe))
& Map.mapWithKey \name -> map (HQ.take hashLen . HQ.HashQualified name . Reference.toShortHash) . Set.toList
let conflictedTermNames :: Map Name [HQ.HashQualified Name]
conflictedTermNames =
conflictedNames
& Names.terms
& R.domain
& fmap (foldMap (pure @[] . PPE.termName ppe))
& Map.mapWithKey \name -> map (HQ.take hashLen . HQ.HashQualified name . Referent.toShortHash) . Set.toList
let allConflictedNames :: [Name]
allConflictedNames = Set.toList (Map.keysSet conflictedTermNames <> Map.keysSet conflictedTypeNames)
prettyConflictedTypes <- showConflictedNames "type" conflictedTypeNames
@ -2639,13 +2639,14 @@ renderNameConflicts ppe conflictedNames = do
prettyConflicts <- for hashes \hash -> do
n <- addNumberedArg $ SA.HashQualified hash
pure $ formatNum n <> (P.blue . P.syntaxToColor . prettyHashQualified $ hash)
pure . P.wrap $
( "The "
<> thingKind
<> " "
<> P.green (prettyName name)
<> " has conflicting definitions:"
)
pure $
P.wrap
( "The "
<> thingKind
<> " "
<> P.green (prettyName name)
<> " has conflicting definitions:"
)
<> P.newline
<> P.newline
<> P.indentN 2 (P.lines prettyConflicts)
@ -2722,7 +2723,7 @@ handleTodoOutput todo
prettyConflicts <-
if todo.nameConflicts == mempty
then pure mempty
else renderNameConflicts todo.ppe.unsuffixifiedPPE todo.nameConflicts
else renderNameConflicts todo.hashLen todo.nameConflicts
let prettyDefnsInLib =
if todo.defnsInLib

View File

@ -139,8 +139,10 @@ scratch/main> todo
The term bar has conflicting definitions: 1. foo 2.
bar#cq22mm4sca
The term bar has conflicting definitions:
1. bar#14ibahkll6
2. bar#cq22mm4sca
Tip: Use `move.term` or `delete.term` to resolve the
conflicts.