Skip to content

Consolidate data tracked over an async completion session#59553

Merged
genlu merged 9 commits intodotnet:mainfrom
genlu:SessionData
Feb 17, 2022
Merged

Consolidate data tracked over an async completion session#59553
genlu merged 9 commits intodotnet:mainfrom
genlu:SessionData

Conversation

@genlu
Copy link
Copy Markdown
Member

@genlu genlu commented Feb 15, 2022

Fix #59262

Based on the public async completion API, it's not mentioned that the same session object would be used over an async completion session, even though the underlying implementation guarantees it. So I have aggregated all data into a single object but still uses the property bag to track it over the session, instead of using a CWT.

@genlu genlu requested a review from a team as a code owner February 15, 2022 02:08
@ghost ghost added the Area-IDE label Feb 15, 2022
private CompletionItemData(RoslynCompletionItem roslynItem, SnapshotPoint? triggerLocation)
{
RoslynItem = roslynItem;
TriggerLocation = triggerLocation ?? new();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

❕ Don't use new T() (or new()) for value types unless they have a default constructor. Also, I'm concerned this line may be treating new() as new SnapshotPoint() and not new Optional<SnapshotPoint>() (even if it's not, it's confusing).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

You are right, new() here actually is new SnapshotPoint(). Fixed

@genlu genlu requested a review from a team February 15, 2022 22:51
public bool HasSuggestionItemOptions { get; set; }

public Optional<SnapshotPoint> ExpandedItemTriggerLocation { get; set; }
public Optional<TextSpan> CompletionListSpan { get; set; }
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

can all of these be optional at different times? Or does one being provided mean the rest are provided as well?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think the following three could be in one such group, but I'm not sure I'd like to have another type to bundle them together (if that's what you are suggesting)

        public Optional<SnapshotPoint> ExpandedItemTriggerLocation { get; set; }
        public Optional<TextSpan> CompletionListSpan { get; set; }
        public Optional<ImmutableArray<char>> ExcludedCommitCharacters { get; set; }

internal const string ExpandedItemsTask = nameof(ExpandedItemsTask);

// Don't change this property! Editor code currently has a dependency on it.
internal const string ExcludedCommitCharacters = nameof(ExcludedCommitCharacters);
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member Author

@genlu genlu Feb 17, 2022

Choose a reason for hiding this comment

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

@olegtk @AmadeusW This feels so wrong. Any idea how can we remove this dependency?
tracking bug: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1484552

@genlu genlu enabled auto-merge February 17, 2022 00:57
@genlu genlu merged commit ed5caf4 into dotnet:main Feb 17, 2022
@ghost ghost added this to the Next milestone Feb 17, 2022
@genlu genlu deleted the SessionData branch February 18, 2022 06:52
@RikkiGibson RikkiGibson modified the milestones: Next, 17.2.P2 Mar 1, 2022
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.

Consolidate data tracked over an async completion session

4 participants