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

Quick info api2 #13623

Closed
wants to merge 13 commits into from
Closed

Quick info api2 #13623

wants to merge 13 commits into from

Conversation

mattwar
Copy link
Contributor

@mattwar mattwar commented Sep 6, 2016

@DustinCampbell @jasonmalinowski @Pilchie @dpoeschl @CyrusNajmabadi please review

Here is my proposal for the new public QuickInfo API... (note: the API as presented is not yet public.)

This is the "simple" form of the API, not the "almost as complicated as XML" form that I describe a few weeks ago. It has one API to get the QuickInfoItem for a position in document, and that item simply lays out the data/text that we typically display for C# and VB. It also includes information we use in the syntactic c# provider (that shows ranges of the original document where the matching open braces are). The presenter then choses what to do with it. There is no customization of the presenter on the editor side.

If other languages need different information and different presentation, the plan is to add those extra data times to the one QuickInfoItem class and change the single presenter to account for it. Worst case scenario if we decide we want something drastically different in the future, then we invent QuickInfo2.

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="Globals">
<ProjectGuid>c1930979-c824-496b-a630-70f5369a636f</ProjectGuid>
<ProjectGuid>cd77a8cc-2885-47a7-b99c-fbf13353400b</ProjectGuid>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You likely are far out of date with master. you shoudl merge in master.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just merged last friday.. Not sure why sln file changed. I didn't add any projects, etc.

textEditorFactoryService, glyphService, typeMap)

Imports Microsoft.CodeAnalysis.QuickInfo
Imports System.Collections.Immutable
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sort imports.

@paulvanbrenk
Copy link
Contributor

At first glance this looks very similar to the other public APIs, so it shouldn't be an issue for TypeScript to implement this. Is there anything we have to do specifically for the 'semantic' vs. 'syntactic' quickinfo, or is that optional?

@CyrusNajmabadi
Copy link
Member

Is there anything we have to do specifically for the 'semantic' vs. 'syntactic' quickinfo, or is that optional?

That's optional. C# happens to have two different providers that serve different purposes. "Semantic" is the traditional provider which gives you symbolic informaiton when you hover on an identifier.

"Syntactic" is the quick info provider we use when you hover over a close-curly and want to see the beginning of the declaration that close curly belongs to.

You can implement either of these (or none of these) as you wish. We happened to use two separate providers because it kept hte code cleanly separated.

using Microsoft.VisualStudio.Language.Intellisense;
using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.Text.Projection;
using Roslyn.Test.Utilities;
using Xunit;
using Microsoft.CodeAnalysis.QuickInfo;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sort usings.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -15,6 +15,7 @@
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Editor;
using Roslyn.Utilities;
using Microsoft.CodeAnalysis.QuickInfo;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sort

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

/// used to create an elision buffer out that will then be displayed in the quick info
/// window.
/// </summary>
internal class ElisionBufferContent
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably want to make this a ForegroundThreadAffinitizedObject. And add asserts in our methods ot make sure the UI stuff only happens on the UI thread.

internal class TextBlockElement
{
public string Kind { get; }
public TextBlock Block { get; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not certain what direction this is. Is this basically the owner of this "TextBlockElement", or is this something the TextBlockElement contains?

internal TextBlock TypeParameterMap => _textBlocks.FirstOrDefault(tb => tb.Kind == QuickInfoTextKinds.TypeParameters)?.Block;
internal TextBlock AnonymousTypes => _textBlocks.FirstOrDefault(tb => tb.Kind == QuickInfoTextKinds.AnonymousTypes)?.Block;
internal TextBlock UsageText => _textBlocks.FirstOrDefault(tb => tb.Kind == QuickInfoTextKinds.Usage)?.Block;
internal TextBlock ExceptionText => _textBlocks.FirstOrDefault(tb => tb.Kind == QuickInfoTextKinds.Exception)?.Block;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, it's not totally clear to me why these are needed. Do we have specfici code elsewhere that needs to know "is this the type parameter map"? It seems highly desirable for "private ImmutableArray _textBlocks;" to contain enough information in it alone that the presentation can work off of.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is just for tests, then that's fine. However, we should then change the names to "_ForTestingPurposesOnly" on them. That way we can ensure that they're not used in the actual product code.

@@ -1067,4 +1067,7 @@ This version used in: {2}</value>
<data name="Install_package_0" xml:space="preserve">
<value>Install package '{0}'</value>
</data>
<data name="Mutiple_Types" xml:space="preserve">
<value>&lt;Multiple Types&gt;</value>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where is this used?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like it's used in VB for cases like this:

Dim x As Integer, y As String

using System.Collections.Immutable;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sort.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


namespace Microsoft.CodeAnalysis.QuickInfo
{
// Reproduces logic in IProjectionBufferFactoryServiceExtensions (editor layer)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

definitely concerning. is there a reason that we can't just have the logic exist here and have IProjectionBufferFactoryServiceExtensions call this instead?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will take a look.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, this is not trivial to do. IProjectionBufferFactoryServiceExtensions operates directly on editor primitives. Converting those to use this is not trivial. However, this is really just there for tests.

/// <summary>
/// The span of the document that the item is based on.
/// </summary>
public TextSpan Span { get; set; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

public settable?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That does feel weird. Was that intentional?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

/// </summary>
public static QuickInfoService GetService(Workspace workspace, string language)
{
return workspace.Services.GetLanguageServices(language)?.GetService<QuickInfoService>() ?? NoOpService.Instance;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this a pattern we want to use everywhere?


private string _rawText;

public string RawText
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this needed publicly? or is this just for tests?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have something similar on CompletionDescription, but it's just called Text. The property called Text on this class is called TaggedParts on CompletionDescription. I'll keep them similar here.

@@ -1235,4 +1235,7 @@ Sub(&lt;parameterList&gt;) &lt;statement&gt;</value>
<data name="Make_Async_Sub" xml:space="preserve">
<value>Make Async Sub</value>
</data>
<data name="Multiple_Types" xml:space="preserve">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this here as well? What is it needed for? If it is needed, we def should not have the same string in two different projects.

Copy link
Member

@CyrusNajmabadi CyrusNajmabadi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

/// Descriptive tags from the <see cref="Microsoft.CodeAnalysis.Completion.CompletionTags"/> type.
/// These tags may influence how the item is displayed.
/// </summary>
public ImmutableArray<string> Tags { get; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have examples of what sort of tags we use here? Is this to give things like the icon displayed in QuickInfo? Or is that information within the TextBlocks?

Copy link
Member

@DustinCampbell DustinCampbell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM pending Cyrus's API questions

@@ -2,6 +2,7 @@

using Microsoft.CodeAnalysis.Text;
using Microsoft.CodeAnalysis.Text.Shared.Extensions;
using Microsoft.CodeAnalysis.QuickInfo;
using Microsoft.VisualStudio.Text;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sort usings

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

/// <summary>
/// The span of the document that the item is based on.
/// </summary>
public TextSpan Span { get; set; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That does feel weird. Was that intentional?

@DustinCampbell
Copy link
Member

Looks like post-dev15 is up-to-date. You should be able to rebase this on that

@DustinCampbell
Copy link
Member

Closing in favor of #20554

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants