Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5c1e4a9

Browse files
vasily-kirichenkoKevinRansom
authored andcommitted
filter out duplicated parser errors (dotnet#2142)
1 parent901923e commit5c1e4a9

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

‎vsintegration/src/FSharp.Editor/Diagnostics/DocumentDiagnosticAnalyzer.fs‎

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -81,23 +81,24 @@ type internal FSharpDocumentDiagnosticAnalyzer() =
8181
}
8282

8383
letresults=
84-
(errors|> Seq.choose(fun error->
85-
if error.StartLineAlternate=0|| error.EndLineAlternate=0then
86-
// F# error line numbers are one-based. Compiler returns 0 for global errors (reported by ProjectDiagnosticAnalyzer)
87-
None
88-
else
89-
// Roslyn line numbers are zero-based
90-
letlinePositionSpan= LinePositionSpan(LinePosition(error.StartLineAlternate-1, error.StartColumn),LinePosition(error.EndLineAlternate-1, error.EndColumn))
91-
lettextSpan= sourceText.Lines.GetTextSpan(linePositionSpan)
92-
93-
// F# compiler report errors at end of file if parsing fails. It should be corrected to match Roslyn boundaries
94-
letcorrectedTextSpan=
95-
if textSpan.End< sourceText.Lengththen textSpan
96-
else TextSpan.FromBounds(max0(sourceText.Length-1), sourceText.Length)
97-
98-
letlocation= Location.Create(filePath, correctedTextSpan, linePositionSpan)
99-
Some(CommonRoslynHelpers.ConvertError(error, location)))
100-
).ToImmutableArray()
84+
(HashSet(errors, errorInfoEqualityComparer)
85+
|> Seq.choose(fun error->
86+
if error.StartLineAlternate=0|| error.EndLineAlternate=0then
87+
// F# error line numbers are one-based. Compiler returns 0 for global errors (reported by ProjectDiagnosticAnalyzer)
88+
None
89+
else
90+
// Roslyn line numbers are zero-based
91+
letlinePositionSpan= LinePositionSpan(LinePosition(error.StartLineAlternate-1, error.StartColumn), LinePosition(error.EndLineAlternate-1, error.EndColumn))
92+
lettextSpan= sourceText.Lines.GetTextSpan(linePositionSpan)
93+
94+
// F# compiler report errors at end of file if parsing fails. It should be corrected to match Roslyn boundaries
95+
letcorrectedTextSpan=
96+
if textSpan.End< sourceText.Lengththen textSpan
97+
else TextSpan.FromBounds(max0(sourceText.Length-1), sourceText.Length)
98+
99+
letlocation= Location.Create(filePath, correctedTextSpan, linePositionSpan)
100+
Some(CommonRoslynHelpers.ConvertError(error, location)))
101+
).ToImmutableArray()
101102
return results
102103
}
103104

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp