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

Don't duplicate find symbols results from C# files #1282

Merged
merged 12 commits into from
Sep 6, 2018

Conversation

rchande
Copy link

@rchande rchande commented Aug 31, 2018

Fixes #1281

Copy link
Contributor

@akshita31 akshita31 left a comment

Choose a reason for hiding this comment

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

Thanks!

Copy link
Member

@bjorkstromm bjorkstromm left a comment

Choose a reason for hiding this comment

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

Some thoughts. Also wondering if this bug have been present ever since Cake support was added?!

: true;

return Workspace.CurrentSolution.FindSymbols(isMatch,
p => p.Name.EndsWith(".cake", StringComparison.OrdinalIgnoreCase));
Copy link
Member

Choose a reason for hiding this comment

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

Could we reuse the extension as defined in the project system?

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe the project system and this handler should point to the same constant?

@@ -30,57 +27,8 @@ public async Task<QuickFixResponse> Handle(FindSymbolsRequest request = null)
? candidate.IsValidCompletionFor(request.Filter)
: true;

return await FindSymbols(isMatch);
return await _workspace.CurrentSolution.FindSymbols(isMatch,
p => !p.Name.EndsWith(".cake", StringComparison.OrdinalIgnoreCase));
Copy link
Member

Choose a reason for hiding this comment

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

Could we try avoiding to use .cake extension in OmniSharp.Roslyn.CSharp, instead allow only .cs and .csx..? Would be difficult to get from project system, since OmniSharp.Roslyn.CSharp doesn't have (and shouldn't) have a dependency on OmniSharp.Scripting.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, this feels weird. It would certainly fix the issue, but it feels a bit dirty and easily broken.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah I think being explicit about the file types supported makes sense, instead of excluding things. If for example we ever add vb support, then this will start to leak again.

@rchande
Copy link
Author

rchande commented Sep 4, 2018

@mholo65 Done; thanks. It does kind of look like this has been present for as long as cake...

@rchande
Copy link
Author

rchande commented Sep 4, 2018

@mholo65 @DustinCampbell Another approach could be to simply remove the "cake" flavored handler. Ctrl-t in VS Code doesn't specify a language, so the C# extension doesn't pass one to OmniSharp, thus running both handlers.

However, the symbol provider (https://code.visualstudio.com/docs/extensionAPI/vscode-api#DocumentSymbolProvider) gets access to the current document, so we could specify a language in the request based on the current document. Of course, that means you could only search for Cake symbols from a Cake file and vice versa. Thoughts?

? candidate.IsValidCompletionFor(request.Filter)
: true;

return Workspace.CurrentSolution.FindSymbols(isMatch,
Copy link
Contributor

Choose a reason for hiding this comment

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

Should the FindSymbols extension method just take the file extension? It seems error prone to always remember to specify StringComparison.OrdinalIgnoreCase.

Copy link
Author

Choose a reason for hiding this comment

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

Good idea.

Copy link
Member

@david-driscoll david-driscoll left a comment

Choose a reason for hiding this comment

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

I can comment on outdated things!

Looks good to me now, feedback looks complete.

Copy link
Member

@bjorkstromm bjorkstromm 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! Two questions though that might need answers.

@@ -28,7 +28,7 @@ public async Task<QuickFixResponse> Handle(FindSymbolsRequest request = null)
: true;

return await _workspace.CurrentSolution.FindSymbols(isMatch,
p => !p.Name.EndsWith(".cake", StringComparison.OrdinalIgnoreCase));
p => p.Name.EndsWith(".csproj", StringComparison.OrdinalIgnoreCase));
Copy link
Member

Choose a reason for hiding this comment

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

Correct me if I’m wrong, but this will stop finding symbols in.csx files also?

@@ -119,7 +119,7 @@ private ProjectInfo CreateMiscFilesProject(string language)
var projectInfo = ProjectInfo.Create(
id: ProjectId.CreateNewId(),
version: VersionStamp.Create(),
name: "MiscellaneousFiles",
name: "MiscellaneousFiles.csproj",
Copy link
Member

Choose a reason for hiding this comment

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

What if someone already has a project called MiscellaneousFiles.csproj in their workspace? Would a GUID or some obscure name be beneficial to avoid a name clash?


return new SymbolLocation
var csprojSymbols = await _workspace.CurrentSolution.FindSymbols(isMatch, ".csproj");
var projectJsonSymbols = await _workspace.CurrentSolution.FindSymbols(isMatch, ".json");
Copy link
Member

Choose a reason for hiding this comment

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

What about .csx? I think it should be here.

Copy link
Member

Choose a reason for hiding this comment

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

Ping @filipw

@DustinCampbell
Copy link
Contributor

@mholo65 @DustinCampbell Another approach could be to simply remove the "cake" flavored handler. Ctrl-t in VS Code doesn't specify a language, so the C# extension doesn't pass one to OmniSharp, thus running both handlers.

However, the symbol provider (https://code.visualstudio.com/docs/extensionAPI/vscode-api#DocumentSymbolProvider) gets access to the current document, so we could specify a language in the request based on the current document. Of course, that means you could only search for Cake symbols from a Cake file and vice versa. Thoughts?

I think there should be a single FindSymbolsHandler that lives in the OmniSharp.Roslyn.CSharp project that returns results from the entire workspace for all project systems. The cake handlers really just translate locations don't they? This could be done by calling into a method exposed by the project system from the findsymbols endpoint.

@rchande
Copy link
Author

rchande commented Sep 6, 2018

In the interest of being able to release today, I'm going to merge this PR. I filed #1287 to track cleaning this up further.

@rchande rchande merged commit 0cf97a6 into OmniSharp:master Sep 6, 2018
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.

5 participants