From 5e45da9c240283bc9dfe7c4e2042c844617eba81 Mon Sep 17 00:00:00 2001 From: Don Syme Date: Wed, 30 Mar 2016 04:54:52 +0100 Subject: [PATCH 1/4] Fix 545 --- src/fsharp/tast.fs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/fsharp/tast.fs b/src/fsharp/tast.fs index 5404617044..e6c3ba64fe 100755 --- a/src/fsharp/tast.fs +++ b/src/fsharp/tast.fs @@ -3197,7 +3197,7 @@ and UnionCaseRef = member x.DefinitionRange = x.UnionCase.DefinitionRange - member x.SigRange = x.UnionCase.DefinitionRange + member x.SigRange = x.UnionCase.SigRange member x.Index = try @@ -3227,7 +3227,7 @@ and RecdFieldRef = member x.DefinitionRange = x.RecdField.DefinitionRange - member x.SigRange = x.RecdField.DefinitionRange + member x.SigRange = x.RecdField.SigRange member x.Index = let (RFRef(tcref,id)) = x From 7cf1831baae1a40852343856154c5f44f0fd2b87 Mon Sep 17 00:00:00 2001 From: Don Syme Date: Wed, 30 Mar 2016 05:11:26 +0100 Subject: [PATCH 2/4] Fix 545 - tests --- tests/service/ProjectAnalysisTests.fs | 83 ++++++++++++++++++++++++++- 1 file changed, 82 insertions(+), 1 deletion(-) diff --git a/tests/service/ProjectAnalysisTests.fs b/tests/service/ProjectAnalysisTests.fs index 6f1a9f0218..0217fc2ea4 100644 --- a/tests/service/ProjectAnalysisTests.fs +++ b/tests/service/ProjectAnalysisTests.fs @@ -2689,6 +2689,85 @@ let ``Test Project16 sig symbols are equal to impl symbols`` () = testFind ("implementation", symbolsImpl) ("implementation", symbolsImpl) // of course this should pass... testFind ("signature", symbolsSig) ("signature", symbolsSig) // of course this should pass... +[] +let ``Test Project16 sym locations`` () = + + let wholeProjectResults = checker.ParseAndCheckProject(Project16.options) |> Async.RunSynchronously + + let fmtLoc (mOpt: Range.range option) = + match mOpt with + | None -> ("NONE", (0, 0), (0, 0)) + | Some m -> (Project16.cleanFileName m.FileName, (m.StartLine, m.StartColumn), (m.EndLine, m.EndColumn )) + + let allUsesOfAllSymbols = + wholeProjectResults.GetAllUsesOfAllSymbols() + |> Async.RunSynchronously + |> Array.map (fun su -> su.Symbol.ToString(), fmtLoc su.Symbol.SignatureLocation, fmtLoc su.Symbol.DeclarationLocation, fmtLoc su.Symbol.ImplementationLocation) + + allUsesOfAllSymbols |> shouldEqual + [|("ClassAttribute", ("??", (226, 9), (226, 23)),("??", (226, 9), (226, 23)), ("??", (226, 9), (226, 23))); + ("ClassAttribute", ("??", (226, 9), (226, 23)),("??", (226, 9), (226, 23)), ("??", (226, 9), (226, 23))); + ("member .ctor", ("??", (230, 8), (230, 11)), ("??", (230, 8), (230, 11)),("??", (244, 9), (244, 23))); + ("ClassAttribute", ("??", (226, 9), (226, 23)),("??", (226, 9), (226, 23)), ("??", (226, 9), (226, 23))); + ("ClassAttribute", ("??", (226, 9), (226, 23)),("??", (226, 9), (226, 23)), ("??", (226, 9), (226, 23))); + ("member .ctor", ("??", (230, 8), (230, 11)), ("??", (230, 8), (230, 11)),("??", (244, 9), (244, 23))); + ("int", ("??", (69, 9), (69, 12)), ("??", (69, 9), (69, 12)),("??", (69, 9), (69, 12))); + ("int", ("??", (69, 9), (69, 12)), ("??", (69, 9), (69, 12)),("??", (69, 9), (69, 12))); + ("int", ("??", (69, 9), (69, 12)), ("??", (69, 9), (69, 12)),("??", (69, 9), (69, 12))); + ("int", ("??", (69, 9), (69, 12)), ("??", (69, 9), (69, 12)),("??", (69, 9), (69, 12))); + ("int", ("??", (69, 9), (69, 12)), ("??", (69, 9), (69, 12)),("??", (69, 9), (69, 12))); + ("field Field1", ("sig1", (16, 10), (16, 16)),("sig1", (16, 10), (16, 16)), ("file1", (13, 10), (13, 16))); + ("field Field2", ("sig1", (16, 24), (16, 30)),("sig1", (16, 24), (16, 30)), ("file1", (13, 24), (13, 30))); + ("int", ("??", (69, 9), (69, 12)), ("??", (69, 9), (69, 12)),("??", (69, 9), (69, 12))); + ("Case1", ("sig1", (17, 8), (17, 13)), ("sig1", (17, 8), (17, 13)),("file1", (14, 8), (14, 13))); + ("Case2", ("sig1", (17, 16), (17, 21)), ("sig1", (17, 16), (17, 21)),("file1", (14, 16), (14, 21))); + ("C", ("sig1", (4, 5), (4, 6)), ("sig1", (4, 5), (4, 6)),("file1", (4, 5), (4, 6))); + ("unit", ("??", (22, 8), (22, 12)), ("??", (22, 8), (22, 12)),("??", (22, 8), (22, 12))); + ("C", ("sig1", (4, 5), (4, 6)), ("sig1", (4, 5), (4, 6)),("file1", (4, 5), (4, 6))); + ("member .ctor", ("sig1", (5, 4), (5, 7)), ("sig1", (5, 4), (5, 7)),("file1", (4, 5), (4, 6))); + ("int", ("??", (69, 9), (69, 12)), ("??", (69, 9), (69, 12)),("??", (69, 9), (69, 12))); + ("member get_PC", ("sig1", (6, 11), (6, 13)), ("sig1", (6, 11), (6, 13)),("file1", (5, 13), (5, 15))); + ("D", ("sig1", (8, 14), (8, 15)), ("sig1", (8, 14), (8, 15)),("file1", (7, 4), (7, 5))); + ("unit", ("??", (22, 8), (22, 12)), ("??", (22, 8), (22, 12)),("??", (22, 8), (22, 12))); + ("D", ("sig1", (8, 14), (8, 15)), ("sig1", (8, 14), (8, 15)),("file1", (7, 4), (7, 5))); + ("member .ctor", ("sig1", (9, 4), (9, 7)), ("sig1", (9, 4), (9, 7)),("file1", (7, 4), (7, 5))); + ("int", ("??", (69, 9), (69, 12)), ("??", (69, 9), (69, 12)),("??", (69, 9), (69, 12))); + ("member get_PD", ("sig1", (10, 11), (10, 13)),("sig1", (10, 11), (10, 13)), ("file1", (8, 13), (8, 15))); + ("E", ("sig1", (12, 14), (12, 15)), ("sig1", (12, 14), (12, 15)),("file1", (10, 4), (10, 5))); + ("unit", ("??", (22, 8), (22, 12)), ("??", (22, 8), (22, 12)),("??", (22, 8), (22, 12))); + ("E", ("sig1", (12, 14), (12, 15)), ("sig1", (12, 14), (12, 15)),("file1", (10, 4), (10, 5))); + ("member .ctor", ("sig1", (13, 4), (13, 7)), ("sig1", (13, 4), (13, 7)),("file1", (10, 4), (10, 5))); + ("int", ("??", (69, 9), (69, 12)), ("??", (69, 9), (69, 12)),("??", (69, 9), (69, 12))); + ("member get_PE", ("sig1", (14, 11), (14, 13)),("sig1", (14, 11), (14, 13)), ("file1", (11, 13), (11, 15))); + ("F", ("sig1", (16, 4), (16, 5)), ("sig1", (16, 4), (16, 5)),("file1", (13, 4), (13, 5))); + ("G", ("sig1", (17, 4), (17, 5)), ("sig1", (17, 4), (17, 5)),("file1", (14, 4), (14, 5))); + ("Impl", ("sig1", (2, 7), (2, 11)), ("sig1", (2, 7), (2, 11)),("file1", (2, 7), (2, 11))); + ("int", ("??", (69, 9), (69, 12)), ("??", (69, 9), (69, 12)),("??", (69, 9), (69, 12))); + ("int", ("??", (69, 9), (69, 12)), ("??", (69, 9), (69, 12)),("??", (69, 9), (69, 12))); + ("int", ("??", (69, 9), (69, 12)), ("??", (69, 9), (69, 12)),("??", (69, 9), (69, 12))); + ("int", ("??", (69, 9), (69, 12)), ("??", (69, 9), (69, 12)),("??", (69, 9), (69, 12))); + ("int", ("??", (69, 9), (69, 12)), ("??", (69, 9), (69, 12)),("??", (69, 9), (69, 12))); + ("field Field1", ("sig1", (16, 10), (16, 16)),("file1", (13, 10), (13, 16)), ("file1", (13, 10), (13, 16))); + ("field Field2", ("sig1", (16, 24), (16, 30)),("file1", (13, 24), (13, 30)), ("file1", (13, 24), (13, 30))); + ("int", ("??", (69, 9), (69, 12)), ("??", (69, 9), (69, 12)),("??", (69, 9), (69, 12))); + ("Case1", ("sig1", (17, 8), (17, 13)), ("file1", (14, 8), (14, 13)),("file1", (14, 8), (14, 13))); + ("Case2", ("sig1", (17, 16), (17, 21)), ("file1", (14, 16), (14, 21)),("file1", (14, 16), (14, 21))); + ("C", ("sig1", (4, 5), (4, 6)), ("file1", (4, 5), (4, 6)),("file1", (4, 5), (4, 6))); + ("D", ("sig1", (8, 14), (8, 15)), ("file1", (7, 4), (7, 5)),("file1", (7, 4), (7, 5))); + ("E", ("sig1", (12, 14), (12, 15)), ("file1", (10, 4), (10, 5)),("file1", (10, 4), (10, 5))); + ("F", ("sig1", (16, 4), (16, 5)), ("file1", (13, 4), (13, 5)),("file1", (13, 4), (13, 5))); + ("G", ("sig1", (17, 4), (17, 5)), ("file1", (14, 4), (14, 5)),("file1", (14, 4), (14, 5))); + ("member .ctor", ("sig1", (5, 4), (5, 7)), ("file1", (4, 5), (4, 6)),("file1", (4, 5), (4, 6))); + ("member get_PC", ("sig1", (6, 11), (6, 13)), ("file1", (5, 13), (5, 15)),("file1", (5, 13), (5, 15))); + ("member .ctor", ("sig1", (9, 4), (9, 7)), ("file1", (7, 4), (7, 5)),("file1", (7, 4), (7, 5))); + ("member get_PD", ("sig1", (10, 11), (10, 13)),("file1", (8, 13), (8, 15)), ("file1", (8, 13), (8, 15))); + ("member .ctor", ("sig1", (13, 4), (13, 7)), ("file1", (10, 4), (10, 5)),("file1", (10, 4), (10, 5))); + ("member get_PE", ("sig1", (14, 11), (14, 13)),("file1", (11, 13), (11, 15)), ("file1", (11, 13), (11, 15))); + ("val x", ("file1", (5, 11), (5, 12)), ("file1", (5, 11), (5, 12)),("file1", (5, 11), (5, 12))); + ("val x", ("file1", (8, 11), (8, 12)), ("file1", (8, 11), (8, 12)),("file1", (8, 11), (8, 12))); + ("val x", ("file1", (11, 11), (11, 12)), ("file1", (11, 11), (11, 12)),("file1", (11, 11), (11, 12))); + ("Impl", ("sig1", (2, 7), (2, 11)), ("file1", (2, 7), (2, 11)),("file1", (2, 7), (2, 11)))|] + //----------------------------------------------------------------------------------------- @@ -4691,7 +4770,9 @@ type A<'XX, 'YY>() = [] let ``Test project38 abstract slot information`` () = let printAbstractSignature (s: FSharpAbstractSignature) = - let printType (t: FSharpType) = (string t).[5 ..] + let printType (t: FSharpType) = + hash t |> ignore // smoke test to check hash code doesn't loop + (string t).[5 ..] let args = (s.AbstractArguments |> Seq.concat |> Seq.map (fun a -> (match a.Name with Some n -> n + ":" | _ -> "") + printType a.Type) |> String.concat " * ") From 96d40ae3f3a3be555ceb6ddd03cd1a748123b47d Mon Sep 17 00:00:00 2001 From: Don Syme Date: Wed, 30 Mar 2016 05:12:46 +0100 Subject: [PATCH 3/4] Fix 545 - tests (2) --- tests/service/ProjectAnalysisTests.fs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/service/ProjectAnalysisTests.fs b/tests/service/ProjectAnalysisTests.fs index 0217fc2ea4..8a31e2a6b3 100644 --- a/tests/service/ProjectAnalysisTests.fs +++ b/tests/service/ProjectAnalysisTests.fs @@ -4770,9 +4770,7 @@ type A<'XX, 'YY>() = [] let ``Test project38 abstract slot information`` () = let printAbstractSignature (s: FSharpAbstractSignature) = - let printType (t: FSharpType) = - hash t |> ignore // smoke test to check hash code doesn't loop - (string t).[5 ..] + let printType (t: FSharpType) = (string t).[5 ..] let args = (s.AbstractArguments |> Seq.concat |> Seq.map (fun a -> (match a.Name with Some n -> n + ":" | _ -> "") + printType a.Type) |> String.concat " * ") From e2ff74d034a494d265d2561df6cf3a6c12e715d1 Mon Sep 17 00:00:00 2001 From: Don Syme Date: Wed, 30 Mar 2016 05:47:04 +0100 Subject: [PATCH 4/4] update tests --- tests/service/ProjectAnalysisTests.fs | 38 +++++++-------------------- 1 file changed, 10 insertions(+), 28 deletions(-) diff --git a/tests/service/ProjectAnalysisTests.fs b/tests/service/ProjectAnalysisTests.fs index 8a31e2a6b3..c4ca411668 100644 --- a/tests/service/ProjectAnalysisTests.fs +++ b/tests/service/ProjectAnalysisTests.fs @@ -2696,60 +2696,42 @@ let ``Test Project16 sym locations`` () = let fmtLoc (mOpt: Range.range option) = match mOpt with - | None -> ("NONE", (0, 0), (0, 0)) - | Some m -> (Project16.cleanFileName m.FileName, (m.StartLine, m.StartColumn), (m.EndLine, m.EndColumn )) + | None -> None + | Some m -> + let file = Project16.cleanFileName m.FileName + if file = "??" then None + else Some (file, (m.StartLine, m.StartColumn), (m.EndLine, m.EndColumn )) let allUsesOfAllSymbols = wholeProjectResults.GetAllUsesOfAllSymbols() |> Async.RunSynchronously - |> Array.map (fun su -> su.Symbol.ToString(), fmtLoc su.Symbol.SignatureLocation, fmtLoc su.Symbol.DeclarationLocation, fmtLoc su.Symbol.ImplementationLocation) + |> Array.choose (fun su -> + match fmtLoc su.Symbol.SignatureLocation, fmtLoc su.Symbol.DeclarationLocation, fmtLoc su.Symbol.ImplementationLocation with + | Some a, Some b, Some c -> Some (su.Symbol.ToString(), a, b, c) + | _ -> None) allUsesOfAllSymbols |> shouldEqual - [|("ClassAttribute", ("??", (226, 9), (226, 23)),("??", (226, 9), (226, 23)), ("??", (226, 9), (226, 23))); - ("ClassAttribute", ("??", (226, 9), (226, 23)),("??", (226, 9), (226, 23)), ("??", (226, 9), (226, 23))); - ("member .ctor", ("??", (230, 8), (230, 11)), ("??", (230, 8), (230, 11)),("??", (244, 9), (244, 23))); - ("ClassAttribute", ("??", (226, 9), (226, 23)),("??", (226, 9), (226, 23)), ("??", (226, 9), (226, 23))); - ("ClassAttribute", ("??", (226, 9), (226, 23)),("??", (226, 9), (226, 23)), ("??", (226, 9), (226, 23))); - ("member .ctor", ("??", (230, 8), (230, 11)), ("??", (230, 8), (230, 11)),("??", (244, 9), (244, 23))); - ("int", ("??", (69, 9), (69, 12)), ("??", (69, 9), (69, 12)),("??", (69, 9), (69, 12))); - ("int", ("??", (69, 9), (69, 12)), ("??", (69, 9), (69, 12)),("??", (69, 9), (69, 12))); - ("int", ("??", (69, 9), (69, 12)), ("??", (69, 9), (69, 12)),("??", (69, 9), (69, 12))); - ("int", ("??", (69, 9), (69, 12)), ("??", (69, 9), (69, 12)),("??", (69, 9), (69, 12))); - ("int", ("??", (69, 9), (69, 12)), ("??", (69, 9), (69, 12)),("??", (69, 9), (69, 12))); - ("field Field1", ("sig1", (16, 10), (16, 16)),("sig1", (16, 10), (16, 16)), ("file1", (13, 10), (13, 16))); + [|("field Field1", ("sig1", (16, 10), (16, 16)),("sig1", (16, 10), (16, 16)), ("file1", (13, 10), (13, 16))); ("field Field2", ("sig1", (16, 24), (16, 30)),("sig1", (16, 24), (16, 30)), ("file1", (13, 24), (13, 30))); - ("int", ("??", (69, 9), (69, 12)), ("??", (69, 9), (69, 12)),("??", (69, 9), (69, 12))); ("Case1", ("sig1", (17, 8), (17, 13)), ("sig1", (17, 8), (17, 13)),("file1", (14, 8), (14, 13))); ("Case2", ("sig1", (17, 16), (17, 21)), ("sig1", (17, 16), (17, 21)),("file1", (14, 16), (14, 21))); ("C", ("sig1", (4, 5), (4, 6)), ("sig1", (4, 5), (4, 6)),("file1", (4, 5), (4, 6))); - ("unit", ("??", (22, 8), (22, 12)), ("??", (22, 8), (22, 12)),("??", (22, 8), (22, 12))); ("C", ("sig1", (4, 5), (4, 6)), ("sig1", (4, 5), (4, 6)),("file1", (4, 5), (4, 6))); ("member .ctor", ("sig1", (5, 4), (5, 7)), ("sig1", (5, 4), (5, 7)),("file1", (4, 5), (4, 6))); - ("int", ("??", (69, 9), (69, 12)), ("??", (69, 9), (69, 12)),("??", (69, 9), (69, 12))); ("member get_PC", ("sig1", (6, 11), (6, 13)), ("sig1", (6, 11), (6, 13)),("file1", (5, 13), (5, 15))); ("D", ("sig1", (8, 14), (8, 15)), ("sig1", (8, 14), (8, 15)),("file1", (7, 4), (7, 5))); - ("unit", ("??", (22, 8), (22, 12)), ("??", (22, 8), (22, 12)),("??", (22, 8), (22, 12))); ("D", ("sig1", (8, 14), (8, 15)), ("sig1", (8, 14), (8, 15)),("file1", (7, 4), (7, 5))); ("member .ctor", ("sig1", (9, 4), (9, 7)), ("sig1", (9, 4), (9, 7)),("file1", (7, 4), (7, 5))); - ("int", ("??", (69, 9), (69, 12)), ("??", (69, 9), (69, 12)),("??", (69, 9), (69, 12))); ("member get_PD", ("sig1", (10, 11), (10, 13)),("sig1", (10, 11), (10, 13)), ("file1", (8, 13), (8, 15))); ("E", ("sig1", (12, 14), (12, 15)), ("sig1", (12, 14), (12, 15)),("file1", (10, 4), (10, 5))); - ("unit", ("??", (22, 8), (22, 12)), ("??", (22, 8), (22, 12)),("??", (22, 8), (22, 12))); ("E", ("sig1", (12, 14), (12, 15)), ("sig1", (12, 14), (12, 15)),("file1", (10, 4), (10, 5))); ("member .ctor", ("sig1", (13, 4), (13, 7)), ("sig1", (13, 4), (13, 7)),("file1", (10, 4), (10, 5))); - ("int", ("??", (69, 9), (69, 12)), ("??", (69, 9), (69, 12)),("??", (69, 9), (69, 12))); ("member get_PE", ("sig1", (14, 11), (14, 13)),("sig1", (14, 11), (14, 13)), ("file1", (11, 13), (11, 15))); ("F", ("sig1", (16, 4), (16, 5)), ("sig1", (16, 4), (16, 5)),("file1", (13, 4), (13, 5))); ("G", ("sig1", (17, 4), (17, 5)), ("sig1", (17, 4), (17, 5)),("file1", (14, 4), (14, 5))); ("Impl", ("sig1", (2, 7), (2, 11)), ("sig1", (2, 7), (2, 11)),("file1", (2, 7), (2, 11))); - ("int", ("??", (69, 9), (69, 12)), ("??", (69, 9), (69, 12)),("??", (69, 9), (69, 12))); - ("int", ("??", (69, 9), (69, 12)), ("??", (69, 9), (69, 12)),("??", (69, 9), (69, 12))); - ("int", ("??", (69, 9), (69, 12)), ("??", (69, 9), (69, 12)),("??", (69, 9), (69, 12))); - ("int", ("??", (69, 9), (69, 12)), ("??", (69, 9), (69, 12)),("??", (69, 9), (69, 12))); - ("int", ("??", (69, 9), (69, 12)), ("??", (69, 9), (69, 12)),("??", (69, 9), (69, 12))); ("field Field1", ("sig1", (16, 10), (16, 16)),("file1", (13, 10), (13, 16)), ("file1", (13, 10), (13, 16))); ("field Field2", ("sig1", (16, 24), (16, 30)),("file1", (13, 24), (13, 30)), ("file1", (13, 24), (13, 30))); - ("int", ("??", (69, 9), (69, 12)), ("??", (69, 9), (69, 12)),("??", (69, 9), (69, 12))); ("Case1", ("sig1", (17, 8), (17, 13)), ("file1", (14, 8), (14, 13)),("file1", (14, 8), (14, 13))); ("Case2", ("sig1", (17, 16), (17, 21)), ("file1", (14, 16), (14, 21)),("file1", (14, 16), (14, 21))); ("C", ("sig1", (4, 5), (4, 6)), ("file1", (4, 5), (4, 6)),("file1", (4, 5), (4, 6)));