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
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ module internal Tokenizer =
type FSharpTokenInfo with

member token.IsIdentifier = (token.CharClass = FSharpTokenCharKind.Identifier)
member token.IsOperator = (token.ColorClass = FSharpTokenColorKind.Operator)
member token.IsOperator = (token.CharClass = FSharpTokenCharKind.Operator)
member token.IsPunctuation = (token.ColorClass = FSharpTokenColorKind.Punctuation)
member token.IsString = (token.ColorClass = FSharpTokenColorKind.String)
member token.IsComment = (token.ColorClass = FSharpTokenColorKind.Comment)
Expand Down
41 changes: 41 additions & 0 deletions vsintegration/tests/FSharp.Editor.Tests/FindReferencesTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,44 @@ module FindReferences =
foundReferences.Count <> 2 // One in signature file, one in Third file
then
failwith $"Expected 2 references but found {foundReferences.Count}"

[<Theory>]
[<InlineData(">=>")>]
[<InlineData(">++")>]
let ``Find references to operators start with >`` operator =

let project2 =
SyntheticProject.Create(
{ sourceFile "First" [] with
SignatureFile = No
ExtraSource =
"let compose x = fun y -> x - y\n"
+ $"let ({operator}) = compose\n"
+ $"let test t = t {operator} 5\n"
},
{ sourceFile "Second" [ "First" ] with
ExtraSource = "open ModuleFirst\n" + $"let z = 4 {operator} 5\n"
}
)

let solution2, _ = RoslynTestHelpers.CreateSolution project2

let context, foundDefinitions, foundReferences = getContext ()

let documentPath = project2.GetFilePath "Second"

let document =
solution2.TryGetDocumentFromPath documentPath
|> Option.defaultWith (fun _ -> failwith "Document not found")

findUsagesService
.FindReferencesAsync(document, getPositionOf operator documentPath, context)
.Wait()

// We cannot easily inspect what exactly was found here, but that should be verified
// in FSharp.Compiler.ComponentTests.FSharpChecker.FindReferences
if foundDefinitions.Count <> 1 then
failwith $"Expected 1 definition but found {foundDefinitions.Count}"

if foundReferences.Count <> 2 then
failwith $"Expected 2 reference but found {foundReferences.Count}"