提交 eba5108c 编写于 作者: J Jason Ramsay

For a a document that contains both C# blocks and JS script blocks, the call to:

document.Project.LanguageServices.GetService().GetAdditionalReferencesAsync(document, symbol, cancellationToken)
throws a null reference exception.

Adding the null check to support this scenario.
上级 2d887b8b
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
......@@ -113,8 +114,13 @@ private bool ShouldConsiderSymbol(ISymbol symbol)
private Task<IEnumerable<Location>> GetAdditionalReferencesAsync(
Document document, ISymbol symbol, CancellationToken cancellationToken)
{
return document.Project.LanguageServices.GetService<IReferenceHighlightingAdditionalReferenceProvider>()
.GetAdditionalReferencesAsync(document, symbol, cancellationToken);
var additionalReferenceProvider = document.Project.LanguageServices.GetService<IReferenceHighlightingAdditionalReferenceProvider>();
if (additionalReferenceProvider != null)
{
return additionalReferenceProvider.GetAdditionalReferencesAsync(document, symbol, cancellationToken);
}
return Task.FromResult<IEnumerable<Location>>(Array.Empty<Location>());
}
private async Task<IEnumerable<DocumentHighlights>> CreateSpansAsync(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册