提交 9a7a5387 编写于 作者: C CyrusNajmabadi

Get navigation on symbols working.

上级 e8c8f2e1
using System;
// 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 Microsoft.VisualStudio.Utilities;
using Microsoft.VisualStudio.Text.Tagging;
using System.ComponentModel.Composition;
using Microsoft.CodeAnalysis.Editor;
using Microsoft.VisualStudio.Text;
using System.Collections.Generic;
using Roslyn.Utilities;
using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.Shell.TableControl;
using Microsoft.VisualStudio.Text.Classification;
namespace Microsoft.VisualStudio.LanguageServices.FindReferences
{
//[Export(typeof(IViewTaggerProvider))]
//[TagType(typeof(TextMarkerTag))]
//[ContentType("text")]
//// [ContentType(ContentTypeNames.VisualBasicContentType)]
////[ContentType(WellKnownContentTypeNames)]
//internal partial class DiagnosticsSquiggleTaggerProvider : IViewTaggerProvider
//{
// public static readonly object Key = new object();
// public ITagger<T> CreateTagger<T>(ITextView textView, ITextBuffer buffer) where T : ITag
// {
// return new Tagger(buffer) as ITagger<T>;
// }
// private class Tagger : ITagger<TextMarkerTag>
// {
// private readonly ITextBuffer buffer;
// public Tagger(ITextBuffer buffer)
// {
// this.buffer = buffer;
// }
// public event EventHandler<SnapshotSpanEventArgs> TagsChanged;
// public IEnumerable<ITagSpan<TextMarkerTag>> GetTags(NormalizedSnapshotSpanCollection spans)
// {
// return SpecializedCollections.EmptyEnumerable<ITagSpan<TextMarkerTag>>();
// }
// }
//}
//[Export(typeof(ITableControlEventProcessorProvider)), Shared]
//[DataSourceType(StreamingFindReferencesPresenter.RoslynFindReferencesTableDataSourceSourceTypeIdentifier)]
//[DataSource(StreamingFindReferencesPresenter.RoslynFindReferencesTableDataSourceIdentifier)]
//[Name(nameof(FindReferencesTableControlEventProcessorProvider))]
//[Order(Before = Priority.Default)]
//// [Order(Before=Priority.Default)]
//// Optional. The IWpfTableControl may have multiple event processors
//// registered. The Order attribute defines in which order (Before and After)
//// the event processors are called.
//// The expected values for Before and After properties are event processor
//// names or predefined orders(such as Priority or StandardTableControlEventProcessors).
//// You can ignore it or use[Order(After = Priority.Default, Before = StandardTableControlEventProcessors.Default)]
//// </remarks>
//[CLSCompliant(false)]
//class FindReferencesTableControlEventProcessorProvider
//{
//}
[Export(typeof(ITableControlEventProcessorProvider))]
[DataSourceType(StreamingFindReferencesPresenter.RoslynFindReferencesTableDataSourceSourceTypeIdentifier)]
[DataSource(StreamingFindReferencesPresenter.RoslynFindReferencesTableDataSourceIdentifier)]
[Name(nameof(FindReferencesTableControlEventProcessorProvider))]
[Order(Before = Priority.Default)]
internal class FindReferencesTableControlEventProcessorProvider : ITableControlEventProcessorProvider
{
public ITableControlEventProcessor GetAssociatedEventProcessor(
IWpfTableControl tableControl)
{
return new TableControlEventProcessor();
}
private class TableControlEventProcessor : TableControlEventProcessorBase
{
public override void PreprocessNavigate(ITableEntryHandle entry, TableEntryNavigateEventArgs e)
{
var supportsNavigation = entry.Identity as ISupportsNavigation;
if (supportsNavigation != null)
{
if (supportsNavigation.TryNavigateTo())
{
e.Handled = true;
return;
}
}
base.PreprocessNavigate(entry, e);
}
}
}
}
// 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.VisualStudio.LanguageServices.FindReferences
{
internal interface ISupportsNavigation
{
bool TryNavigateTo();
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
// 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.Windows;
using System.Windows.Controls;
using System.Windows.Media;
......
using System;
// 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.Windows;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Editor;
......@@ -10,16 +12,12 @@
using Microsoft.VisualStudio.Shell.TableControl;
using Microsoft.VisualStudio.Shell.TableManager;
using Microsoft.VisualStudio.Text;
using System.IO;
using System.Windows.Media;
using Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem;
using Microsoft.VisualStudio.LanguageServices.Implementation.Extensions;
using Microsoft.CodeAnalysis.Text.Shared.Extensions;
using Roslyn.Utilities;
using System.Collections;
using System.Collections.Generic;
using Microsoft.CodeAnalysis.Editor.Shared.Preview;
using Microsoft.CodeAnalysis.Editor.Implementation.ReferenceHighlighting;
using Microsoft.VisualStudio.Text.Editor;
using System.Linq;
using System.Windows.Controls;
......
using System.Collections.Generic;
// 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.Windows;
using System.Windows.Documents;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Editor.Navigation;
using Microsoft.CodeAnalysis.Editor.Shared.Extensions;
using Microsoft.CodeAnalysis.FindReferences;
using Microsoft.VisualStudio.Shell.FindAllReferences;
using Microsoft.VisualStudio.Shell.TableControl;
using Microsoft.VisualStudio.Shell.TableManager;
using System.Linq;
namespace Microsoft.VisualStudio.LanguageServices.FindReferences
{
internal partial class StreamingFindReferencesPresenter
{
private class RoslynDefinitionBucket : DefinitionBucket
private class RoslynDefinitionBucket : DefinitionBucket, ISupportsNavigation
{
private readonly StreamingFindReferencesPresenter _presenter;
private readonly TableDataSourceFindReferencesContext _context;
......@@ -33,6 +35,19 @@ private class RoslynDefinitionBucket : DefinitionBucket
DefinitionItem = definitionItem;
}
public bool TryNavigateTo()
{
foreach (var location in DefinitionItem.Locations)
{
if (location.TryNavigateTo())
{
return true;
}
}
return false;
}
public override bool TryGetValue(string key, out object content)
{
content = GetValue(key);
......
using System;
// 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 Microsoft.VisualStudio.Shell.TableManager;
namespace Microsoft.VisualStudio.LanguageServices.FindReferences
......
using System;
// 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.Concurrent;
using System.Collections.Generic;
using System.Collections.Immutable;
......@@ -8,7 +10,6 @@
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Classification;
using Microsoft.CodeAnalysis.Editor;
using Microsoft.CodeAnalysis.Editor.Navigation;
using Microsoft.CodeAnalysis.ErrorReporting;
using Microsoft.CodeAnalysis.FindReferences;
using Microsoft.CodeAnalysis.Shared.Extensions;
......
using System.Collections.Immutable;
// 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.Windows;
using Microsoft.VisualStudio.Shell.TableControl;
using Microsoft.VisualStudio.Shell.TableManager;
......
using System;
// 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;
......@@ -10,7 +12,6 @@
using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.Text.Projection;
using Microsoft.VisualStudio.Text.Classification;
using System.Linq;
using Microsoft.VisualStudio.Utilities;
using Microsoft.VisualStudio.Language.Intellisense;
......
using Microsoft.CodeAnalysis;
// 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 Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Text;
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Microsoft.VisualStudio.LanguageServices.FindReferences
{
......
......@@ -25,6 +25,7 @@
<ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>None</ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>
</PropertyGroup>
<ItemGroup Label="Build Items">
<Compile Include="FindReferences\ISupportsNavigation.cs" />
<Compile Include="FindReferences\LazyToolTip.cs" />
<Compile Include="FindReferences\StreamingFindReferencesPresenter.cs" />
<Compile Include="FindReferences\StreamingFindReferencesPresenter.RoslynDefinitionBucket.cs" />
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册