Skip to content

Commit

Permalink
Exclude a function's defintion from its reference count
Browse files Browse the repository at this point in the history
This change causes a function's definition to be excluded from its
reference count when showing reference CodeLenses.  This was causing a
function definition to show that it had "1 reference" when there were no
other references to it in the workspace.
  • Loading branch information
daviwil committed Jun 12, 2017
1 parent 2bb2f8c commit 393d4dd
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ await editorSession.LanguageService.FindReferencesOfSymbol(
? new Location[0]
: referencesResult
.FoundReferences
.Where(r => NotReferenceDefinition(foundSymbol, r))
.Select(
r => new Location
{
Expand All @@ -94,6 +95,16 @@ await editorSession.LanguageService.FindReferencesOfSymbol(
));
}

private static bool NotReferenceDefinition(
SymbolReference definition,
SymbolReference reference)
{
return
definition.ScriptRegion.StartLineNumber != reference.ScriptRegion.StartLineNumber
|| definition.SymbolType != reference.SymbolType
|| !string.Equals(definition.SymbolName, reference.SymbolName, StringComparison.OrdinalIgnoreCase);
}

private static string GetFileUri(string filePath)
{
// If the file isn't untitled, return a URI-style path
Expand Down

0 comments on commit 393d4dd

Please sign in to comment.