Skip to content

Commit

Permalink
fix invalid span bug in symbolIsFullyQualified
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudRoutine committed Mar 29, 2017
1 parent 9b49be6 commit d5b8980
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ module private UnusedOpens =

let symbolIsFullyQualified (sourceText: SourceText) (sym: FSharpSymbolUse) (fullName: string) =
match CommonRoslynHelpers.TryFSharpRangeToTextSpan(sourceText, sym.RangeAlternate) with
| Some span -> sourceText.ToString(span) = fullName
| Some span // check that the symbol hasn't provided an invalid span
when sourceText.Length < span.Start
|| sourceText.Length < span.End -> false
| Some span -> sourceText.ToString span = fullName
| None -> false

let getUnusedOpens (sourceText: SourceText) (parsedInput: ParsedInput) (symbolUses: FSharpSymbolUse[]) =
Expand All @@ -86,7 +89,6 @@ module private UnusedOpens =
let getPossibleNamespaces (symbolUse: FSharpSymbolUse) : string list =
let isQualified = symbolIsFullyQualified sourceText symbolUse
maybe {

let! fullNames, declaringEntity =
match symbolUse with
| SymbolUse.Entity (ent, cleanFullNames) when not (cleanFullNames |> List.exists isQualified) ->
Expand Down

0 comments on commit d5b8980

Please sign in to comment.