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

Several refactorings to rework the internal Completion List API #3955

Merged
merged 7 commits into from
Jul 16, 2015

Conversation

DustinCampbell
Copy link
Member

  • Convert the ICompletionProvider interface to a CompletionListProvider abstract class.
  • Rename CompletionItemGroup to CompletionList
  • Introduce a CompletionListContext type to be used by providers to specify the contents and
    details of CompletionLists with a RegisterCompletionListAsync() method.
  • Change GetGroupsAsync() method to GetCompletionListAsync(), which returns Task<CompletionList> rather
    than Task<IEnumerable<CompletionList>>.
  • Move code that merges, de-dupes and sorts completion lists from the controller into the
    completion service. This affected a few VB spell check unit tests which now change their ordering
    slightly.

* Convert the ICompletionProvider interface to a CompletionListProvider abstract class.
* Rename CompletionItemGroup to CompletionList
* Introduce a CompletionListContext type to be used by providers to specify the contents and
  details of CompletionLists with a RegisterCompletionListAsync() method.
* Change GetGroupsAsync() method to GetCompletionListAsync(), which returns Task<CompletionList> rather
  than Task<IEnumerable<CompletionList>>.
* Move code that merges, de-dupes and sorts completion lists from the controller into the
  completion service. This affected a few VB spell check unit tests which now change their ordering
  slightly.
@DustinCampbell DustinCampbell added Area-IDE Concept-API This issue involves adding, removing, clarification, or modification of an API. labels Jul 14, 2015
@DustinCampbell DustinCampbell added this to the 1.1 milestone Jul 14, 2015
@DustinCampbell DustinCampbell self-assigned this Jul 14, 2015
@DustinCampbell
Copy link
Member Author

This is all part of the work for Issue #3538. There's much more to come yet. 😄

Adding @CyrusNajmabadi, @rchande, @Pilchie, @jasonmalinowski, @dpoeschl

@DustinCampbell
Copy link
Member Author

A VB spell check unit test failed because the suggestions do not have a stable sort. They're sorted by goodness but need to be further sorted by display text when the goodness is the same. I'll fix that up tomorrow. This shouldn't block reviewing the change though.


namespace Microsoft.CodeAnalysis.Editor.Extensibility.Completion
{
internal abstract class SnippetCompletionProvider : AbstractCompletionProvider, ISnippetCompletionProvider, ICustomCommitCompletionProvider
Copy link
Member

Choose a reason for hiding this comment

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

Hrmm.... How can this implement ISnippetCompletionProvider. I saw you removed it above... Or did it move? If so, odd that git didn't notice.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, it moved down to Features. Looks different enough that git didn't call it a rename.

throw new ArgumentNullException(nameof(item));
}

_addCompletionItem(item);
Copy link
Member

Choose a reason for hiding this comment

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

Even if this is a struct, i don't think i see the need for this indirection. We could just move the immutablearraybuilder into this type, and have it internally exposed for the completion list infrastructure to get at the actual values.

This is willfuilly inconsistent with the methods in CodeFixProvider, CodeRefactoringProvider
and DiagnosticAnalyzer becuase the name feels a bit better in this case. This might be changed
following an API design review before being made public.
@DustinCampbell
Copy link
Member Author

Added a few commits to address some of the CR feedback. I went ahead and made CompletionList.Items an ImmutableArray<CompletionItem> as part of this change. Also, we'll go with ProduceCompletionListAsync until do an API design review. It's inconsistent with our existing extensibility points but speaks better IMO.

@sharwell
Copy link
Member

Just please don't rename CustomCommitCompletion. I looked through this briefly and I don't think it will break the completion list wrapper that we use in SHFB to provide enhanced completion lists inside of documentation comments.

@DustinCampbell
Copy link
Member Author

@sharwell -- that's extremely foul! 😄 🙈

FWIW, there isn't a plan to change that particular type ATM. Of course, that's the danger of using reflection to access internal stuff. We intend to expose several of our currently internal bits as public API and we reserve the right to change our internal APIs to better expose them.

/// </summary>
public static Task<IEnumerable<CompletionItemGroup>> GetCompletionItemGroupsAsync(Document document, int position, CompletionTriggerInfo triggerInfo, IEnumerable<ICompletionProvider> completionProviders = null, CancellationToken cancellationToken = default(CancellationToken))
public static Task<CompletionList> GetCompletionListAsync(Document document, int position, CompletionTriggerInfo triggerInfo, IEnumerable<CompletionListProvider> completionProviders = null, CancellationToken cancellationToken = default(CancellationToken))
Copy link
Contributor

Choose a reason for hiding this comment

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

I like this :)

Copy link
Member Author

Choose a reason for hiding this comment

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

😄

@sharwell
Copy link
Member

FWIW, there isn't a plan to change that particular type ATM. Of course, that's the danger of using reflection to access internal stuff. We intend to expose several of our currently internal bits as public API and we reserve the right to change our internal APIs to better expose them.

I realized that we can actually avoid reflection in this case by being clever a different way: EWSoftware/SHFB#146.

DustinCampbell added a commit that referenced this pull request Jul 16, 2015
Several refactorings to rework the internal Completion List API
@DustinCampbell DustinCampbell merged commit 4b74c3f into dotnet:master Jul 16, 2015
@DustinCampbell DustinCampbell deleted the completion branch August 1, 2015 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE cla-already-signed Concept-API This issue involves adding, removing, clarification, or modification of an API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants