Skip to content

Remove duplication in AbstractSymbolCompletionProvider.CreateItems#36523

Merged
jasonmalinowski merged 1 commit intodotnet:masterfrom
jasonmalinowski:fix-shared-project-non-fatal-watson
Jun 18, 2019
Merged

Remove duplication in AbstractSymbolCompletionProvider.CreateItems#36523
jasonmalinowski merged 1 commit intodotnet:masterfrom
jasonmalinowski:fix-shared-project-non-fatal-watson

Conversation

@jasonmalinowski
Copy link
Copy Markdown
Member

We had two overloads of AbstractSymbolCompletionProvider.CreateItems, once which handles the case of a single file and one that handles linked files. The code is almost identical, but the linked file one incorrectly handled the case of not having any symbols. Rather than fixing the bug in just that branch, I'm refactoring it to simply remove the second copy so both the single file and linked file cases
go through the same helper. The intent here is to avoid hiding simple bugs that had nothing to do with linked files in the linked-file-only path.

Fixes #36080 by virtue of deleting the offending code entirely. No new tests are added since I've confirmed that the existing tests (once the refactoring was complete) would have been sufficient for discovering this problem.

We had two overloads of AbstractSymbolCompletionProvider.CreateItems,
once which handles the case of a single file and one that handles
linked files. The code is almost identical, but the linked file one
incorrectly handled the case of not having any symbols. Rather than
fixing the bug in just that branch, I'm refactoring it to simply
remove the second copy so both the single file and linked file cases
go through the same helper. The intent here is to avoid hiding simple
bugs that had nothing to do with linked files in the linked-file-only
path.

Fixes dotnet#36080 by virtue of
deleting the offending code entirely. No new tests are added since
I've confirmed that the existing tests (once the refactoring was
complete) would have been sufficient for discovering this problem.
@jasonmalinowski jasonmalinowski self-assigned this Jun 17, 2019
@CyrusNajmabadi
Copy link
Copy Markdown
Contributor

Yaaay, dedupe.

It's also worth noting that hte entire internal architecture of completion is pretty awful. There's a lot of independent calls to compute information, lots of which have to recompute intermediary state computed by prvious passes. There's a lot of opportunity for cleanup and dedupe here, that will likely also improve perf a lot.

@jasonmalinowski jasonmalinowski force-pushed the fix-shared-project-non-fatal-watson branch from 8bdc124 to d3fe0eb Compare June 18, 2019 17:53
@jasonmalinowski jasonmalinowski marked this pull request as ready for review June 18, 2019 17:53
@jasonmalinowski jasonmalinowski requested a review from a team as a code owner June 18, 2019 17:53
{
foreach (var symbol in symbolGroup)
{
foreach (var syntaxContext in originatingContextMap.Values)
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.

Deleting this code is also fixing a potentially big perf problem: to determine if a target type matched, we were accidentally binding each symbol up to n times, where n is the number of total symbols in the list. This should have been only finding the syntaxContexts for the symbol by looking it up in the dictionary, but instead by matching all was binding far more than it needed to.

{
foreach (var symbol in symbolGroup)
{
foreach (var syntaxContext in originatingContextMap.Values)
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.

🤦‍♂️👏

@jasonmalinowski
Copy link
Copy Markdown
Member Author

Tagging @jinujoseph for delegated M2 approval.

@dpoeschl
Copy link
Copy Markdown
Contributor

I'm testing this out locally as well.

Copy link
Copy Markdown
Contributor

@dpoeschl dpoeschl left a comment

Choose a reason for hiding this comment

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

Thanks for this. 🙂

Copy link
Copy Markdown
Member

@genlu genlu left a comment

Choose a reason for hiding this comment

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

:shipit:

@jasonmalinowski jasonmalinowski merged commit 56b512b into dotnet:master Jun 18, 2019
@jasonmalinowski jasonmalinowski deleted the fix-shared-project-non-fatal-watson branch June 18, 2019 23:35
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.

"Sequence contains no elements" in AbstractSymbolCompletionProvider for shared files

5 participants