提交 bd8ee989 编写于 作者: P Paul Vick

Updated based on comments

上级 80ed32ec
...@@ -78,21 +78,14 @@ private static bool FilterDefinition(ISymbol definition) ...@@ -78,21 +78,14 @@ private static bool FilterDefinition(ISymbol definition)
(definition as IMethodSymbol)?.AssociatedSymbol != null; (definition as IMethodSymbol)?.AssociatedSymbol != null;
} }
/// <summary> // Returns partial symbol locations whose node does not match the queried syntaxNode
/// Returns partial symbol locations whose node does not match the queried syntaxNode
/// </summary>
/// <param name="symbol">Symbol whose locations are queried</param>
/// <param name="cancellationToken">Cancellation token</param>
/// <returns>Partial locations</returns>
private IEnumerable<Location> GetPartialLocations(ISymbol symbol, CancellationToken cancellationToken) private IEnumerable<Location> GetPartialLocations(ISymbol symbol, CancellationToken cancellationToken)
{ {
// Returns nodes from source not equal to actual location // Returns nodes from source not equal to actual location
return from syntaxReference in symbol.DeclaringSyntaxReferences return from syntaxReference in symbol.DeclaringSyntaxReferences
let candidateSyntaxNode = syntaxReference.GetSyntax(cancellationToken) let candidateSyntaxNode = syntaxReference.GetSyntax(cancellationToken)
where !(_queriedNode.Span == candidateSyntaxNode.Span && where _queriedNode != candidateSyntaxNode
_queriedNode.SyntaxTree.FilePath.Equals(candidateSyntaxNode.SyntaxTree.FilePath, select candidateSyntaxNode.GetLocation();
StringComparison.OrdinalIgnoreCase))
select syntaxReference.SyntaxTree.GetLocation(syntaxReference.Span);
} }
public void OnDefinitionFound(ISymbol symbol) public void OnDefinitionFound(ISymbol symbol)
......
...@@ -33,10 +33,6 @@ internal sealed class CodeLensReferenceService : ICodeLensReferencesService ...@@ -33,10 +33,6 @@ internal sealed class CodeLensReferenceService : ICodeLensReferencesService
} }
var semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false); var semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
if (semanticModel == null)
{
return null;
}
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();
...@@ -92,10 +88,6 @@ private static async Task<ReferenceLocationDescriptor> GetDescriptorOfEnclosingS ...@@ -92,10 +88,6 @@ private static async Task<ReferenceLocationDescriptor> GetDescriptorOfEnclosingS
} }
var semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false); var semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
if (semanticModel == null)
{
return null;
}
var langServices = document.GetLanguageService<ICodeLensDisplayInfoService>(); var langServices = document.GetLanguageService<ICodeLensDisplayInfoService>();
if (langServices == null) if (langServices == null)
...@@ -231,11 +223,6 @@ private static async Task<ReferenceMethodDescriptor> GetMethodDescriptorAsync(Lo ...@@ -231,11 +223,6 @@ private static async Task<ReferenceMethodDescriptor> GetMethodDescriptorAsync(Lo
var document = solution.GetDocument(doc.Id); var document = solution.GetDocument(doc.Id);
var semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false); var semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
if (semanticModel == null)
{
return null;
}
var fullName = GetEnclosingMethod(semanticModel, commonLocation)?.ToDisplayString(MethodDisplayFormat); var fullName = GetEnclosingMethod(semanticModel, commonLocation)?.ToDisplayString(MethodDisplayFormat);
return !string.IsNullOrEmpty(fullName) ? new ReferenceMethodDescriptor(fullName, document.FilePath) : null; return !string.IsNullOrEmpty(fullName) ? new ReferenceMethodDescriptor(fullName, document.FilePath) : null;
...@@ -269,10 +256,6 @@ public async Task<IEnumerable<ReferenceMethodDescriptor>> FindReferenceMethodsAs ...@@ -269,10 +256,6 @@ public async Task<IEnumerable<ReferenceMethodDescriptor>> FindReferenceMethodsAs
var document = solution.GetDocument(doc.Id); var document = solution.GetDocument(doc.Id);
var semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false); var semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
if (semanticModel == null)
{
return null;
}
return GetEnclosingMethod(semanticModel, commonLocation)?.ToDisplayString(MethodDisplayFormat); return GetEnclosingMethod(semanticModel, commonLocation)?.ToDisplayString(MethodDisplayFormat);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册