Skip to content

Simplify logic of determining Reference definition #1139

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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 @@ -139,7 +139,7 @@ public CodeLens ResolveCodeLens(CodeLens codeLens, ScriptFile scriptFile)
}

/// <summary>
/// Check whether a SymbolReference is not a reference to another defined symbol.
/// Check whether a SymbolReference is the actual definition of that symbol.
/// </summary>
/// <param name="definition">The symbol definition that may be referenced.</param>
/// <param name="reference">The reference symbol to check.</param>
Expand All @@ -148,11 +148,15 @@ private static bool IsReferenceDefinition(
SymbolReference definition,
SymbolReference reference)
{
// First check if we are in the same file as the definition. if we are...
// check if it's on the same line number.

// TODO: Do we care about two symbol definitions of the same name?
// if we do, how could we possibly know that a reference in one file is a reference
// of a particular symbol definition?
return
definition.FilePath != reference.FilePath
|| definition.ScriptRegion.StartLineNumber != reference.ScriptRegion.StartLineNumber
|| definition.SymbolType != reference.SymbolType
|| !string.Equals(definition.SymbolName, reference.SymbolName, StringComparison.OrdinalIgnoreCase);
definition.FilePath == reference.FilePath &&
definition.ScriptRegion.StartLineNumber == reference.ScriptRegion.StartLineNumber;
}

/// <summary>
Expand Down