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

Implementation of new editor completion API #25770

Closed
wants to merge 96 commits into from

Conversation

dpoeschl
Copy link
Contributor

@dpoeschl dpoeschl commented Mar 27, 2018

Previous review: #25537

TODOs: https://github.com/dotnet/roslyn/projects/38

Ask Mode template not completed

Customer scenario

What does the customer do to get into this situation, and why do we think this
is common enough to address for this release. (Granted, sometimes this will be
obvious "Open project, VS crashes" but in general, I need to understand how
common a scenario is)

Bugs this fixes

(either VSO or GitHub links)

Workarounds, if any

Also, why we think they are insufficient for RC vs. RC2, RC3, or RTW

Risk

This is generally a measure our how central the affected code is to adjacent
scenarios and thus how likely your fix is to destabilize a broader area of code

Performance impact

(with a brief justification for that assessment (e.g. "Low perf impact because no extra allocations/no complexity changes" vs. "Low")

Is this a regression from a previous update?

Root cause analysis

How did we miss it? What tests are we adding to guard against it in the future?

How was the bug found?

(E.g. customer reported it vs. ad hoc testing)

Test documentation updated?

If this is a new non-compiler feature or a significant improvement to an existing feature, update https://github.com/dotnet/roslyn/wiki/Manual-Testing once you know which release it is targeting.

Copy link
Contributor

@AmadeusW AmadeusW left a comment

Choose a reason for hiding this comment

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

Looks good :) I left a few comments but I haven't looked in depth at committing and handling non-roslyn items.

[ContentType(ContentTypeNames.RoslynContentType)]
internal class CompletionItemSourceProvider : IAsyncCompletionCommitManagerProvider
{
IAsyncCompletionCommitManager _instance;
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider cleaning up when the Roslyn workspace is unloaded

Copy link
Member

Choose a reason for hiding this comment

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

@AmadeusW Why? We have no sane unload operation.

internal const string TriggerBuffer = nameof(TriggerBuffer);
internal const string MatchPriority = nameof(MatchPriority);
internal const string SelectionBehavior = nameof(SelectionBehavior);
internal const string InsertionText = "InsertionText";
Copy link
Contributor

Choose a reason for hiding this comment

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

nameof

return false;
}

// TODO: TypeChar of 0 means Invoke or InvokeAndCommitIfUnique. An API update will make this better.
Copy link
Contributor

Choose a reason for hiding this comment

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

How would you like the API to look like?
I'd make the comment explicitly state that we have to provide a span in Invoke or InvokeAndCommitIfUnique scenarios

[ContentType(ContentTypeNames.RoslynContentType)]
internal class CompletionSourceProvider : IAsyncCompletionSourceProvider
{
IAsyncCompletionSource _instance;
Copy link
Contributor

Choose a reason for hiding this comment

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

cleanup when workspace is unloaded


private static bool IsAllPunctuation(string filterText)
{
foreach (var ch in filterText)
Copy link
Contributor

Choose a reason for hiding this comment

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

for loop will reduce allocations

Copy link
Member

@sharwell sharwell May 8, 2018

Choose a reason for hiding this comment

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

This is not correct. Neither form will result in allocations. The generated code is not quite identical in debug builds but for all practical purposes it's the same. With optimizations enabled the generated IL is equal.

Copy link
Contributor

Choose a reason for hiding this comment

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

That's good to know, thanks!


if (usePreviousCharAsTrigger)
{
trigger = CompletionTrigger.CreateInsertionTrigger(insertedCharacter: code.ElementAt(position - 1));
trigger = RoslynCompletion.CompletionTrigger.CreateInsertionTrigger(insertedCharacter: code.ElementAt(position - 1));
Copy link
Contributor

Choose a reason for hiding this comment

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

is there a potential error when document is empty or position is otherwise 0?

@@ -21,6 +21,7 @@ namespace Microsoft.VisualStudio.LanguageServices.CSharp.Snippets
[Name("CSharp Snippets")]
[Order(After = CodeAnalysis.Editor.PredefinedCommandHandlerNames.Completion)]
[Order(After = CodeAnalysis.Editor.PredefinedCommandHandlerNames.IntelliSense)]
[Order(After = "CompletionCommandHandlers")]
Copy link
Contributor

Choose a reason for hiding this comment

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

PredefinedCompletionNames.CompletionCommandHandlers

public bool IsCaretOnScreen()
=> _editorInProc.IsCaretOnScreen();
//public bool IsCaretOnScreen()
// => _editorInProc.IsCaretOnScreen();
Copy link
Contributor

Choose a reason for hiding this comment

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

did completion affect this, or is this unrelated?

dpoeschl and others added 17 commits May 10, 2018 16:10
This fixes a signing regression caused be #25751. That changed us to
directly call the SWIX build props / targets vs. getting them implicitly
from the microbuild props / targets. One of the behaviors that the
microbuild props / targets had that wasn't accounted for was the signing
of the VSIX after they are constructed. Hence this lead to signing
errors on insertion.

This PR fixes that by making the following changes:

1. Adds SWIX VSIX to SignToolData.json so they are accounted for during
normal batch signing.
1. Moves the SWIX build to the pre-sign portion of our build.
1. Removes the references from VSMAN -> SWIX. These references are there
only to enforce ordering which is unnecessary. Having them remain risks
that building the VSMAN will cause the SWIX to be re-built which could
possibly invalidate signing.
@dpoeschl dpoeschl removed request for a team May 14, 2018 21:38
@ivanbasov
Copy link
Contributor

@dotnet-bot retest

commitCharacter,
token).WaitAndGetResult(token);

edit.Replace(change.TextChange.Span.ToSpan(), change.TextChange.NewText);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

token).WaitAndGetResult(token);

edit.Replace(change.TextChange.Span.ToSpan(), change.TextChange.NewText);
edit.Apply();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

char commitCharacter,
CancellationToken token)
{
var document = buffer.CurrentSnapshot.GetOpenDocumentInCurrentContextWithChanges();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

}

var completionService = document.GetLanguageService<CompletionService>();
if (!item.Properties.TryGetProperty<RoslynCompletionItem>(CompletionItemSource.RoslynItem, out var roslynItem))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, such as Razor items.

var completionList = await completionService.GetCompletionsAsync(
document,
triggerLocation,
GetRoslynTrigger(trigger)).ConfigureAwait(false);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -26,7 +26,7 @@ internal abstract class AbstractCommandHandlerTestState : IDisposable
public readonly TestWorkspace Workspace;
public readonly IEditorOperations EditorOperations;
public readonly ITextUndoHistoryRegistry UndoHistoryRegistry;
private readonly ITextView _textView;
protected readonly ITextView _textView;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

namespace Microsoft.CodeAnalysis.Test.Utilities.ExperimentationService
{
[Export(typeof(IExperimentationServiceInternal)), Shared]
internal class TestExperimentationServiceInternal : IExperimentationServiceInternal
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ivanbasov Do we need to be able to set this up differently for old/new unit tests?

namespace Microsoft.CodeAnalysis.Test.Utilities.ExperimentationService
{
[Export(typeof(IExperimentationServiceInternal)), Shared]
internal class TestExperimentationServiceInternal : IExperimentationServiceInternal
Copy link
Contributor Author

Choose a reason for hiding this comment

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

attributeImages = ImmutableArray.Create(
new ImageElement(
warningImage,
"Temporary Automation Name")); // TODO: Get automation names, here and below
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ImmutableArray<EditorCompletion.CompletionFilter> activeFilters,
bool mustSetSelection)
{
// TODO: DismissIfEmpty?
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ivanbasov
Copy link
Contributor

retest this please

@ivanbasov
Copy link
Contributor

now it is covered by #29016. I'll remove this branch when I'll migrate #28219 to a new base.

@ivanbasov ivanbasov closed this Aug 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants