Skip to content
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

New Quick Info API #20554

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
66920bb
General API variant
mattwar Aug 11, 2016
2eead77
make tests compile
mattwar Sep 1, 2016
f97475e
simpler QuickInfo API
mattwar Sep 2, 2016
785efef
merge with master and fix conflicts
mattwar Sep 2, 2016
3f9aa4d
removal of old or unused code & declarations
mattwar Sep 2, 2016
3b09c7d
Merge remote-tracking branch 'dotnet/master' into QuickInfoAPI2
mattwar Sep 12, 2016
1493c75
merge with master and fix conflicts
mattwar Sep 12, 2016
f447083
fix feedback issues
mattwar Sep 12, 2016
698362c
Merge remote-tracking branch 'dotnet/master' into QuickInfoAPI2
mattwar Sep 13, 2016
c48e203
use extension manager for providers
mattwar Sep 13, 2016
90cb667
Change to list of text blocks
mattwar Sep 14, 2016
1590e67
Use QuickInfoService.GetService
mattwar Sep 14, 2016
c68bf9f
merge with master and fix conflicts
mattwar Jan 4, 2017
752abba
Merge branch 'QuickInfoAPI2' of https://github.com/mattwar/roslyn int…
DustinCampbell Jun 29, 2017
61666b2
Merge branch 'master' into new-quick-info-api
DustinCampbell Jul 6, 2017
df0d315
Lots of clean up and code review feedback addressed
DustinCampbell Jul 6, 2017
d4771bf
Merge branch 'master' into new-quick-info-api
DustinCampbell Jul 11, 2017
a598588
Rename QuickInfoTextBlock -> QuickInfoSection
DustinCampbell Jul 11, 2017
c4e1902
Clean up CommonSemanticQuickInfoProvider
DustinCampbell Jul 11, 2017
63b3c9d
Move IndentationHelper.IsWhitespace(...) logic to TestLine.IsEmptyOrW…
DustinCampbell Jul 11, 2017
27212a7
Merge branch 'master' into new-quick-info-api
DustinCampbell Sep 19, 2017
5fcbad6
Merge branch 'master' into new-quick-info-api
DustinCampbell Dec 4, 2017
17167d0
Merge branch 'master' into new-quick-info-api
DustinCampbell Dec 5, 2017
03d737c
Remove unnecessary public constructors
DustinCampbell Dec 5, 2017
03461bb
Expose public Quick Info API
DustinCampbell Dec 5, 2017
27223c3
Merge branch 'master' into new-quick-info-api
DustinCampbell Dec 9, 2017
efd4f84
Update localization files
DustinCampbell Dec 9, 2017
6a75337
Add QuickInfoContext and make QuickInfoProvider internal
DustinCampbell Dec 11, 2017
3cd46e3
Merge branch 'master' into new-quick-info-api
DustinCampbell Jan 2, 2018
11ca68d
Fix build break in Quick Info unit tests and add traits
DustinCampbell Jan 3, 2018
4946365
Fix desktop test searching
jaredpar Dec 14, 2017
45727e2
Respond to PR feedback
jaredpar Jan 5, 2018
99956e0
Mistake
jaredpar Jan 5, 2018
a8b2307
Adding entries for 15.6 branches
VSadov Jan 8, 2018
0070d81
PR feedback
VSadov Jan 8, 2018
4b36243
Bumped up the version in master-vs-deps
VSadov Jan 8, 2018
252821c
updated channel for master-vs-deps
VSadov Jan 8, 2018
067ed0a
Merge pull request #24109 from VSadov/15_6
jasonmalinowski Jan 9, 2018
451e54f
Merge pull request #23793 from jaredpar/fix-mono
jaredpar Jan 9, 2018
6d840be
Merge pull request #24115 from dotnet/merges/dev15.6.x-to-master-2018…
jasonmalinowski Jan 9, 2018
f809a7f
Further update PublishData.json for correct publishing semantics
jasonmalinowski Jan 9, 2018
1650b9e
Merge pull request #24132 from jasonmalinowski/more-publishdata-fixes
jasonmalinowski Jan 10, 2018
542daef
Merge pull request #24141 from dotnet/merges/dev15.6.x-to-master-2018…
VSadov Jan 10, 2018
8cc0312
Merge pull request #24166 from dotnet/merges/dev15.6.x-to-master-2018…
VSadov Jan 11, 2018
54f324b
Merge pull request #24200 from dotnet/merges/dev15.6.x-to-master-2018…
VSadov Jan 12, 2018
20c1851
Consolidate 'remove unused local' fixer in Roslyn and Roslyn-analyzer…
ivanbasov Jan 13, 2018
6db0410
Merge pull request #24240 from dotnet/merges/dev15.6.x-to-master-2018…
agocke Jan 16, 2018
a086562
Merge pull request #24280 from dotnet/merges/dev15.6.x-to-master-2018…
agocke Jan 17, 2018
2aa272e
Merge branch 'master' into new-quick-info-api
DustinCampbell Jan 17, 2018
144266e
Merge remote-tracking branch 'upstream/features/quick-info-party' int…
DustinCampbell Feb 14, 2018
083e2d2
Clean up unintentionally changed files
DustinCampbell Feb 14, 2018
27cf44d
Add initial changes from code review feedback
DustinCampbell Feb 14, 2018
6b9f0c4
Obsolete CompletionTags in favor or WellKnownTags
DustinCampbell Feb 14, 2018
0c10f4b
Apply code review feedback to Quick Info PR
DustinCampbell Feb 15, 2018
b9f774b
Revert some unintentional changes that snuck into this branch
DustinCampbell Feb 15, 2018
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
21 changes: 0 additions & 21 deletions src/EditorFeatures/CSharp/QuickInfo/SemanticQuickInfoProvider.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,9 @@
using System.Threading.Tasks;
using System.Xml.Linq;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.Editor.CSharp.QuickInfo;
using Microsoft.CodeAnalysis.Editor.Shared.Utilities;
using Microsoft.CodeAnalysis.Editor.UnitTests.QuickInfo;
using Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces;
using Microsoft.VisualStudio.Language.Intellisense;
using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.Text.Projection;
using Microsoft.CodeAnalysis.QuickInfo;
using Roslyn.Test.Utilities;
using Roslyn.Utilities;
using Xunit;
Expand All @@ -22,24 +18,24 @@ namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.QuickInfo
{
public class SemanticQuickInfoSourceTests : AbstractSemanticQuickInfoSourceTests
{
private async Task TestWithOptionsAsync(CSharpParseOptions options, string markup, params Action<object>[] expectedResults)
private async Task TestWithOptionsAsync(CSharpParseOptions options, string markup, params Action<QuickInfoItem>[] expectedResults)
{
using (var workspace = TestWorkspace.CreateCSharp(markup, options))
{
await TestWithOptionsAsync(workspace, expectedResults);
}
}

private async Task TestWithOptionsAsync(TestWorkspace workspace, params Action<object>[] expectedResults)
private async Task TestWithOptionsAsync(TestWorkspace workspace, params Action<QuickInfoItem>[] expectedResults)
{
var testDocument = workspace.DocumentWithCursor;
var position = testDocument.CursorPosition.GetValueOrDefault();
var documentId = workspace.GetDocumentId(testDocument);
var document = workspace.CurrentSolution.GetDocument(documentId);

var provider = new SemanticQuickInfoProvider();
var service = QuickInfoService.GetService(document);

await TestWithOptionsAsync(document, provider, position, expectedResults);
await TestWithOptionsAsync(document, service, position, expectedResults);

// speculative semantic model
if (await CanUseSpeculativeSemanticModelAsync(document, position))
Expand All @@ -52,34 +48,30 @@ private async Task TestWithOptionsAsync(TestWorkspace workspace, params Action<o
edit.Apply();
}

await TestWithOptionsAsync(document, provider, position, expectedResults);
await TestWithOptionsAsync(document, service, position, expectedResults);
}
}

private async Task TestWithOptionsAsync(Document document, SemanticQuickInfoProvider provider, int position, Action<object>[] expectedResults)
private async Task TestWithOptionsAsync(Document document, QuickInfoService service, int position, Action<QuickInfoItem>[] expectedResults)
{
var state = await provider.GetItemAsync(document, position, cancellationToken: CancellationToken.None);
if (state != null)
{
WaitForDocumentationComment(state.Content);
}
var info = await service.GetQuickInfoAsync(document, position, cancellationToken: CancellationToken.None);

if (expectedResults.Length == 0)
{
Assert.Null(state);
Assert.Null(info);
}
else
{
Assert.NotNull(state);
Assert.NotNull(info);

foreach (var expected in expectedResults)
{
expected(state.Content);
expected(info);
}
}
}

private async Task VerifyWithMscorlib45Async(string markup, Action<object>[] expectedResults)
private async Task VerifyWithMscorlib45Async(string markup, Action<QuickInfoItem>[] expectedResults)
{
var xmlString = string.Format(@"
<Workspace>
Expand All @@ -96,37 +88,33 @@ private async Task VerifyWithMscorlib45Async(string markup, Action<object>[] exp
var documentId = workspace.Documents.Where(d => d.Name == "SourceDocument").Single().Id;
var document = workspace.CurrentSolution.GetDocument(documentId);

var provider = new SemanticQuickInfoProvider();
var service = QuickInfoService.GetService(document);

var state = await provider.GetItemAsync(document, position, cancellationToken: CancellationToken.None);
if (state != null)
{
WaitForDocumentationComment(state.Content);
}
var info = await service.GetQuickInfoAsync(document, position, cancellationToken: CancellationToken.None);

if (expectedResults.Length == 0)
{
Assert.Null(state);
Assert.Null(info);
}
else
{
Assert.NotNull(state);
Assert.NotNull(info);

foreach (var expected in expectedResults)
{
expected(state.Content);
expected(info);
}
}
}
}

protected override async Task TestAsync(string markup, params Action<object>[] expectedResults)
protected override async Task TestAsync(string markup, params Action<QuickInfoItem>[] expectedResults)
{
await TestWithOptionsAsync(Options.Regular, markup, expectedResults);
await TestWithOptionsAsync(Options.Script, markup, expectedResults);
}

protected async Task TestWithUsingsAsync(string markup, params Action<object>[] expectedResults)
private async Task TestWithUsingsAsync(string markup, params Action<QuickInfoItem>[] expectedResults)
{
var markupWithUsings =
@"using System;
Expand All @@ -137,13 +125,13 @@ protected async Task TestWithUsingsAsync(string markup, params Action<object>[]
await TestAsync(markupWithUsings, expectedResults);
}

protected Task TestInClassAsync(string markup, params Action<object>[] expectedResults)
private Task TestInClassAsync(string markup, params Action<QuickInfoItem>[] expectedResults)
{
var markupInClass = "class C { " + markup + " }";
return TestWithUsingsAsync(markupInClass, expectedResults);
}

protected Task TestInMethodAsync(string markup, params Action<object>[] expectedResults)
private Task TestInMethodAsync(string markup, params Action<QuickInfoItem>[] expectedResults)
{
var markupInMethod = "class C { void M() { " + markup + " } }";
return TestWithUsingsAsync(markupInMethod, expectedResults);
Expand All @@ -153,7 +141,7 @@ private async Task TestWithReferenceAsync(string sourceCode,
string referencedCode,
string sourceLanguage,
string referencedLanguage,
params Action<object>[] expectedResults)
params Action<QuickInfoItem>[] expectedResults)
{
await TestWithMetadataReferenceHelperAsync(sourceCode, referencedCode, sourceLanguage, referencedLanguage, expectedResults);
await TestWithProjectReferenceHelperAsync(sourceCode, referencedCode, sourceLanguage, referencedLanguage, expectedResults);
Expand All @@ -170,7 +158,7 @@ private async Task TestWithMetadataReferenceHelperAsync(
string referencedCode,
string sourceLanguage,
string referencedLanguage,
params Action<object>[] expectedResults)
params Action<QuickInfoItem>[] expectedResults)
{
var xmlString = string.Format(@"
<Workspace>
Expand All @@ -195,7 +183,7 @@ private async Task TestWithProjectReferenceHelperAsync(
string referencedCode,
string sourceLanguage,
string referencedLanguage,
params Action<object>[] expectedResults)
params Action<QuickInfoItem>[] expectedResults)
{
var xmlString = string.Format(@"
<Workspace>
Expand All @@ -221,7 +209,7 @@ private async Task TestInSameProjectHelperAsync(
string sourceCode,
string referencedCode,
string sourceLanguage,
params Action<object>[] expectedResults)
params Action<QuickInfoItem>[] expectedResults)
{
var xmlString = string.Format(@"
<Workspace>
Expand All @@ -238,33 +226,29 @@ private async Task TestInSameProjectHelperAsync(
await VerifyWithReferenceWorkerAsync(xmlString, expectedResults);
}

private async Task VerifyWithReferenceWorkerAsync(string xmlString, params Action<object>[] expectedResults)
private async Task VerifyWithReferenceWorkerAsync(string xmlString, params Action<QuickInfoItem>[] expectedResults)
{
using (var workspace = TestWorkspace.Create(xmlString))
{
var position = workspace.Documents.First(d => d.Name == "SourceDocument").CursorPosition.Value;
var documentId = workspace.Documents.First(d => d.Name == "SourceDocument").Id;
var document = workspace.CurrentSolution.GetDocument(documentId);

var provider = new SemanticQuickInfoProvider();
var service = QuickInfoService.GetService(document);

var state = await provider.GetItemAsync(document, position, cancellationToken: CancellationToken.None);
if (state != null)
{
WaitForDocumentationComment(state.Content);
}
var info = await service.GetQuickInfoAsync(document, position, cancellationToken: CancellationToken.None);

if (expectedResults.Length == 0)
{
Assert.Null(state);
Assert.Null(info);
}
else
{
Assert.NotNull(state);
Assert.NotNull(info);

foreach (var expected in expectedResults)
{
expected(state.Content);
expected(info);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,10 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.Editor.CSharp.QuickInfo;
using Microsoft.CodeAnalysis.Editor.Implementation.IntelliSense.QuickInfo;
using Microsoft.CodeAnalysis.Editor.QuickInfo;
using Microsoft.CodeAnalysis.Editor.Shared.Utilities;
using Microsoft.CodeAnalysis.CSharp.QuickInfo;
using Microsoft.CodeAnalysis.Editor.UnitTests.QuickInfo;
using Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces;
using Microsoft.VisualStudio.Language.Intellisense;
using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.Text.Projection;
using Microsoft.CodeAnalysis.QuickInfo;
using Roslyn.Test.Utilities;
using Xunit;

Expand Down Expand Up @@ -263,9 +258,9 @@ await TestInMethodAndScriptAsync(
{");
}

private IQuickInfoProvider CreateProvider(TestWorkspace workspace)
private QuickInfoProvider CreateProvider(TestWorkspace workspace)
{
return new SyntacticQuickInfoProvider();
return new CSharpSyntacticQuickInfoProvider();
}

protected override async Task AssertNoContentAsync(
Expand All @@ -274,7 +269,7 @@ protected override async Task AssertNoContentAsync(
int position)
{
var provider = CreateProvider(workspace);
Assert.Null(await provider.GetItemAsync(document, position, CancellationToken.None));
Assert.Null(await provider.GetQuickInfoAsync(new QuickInfoContext(document, position, CancellationToken.None)));
}

protected override async Task AssertContentIsAsync(
Expand All @@ -285,14 +280,15 @@ protected override async Task AssertContentIsAsync(
string expectedDocumentationComment = null)
{
var provider = CreateProvider(workspace);
var state = await provider.GetItemAsync(document, position, cancellationToken: CancellationToken.None);
Assert.NotNull(state);

var hostingControlFactory = workspace.GetService<DeferredContentFrameworkElementFactory>();

var viewHostingControl = (ViewHostingControl)hostingControlFactory.CreateElement(state.Content);
var actualContent = viewHostingControl.GetText_TestOnly();
Assert.Equal(expectedContent, actualContent);
var info = await provider.GetQuickInfoAsync(new QuickInfoContext(document, position, CancellationToken.None));
Assert.NotNull(info);

Assert.NotEqual(0, info.RelatedSpans.Length);
var tabSize = document.Project.Solution.Workspace.Options.GetOption(Microsoft.CodeAnalysis.Formatting.FormattingOptions.TabSize, document.Project.Language);
var text = await document.GetTextAsync();
var spans = IndentationHelper.GetSpansWithAlignedIndentation(text, info.RelatedSpans, tabSize);
var actualText = string.Concat(spans.Select(s => text.GetSubText(s).ToString()));
Assert.Equal(expectedContent, actualText);
}

protected override Task TestInMethodAsync(string code, string expectedContent, string expectedDocumentationComment = null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Microsoft.CodeAnalysis.Completion;
using Microsoft.CodeAnalysis.Editor.Shared.Extensions;
using Microsoft.CodeAnalysis.Editor.Wpf;
using Microsoft.CodeAnalysis.Tags;
using Microsoft.CodeAnalysis.Text;
using Microsoft.VisualStudio.Imaging.Interop;
using Microsoft.VisualStudio.Language.Intellisense;
Expand All @@ -31,7 +32,7 @@ public CustomCommitCompletion(
// extra allocation is avoided.
_completionPresenterSession = completionPresenterSession;
this.CompletionItem = completionItem;
_imageMoniker = ImageMonikers.GetImageMoniker(CompletionItem.Tags);
_imageMoniker = ImageMonikers.GetFirstImageMoniker(CompletionItem.Tags);
}

public void Commit()
Expand Down Expand Up @@ -74,7 +75,7 @@ public override IEnumerable<CompletionIcon> AttributeIcons
{
get
{
if (this.CompletionItem.Tags.Contains(CompletionTags.Warning))
if (this.CompletionItem.Tags.Contains(WellKnownTags.Warning))
{
return new[] { new CompletionIcon2(Glyph.CompletionWarning.GetImageMoniker(), s_glyphCompletionWarning, s_glyphCompletionWarning) };
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
// 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 Microsoft.CodeAnalysis.Editor.Shared.Extensions;
using Microsoft.CodeAnalysis.Editor.Wpf;
using Microsoft.VisualStudio.Imaging.Interop;

namespace Microsoft.CodeAnalysis.Editor.Implementation.IntelliSense.Completion.Presentation
{
internal static class ImageMonikers
{
public static ImageMoniker GetImageMoniker(ImmutableArray<string> tags)
public static ImageMoniker GetFirstImageMoniker(ImmutableArray<string> tags)
{
return tags.GetGlyph().GetImageMoniker();
return tags.GetFirstGlyph().GetImageMoniker();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ internal class IntellisenseFilter2 : IntellisenseFilter

public IntellisenseFilter2(
RoslynCompletionSet completionSet, CompletionItemFilter filter)
: base(ImageMonikers.GetImageMoniker(filter.Tags), GetToolTip(filter),
: base(ImageMonikers.GetFirstImageMoniker(filter.Tags), GetToolTip(filter),
filter.AccessKey.ToString(), automationText: filter.Tags[0])
{
_completionSet = completionSet;
Expand Down
Loading