Skip to content

Commit

Permalink
Filter completions on abstract member type signature (#13090)
Browse files Browse the repository at this point in the history
* Filter completions on abstract member type signature
  • Loading branch information
kerams authored Oct 21, 2022
1 parent 7d842a5 commit ddbaafd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/Compiler/Service/ServiceParseTreeWalk.fs
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ type SyntaxVisitorBase<'T>() =
ignore (path, isRecursive, defaultTraverse, bindings, range)
None

/// VisitType allows overriding behavior when visiting simple pats
/// VisitSimplePats allows overriding behavior when visiting simple pats
abstract VisitSimplePats: path: SyntaxVisitorPath * synPats: SynSimplePat list -> 'T option

default _.VisitSimplePats(path, synPats) =
Expand Down Expand Up @@ -813,8 +813,7 @@ module SyntaxTraversal =

match ty with
| SynType.App (typeName, _, typeArgs, _, _, _, _)
| SynType.LongIdentApp (typeName, _, _, typeArgs, _, _, _) ->
[ yield typeName; yield! typeArgs ] |> List.tryPick (traverseSynType path)
| SynType.LongIdentApp (typeName, _, _, typeArgs, _, _, _) -> typeName :: typeArgs |> List.tryPick (traverseSynType path)
| SynType.Fun (argType = ty1; returnType = ty2) -> [ ty1; ty2 ] |> List.tryPick (traverseSynType path)
| SynType.MeasurePower (ty, _, _)
| SynType.HashConstraint (ty, _)
Expand Down Expand Up @@ -921,12 +920,12 @@ module SyntaxTraversal =
| SynMemberDefn.AutoProperty (synExpr = synExpr) -> traverseSynExpr path synExpr
| SynMemberDefn.LetBindings (synBindingList, isRecursive, _, range) ->
match visitor.VisitLetOrUse(path, isRecursive, traverseSynBinding path, synBindingList, range) with
| Some x -> Some x
| None ->
synBindingList
|> List.map (fun x -> dive x x.RangeOfBindingWithRhs (traverseSynBinding path))
|> pick m
| SynMemberDefn.AbstractSlot (_synValSig, _memberFlags, _range) -> None
| x -> x
| SynMemberDefn.AbstractSlot (SynValSig (synType = synType), _memberFlags, _range) -> traverseSynType path synType
| SynMemberDefn.Interface (interfaceType = synType; members = synMemberDefnsOption) ->
match visitor.VisitInterfaceSynMemberDefnType(path, synType) with
| None ->
Expand Down
8 changes: 8 additions & 0 deletions vsintegration/tests/UnitTests/CompletionProviderTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,14 @@ type T() =
"""
VerifyNoCompletionList(fileContents, "member this.M(p:int, h")

[<Test>]
let ``Completion list on abstract member type signature contains modules and types but not keywords or functions`` =
let fileContents = """
type Interface =
abstract member Eat: l
"""
VerifyCompletionList(fileContents, "Eat: l", ["LanguagePrimitives"; "List" ], ["let"; "log"])

[<Test>]
let ``Provide completion on first function argument type hint``() =
let fileContents = """
Expand Down

0 comments on commit ddbaafd

Please sign in to comment.