in ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Features/Daemon/ContextHighlighters/FSharpUsagesContextHighlighter.cs [85:129]
private static void AddUsagesRanges(FSharpSymbol symbol, HashSet<DocumentRange> ranges,
FSharpCheckFileResults checkResults, IDocument document, IFSharpFile fsFile)
{
var isActivePatternCase = symbol is FSharpActivePatternCase;
var isGreaterOp =
symbol is FSharpMemberOrFunctionOrValue { LogicalName: StandardOperatorNames.GreaterThan };
var symbolUsages = checkResults?.GetUsesOfSymbolInFile(symbol, null);
if (symbolUsages == null)
return;
foreach (var symbolUse in symbolUsages)
{
var treeOffset = document.GetTreeEndOffset(symbolUse.Range);
var usageToken = fsFile.FindTokenAt(treeOffset - 1);
if (usageToken == null)
continue;
if (isActivePatternCase && symbolUse.IsFromDefinition)
{
if (!(symbolUse.Symbol is FSharpActivePatternCase useSymbol))
continue;
if (useSymbol.DeclarationLocation.Equals(symbolUse.Range))
{
var caseDeclaration = usageToken.GetContainingNode<IActivePatternId>()?.Cases[useSymbol.Index];
if (caseDeclaration != null)
{
ranges.Add(caseDeclaration.GetDocumentRange());
continue;
}
}
}
if (!(usageToken is IFSharpIdentifierToken identToken))
continue;
var tokenType = identToken.GetTokenType();
if ((tokenType == FSharpTokenType.GREATER || tokenType == FSharpTokenType.GREATER_RBRACK) && !isGreaterOp)
continue; // found usage of generic symbol with specified type parameter
ranges.Add(identToken.GetDocumentRange());
}
}