Skip to content

Commit

Permalink
Merge branch 'main' into nightly
Browse files Browse the repository at this point in the history
  • Loading branch information
baronfel committed Mar 12, 2023
2 parents 78f2864 + 59d38b8 commit b108431
Show file tree
Hide file tree
Showing 17 changed files with 993 additions and 329 deletions.
1 change: 1 addition & 0 deletions .github/workflows/bump-fcs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
- name: bump FCS
run: dotnet paket update FSharp.Compiler.Service
- name: check if there are changes
continue-on-error: true # nonzero exit codes are expected if there are changes
id: check
run: |
git diff --exit-code
Expand Down
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# Changelog

## [0.59.2] - 2023-03-12

### Added

* [A new codefix that converts 'bare' ///-comments to full XML documentation comments](https://github.com/fsharp/fsautocomplete/pull/1068) (thanks @dawedawe!)

### Changed

* [Enhancements to Find All References and Rename operations](https://github.com/fsharp/fsautocomplete/pull/1037) (thanks @BooksBaum and @theangrybyrd!)
* [Internal errors no longer report as LSP protocol errors](https://github.com/fsharp/fsautocomplete/pull/1069)
* [TestAdapterEntry items now include module information as well](https://github.com/fsharp/fsautocomplete/pull/1071) (thanks @kojo12228!)

### Fixed

* [IndexOutOfRange issue in signatureHelp](https://github.com/fsharp/fsautocomplete/pull/1067) (thanks @vain0x!)
* [ThreadPool exhaustion issue with ProgressListener](https://github.com/fsharp/fsautocomplete/pull/1070) (thanks @theangrybyrd!)
* [The 'convert positional DU usage to named patterns' codefix now works with multiple match clauses in the same pattern](https://github.com/fsharp/fsautocomplete/pull/1073) (thanks @dawedawe!)

## [0.59.1] - 2023-02-26

### Added
Expand Down
72 changes: 38 additions & 34 deletions src/FsAutoComplete.Core/Commands.fs
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,10 @@ type DocumentEdit =
module private Result =
let ofCoreResponse (r: CoreResponse<'a>) =
match r with
| CoreResponse.Res a -> Ok a
| CoreResponse.ErrorRes msg
| CoreResponse.InfoRes msg -> Error msg
| CoreResponse.Res a -> Ok(Some a)
| CoreResponse.InfoRes _ -> Ok None
| CoreResponse.ErrorRes msg -> Error msg


module AsyncResult =

Expand Down Expand Up @@ -1894,47 +1895,50 @@ type Commands(checker: FSharpCompilerServiceChecker, state: State, hasAnalyzers:
let indentLength = lineStr.Length - trimmed.Length
let indentString = String.replicate indentLength " "

let! (_, memberParameters, genericParameters) =
Commands.SignatureData tyRes triggerPosition lineStr |> Result.ofCoreResponse
match! Commands.SignatureData tyRes triggerPosition lineStr |> Result.ofCoreResponse with
| None -> return None
| Some(_, memberParameters, genericParameters) ->

let summarySection = "/// <summary></summary>"

let parameterSection (name, _type) =
$"/// <param name=\"%s{name}\"></param>"
let summarySection = "/// <summary></summary>"

let genericArg name =
$"/// <typeparam name=\"'%s{name}\"></typeparam>"
let parameterSection (name, _type) =
$"/// <param name=\"%s{name}\"></param>"

let returnsSection = "/// <returns></returns>"
let genericArg name =
$"/// <typeparam name=\"'%s{name}\"></typeparam>"

let formattedXmlDoc =
seq {
yield summarySection
let returnsSection = "/// <returns></returns>"

match memberParameters with
| [] -> ()
| parameters ->
yield!
parameters
|> List.concat
|> List.mapi (fun _index parameter -> parameterSection parameter)
let formattedXmlDoc =
seq {
yield summarySection

match genericParameters with
| [] -> ()
| generics -> yield! generics |> List.mapi (fun _index generic -> genericArg generic)
match memberParameters with
| [] -> ()
| parameters ->
yield!
parameters
|> List.concat
|> List.mapi (fun _index parameter -> parameterSection parameter)

yield returnsSection
}
|> Seq.map (fun s -> indentString + s)
|> String.concat Environment.NewLine
|> fun s -> s + Environment.NewLine // need a newline at the very end
match genericParameters with
| [] -> ()
| generics -> yield! generics |> List.mapi (fun _index generic -> genericArg generic)

yield returnsSection
}
|> Seq.map (fun s -> indentString + s)
|> String.concat Environment.NewLine
|> fun s -> s + Environment.NewLine // need a newline at the very end

// always insert at the start of the line, because we've prepended the indent to the start of the summary section
let insertPosition = Position.mkPos triggerPosition.Line 0
// always insert at the start of the line, because we've prepended the indent to the start of the summary section
let insertPosition = Position.mkPos triggerPosition.Line 0

return
{ InsertPosition = insertPosition
InsertText = formattedXmlDoc }
return
Some
{ InsertPosition = insertPosition
InsertText = formattedXmlDoc }
}

member private x.GetDeclarationLocation(symbolUse, text) =
Expand Down
95 changes: 90 additions & 5 deletions src/FsAutoComplete.Core/TestAdapter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ type TestAdapterEntry<'range> =
Childs: ResizeArray<TestAdapterEntry<'range>>
Id: int
List: bool
ModuleType: string
Type: string }

[<Literal>]
Expand All @@ -21,6 +22,18 @@ let private NUnitType = "NUnit"
[<Literal>]
let private XUnitType = "XUnit"

[<Literal>]
let private NoneModuleType = "NoneModule"

[<Literal>]
let private ModuleType = "Module"

[<Literal>]
let private TypeInModule = "TypeInModule"

[<Literal>]
let private ModuleWithSuffixType = "ModuleWithSuffix"

let rec private (|Sequentials|_|) =
function
| SynExpr.Sequential(_, _, e, Sequentials es, _) -> Some(e :: es)
Expand Down Expand Up @@ -86,6 +99,7 @@ let getExpectoTests (ast: ParsedInput) : TestAdapterEntry<range> list =
Childs = ResizeArray()
Id = ident
List = true
ModuleType = NoneModuleType
Type = ExpectoType }

parent.Childs.Add entry
Expand All @@ -103,6 +117,7 @@ let getExpectoTests (ast: ParsedInput) : TestAdapterEntry<range> list =
Childs = ResizeArray()
Id = ident
List = false
ModuleType = NoneModuleType
Type = ExpectoType }

parent.Childs.Add entry
Expand Down Expand Up @@ -131,6 +146,7 @@ let getExpectoTests (ast: ParsedInput) : TestAdapterEntry<range> list =
Childs = ResizeArray()
Id = ident
List = false
ModuleType = NoneModuleType
Type = ExpectoType }

parent.Childs.Add entry
Expand Down Expand Up @@ -208,6 +224,7 @@ let getExpectoTests (ast: ParsedInput) : TestAdapterEntry<range> list =
Childs = ResizeArray()
Id = -1
List = false
ModuleType = NoneModuleType
Type = "" }

match ast with
Expand Down Expand Up @@ -256,6 +273,13 @@ let getNUnitTest (ast: ParsedInput) : TestAdapterEntry<range> list =
let (SynTypeDefn(typeInfo = ci; typeRepr = om; members = members)) = t
let (SynComponentInfo(longId = ids; range = r)) = ci
let name = String.concat "." [ for i in ids -> i.idText ]

let moduleType =
if parent.ModuleType = ModuleType || parent.ModuleType = ModuleWithSuffixType then
TypeInModule
else
NoneModuleType

ident <- ident + 1

let entry =
Expand All @@ -264,6 +288,7 @@ let getNUnitTest (ast: ParsedInput) : TestAdapterEntry<range> list =
Childs = ResizeArray()
Id = ident
List = true
ModuleType = moduleType
Type = NUnitType }

parent.Childs.Add entry
Expand Down Expand Up @@ -292,11 +317,27 @@ let getNUnitTest (ast: ParsedInput) : TestAdapterEntry<range> list =
Childs = ResizeArray()
Id = ident
List = false
ModuleType = NoneModuleType
Type = NUnitType }

parent.Childs.Add entry

let rec visitDeclarations (parent: TestAdapterEntry<range>) decls =
let typeNames =
decls
|> List.fold
(fun types declaration ->
match declaration with
| SynModuleDecl.Types(typeDefns, _) ->
typeDefns
|> List.map (fun (SynTypeDefn(typeInfo = ci)) ->
let (SynComponentInfo(longId = ids)) = ci
String.concat "." [ for i in ids -> i.idText ])
|> List.append types
| _ -> types)
([])
|> Set.ofList

for declaration in decls do
match declaration with
| SynModuleDecl.Let(_, bindings, _) ->
Expand All @@ -305,6 +346,13 @@ let getNUnitTest (ast: ParsedInput) : TestAdapterEntry<range> list =
| SynModuleDecl.NestedModule(moduleInfo = ci; decls = decls) ->
let (SynComponentInfo(longId = ids; range = r)) = ci
let name = String.concat "." [ for i in ids -> i.idText ]

let moduleType =
if Set.contains name typeNames then
ModuleWithSuffixType
else
ModuleType

ident <- ident + 1

let entry =
Expand All @@ -313,6 +361,7 @@ let getNUnitTest (ast: ParsedInput) : TestAdapterEntry<range> list =
Childs = ResizeArray()
Id = ident
List = true
ModuleType = moduleType
Type = NUnitType }

parent.Childs.Add entry
Expand All @@ -327,8 +376,9 @@ let getNUnitTest (ast: ParsedInput) : TestAdapterEntry<range> list =

let visitModulesAndNamespaces parent modulesOrNss =
Seq.iter
(fun (SynModuleOrNamespace(longId = ids; decls = decls; range = r)) ->
(fun (SynModuleOrNamespace(longId = ids; decls = decls; range = r; kind = kind)) ->
let name = String.concat "." [ for i in ids -> i.idText ]
let moduleType = if kind.IsModule then ModuleType else NoneModuleType
ident <- ident + 1

let entry =
Expand All @@ -337,6 +387,7 @@ let getNUnitTest (ast: ParsedInput) : TestAdapterEntry<range> list =
Childs = ResizeArray()
Id = ident
List = true
ModuleType = moduleType
Type = NUnitType }

parent.Childs.Add entry
Expand All @@ -352,6 +403,7 @@ let getNUnitTest (ast: ParsedInput) : TestAdapterEntry<range> list =
Childs = ResizeArray()
Id = -1
List = false
ModuleType = NoneModuleType
Type = "" }

match ast with
Expand Down Expand Up @@ -395,6 +447,13 @@ let getXUnitTest ast : TestAdapterEntry<range> list =
let (SynTypeDefn(typeInfo = ci; typeRepr = om; members = members)) = t
let (SynComponentInfo(longId = ids; range = r)) = ci
let name = String.concat "." [ for i in ids -> i.idText ]

let moduleType =
if parent.ModuleType = ModuleType || parent.ModuleType = ModuleWithSuffixType then
TypeInModule
else
NoneModuleType

ident <- ident + 1

let entry =
Expand All @@ -403,6 +462,7 @@ let getXUnitTest ast : TestAdapterEntry<range> list =
Childs = ResizeArray()
Id = ident
List = true
ModuleType = moduleType
Type = XUnitType }

parent.Childs.Add entry
Expand Down Expand Up @@ -431,13 +491,27 @@ let getXUnitTest ast : TestAdapterEntry<range> list =
Childs = ResizeArray()
Id = ident
List = false
Type = XUnitType

}
ModuleType = NoneModuleType
Type = XUnitType }

parent.Childs.Add entry

let rec visitDeclarations (parent: TestAdapterEntry<range>) decls =
let typeNames =
decls
|> List.fold
(fun types declaration ->
match declaration with
| SynModuleDecl.Types(typeDefns, _) ->
typeDefns
|> List.map (fun (SynTypeDefn(typeInfo = ci)) ->
let (SynComponentInfo(longId = ids)) = ci
String.concat "." [ for i in ids -> i.idText ])
|> List.append types
| _ -> types)
([])
|> Set.ofList

for declaration in decls do
match declaration with
| SynModuleDecl.Let(_, bindings, _) ->
Expand All @@ -446,6 +520,13 @@ let getXUnitTest ast : TestAdapterEntry<range> list =
| SynModuleDecl.NestedModule(moduleInfo = ci; decls = decls) ->
let (SynComponentInfo(longId = ids; range = r)) = ci
let name = String.concat "." [ for i in ids -> i.idText ]

let moduleType =
if Set.contains name typeNames then
ModuleWithSuffixType
else
ModuleType

ident <- ident + 1

let entry =
Expand All @@ -454,6 +535,7 @@ let getXUnitTest ast : TestAdapterEntry<range> list =
Childs = ResizeArray()
Id = ident
List = true
ModuleType = moduleType
Type = XUnitType }

parent.Childs.Add entry
Expand All @@ -468,8 +550,9 @@ let getXUnitTest ast : TestAdapterEntry<range> list =

let visitModulesAndNamespaces parent modulesOrNss =
Seq.iter
(fun (SynModuleOrNamespace(longId = ids; decls = decls; range = r)) ->
(fun (SynModuleOrNamespace(longId = ids; decls = decls; range = r; kind = kind)) ->
let name = String.concat "." [ for i in ids -> i.idText ]
let moduleType = if kind.IsModule then ModuleType else NoneModuleType
ident <- ident + 1

let entry =
Expand All @@ -478,6 +561,7 @@ let getXUnitTest ast : TestAdapterEntry<range> list =
Childs = ResizeArray()
Id = ident
List = true
ModuleType = moduleType
Type = XUnitType }

parent.Childs.Add entry
Expand All @@ -493,6 +577,7 @@ let getXUnitTest ast : TestAdapterEntry<range> list =
Childs = ResizeArray()
Id = -1
List = false
ModuleType = NoneModuleType
Type = "" }

match ast with
Expand Down
Loading

0 comments on commit b108431

Please sign in to comment.