Skip to content
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
7 changes: 7 additions & 0 deletions src/fsharp/service/FSharpParseFileResults.fs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ type FSharpParseFileResults(diagnostics: FSharpDiagnostic[], input: ParsedInput,
SyntaxTraversal.Traverse(pos, input, { new SyntaxVisitorBase<_>() with
member _.VisitExpr(_, traverseSynExpr, defaultTraverse, expr) =
match expr with
| SynExpr.TypeApp (_, _, _, _, _, _, range) when rangeContainsPos range pos ->
Some range
| SynExpr.App(_, _, _, SynExpr.CompExpr (_, _, expr, _), range) when rangeContainsPos range pos ->
traverseSynExpr expr
| SynExpr.App (_, _, _, _, range) when rangeContainsPos range pos ->
Expand All @@ -176,6 +178,9 @@ type FSharpParseFileResults(diagnostics: FSharpDiagnostic[], input: ParsedInput,
| SynExpr.Paren (expr, _, _, range) when rangeContainsPos range pos ->
getIdentRangeForFuncExprInApp traverseSynExpr expr pos

| SynExpr.TypeApp (expr, _, _, _, _, _, _) ->
getIdentRangeForFuncExprInApp traverseSynExpr expr pos

| SynExpr.App (_, _, funcExpr, argExpr, _) ->
match argExpr with
| SynExpr.App (_, _, _, _, range) when rangeContainsPos range pos ->
Expand Down Expand Up @@ -269,6 +274,8 @@ type FSharpParseFileResults(diagnostics: FSharpDiagnostic[], input: ParsedInput,
SyntaxTraversal.Traverse(pos, input, { new SyntaxVisitorBase<_>() with
member _.VisitExpr(_, traverseSynExpr, defaultTraverse, expr) =
match expr with
| SynExpr.TypeApp (expr, _, _, _, _, _, range) when rangeContainsPos range pos ->
getIdentRangeForFuncExprInApp traverseSynExpr expr pos
| SynExpr.App (_, _, _funcExpr, _, range) as app when rangeContainsPos range pos ->
getIdentRangeForFuncExprInApp traverseSynExpr app pos
| _ -> defaultTraverse expr
Expand Down
28 changes: 26 additions & 2 deletions tests/service/ServiceUntypedParseTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ async {
Assert.False(parseFileResults.IsPosContainedInApplication (mkPos 2 5), "Pos should not be in application")

[<Test>]
let ``TryRangeOfFunctionOrMethodBeingApplied - inside CE return - no``() =
let ``IsPosContainedInApplication - inside CE return - no``() =
let source = """
async {
return sqrt
Expand All @@ -693,7 +693,7 @@ async {
Assert.False(parseFileResults.IsPosContainedInApplication (mkPos 2 5), "Pos should not be in application")

[<Test>]
let ``TryRangeOfFunctionOrMethodBeingApplied - inside CE - yes``() =
let ``IsPosContainedInApplication - inside CE - yes``() =
let source = """
let myAdd x y = x + y
async {
Expand All @@ -703,6 +703,15 @@ async {
let parseFileResults, _ = getParseAndCheckResults source
Assert.False(parseFileResults.IsPosContainedInApplication (mkPos 3 18), "Pos should not be in application")

[<Test>]
let ``IsPosContainedInApplication - inside type application``() =
let source = """
let f<'x> x = ()
f<int>
"""
let parseFileResults, _ = getParseAndCheckResults source
Assert.True(parseFileResults.IsPosContainedInApplication (mkPos 3 6), "A type application is an application, expected True.")

[<Test>]
let ``TryRangeOfFunctionOrMethodBeingApplied - no application``() =
let source = """
Expand Down Expand Up @@ -982,6 +991,21 @@ C.Yeet(1, 2, (fun x -> sqrt))
|> tups
|> shouldEqual ((3, 23), (3, 27))

[<Test>]
let ``TryRangeOfFunctionOrMethodBeingApplied - generic-typed app``() =
let source = """
let f<'x> x = ()
f<int>
"""
let parseFileResults, _ = getParseAndCheckResults source
let res = parseFileResults.TryRangeOfFunctionOrMethodBeingApplied (mkPos 3 6)
match res with
| None -> Assert.Fail("Expected 'f' but got nothing")
| Some range ->
range
|> tups
|> shouldEqual ((3, 0), (3, 1))

module PipelinesAndArgs =
[<Test>]
let ``TryIdentOfPipelineContainingPosAndNumArgsApplied - No pipeline, no infix app``() =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ type internal FSharpSignatureHelpProvider
// Generally ' ' indicates a function application, but it's also used commonly after a comma in a method call.
// This means that the adjusted position relative to the caret could be a ',' or a '(' or '<',
// which would mean we're already inside of a method call - not a function argument. So we bail if that's the case.
| Some ' ', None when adjustedColumnChar <> ',' && adjustedColumnChar <> '(' && adjustedColumnChar <> '<' ->
| Some ' ', _ when adjustedColumnChar <> ',' && adjustedColumnChar <> '(' && adjustedColumnChar <> '<' ->
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is actually the most impactful change. It's what enables triggering function signature help when in a parenthesized context without any quirks.

return!
FSharpSignatureHelpProvider.ProvideParametersAsyncAux(
parseResults,
Expand Down