diff --git a/src/Compiler/Symbols/SymbolHelpers.fs b/src/Compiler/Symbols/SymbolHelpers.fs index c641790d02c..75275eb1582 100644 --- a/src/Compiler/Symbols/SymbolHelpers.fs +++ b/src/Compiler/Symbols/SymbolHelpers.fs @@ -94,7 +94,7 @@ module internal SymbolHelpers = | Item.Value vref | Item.CustomBuilder (_, vref) -> Some (rangeOfValRef preferFlag vref) | Item.UnionCase(ucinfo, _) -> Some (rangeOfUnionCaseInfo preferFlag ucinfo) | Item.ActivePatternCase apref -> Some (rangeOfValRef preferFlag apref.ActivePatternVal) - | Item.ExnCase tcref -> Some tcref.Range + | Item.ExnCase tcref -> Some (rangeOfEntityRef preferFlag tcref) | Item.AnonRecdField (_,_,_,m) -> Some m | Item.RecdField rfinfo -> Some (rangeOfRecdFieldInfo preferFlag rfinfo) | Item.UnionCaseField (UnionCaseInfo (_, ucref), fieldIndex) -> Some (rangeOfRecdField preferFlag (ucref.FieldByIndex(fieldIndex))) diff --git a/tests/FSharp.Compiler.ComponentTests/FSharpChecker/FindReferences.fs b/tests/FSharp.Compiler.ComponentTests/FSharpChecker/FindReferences.fs index fd98658e884..3abce08badc 100644 --- a/tests/FSharp.Compiler.ComponentTests/FSharpChecker/FindReferences.fs +++ b/tests/FSharp.Compiler.ComponentTests/FSharpChecker/FindReferences.fs @@ -266,11 +266,22 @@ val myFunc2: param: int -> int } module Exceptions = - let project() = SyntheticProject.Create( - { sourceFile "First" [] with ExtraSource = "exception MyException of string" }, - { sourceFile "Second" [] with ExtraSource = """ + let source1 = "exception MyException of string" + let signature1 = "exception MyException of string" + + let source2 = """ open ModuleFirst -let foo x = raise (MyException "foo")""" }) +let foo x = raise (MyException "foo") +""" + let project() = SyntheticProject.Create( + { sourceFile "First" [] with ExtraSource = source1 }, + { sourceFile "Second" [] with ExtraSource = source2 }) + + let projectWithSignature() = SyntheticProject.Create( + { sourceFile "First" [] with + ExtraSource = source1 + SignatureFile = Custom signature1 }, + { sourceFile "Second" [] with ExtraSource = source2 }) [] let ``We find exception from definition`` () = @@ -292,6 +303,28 @@ let foo x = raise (MyException "foo")""" }) ]) } + [] + let ``We find exception from definition and signature`` () = + projectWithSignature().Workflow { + placeCursor "First" 6 21 "exception MyException of string" ["MyException"] + findAllReferences (expectToFind [ + "FileFirst.fs", 6, 10, 21 + "FileFirst.fsi", 2, 10, 21 + "FileSecond.fs", 8, 19, 30 + ]) + } + + [] + let ``We find exception from usage and signature`` () = + projectWithSignature().Workflow { + placeCursor "Second" 8 30 "raise (MyException \"foo\")" ["MyException"] + findAllReferences (expectToFind [ + "FileFirst.fs", 6, 10, 21 + "FileFirst.fsi", 2, 10, 21 + "FileSecond.fs", 8, 19, 30 + ]) + } + module Attributes = let project() = SyntheticProject.Create(