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

Fixed signature help with tuple arg on one line #6011

Merged
merged 6 commits into from
Feb 6, 2019
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
2 changes: 1 addition & 1 deletion src/fsharp/pars.fsy
Original file line number Diff line number Diff line change
Expand Up @@ -3834,7 +3834,7 @@ parenExpr:

| LPAREN parenExprBody ends_other_than_rparen_coming_soon_or_recover
{ if not $3 then reportParseErrorAt (rhs parseState 1) (FSComp.SR.parsUnmatchedParen())
let lhsm = unionRangeWithPos (rhs parseState 1) (rhs parseState 3).Start
let lhsm = unionRangeWithPos (rhs parseState 1) (rhs parseState 2).End
SynExpr.Paren(exprFromParseError ($2 lhsm), rhs parseState 1, None, lhsm) }

| LPAREN error rparen
Expand Down
2 changes: 1 addition & 1 deletion src/fsharp/service/ServiceParamInfoLocations.fs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ module internal NoteworthyParamInfoLocationsImpl =
let inner = traverseSynExpr synExpr
match inner with
| None ->
if AstTraversal.rangeContainsPosEdgesExclusive parenRange pos then
if AstTraversal.rangeContainsPosLeftEdgeExclusiveAndRightEdgeInclusive parenRange pos then
let commasAndCloseParen = ((synExprList, commaRanges@[parenRange]) ||> List.map2 (fun e c -> c.End, getNamedParamName e))
let r = Found (parenRange.Start, commasAndCloseParen, rpRangeOpt.IsSome)
r, None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1278,85 +1278,6 @@ We really need to rewrite some code paths here to use the real parse tree rather
arr.[1] <- ^System.Int32.Parse^(^$
namespace^ Other""")

[<Test>]
member public this.``LocationOfParams.UnmatchedParens.Bug91609.Ok``() =
this.TestParameterInfoLocationOfParams("""
let arr = Array.create 4 1
arr.[1] <- ^System.Int32.Parse^(^$
let squares3 = ()
^type Expr = class end
let rec Evaluate (env:Map<string,int>) exp = ()""")

[<Test>]
member public this.``LocationOfParams.UnmatchedParens.Bug91609.AlsoOk``() =
this.TestParameterInfoLocationOfParams("""
let arr = Array.create 4 1
arr.[1] <- System.Int32.Parse(int(int(int(^int^(^$
let squares3 = ()
^type Expr = class end
let rec Evaluate (env:Map<string,int>) exp = ()""")

[<Test>]
member public this.``LocationOfParams.UnmatchedParens.Bug91609.NowGood``() =
// This case originally failed, by Design, as there is a finite limit to how many unmatched parens we can handle before the parser gives up and fails catastrophically.
// However now that we recover from more kinds of tokens, e.g. OBLOCKEND, we can easily go much much deeper, and so this case (and most practical cases) now succeeds.
this.TestParameterInfoLocationOfParams("""
let arr = Array.create 4 1
arr.[1] <- System.Int32.Parse(int(int(int(int(int(int(^int^(^$
let squares3 = ()
^type Expr = class end
let rec Evaluate (env:Map<string,int>) exp = ()""")

[<Test>]
member public this.``LocationOfParams.UnmatchedParens.Bug150492.Case1``() =
this.TestParameterInfoLocationOfParams("""
module Inner =
^System.Console.Write^(^$
let y = 4
^type Foo() = inherit obj()
[<assembly:System.Security.AllowPartiallyTrustedCallersAttribute>]
do () """)

[<Test>]
member public this.``LocationOfParams.UnmatchedParens.Bug150492.Case2``() =
// like previous test, but with explicit begin-end at module
this.TestParameterInfoLocationOfParams("""
module Inner = begin
^System.Console.Write^(^$
let y = 4
^end
type Foo() = inherit obj()
[<assembly:System.Security.AllowPartiallyTrustedCallersAttribute>]
do () """)

[<Test>]
member public this.``LocationOfParams.UnmatchedParens.Bug150492.Case1.WhenExtraModule``() =
this.TestParameterInfoLocationOfParams("""
module Program
let xxx = 42
type FooBaz() = class end
module Inner =
^System.Console.Write^(^$
let y = 4
^type Foo() = inherit obj()
[<assembly:System.Security.AllowPartiallyTrustedCallersAttribute>]
do () """)

[<Test>]
member public this.``LocationOfParams.UnmatchedParens.Bug150492.Case2.OkWhenExtraModule``() =
// like previous test, but with explicit begin-end at module
this.TestParameterInfoLocationOfParams("""
module Program
let xxx = 42
type FooBaz() = class end
module Inner = begin
^System.Console.Write^(^$
let y = 4
^end
type Foo() = inherit obj()
[<assembly:System.Security.AllowPartiallyTrustedCallersAttribute>]
do () """)

[<Test>]
member this.``LocationOfParams.InheritsClause.Bug192134``() =
this.TestParameterInfoLocationOfParams("""
Expand Down Expand Up @@ -1396,30 +1317,6 @@ We really need to rewrite some code paths here to use the real parse tree rather
while true do
($) """)

[<Test>]
member public this.``LocationOfParams.UnmatchedParensBeforeModuleKeyword.Bug245850.Case1a``() =
this.TestParameterInfoLocationOfParams("""
module Repro =
for a in ^System.Int16.TryParse^(^$
^module AA =
let x = 10 """)

[<Test>]
member public this.``LocationOfParams.UnmatchedParensBeforeModuleKeyword.Bug245850.Case1b``() =
this.TestParameterInfoLocationOfParams("""
module Repro =
for a in ^System.Int16.TryParse^(^"4$2"
^module AA =
let x = 10 """)

[<Test>]
member public this.``LocationOfParams.UnmatchedParensBeforeModuleKeyword.Bug245850.Case1c``() =
this.TestParameterInfoLocationOfParams("""
module Repro =
for a in ^System.Int16.TryParse^(^"4$2",^
^module AA =
let x = 10 """)

[<Test>]
member public this.``LocationOfParams.UnmatchedParensBeforeModuleKeyword.Bug245850.Case2a``() =
this.TestParameterInfoLocationOfParams("""
Expand All @@ -1428,78 +1325,6 @@ We really need to rewrite some code paths here to use the real parse tree rather
^module AA =
let x = 10 """)

[<Test>]
member public this.``LocationOfParams.UnmatchedParensBeforeModuleKeyword.Bug245850.Case2b``() =
this.TestParameterInfoLocationOfParams("""
module Repro =
query { for a in ^System.Int16.TryParse^(^"4$2"
^module AA =
let x = 10 """)

[<Test>]
member public this.``LocationOfParams.UnmatchedParensBeforeModuleKeyword.Bug245850.Case2c``() =
this.TestParameterInfoLocationOfParams("""
module Repro =
query { for a in ^System.Int16.TryParse^(^"4$2",^
^module AA =
let x = 10 """)

[<Test>]
[<Ignore("https://github.com/Microsoft/visualfsharp/issues/6166")>]
member public this.``LocationOfParams.QueryCustomOperation.Bug222128``() =
this.TestParameterInfoLocationOfParams("""
type T() =
member x.GetCollection() = [1;2;3;4]
let q2 = query {
for e in T().GetCollection() do
where (e > 250)
^skip^(^$
^} """)

[<Test>]
member public this.``LocationOfParams.QueryCurlies.Bug204150.Case1``() =
this.TestParameterInfoLocationOfParams("""
type T() =
member x.GetCollection() = [1;2;3;4]
open System.Linq
let q6 =
query {
for E in ^T().GetCollection().Aggregate^(^$
^} """)

[<Test>]
member public this.``LocationOfParams.QueryCurlies.Bug204150.Case2``() =
this.TestParameterInfoLocationOfParams("""
type T() =
member x.GetCollection() = [1;2;3;4]
open System.Linq
let q6 =
query {
for E in ^T().GetCollection().Aggregate^(^42$
^} """)

[<Test>]
member public this.``LocationOfParams.QueryCurlies.Bug204150.Case3``() =
this.TestParameterInfoLocationOfParams("""
type T() =
member x.GetCollection() = [1;2;3;4]
open System.Linq
let q6 =
query {
for E in ^T().GetCollection().Aggregate^(^42,^$
^} """)

[<Test>]
member public this.``LocationOfParams.QueryCurlies.Bug204150.Case4``() =
this.TestParameterInfoLocationOfParams("""
type T() =
member x.GetCollection() = [1;2;3;4]
open System.Linq
let q6 =
query {
for E in ^T().GetCollection().Aggregate^(^42,^ 43$
^} """)

(* Tests for type provider static argument parameterinfos ------------------------------------------ *)

member public this.TestParameterInfoLocationOfParamsWithVariousSurroundingContexts (testLine:string, ?markAtEnd, ?additionalReferenceAssemblies) =
Expand Down
4 changes: 3 additions & 1 deletion vsintegration/tests/UnitTests/SignatureHelpProviderTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ System.Console.WriteLine(format="Hello, {0}",arg0="World")
("arg0", Some ("[7..64)", 1, 2, Some "arg0"));
("arg0=", Some ("[7..64)", 1, 2, Some "arg0"));
("World", Some ("[7..64)", 1, 2, Some "arg0"));
(")", None)]);
(")", Some("[7..64)", 0, 2, Some "format"))]);
( """
//2
open System
Expand Down Expand Up @@ -127,6 +127,8 @@ type foo5 = N1.T<Param1=1,ParamIgnored= >
//Test case 5
( """let _ = System.DateTime(""",
[("let _ = System.DateTime(", Some ("[8..24)", 0, 0, None)) ])
( """let _ = System.DateTime(1L,""",
[("let _ = System.DateTime(1L,", Some ("[8..27)", 1, 2, None )) ])
]

let sb = StringBuilder()
Expand Down