提交 e47543b2 编写于 作者: R Ravi Chande

Implement INavigableSymbols

Breaks the internal GTD infrastructure into seperate symbols for
determining the navigable symbol at the caret position and performing
the navigation.
上级 b8afd807
......@@ -75,7 +75,7 @@
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0"/>
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0"/>
</dependentAssembly>
<!-- Even though all of our references are to Dev15 binaries we are still pulling in BasicUndo
......
......@@ -83,7 +83,7 @@
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0"/>
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0"/>
</dependentAssembly>
<!-- Even though all of our references are to Dev15 binaries we are still pulling in BasicUndo
......
......@@ -41,7 +41,7 @@
<MicrosoftDiaSymReaderPortablePdbVersion>1.3.0</MicrosoftDiaSymReaderPortablePdbVersion>
<MicrosoftDotNetIBCMerge>4.7.2-alpha-00001</MicrosoftDotNetIBCMerge>
<MicrosoftIdentityModelClientsActiveDirectoryVersion>3.13.8</MicrosoftIdentityModelClientsActiveDirectoryVersion>
<MicrosoftInternalPerformanceCodeMarkersDesignTimeVersion>15.0.26507-alpha</MicrosoftInternalPerformanceCodeMarkersDesignTimeVersion>
<MicrosoftInternalPerformanceCodeMarkersDesignTimeVersion>15.0.26606-alpha</MicrosoftInternalPerformanceCodeMarkersDesignTimeVersion>
<MicrosoftInternalVisualStudioShellInterop140DesignTimeVersion>14.3.25407-alpha</MicrosoftInternalVisualStudioShellInterop140DesignTimeVersion>
<MicrosoftMetadataVisualizerVersion>1.0.0-beta1-61531-03</MicrosoftMetadataVisualizerVersion>
<MicrosoftMSXMLVersion>8.0.0.0-alpha</MicrosoftMSXMLVersion>
......@@ -60,35 +60,35 @@
<MicrosoftNetSdkVersion>2.0.0-alpha-20170405-2</MicrosoftNetSdkVersion>
<MicrosoftNuGetBuildTasksVersion>0.1.0</MicrosoftNuGetBuildTasksVersion>
<MicrosoftPortableTargetsVersion>0.1.2-dev</MicrosoftPortableTargetsVersion>
<MicrosoftServiceHubClientVersion>1.1.18-rc-g92b2150dd1</MicrosoftServiceHubClientVersion>
<MicrosoftServiceHubClientVersion>1.1.31-rc</MicrosoftServiceHubClientVersion>
<MicrosoftTplDataflowVersion>4.5.24</MicrosoftTplDataflowVersion>
<MicrosoftVisualBasicVersion>10.1.0</MicrosoftVisualBasicVersion>
<MicrosoftVisualStudioCallHierarchyPackageDefinitionsVersion>15.0.26507-alpha</MicrosoftVisualStudioCallHierarchyPackageDefinitionsVersion>
<MicrosoftVisualStudioCodeAnalysisSdkUIVersion>15.0.26507-alpha</MicrosoftVisualStudioCodeAnalysisSdkUIVersion>
<MicrosoftVisualStudioComponentModelHostVersion>15.0.26507-alpha</MicrosoftVisualStudioComponentModelHostVersion>
<MicrosoftVisualStudioCallHierarchyPackageDefinitionsVersion>15.0.26606-alpha</MicrosoftVisualStudioCallHierarchyPackageDefinitionsVersion>
<MicrosoftVisualStudioCodeAnalysisSdkUIVersion>15.0.26606-alpha</MicrosoftVisualStudioCodeAnalysisSdkUIVersion>
<MicrosoftVisualStudioComponentModelHostVersion>15.0.26606-alpha</MicrosoftVisualStudioComponentModelHostVersion>
<MicrosoftVisualStudioCompositionVersion>15.0.66-rc</MicrosoftVisualStudioCompositionVersion>
<MicrosoftVisualStudioCoreUtilityVersion>15.0.26507-alpha</MicrosoftVisualStudioCoreUtilityVersion>
<MicrosoftVisualStudioCoreUtilityVersion>15.0.26606-alpha</MicrosoftVisualStudioCoreUtilityVersion>
<MicrosoftVisualStudioDebuggerEngineVersion>15.0.26201-gamma</MicrosoftVisualStudioDebuggerEngineVersion>
<MicrosoftVisualStudioDebuggerMetadataVersion>15.0.26201-gamma</MicrosoftVisualStudioDebuggerMetadataVersion>
<MicrosoftVisualStudioDebuggerInterop100Version>10.0.30319</MicrosoftVisualStudioDebuggerInterop100Version>
<MicrosoftVisualStudioDesignerInterfacesVersion>1.1.4322</MicrosoftVisualStudioDesignerInterfacesVersion>
<MicrosoftVisualStudioDiagnosticsPerformanceProviderVersion>15.0.26507-alpha</MicrosoftVisualStudioDiagnosticsPerformanceProviderVersion>
<MicrosoftVisualStudioEditorVersion>15.0.26507-alpha</MicrosoftVisualStudioEditorVersion>
<MicrosoftVisualStudioGraphModelVersion>15.0.26507-alpha</MicrosoftVisualStudioGraphModelVersion>
<MicrosoftVisualStudioImageCatalogVersion>15.0.26507-alpha</MicrosoftVisualStudioImageCatalogVersion>
<MicrosoftVisualStudioImagingVersion>15.0.26507-alpha</MicrosoftVisualStudioImagingVersion>
<MicrosoftVisualStudioDiagnosticsPerformanceProviderVersion>15.0.26606-alpha</MicrosoftVisualStudioDiagnosticsPerformanceProviderVersion>
<MicrosoftVisualStudioEditorVersion>15.0.26606-alpha</MicrosoftVisualStudioEditorVersion>
<MicrosoftVisualStudioGraphModelVersion>15.0.26606-alpha</MicrosoftVisualStudioGraphModelVersion>
<MicrosoftVisualStudioImageCatalogVersion>15.0.26606-alpha</MicrosoftVisualStudioImageCatalogVersion>
<MicrosoftVisualStudioImagingVersion>15.0.26606-alpha</MicrosoftVisualStudioImagingVersion>
<MicrosoftVisualStudioImagingInterop140DesignTimeVersion>14.3.25407</MicrosoftVisualStudioImagingInterop140DesignTimeVersion>
<MicrosoftVisualStudioInteractiveWindowVersion>2.0.0-rc3-61304-01</MicrosoftVisualStudioInteractiveWindowVersion>
<MicrosoftVisualStudioLanguageCallHierarchyVersion>15.0.26507-alpha</MicrosoftVisualStudioLanguageCallHierarchyVersion>
<MicrosoftVisualStudioLanguageIntellisenseVersion>15.0.26507-alpha</MicrosoftVisualStudioLanguageIntellisenseVersion>
<MicrosoftVisualStudioLanguageNavigateToInterfacesVersion>15.0.26507-alpha</MicrosoftVisualStudioLanguageNavigateToInterfacesVersion>
<MicrosoftVisualStudioLanguageStandardClassificationVersion>15.0.26507-alpha</MicrosoftVisualStudioLanguageStandardClassificationVersion>
<MicrosoftVisualStudioLanguageCallHierarchyVersion>15.0.26606-alpha</MicrosoftVisualStudioLanguageCallHierarchyVersion>
<MicrosoftVisualStudioLanguageIntellisenseVersion>15.0.26606-alpha</MicrosoftVisualStudioLanguageIntellisenseVersion>
<MicrosoftVisualStudioLanguageNavigateToInterfacesVersion>15.0.26606-alpha</MicrosoftVisualStudioLanguageNavigateToInterfacesVersion>
<MicrosoftVisualStudioLanguageStandardClassificationVersion>15.0.26606-alpha</MicrosoftVisualStudioLanguageStandardClassificationVersion>
<MicrosoftVisualStudioOLEInteropVersion>7.10.6070</MicrosoftVisualStudioOLEInteropVersion>
<MicrosoftVisualStudioPlatformVSEditorVersion>15.0.26507-alpha</MicrosoftVisualStudioPlatformVSEditorVersion>
<MicrosoftVisualStudioPlatformVSEditorInteropVersion>15.0.26507-alpha</MicrosoftVisualStudioPlatformVSEditorInteropVersion>
<MicrosoftVisualStudioProgressionCodeSchemaVersion>15.0.26507-alpha</MicrosoftVisualStudioProgressionCodeSchemaVersion>
<MicrosoftVisualStudioProgressionCommonVersion>15.0.26507-alpha</MicrosoftVisualStudioProgressionCommonVersion>
<MicrosoftVisualStudioProgressionInterfacesVersion>15.0.26507-alpha</MicrosoftVisualStudioProgressionInterfacesVersion>
<MicrosoftVisualStudioPlatformVSEditorVersion>15.0.26606-alpha</MicrosoftVisualStudioPlatformVSEditorVersion>
<MicrosoftVisualStudioPlatformVSEditorInteropVersion>15.0.26606-alpha</MicrosoftVisualStudioPlatformVSEditorInteropVersion>
<MicrosoftVisualStudioProgressionCodeSchemaVersion>15.0.26606-alpha</MicrosoftVisualStudioProgressionCodeSchemaVersion>
<MicrosoftVisualStudioProgressionCommonVersion>15.0.26606-alpha</MicrosoftVisualStudioProgressionCommonVersion>
<MicrosoftVisualStudioProgressionInterfacesVersion>15.0.26606-alpha</MicrosoftVisualStudioProgressionInterfacesVersion>
<MicrosoftVisualStudioProjectSystemVersion>15.3.178-pre-g209fb07c2e</MicrosoftVisualStudioProjectSystemVersion>
<MicrosoftVisualStudioQualityToolsUnitTestFrameworkVersion>10.0.0.0-alpha</MicrosoftVisualStudioQualityToolsUnitTestFrameworkVersion>
<MicrosoftVisualStudioRemoteControlVersion>14.0.249-master2E2DC10C</MicrosoftVisualStudioRemoteControlVersion>
......@@ -96,32 +96,33 @@
<MicrosoftVisualStudioSetupConfigurationNativex86Version>1.3.269-rc</MicrosoftVisualStudioSetupConfigurationNativex86Version>
<MicrosoftVisualStudioSettings140Version>14.3.25407</MicrosoftVisualStudioSettings140Version>
<MicrosoftVisualStudioShell140Version>14.3.25407</MicrosoftVisualStudioShell140Version>
<MicrosoftVisualStudioShell150Version>15.0.26507-alpha</MicrosoftVisualStudioShell150Version>
<MicrosoftVisualStudioShellDesignVersion>15.0.26507-alpha</MicrosoftVisualStudioShellDesignVersion>
<MicrosoftVisualStudioShellFrameworkVersion>15.0.26507-alpha</MicrosoftVisualStudioShellFrameworkVersion>
<MicrosoftVisualStudioShellImmutable100Version>15.0.26507-alpha</MicrosoftVisualStudioShellImmutable100Version>
<MicrosoftVisualStudioShell150Version>15.0.26606-alpha</MicrosoftVisualStudioShell150Version>
<MicrosoftVisualStudioShellDesignVersion>15.0.26606-alpha</MicrosoftVisualStudioShellDesignVersion>
<MicrosoftVisualStudioShellInterop153DesignTimeVersion>15.0.26606-alpha</MicrosoftVisualStudioShellInterop153DesignTimeVersion>
<MicrosoftVisualStudioShellFrameworkVersion>15.0.26606-alpha</MicrosoftVisualStudioShellFrameworkVersion>
<MicrosoftVisualStudioShellImmutable100Version>15.0.26606-alpha</MicrosoftVisualStudioShellImmutable100Version>
<MicrosoftVisualStudioShellImmutable110Version>15.0.25413-Preview5</MicrosoftVisualStudioShellImmutable110Version>
<MicrosoftVisualStudioShellInteropVersion>7.10.6071</MicrosoftVisualStudioShellInteropVersion>
<MicrosoftVisualStudioShellInterop100Version>10.0.30319</MicrosoftVisualStudioShellInterop100Version>
<MicrosoftVisualStudioShellInterop110Version>11.0.61030</MicrosoftVisualStudioShellInterop110Version>
<MicrosoftVisualStudioShellInterop121DesignTimeVersion>12.1.30328</MicrosoftVisualStudioShellInterop121DesignTimeVersion>
<MicrosoftVisualStudioShellInterop140DesignTimeVersion>14.3.25407</MicrosoftVisualStudioShellInterop140DesignTimeVersion>
<MicrosoftVisualStudioShellInterop150DesignTimeVersion>15.0.26507-alpha</MicrosoftVisualStudioShellInterop150DesignTimeVersion>
<MicrosoftVisualStudioShellInterop150DesignTimeVersion>15.0.26606-alpha</MicrosoftVisualStudioShellInterop150DesignTimeVersion>
<MicrosoftVisualStudioShellInterop80Version>8.0.50727</MicrosoftVisualStudioShellInterop80Version>
<MicrosoftVisualStudioShellInterop90Version>9.0.30729</MicrosoftVisualStudioShellInterop90Version>
<MicrosoftVisualStudioTelemetryVersion>15.0.26507-alpha</MicrosoftVisualStudioTelemetryVersion>
<MicrosoftVisualStudioTelemetryVersion>15.0.26606-alpha</MicrosoftVisualStudioTelemetryVersion>
<MicrosoftVisualStudioTemplateWizardInterfaceVersion>8.0.0.0-alpha</MicrosoftVisualStudioTemplateWizardInterfaceVersion>
<MicrosoftVisualStudioTextDataVersion>15.0.26507-alpha</MicrosoftVisualStudioTextDataVersion>
<MicrosoftVisualStudioTextInternalVersion>15.0.26507-alpha</MicrosoftVisualStudioTextInternalVersion>
<MicrosoftVisualStudioTextLogicVersion>15.0.26507-alpha</MicrosoftVisualStudioTextLogicVersion>
<MicrosoftVisualStudioTextUIVersion>15.0.26507-alpha</MicrosoftVisualStudioTextUIVersion>
<MicrosoftVisualStudioTextUIWpfVersion>15.0.26507-alpha</MicrosoftVisualStudioTextUIWpfVersion>
<MicrosoftVisualStudioTextDataVersion>15.0.26606-alpha</MicrosoftVisualStudioTextDataVersion>
<MicrosoftVisualStudioTextInternalVersion>15.0.26606-alpha</MicrosoftVisualStudioTextInternalVersion>
<MicrosoftVisualStudioTextLogicVersion>15.0.26606-alpha</MicrosoftVisualStudioTextLogicVersion>
<MicrosoftVisualStudioTextUIVersion>15.0.26606-alpha</MicrosoftVisualStudioTextUIVersion>
<MicrosoftVisualStudioTextUIWpfVersion>15.0.26606-alpha</MicrosoftVisualStudioTextUIWpfVersion>
<MicrosoftVisualStudioTextManagerInteropVersion>7.10.6070</MicrosoftVisualStudioTextManagerInteropVersion>
<MicrosoftVisualStudioTextManagerInterop100Version>10.0.30319</MicrosoftVisualStudioTextManagerInterop100Version>
<MicrosoftVisualStudioTextManagerInterop120Version>12.0.30110</MicrosoftVisualStudioTextManagerInterop120Version>
<MicrosoftVisualStudioTextManagerInterop121DesignTimeVersion>12.1.30328</MicrosoftVisualStudioTextManagerInterop121DesignTimeVersion>
<MicrosoftVisualStudioThreadingVersion>15.3.20</MicrosoftVisualStudioThreadingVersion>
<MicrosoftVisualStudioUtilitiesVersion>15.0.26507-alpha</MicrosoftVisualStudioUtilitiesVersion>
<MicrosoftVisualStudioUtilitiesVersion>15.0.26606-alpha</MicrosoftVisualStudioUtilitiesVersion>
<MicrosoftVisualStudioValidationVersion>15.3.15</MicrosoftVisualStudioValidationVersion>
<MicrosoftVisualStudioVsInteractiveWindowVersion>2.0.0-rc3-61304-01</MicrosoftVisualStudioVsInteractiveWindowVersion>
<MicrosoftWin32PrimitivesVersion>4.3.0</MicrosoftWin32PrimitivesVersion>
......@@ -130,7 +131,7 @@
<MoqVersion>4.2.1402.2112</MoqVersion>
<NerdbankFullDuplexStreamVersion>1.0.1</NerdbankFullDuplexStreamVersion>
<NETStandardLibraryVersion>1.6.1</NETStandardLibraryVersion>
<NewtonsoftJsonVersion>8.0.3</NewtonsoftJsonVersion>
<NewtonsoftJsonVersion>9.0.1</NewtonsoftJsonVersion>
<NuGetCommandLineVersion>2.8.5</NuGetCommandLineVersion>
<NuGetCommandLineXPlatVersion>3.5.0-beta2-1484</NuGetCommandLineXPlatVersion>
<NuGetVisualStudioVersion>4.0.0-rc-2048</NuGetVisualStudioVersion>
......@@ -145,7 +146,7 @@
<RoslynToolsMicrosoftVSIXExpInstallerVersion>0.4.0-beta</RoslynToolsMicrosoftVSIXExpInstallerVersion>
<RoslynToolsReferenceAssembliesVersion>0.1.1</RoslynToolsReferenceAssembliesVersion>
<RoslynMicrosoftVisualStudioExtensionManagerVersion>0.0.4</RoslynMicrosoftVisualStudioExtensionManagerVersion>
<StreamJsonRpcVersion>1.0.2-rc</StreamJsonRpcVersion>
<StreamJsonRpcVersion>1.1.73</StreamJsonRpcVersion>
<SystemAppContextVersion>4.3.0</SystemAppContextVersion>
<SystemCollectionsVersion>4.3.0</SystemCollectionsVersion>
<SystemCollectionsConcurrentVersion>4.3.0</SystemCollectionsConcurrentVersion>
......@@ -228,4 +229,4 @@
<xunitrunnervisualstudioVersion>2.2.0-beta4-build1194</xunitrunnervisualstudioVersion>
</PropertyGroup>
</Project>
</Project>
\ No newline at end of file
......@@ -171,6 +171,9 @@
<PackageReference Include="Microsoft.VisualStudio.Utilities">
<Version>$(MicrosoftVisualStudioUtilitiesVersion)</Version>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.Shell.Interop.15.3.DesignTime">
<Version>$(MicrosoftVisualStudioShellInterop153DesignTimeVersion)</Version>
</PackageReference>
</ItemGroup>
<Import Project="..\..\..\build\Targets\Imports.targets" />
</Project>
......@@ -116,7 +116,9 @@
<Compile Include="Formatting\Indentation\SmartTokenFormatterCommandHandler.cs" />
<Compile Include="Formatting\Indentation\WhitespaceExtensions.cs" />
<Compile Include="Formatting\CSharpEditorFormattingService.PasteFormattingRule.cs" />
<Compile Include="GoToDefinition\CSharpGoToDefinitionItemService.cs" />
<Compile Include="GoToDefinition\CSharpGoToDefinitionService.cs" />
<Compile Include="GoToDefinition\CSharpGoToDefinitionSymbolService.cs" />
<Compile Include="Highlighting\KeywordHighlighters\AbstractAsyncHighlighter.cs" />
<Compile Include="Highlighting\KeywordHighlighters\AsyncAnonymousMethodHighlighter.cs" />
<Compile Include="Highlighting\KeywordHighlighters\AsyncMethodHighlighter.cs" />
......
using System;
using System.Collections.Generic;
using System.Composition;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Editor.GoToDefinition;
using Microsoft.CodeAnalysis.Host.Mef;
namespace Microsoft.CodeAnalysis.Editor.CSharp.GoToDefinition
{
[ExportLanguageService(typeof(IGoToSymbolService), LanguageNames.CSharp), Shared]
internal class CSharpGoToDefinitionItemService : AbstractGoToDefinitionItemService
{
}
}
......@@ -18,10 +18,5 @@ internal class CSharpGoToDefinitionService : AbstractGoToDefinitionService
: base(streamingPresenters)
{
}
protected override ISymbol FindRelatedExplicitlyDeclaredSymbol(ISymbol symbol, Compilation compilation)
{
return symbol;
}
}
}
\ No newline at end of file
// 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.Composition;
using Microsoft.CodeAnalysis.Editor.GoToDefinition;
using Microsoft.CodeAnalysis.Editor.Host;
using Microsoft.CodeAnalysis.Host.Mef;
namespace Microsoft.CodeAnalysis.Editor.CSharp.GoToDefinition
{
[ExportLanguageService(typeof(IGoToDefinitionSymbolService), LanguageNames.CSharp), Shared]
internal class CSharpGoToDefinitionSymbolService : AbstractGoToDefinitionSymbolService
{
protected override ISymbol FindRelatedExplicitlyDeclaredSymbol(ISymbol symbol, Compilation compilation)
{
return symbol;
}
}
}
......@@ -161,6 +161,12 @@
<Compile Include="FindUsages\IFindUsagesContext.cs" />
<Compile Include="FindUsages\IFindUsagesService.cs" />
<Compile Include="FindUsages\SimpleFindUsagesContext.cs" />
<Compile Include="GoToDefinition\AbstractGoToDefinitionItemService.cs" />
<Compile Include="GoToDefinition\AbstractGoToDefinitionSymbolService.cs" />
<Compile Include="GoToDefinition\GoToDefinitionContext.cs" />
<Compile Include="GoToDefinition\IGoToDefinitionSymbolService.cs" />
<Compile Include="GoToDefinition\IGoToSymbolService.cs" />
<Compile Include="GoToDefinition\WellKnownDefinitionTypes.cs" />
<Compile Include="Implementation\InlineRename\Dashboard\DashboardAutomationPeer.cs" />
<Compile Include="Implementation\InlineRename\HighlightTags\RenameConflictTag.cs" />
<Compile Include="Implementation\InlineRename\HighlightTags\RenameConflictTagDefinition.cs" />
......
// 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.Collections.Immutable;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Editor.FindUsages;
using Microsoft.CodeAnalysis.Editor.Shared.Utilities;
using Microsoft.CodeAnalysis.FindUsages;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.Shared.Extensions;
namespace Microsoft.CodeAnalysis.Editor.GoToDefinition
{
internal abstract class AbstractGoToDefinitionItemService : ForegroundThreadAffinitizedObject, IGoToSymbolService
{
public async Task GetDefinitionsAsync(GoToDefinitionContext context)
{
var document = context.Document;
var position = context.Position;
var cancellationToken = context.CancellationToken;
var service = document.GetLanguageService<IGoToDefinitionSymbolService>();
var (symbol, span) = await service.GetSymbolAndBoundSpanAsync(document, position, cancellationToken).ConfigureAwait(false);
if (symbol == null)
{
return;
}
// We want ctrl-click GTD to be as close to regular GTD as possible.
// This means we have to query for "third party navigation", from
// XAML, etc. That call has to be done on the UI thread.
var definitions = await Task.Factory.StartNew(() =>
GoToDefinitionHelpers.GetDefinitions(symbol, document.Project, thirdPartyNavigationAllowed: true, cancellationToken: cancellationToken)
.WhereAsArray(d => d.CanNavigateTo(document.Project.Solution.Workspace)),
cancellationToken,
TaskCreationOptions.None,
ForegroundTaskScheduler).ConfigureAwait(false);
foreach (var definition in definitions)
{
context.AddItem(WellKnownDefinitionTypes.Definition, definition);
}
context.Span = span;
}
}
}
......@@ -6,7 +6,6 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Editor.Host;
using Microsoft.CodeAnalysis.FindSymbols;
using Microsoft.CodeAnalysis.LanguageServices;
using Microsoft.CodeAnalysis.Navigation;
using Microsoft.CodeAnalysis.Shared.Extensions;
......@@ -18,42 +17,17 @@ internal abstract class AbstractGoToDefinitionService : IGoToDefinitionService
{
private readonly IEnumerable<Lazy<IStreamingFindUsagesPresenter>> _streamingPresenters;
protected abstract ISymbol FindRelatedExplicitlyDeclaredSymbol(ISymbol symbol, Compilation compilation);
protected AbstractGoToDefinitionService(
IEnumerable<Lazy<IStreamingFindUsagesPresenter>> streamingPresenters)
{
_streamingPresenters = streamingPresenters;
}
private async Task<ISymbol> FindSymbolAsync(Document document, int position, CancellationToken cancellationToken)
{
if (!document.SupportsSemanticModel)
{
return null;
}
var workspace = document.Project.Solution.Workspace;
var semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
var semanticInfo = await SymbolFinder.GetSemanticInfoAtPositionAsync(semanticModel, position, workspace, cancellationToken).ConfigureAwait(false);
// prefer references to declarations. It's more likely that the user is attempting to
// go to a definition at some other location, rather than the definition they're on.
// This can happen when a token is at a location that is both a reference and a definition.
// For example, on an anonymous type member declaration.
var symbol = semanticInfo.AliasSymbol ??
semanticInfo.ReferencedSymbols.FirstOrDefault() ??
semanticInfo.DeclaredSymbol ??
semanticInfo.Type;
return FindRelatedExplicitlyDeclaredSymbol(symbol, semanticModel.Compilation);
}
public async Task<IEnumerable<INavigableItem>> FindDefinitionsAsync(
Document document, int position, CancellationToken cancellationToken)
{
var symbol = await FindSymbolAsync(document, position, cancellationToken).ConfigureAwait(false);
var symbolService = document.GetLanguageService<IGoToDefinitionSymbolService>();
var (symbol, span) = await symbolService.GetSymbolAndBoundSpanAsync(document, position, cancellationToken).ConfigureAwait(false);
// Try to compute source definitions from symbol.
var items = symbol != null
......@@ -68,7 +42,8 @@ private async Task<ISymbol> FindSymbolAsync(Document document, int position, Can
public bool TryGoToDefinition(Document document, int position, CancellationToken cancellationToken)
{
// First try to compute the referenced symbol and attempt to go to definition for the symbol.
var symbol = FindSymbolAsync(document, position, cancellationToken).WaitAndGetResult(cancellationToken);
var symbolService = document.GetLanguageService<IGoToDefinitionSymbolService>();
var (symbol, span) = symbolService.GetSymbolAndBoundSpanAsync(document, position, cancellationToken).WaitAndGetResult(cancellationToken);
if (symbol == null)
{
return false;
......
// 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.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.FindSymbols;
using Microsoft.CodeAnalysis.Host;
using Microsoft.CodeAnalysis.Text;
namespace Microsoft.CodeAnalysis.Editor.GoToDefinition
{
internal abstract class AbstractGoToDefinitionSymbolService : IGoToDefinitionSymbolService
{
protected abstract ISymbol FindRelatedExplicitlyDeclaredSymbol(ISymbol symbol, Compilation compilation);
public async Task<(ISymbol, TextSpan)> GetSymbolAndBoundSpanAsync(Document document, int position, CancellationToken cancellationToken)
{
var workspace = document.Project.Solution.Workspace;
var semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
var semanticInfo = await SymbolFinder.GetSemanticInfoAtPositionAsync(semanticModel, position, workspace, cancellationToken).ConfigureAwait(false);
// prefer references to declarations. It's more likely that the user is attempting to
// go to a definition at some other location, rather than the definition they're on.
// This can happen when a token is at a location that is both a reference and a definition.
// For example, on an anonymous type member declaration.
var symbol = semanticInfo.AliasSymbol ??
semanticInfo.ReferencedSymbols.FirstOrDefault() ??
semanticInfo.DeclaredSymbol ??
semanticInfo.Type;
return (FindRelatedExplicitlyDeclaredSymbol(symbol, semanticModel.Compilation), semanticInfo.Span);
}
}
}
// 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.Collections.Generic;
using System.Threading;
using Microsoft.CodeAnalysis.FindUsages;
using Microsoft.CodeAnalysis.Text;
namespace Microsoft.CodeAnalysis.Editor.GoToDefinition
{
internal class GoToDefinitionContext
{
private readonly object _gate = new object();
private readonly Dictionary<string, List<DefinitionItem>> _items = new Dictionary<string, List<DefinitionItem>>();
public GoToDefinitionContext(Document document, int position, CancellationToken cancellationToken)
{
Document = document;
Position = position;
CancellationToken = cancellationToken;
}
public Document Document { get; }
public int Position { get; }
public CancellationToken CancellationToken { get; }
public IReadOnlyDictionary<string, List<DefinitionItem>> Items => _items;
public TextSpan Span { get; set; }
public void AddItem(string key, DefinitionItem item)
{
lock (_gate)
{
if (!_items.ContainsKey(key))
{
_items[key] = new List<DefinitionItem>();
}
_items[key].Add(item);
}
}
}
}
......@@ -2,6 +2,7 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using System.Threading;
using Microsoft.CodeAnalysis.Editor.FindUsages;
......@@ -15,13 +16,11 @@ namespace Microsoft.CodeAnalysis.Editor.GoToDefinition
{
internal static class GoToDefinitionHelpers
{
public static bool TryGoToDefinition(
public static ImmutableArray<DefinitionItem> GetDefinitions(
ISymbol symbol,
Project project,
IEnumerable<Lazy<IStreamingFindUsagesPresenter>> streamingPresenters,
CancellationToken cancellationToken,
bool thirdPartyNavigationAllowed = true,
bool throwOnHiddenDefinition = false)
bool thirdPartyNavigationAllowed,
CancellationToken cancellationToken)
{
var alias = symbol as IAliasSymbol;
if (alias != null)
......@@ -29,7 +28,7 @@ internal static class GoToDefinitionHelpers
var ns = alias.Target as INamespaceSymbol;
if (ns != null && ns.IsGlobalNamespace)
{
return false;
return ImmutableArray.Create<DefinitionItem>();
}
}
......@@ -91,13 +90,43 @@ internal static class GoToDefinitionHelpers
}
definitions.Add(definitionItem);
return definitions.ToImmutableAndFree();
}
public static bool TryGoToDefinition(
ISymbol symbol,
Project project,
IEnumerable<Lazy<IStreamingFindUsagesPresenter>> streamingPresenters,
CancellationToken cancellationToken,
bool thirdPartyNavigationAllowed = true,
bool throwOnHiddenDefinition = false)
{
var definitions = GetDefinitions(symbol, project, thirdPartyNavigationAllowed, cancellationToken);
var presenter = streamingPresenters.FirstOrDefault()?.Value;
var title = string.Format(EditorFeaturesResources._0_declarations,
FindUsagesHelpers.GetDisplayName(symbol));
return presenter.TryNavigateToOrPresentItemsAsync(
project.Solution.Workspace, title, definitions.ToImmutableAndFree()).WaitAndGetResult(cancellationToken);
project.Solution.Workspace, title, definitions).WaitAndGetResult(cancellationToken);
}
public static bool TryGoToDefinition(
ImmutableArray<DefinitionItem> definitions,
Project project,
string title,
IEnumerable<Lazy<IStreamingFindUsagesPresenter>> streamingPresenters,
CancellationToken cancellationToken)
{
if (definitions.IsDefaultOrEmpty)
{
return false;
}
var presenter = streamingPresenters.FirstOrDefault()?.Value;
return presenter.TryNavigateToOrPresentItemsAsync(
project.Solution.Workspace, title, definitions).WaitAndGetResult(cancellationToken);
}
}
}
\ No newline at end of file
// 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.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Host;
using Microsoft.CodeAnalysis.Text;
namespace Microsoft.CodeAnalysis.Editor.GoToDefinition
{
internal interface IGoToDefinitionSymbolService : ILanguageService
{
Task<(ISymbol, TextSpan)> GetSymbolAndBoundSpanAsync(Document document, int position, CancellationToken cancellationToken);
}
}
// 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;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Host;
namespace Microsoft.CodeAnalysis.Editor.GoToDefinition
{
internal interface IGoToSymbolService : ILanguageService
{
Task GetDefinitionsAsync(GoToDefinitionContext context);
}
}
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
namespace Microsoft.CodeAnalysis.Editor.GoToDefinition
{
internal class WellKnownDefinitionTypes
{
public const string Definition = nameof(Definition);
}
}
// 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 Microsoft.CodeAnalysis.Editor.GoToDefinition;
using Microsoft.CodeAnalysis.Editor.Host;
using Microsoft.CodeAnalysis.FindUsages;
using Microsoft.VisualStudio.Language.Intellisense;
using Microsoft.VisualStudio.Text;
using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.Editor.NavigableSymbols
{
internal partial class NavigableSymbolService
{
private class NavigableSymbol : INavigableSymbol
{
private readonly ImmutableArray<DefinitionItem> _definitions;
private readonly SnapshotSpan _span;
private readonly Document _document;
private readonly IEnumerable<Lazy<IStreamingFindUsagesPresenter>> _presenters;
private readonly IWaitIndicator _waitIndicator;
public NavigableSymbol(
ImmutableArray<DefinitionItem> definitions,
SnapshotSpan span,
Document document,
IEnumerable<Lazy<IStreamingFindUsagesPresenter>> streamingPresenters,
IWaitIndicator waitIndicator)
{
Contract.ThrowIfFalse(definitions.Length > 0);
_definitions = definitions;
_span = span;
_document = document;
_presenters = streamingPresenters;
_waitIndicator = waitIndicator;
}
public SnapshotSpan SymbolSpan => _span;
public IEnumerable<INavigableRelationship> Relationships =>
SpecializedCollections.SingletonEnumerable(PredefinedNavigableRelationships.Definition);
public void Navigate(INavigableRelationship relationship) =>
_waitIndicator.Wait(
title: EditorFeaturesResources.Go_to_Definition,
message: EditorFeaturesResources.Navigating_to_definition,
allowCancel: true,
showProgress: false,
action: context => GoToDefinitionHelpers.TryGoToDefinition(
_definitions,
_document.Project,
_definitions[0].NameDisplayParts.GetFullText(),
_presenters,
context.CancellationToken)
);
}
}
}
// 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;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Editor.GoToDefinition;
using Microsoft.CodeAnalysis.Editor.Host;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Text;
using Microsoft.VisualStudio.Language.Intellisense;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Editor;
namespace Microsoft.CodeAnalysis.Editor.NavigableSymbols
{
internal partial class NavigableSymbolService
{
private partial class NavigableSymbolSource : INavigableSymbolSource
{
private readonly IEnumerable<Lazy<IStreamingFindUsagesPresenter>> _presenters;
private readonly IWaitIndicator _waitIndicator;
private bool _disposed;
public NavigableSymbolSource(
IEnumerable<Lazy<IStreamingFindUsagesPresenter>> streamingPresenters,
IWaitIndicator waitIndicator)
{
_presenters = streamingPresenters;
_waitIndicator = waitIndicator;
}
public void Dispose()
{
_disposed = true;
}
public async Task<INavigableSymbol> GetNavigableSymbolAsync(SnapshotSpan triggerSpan, CancellationToken cancellationToken)
{
if (_disposed)
{
return null;
}
var snapshot = triggerSpan.Snapshot;
var position = triggerSpan.Start;
var document = snapshot.GetOpenDocumentInCurrentContextWithChanges();
if (document == null)
{
return null;
}
var service = document.GetLanguageService<IGoToSymbolService>();
var context = new GoToDefinitionContext(
document,
position,
cancellationToken: cancellationToken);
await service.GetDefinitionsAsync(context).ConfigureAwait(false);
if (!context.Items.TryGetValue(WellKnownDefinitionTypes.Definition, out var definitions))
{
return null;
}
var span = context.Span;
var snapshotSpan = new SnapshotSpan(snapshot, span.Start, span.Length);
return new NavigableSymbol(definitions.ToImmutableArray(), snapshotSpan, document, _presenters, _waitIndicator);
}
}
}
}
// 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.ComponentModel.Composition;
using Microsoft.CodeAnalysis.Editor.Host;
using Microsoft.CodeAnalysis.Editor.Shared.Extensions;
using Microsoft.VisualStudio.Language.Intellisense;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.Utilities;
namespace Microsoft.CodeAnalysis.Editor.NavigableSymbols
{
[Export(typeof(INavigableSymbolSourceProvider))]
[Name(nameof(NavigableSymbolService))]
[ContentType(ContentTypeNames.RoslynContentType)]
internal partial class NavigableSymbolService : INavigableSymbolSourceProvider
{
private static readonly object s_key = new object();
private readonly IEnumerable<Lazy<IStreamingFindUsagesPresenter>> _streamingPresenters;
private readonly IWaitIndicator _waitIndicator;
[ImportingConstructor]
public NavigableSymbolService(
IWaitIndicator waitIndicator,
[ImportMany] IEnumerable<Lazy<IStreamingFindUsagesPresenter>> streamingPresenters)
{
_waitIndicator = waitIndicator;
_streamingPresenters = streamingPresenters;
}
public INavigableSymbolSource TryCreateNavigableSymbolSource(ITextView textView, ITextBuffer buffer)
{
return textView.GetOrCreatePerSubjectBufferProperty(buffer, s_key,
(v, b) => new NavigableSymbolSource(_streamingPresenters, _waitIndicator));
}
}
}
......@@ -562,7 +562,7 @@ private static void CommentSelection(ITextView textView, IEnumerable<TextChange>
commandHandler.CollectEdits(service,
textView.Selection.GetSnapshotSpansOnBuffer(textView.TextBuffer), textChanges, trackingSpans, operation);
AssertEx.SetEqual(expectedChanges, textChanges);
Roslyn.Test.Utilities.AssertEx.SetEqual(expectedChanges, textChanges);
// Actually apply the edit to let the tracking spans adjust.
using (var edit = textView.TextBuffer.CreateEdit())
......@@ -579,7 +579,7 @@ private static void CommentSelection(ITextView textView, IEnumerable<TextChange>
if (expectedSelectedSpans != null)
{
AssertEx.Equal(expectedSelectedSpans, textView.Selection.SelectedSpans.Select(snapshotSpan => snapshotSpan.Span));
Roslyn.Test.Utilities.AssertEx.Equal(expectedSelectedSpans, textView.Selection.SelectedSpans.Select(snapshotSpan => snapshotSpan.Span));
}
}
......
......@@ -159,12 +159,12 @@ public void BreakIntoWordParts_TwoUppercaseCharacters()
private void VerifyBreakIntoWordParts(string original, params string[] parts)
{
AssertEx.Equal(parts, BreakIntoWordParts(original));
Roslyn.Test.Utilities.AssertEx.Equal(parts, BreakIntoWordParts(original));
}
private void VerifyBreakIntoCharacterParts(string original, params string[] parts)
{
AssertEx.Equal(parts, BreakIntoCharacterParts(original));
Roslyn.Test.Utilities.AssertEx.Equal(parts, BreakIntoCharacterParts(original));
}
private const bool CaseSensitive = true;
......
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports System
Imports System.Linq
Imports System.Threading
Imports System.Threading.Tasks
Imports Microsoft.CodeAnalysis.Editor.Host
Imports Microsoft.CodeAnalysis.Editor.NavigableSymbols
Imports Microsoft.CodeAnalysis.Editor.UnitTests.BraceMatching
Imports Microsoft.CodeAnalysis.Editor.UnitTests.Utilities
Imports Microsoft.CodeAnalysis.Editor.UnitTests.Utilities.GoToHelpers
Imports Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces
Imports Microsoft.CodeAnalysis.Navigation
Imports Microsoft.VisualStudio.Composition
Imports Microsoft.VisualStudio.Text
Imports Roslyn.Test.Utilities
Imports Xunit
Namespace Microsoft.CodeAnalysis.Editor.UnitTests.NavigableSymbols
Public Class NavigableSymbolsTest
Private Shared ReadOnly s_exportProvider As ExportProvider = MinimalTestExportProvider.CreateExportProvider(
TestExportProvider.EntireAssemblyCatalogWithCSharpAndVisualBasic.WithParts(
GetType(MockDocumentNavigationServiceProvider),
GetType(MockSymbolNavigationServiceProvider)))
<WpfFact>
Public Async Function TestCharp() As Task
Using workspace = TestWorkspace.CreateCSharp("
class C
{
C$$ c
}", exportProvider:=s_exportProvider)
Await TestNavigated(workspace)
End Using
End Function
<WpfFact>
Public Async Function TestVB() As Task
Using workspace = TestWorkspace.CreateVisualBasic("
Class C
Dim c as C$$
End Class", exportProvider:=s_exportProvider)
Await TestNavigated(workspace)
End Using
End Function
Private Async Function TestNavigated(workspace As TestWorkspace) As Task
Dim presenter = {New Lazy(Of IStreamingFindUsagesPresenter)(Function() New MockStreamingFindUsagesPresenter(Sub() Return))}
Dim service = New NavigableSymbolService(TestWaitIndicator.Default, presenter)
Dim view = workspace.Documents.First().GetTextView()
Dim Buffer = workspace.Documents.First().GetTextBuffer()
Dim caretPosition = view.Caret.Position.BufferPosition.Position
Dim Span = New SnapshotSpan(Buffer.CurrentSnapshot, New Span(caretPosition, 0))
Dim source = service.TryCreateNavigableSymbolSource(view, Buffer)
Dim symbol = Await source.GetNavigableSymbolAsync(Span, CancellationToken.None)
Assert.NotNull(symbol)
symbol.Navigate(symbol.Relationships.First())
Dim navigationService = DirectCast(workspace.Services.GetService(Of IDocumentNavigationService)(), MockDocumentNavigationServiceProvider.MockDocumentNavigationService)
Assert.Equal(True, navigationService.TryNavigateToLineAndOffsetReturnValue)
Assert.Equal(True, navigationService.TryNavigateToPositionReturnValue)
Assert.Equal(True, navigationService.TryNavigateToSpanReturnValue)
End Function
End Class
End Namespace
......@@ -15,7 +15,17 @@ public static DisposableTextView CreateDisposableTextView(this ITextEditorFactor
public static DisposableTextView CreateDisposableTextView(this ITextEditorFactoryService textEditorFactory, ITextBuffer buffer)
{
return new DisposableTextView(textEditorFactory.CreateTextView(buffer));
// Every default role but outlining. Starting in 15.2, the editor
// OutliningManager imports JoinableTaskContext in a way that's
// difficult to satisfy in our unit tests. Since we don't directly
// depend on it, just disable it
var roles = textEditorFactory.CreateTextViewRoleSet(PredefinedTextViewRoles.Analyzable,
PredefinedTextViewRoles.Document,
PredefinedTextViewRoles.Editable,
PredefinedTextViewRoles.Interactive,
PredefinedTextViewRoles.Zoomable);
return new DisposableTextView(textEditorFactory.CreateTextView(buffer, roles));
}
}
......
......@@ -135,8 +135,8 @@ public bool IsGenerated
}
public TestHostDocument(
string text = "", string displayName = "",
SourceCodeKind sourceCodeKind = SourceCodeKind.Regular,
string text = "", string displayName = "",
SourceCodeKind sourceCodeKind = SourceCodeKind.Regular,
DocumentId id = null, string filePath = null,
IReadOnlyList<string> folders = null)
{
......@@ -194,7 +194,7 @@ public override Task<TextAndVersion> LoadTextAndVersionAsync(Workspace workspace
return Task.FromResult(TextAndVersion.Create(text, VersionStamp.Create(), _hostDocument.FilePath));
}
}
public IWpfTextView GetTextView()
{
if (_textView == null)
......@@ -203,7 +203,18 @@ public IWpfTextView GetTextView()
WpfTestCase.RequireWpfFact($"Creates an IWpfTextView through {nameof(TestHostDocument)}.{nameof(GetTextView)}");
_textView = _exportProvider.GetExportedValue<ITextEditorFactoryService>().CreateTextView(this.TextBuffer);
var factory = _exportProvider.GetExportedValue<ITextEditorFactoryService>();
// Every default role but outlining. Starting in 15.2, the editor
// OutliningManager imports JoinableTaskContext in a way that's
// difficult to satisfy in our unit tests. Since we don't directly
// depend on it, just disable it
var roles = factory.CreateTextViewRoleSet(PredefinedTextViewRoles.Analyzable,
PredefinedTextViewRoles.Document,
PredefinedTextViewRoles.Editable,
PredefinedTextViewRoles.Interactive,
PredefinedTextViewRoles.Zoomable);
_textView = factory.CreateTextView(this.TextBuffer, roles);
if (this.CursorPosition.HasValue)
{
_textView.Caret.MoveTo(new SnapshotPoint(_textView.TextSnapshot, CursorPosition.Value));
......
......@@ -151,6 +151,7 @@
<ItemGroup>
<InternalsVisibleToTest Include="Roslyn.VisualStudio.Services.UnitTests" />
<InternalsVisibleToTest Include="Roslyn.Services.Editor2.UnitTests" />
<InternalsVisibleToTest Include="Roslyn.Services.Editor.UnitTests" />
</ItemGroup>
<ItemGroup>
<Import Include="Microsoft.CodeAnalysis.Editor" />
......
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports Microsoft.CodeAnalysis.Editor.CSharp.GoToDefinition
Imports Microsoft.CodeAnalysis.Editor.VisualBasic.GoToDefinition
Imports Microsoft.CodeAnalysis.Editor.Host
Imports Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces
Imports Microsoft.CodeAnalysis.GeneratedCodeRecognition
......@@ -13,7 +15,9 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.Utilities.GoToHelpers
Public ReadOnly Catalog As ComposableCatalog = TestExportProvider.MinimumCatalogWithCSharpAndVisualBasic.WithParts(
GetType(MockDocumentNavigationServiceFactory),
GetType(DefaultSymbolNavigationServiceFactory),
GetType(GeneratedCodeRecognitionService))
GetType(GeneratedCodeRecognitionService),
GetType(CSharpGoToDefinitionSymbolService),
GetType(VisualBasicGoToDefinitionSymbolService))
Public ReadOnly ExportProvider As ExportProvider = MinimalTestExportProvider.CreateExportProvider(Catalog)
......
......@@ -97,7 +97,9 @@
<Compile Include="Formatting\Indentation\SpecialFormattingOperation.vb" />
<Compile Include="Formatting\Indentation\VisualBasicIndentationService.Indenter.vb" />
<Compile Include="Formatting\Indentation\VisualBasicIndentationService.vb" />
<Compile Include="GoToDefinition\VisualBasicGoToDefinitionItemService.vb" />
<Compile Include="GoToDefinition\VisualBasicGoToDefinitionService.vb" />
<Compile Include="GoToDefinition\VisualBasicGoToDefinitionSymbolService.vb" />
<Compile Include="Highlighting\KeywordHighlighters\AccessorDeclarationHighlighter.vb" />
<Compile Include="Highlighting\KeywordHighlighters\ConditionalPreprocessorHighlighter.vb" />
<Compile Include="Highlighting\KeywordHighlighters\ConstructorDeclarationHighlighter.vb" />
......
Imports System.Composition
Imports Microsoft.CodeAnalysis.Editor.GoToDefinition
Imports Microsoft.CodeAnalysis.Host.Mef
Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.GoToDefinition
<ExportLanguageService(GetType(IGoToSymbolService), LanguageNames.VisualBasic), [Shared]>
Friend Class VisualBasicGoToDefinitionItemService
Inherits AbstractGoToDefinitionItemService
End Class
End Namespace
......@@ -15,9 +15,5 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.GoToDefinition
Public Sub New(<ImportMany> streamingPresenters As IEnumerable(Of Lazy(Of IStreamingFindUsagesPresenter)))
MyBase.New(streamingPresenters)
End Sub
Protected Overrides Function FindRelatedExplicitlyDeclaredSymbol(symbol As ISymbol, compilation As Compilation) As ISymbol
Return symbol.FindRelatedExplicitlyDeclaredSymbol(compilation)
End Function
End Class
End Namespace
\ No newline at end of file
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports System.Composition
Imports Microsoft.CodeAnalysis.Editor.GoToDefinition
Imports Microsoft.CodeAnalysis.Editor.Host
Imports Microsoft.CodeAnalysis.Host.Mef
Imports Microsoft.CodeAnalysis.VisualBasic.Utilities
Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.GoToDefinition
<ExportLanguageService(GetType(IGoToDefinitionSymbolService), LanguageNames.VisualBasic), [Shared]>
Friend Class VisualBasicGoToDefinitionSymbolService
Inherits AbstractGoToDefinitionSymbolService
Protected Overrides Function FindRelatedExplicitlyDeclaredSymbol(symbol As ISymbol, compilation As Compilation) As ISymbol
Return symbol.FindRelatedExplicitlyDeclaredSymbol(compilation)
End Function
End Class
End Namespace
\ No newline at end of file
......@@ -448,6 +448,9 @@
<PackageReference Include="Newtonsoft.Json">
<Version>$(NewtonsoftJsonVersion)</Version>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.Shell.Interop.15.3.DesignTime">
<Version>$(MicrosoftVisualStudioShellInterop153DesignTimeVersion)</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
<Compile Include="CodeMarkers\ManagedCodeMarkers.cs" />
......
......@@ -126,6 +126,12 @@
<PackageReference Include="Microsoft.VisualStudio.Diagnostics.PerformanceProvider">
<Version>$(MicrosoftVisualStudioDiagnosticsPerformanceProviderVersion)</Version>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.Shell.Interop.15.3.DesignTime">
<Version>$(MicrosoftVisualStudioShellInterop153DesignTimeVersion)</Version>
</PackageReference>
<PackageReference Include="StreamJsonRPC">
<Version>$(StreamJsonRPCVersion)</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
<PublicAPI Include="PublicAPI.Shipped.txt" />
......
......@@ -6,6 +6,7 @@
using System.Threading;
using Microsoft.CodeAnalysis.LanguageServices;
using Microsoft.CodeAnalysis.Shared.Utilities;
using Microsoft.CodeAnalysis.Text;
using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.Shared.Extensions
......@@ -13,23 +14,26 @@ namespace Microsoft.CodeAnalysis.Shared.Extensions
internal struct TokenSemanticInfo
{
public static readonly TokenSemanticInfo Empty = new TokenSemanticInfo(
null, null, ImmutableArray<ISymbol>.Empty, null);
null, null, ImmutableArray<ISymbol>.Empty, null, default(TextSpan));
public readonly ISymbol DeclaredSymbol;
public readonly IAliasSymbol AliasSymbol;
public readonly ImmutableArray<ISymbol> ReferencedSymbols;
public readonly ITypeSymbol Type;
public readonly TextSpan Span;
public TokenSemanticInfo(
ISymbol declaredSymbol,
IAliasSymbol aliasSymbol,
ImmutableArray<ISymbol> referencedSymbols,
ITypeSymbol type)
ITypeSymbol type,
TextSpan span)
{
DeclaredSymbol = declaredSymbol;
AliasSymbol = aliasSymbol;
ReferencedSymbols = referencedSymbols;
Type = type;
Span = span;
}
public ImmutableArray<ISymbol> GetSymbols(bool includeType)
......@@ -206,7 +210,7 @@ private static ISymbol MapSymbol(ISymbol symbol, ITypeSymbol type)
}
}
return new TokenSemanticInfo(declaredSymbol, aliasSymbol, allSymbols, type);
return new TokenSemanticInfo(declaredSymbol, aliasSymbol, allSymbols, type, token.Span);
}
public static SemanticModel GetOriginalSemanticModel(this SemanticModel semanticModel)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册