Skip to content

Commit

Permalink
Use of the now public Range propery of PreXmlDoc (#1128)
Browse files Browse the repository at this point in the history
* Having the latest fsc, we can make use of the now public Range property of PreXmlDoc to save resources

* format
  • Loading branch information
dawedawe authored Jul 4, 2023
1 parent 7fc82db commit 6cfa454
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/FsAutoComplete/CodeFixes/AddMissingXmlDocumentation.fs
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@ let title = "Add missing XML documentation"

let private tryGetExistingXmlDoc (pos: FSharp.Compiler.Text.Position) (xmlDoc: PreXmlDoc) =
let tryGetSummaryIfContainsPos (xd: PreXmlDoc) =
let d = xd.ToXmlDoc(false, None)
if rangeContainsPos xd.Range pos then
let d = xd.ToXmlDoc(false, None)

if rangeContainsPos d.Range pos then
if Array.isEmpty d.UnprocessedLines then
None
elif d.UnprocessedLines |> Array.exists (fun s -> s.Contains("<summary>")) then
Some(d.UnprocessedLines, d.Range)
Some(d.UnprocessedLines, xd.Range)
else
let lines =
match d.UnprocessedLines with
| [||] -> [| " <summary></summary>" |]
| [| c |] -> [| $" <summary>%s{c.Trim()}</summary>" |]
| cs -> [| yield " <summary>"; yield! cs; yield " </summary>" |]

Some(lines, d.Range)
Some(lines, xd.Range)
else
None

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ let title = "Convert '///' comment to XML-tagged doc comment"

let private containsPosAndNotEmptyAndNotElaborated (pos: FSharp.Compiler.Text.Position) (xmlDoc: PreXmlDoc) =
let containsPosAndNoSummaryPresent (xd: PreXmlDoc) =
let d = xd.ToXmlDoc(false, None)
if rangeContainsPos xd.Range pos then
let d = xd.ToXmlDoc(false, None)

if rangeContainsPos d.Range pos then
let summaryPresent =
d.UnprocessedLines |> Array.exists (fun s -> s.Contains("<summary>"))

Expand Down

0 comments on commit 6cfa454

Please sign in to comment.