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

Update Roslyn build #1479

Merged
merged 5 commits into from
May 1, 2019
Merged

Update Roslyn build #1479

merged 5 commits into from
May 1, 2019

Conversation

rchande
Copy link

@rchande rchande commented May 1, 2019

No description provided.

@rchande rchande requested review from filipw and akshita31 May 1, 2019 15:14
@filipw
Copy link
Member

filipw commented May 1, 2019

The test failures are real.

@filipw
Copy link
Member

filipw commented May 1, 2019

Looks like the root cause is that Symbols and Provider properties are no longer available on the CompletionItem. We used them to find/decode matching symbols here

public static async Task<IEnumerable<ISymbol>> GetCompletionSymbolsAsync(this CompletionItem completionItem, IEnumerable<ISymbol> recommendedSymbols, Document document)
{
var properties = completionItem.Properties;
// for SymbolCompletionProvider, use the logic of extracting information from recommended symbols
if (properties.TryGetValue(Provider, out var provider) && provider == SymbolCompletionProvider)
{
return recommendedSymbols.Where(x => x.Name == properties[SymbolName] && (int)x.Kind == int.Parse(properties[SymbolKind])).Distinct();
}
// if the completion provider encoded symbols into Properties, we can return them
if (properties.ContainsKey(Symbols))
{
// the API to decode symbols is not public at the moment
// http://source.roslyn.io/#Microsoft.CodeAnalysis.Features/Completion/Providers/SymbolCompletionItem.cs,93
var decodedSymbolsTask = _getSymbolsAsync.InvokeStatic<Task<ImmutableArray<ISymbol>>>(new object[] { completionItem, document, default(CancellationToken) });
if (decodedSymbolsTask != null)
{
return await decodedSymbolsTask;
}
}
return Enumerable.Empty<ISymbol>();

@rchande
Copy link
Author

rchande commented May 1, 2019

Looking...

{
return recommendedSymbols.Where(x => x.Name == properties[SymbolName] && (int)x.Kind == int.Parse(properties[SymbolKind])).Distinct();
}

// if the completion provider encoded symbols into Properties, we can return them
if (properties.ContainsKey(Symbols))
if (properties.ContainsKey(SymbolName))
Copy link
Member

Choose a reason for hiding this comment

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

I thought most (all?) completion items will be created via CreateWithSymbolId? Roslyn doesn't encode the symbol into the completion item anymore?

but if that's the case, we can make this return the same as above - return recommendedSymbols.Where(x => x.Name == properties[SymbolName] && (int)x.Kind == int.Parse(properties[SymbolKind])).Distinct();

Copy link
Member

@filipw filipw left a comment

Choose a reason for hiding this comment

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

I'm a bit worried that we might lose some feature by not decoding the symbol from the completion item but looks like we have tests for most of the more esoteric cases (cref completion, named parameter completion, attribute without suffix completion etc) so LGTM 👍

@rchande rchande merged commit d42ae80 into OmniSharp:master May 1, 2019
Copy link

@SteamUpdate SteamUpdate left a comment

Choose a reason for hiding this comment

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

I read changelog and saw that line

var properties = completionItem.Properties;

// if the completion provider encoded symbols into Properties, we can return them
if (properties.ContainsKey(SymbolName) && properties.ContainsKey(SymbolName))
Copy link

@SteamUpdate SteamUpdate May 11, 2019

Choose a reason for hiding this comment

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

properties.ContainsKey(SymbolName) - why this code is duplicated? Maybe second check must be properties.ContainsKey(SymbolKind) ?

Copy link
Member

Choose a reason for hiding this comment

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

yes, it's a typo thanks for finding this 👍I opened the fix here #1491

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

Successfully merging this pull request may close these issues.

4 participants