Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use of the now public Range propery of PreXmlDoc #1128

Merged
merged 2 commits into from
Jul 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use xd for consistency

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't xd.Range a mistake, xd is not defined.

The above variable is still defined as d.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See line 17, xd is the PreXmlDoc passed to the function.

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)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use xd for consistency

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