@@ -600,7 +600,20 @@ let getErrorString key = SR.GetString key
600
600
601
601
let (| InvalidArgument | _ |) ( exn : exn ) = match exn with :? ArgumentException as e -> Some e.Message | _ -> None
602
602
603
- let OutputPhasedErrorR ( os : StringBuilder ) ( err : PhasedDiagnostic ) ( suggestNames : bool ) =
603
+ let OutputPhasedErrorR ( os : StringBuilder ) ( err : PhasedDiagnostic ) ( canSuggestNames : bool ) =
604
+
605
+ let suggestNames suggestionsF idText =
606
+ if canSuggestNames then
607
+ let buffer = ErrorResolutionHints.SuggestionBuffer idText
608
+ if not buffer.Disabled then
609
+ suggestionsF buffer.Add
610
+ if not buffer.IsEmpty then
611
+ os.Append " " |> ignore
612
+ os.Append( FSComp.SR.undefinedNameSuggestionsIntro()) |> ignore
613
+ for value in buffer do
614
+ os.AppendLine() |> ignore
615
+ os.Append " " |> ignore
616
+ os.Append( DecompileOpName value) |> ignore
604
617
605
618
let rec OutputExceptionR ( os : StringBuilder ) error =
606
619
@@ -822,14 +835,10 @@ let OutputPhasedErrorR (os: StringBuilder) (err: PhasedDiagnostic) (suggestNames
822
835
823
836
| UndefinedName(_, k, id, suggestionsF) ->
824
837
os.Append( k ( DecompileOpName id.idText)) |> ignore
825
- if suggestNames then
826
- let filtered = ErrorResolutionHints.FilterPredictions suggestionsF id.idText
827
- if List.isEmpty filtered |> not then
828
- os.Append( ErrorResolutionHints.FormatPredictions DecompileOpName filtered) |> ignore
829
-
838
+ suggestNames suggestionsF id.idText
830
839
831
840
| InternalUndefinedItemRef( f, smr, ccuName, s) ->
832
- let _ , errs = f( smr, ccuName, s)
841
+ let _ , errs = f( smr, ccuName, s)
833
842
os.Append errs |> ignore
834
843
835
844
| FieldNotMutable _ ->
@@ -1363,10 +1372,7 @@ let OutputPhasedErrorR (os: StringBuilder) (err: PhasedDiagnostic) (suggestNames
1363
1372
1364
1373
| ErrorWithSuggestions ((_, s), _, idText, suggestionF) ->
1365
1374
os.Append( DecompileOpName s) |> ignore
1366
- if suggestNames then
1367
- let filtered = ErrorResolutionHints.FilterPredictions suggestionF idText
1368
- if List.isEmpty filtered |> not then
1369
- os.Append( ErrorResolutionHints.FormatPredictions DecompileOpName filtered) |> ignore
1375
+ suggestNames suggestionF idText
1370
1376
1371
1377
| NumberedError ((_, s), _) -> os.Append s |> ignore
1372
1378
@@ -1582,10 +1588,10 @@ let OutputPhasedErrorR (os: StringBuilder) (err: PhasedDiagnostic) (suggestNames
1582
1588
1583
1589
1584
1590
// remove any newlines and tabs
1585
- let OutputPhasedDiagnostic ( os : System.Text.StringBuilder ) ( err : PhasedDiagnostic ) ( flattenErrors : bool ) ( suggestNames : bool ) =
1591
+ let OutputPhasedDiagnostic ( os : System.Text.StringBuilder ) ( err : PhasedDiagnostic ) ( flattenErrors : bool ) ( canSuggestNames : bool ) =
1586
1592
let buf = new System.Text.StringBuilder()
1587
1593
1588
- OutputPhasedErrorR buf err suggestNames
1594
+ OutputPhasedErrorR buf err canSuggestNames
1589
1595
let s = if flattenErrors then ErrorLogger.NormalizeErrorString ( buf.ToString()) else buf.ToString()
1590
1596
1591
1597
os.Append s |> ignore
@@ -1635,7 +1641,7 @@ type Diagnostic =
1635
1641
| Long of bool * DiagnosticDetailedInfo
1636
1642
1637
1643
/// returns sequence that contains Diagnostic for the given error + Diagnostic for all related errors
1638
- let CollectDiagnostic ( implicitIncludeDir , showFullPaths , flattenErrors , errorStyle , isError , err : PhasedDiagnostic , suggestNames : bool ) =
1644
+ let CollectDiagnostic ( implicitIncludeDir , showFullPaths , flattenErrors , errorStyle , isError , err : PhasedDiagnostic , canSuggestNames : bool ) =
1639
1645
let outputWhere ( showFullPaths , errorStyle ) m : DiagnosticLocation =
1640
1646
if Range.equals m rangeStartup || Range.equals m rangeCmdArgs then
1641
1647
{ Range = m; TextRepresentation = " " ; IsEmpty = true ; File = " " }
@@ -1708,7 +1714,7 @@ let CollectDiagnostic (implicitIncludeDir, showFullPaths, flattenErrors, errorSt
1708
1714
let canonical = OutputCanonicalInformation( err.Subcategory(), GetDiagnosticNumber mainError)
1709
1715
let message =
1710
1716
let os = System.Text.StringBuilder()
1711
- OutputPhasedDiagnostic os mainError flattenErrors suggestNames
1717
+ OutputPhasedDiagnostic os mainError flattenErrors canSuggestNames
1712
1718
os.ToString()
1713
1719
1714
1720
let entry : DiagnosticDetailedInfo = { Location = where; Canonical = canonical; Message = message }
@@ -1723,15 +1729,15 @@ let CollectDiagnostic (implicitIncludeDir, showFullPaths, flattenErrors, errorSt
1723
1729
let relCanonical = OutputCanonicalInformation( err.Subcategory(), GetDiagnosticNumber mainError) // Use main error for code
1724
1730
let relMessage =
1725
1731
let os = System.Text.StringBuilder()
1726
- OutputPhasedDiagnostic os err flattenErrors suggestNames
1732
+ OutputPhasedDiagnostic os err flattenErrors canSuggestNames
1727
1733
os.ToString()
1728
1734
1729
1735
let entry : DiagnosticDetailedInfo = { Location = relWhere; Canonical = relCanonical; Message = relMessage}
1730
1736
errors.Add( Diagnostic.Long ( isError, entry) )
1731
1737
1732
1738
| _ ->
1733
1739
let os = System.Text.StringBuilder()
1734
- OutputPhasedDiagnostic os err flattenErrors suggestNames
1740
+ OutputPhasedDiagnostic os err flattenErrors canSuggestNames
1735
1741
errors.Add( Diagnostic.Short( isError, os.ToString()) )
1736
1742
1737
1743
relatedErrors |> List.iter OutputRelatedError
@@ -1752,7 +1758,7 @@ let CollectDiagnostic (implicitIncludeDir, showFullPaths, flattenErrors, errorSt
1752
1758
/// prints error and related errors to the specified StringBuilder
1753
1759
let rec OutputDiagnostic ( implicitIncludeDir , showFullPaths , flattenErrors , errorStyle , isError ) os ( err : PhasedDiagnostic ) =
1754
1760
1755
- // 'true' for "suggestNames " is passed last here because we want to report suggestions in fsc.exe and fsi.exe, just not in regular IDE usage.
1761
+ // 'true' for "canSuggestNames " is passed last here because we want to report suggestions in fsc.exe and fsi.exe, just not in regular IDE usage.
1756
1762
let errors = CollectDiagnostic ( implicitIncludeDir, showFullPaths, flattenErrors, errorStyle, isError, err, true )
1757
1763
for e in errors do
1758
1764
Printf.bprintf os " \n "
0 commit comments