-
Notifications
You must be signed in to change notification settings - Fork 234
(GH-879) Add filtering for CodeLens and References #877
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
(GH-879) Add filtering for CodeLens and References #877
Conversation
454b6f1
to
46fe7d4
Compare
Looks like I may need to issue TODO - https://microsoft.github.io/language-server-protocol/specification#workspace_configuration |
@TylerLeonhardt @rjmholt @rkeithhill So I've reached a bit of an impasse. The EnumeratePSFiles method can now take include and exclude globs etc. however getting the globs from the Language Client is a little curious. So far I see a couple of options
This could be ok for VSCode, but PSES should be editor agnostic therefore it could be 'files.exclude' on VSCode and 'exclude.files' of Atom (or something else). The advantage for this is that it's a Lang. Server. only change so it doesn't require any client changes.
It would work, but if the user changes it, it will require PSES to restart. Not a great UX
This would make the client responsible for updating the server, which may be ok?. It does mean that until the server receives the client message it will use the "defaults" Any thoughts on what would be the best way to proceed? |
That's a very good question... Quick question... does number 1 only happen at startup and when values are changed? I like number 1 personally... because we might be able to make it a powershell extension specific config like:
which could somehow inherit from |
In my testing, VSCode will send a My thinking was to send a As per your comment:
Because that settings is within the language "namespace" it will appear in the DidChangeConfiguration` notification so there's no need to request more information. |
@glennsarti can listen for vscode.workspace.onDidChangeConfiguration(evt => {
if (evt.affectsConfiguration('files.exclude')) {
console.log('configuration updated');
console.log(vscode.workspace.getConfiguration(undefined, null).get('files.exclude'));
}
}); Then maybe we update our |
That's the hard bit. Do you change the settings in the user's settings? workspace settings? per language settings? There is an update method in WorkspaceConfiguration From the docs and what I know, there is no "in process" view where an extension could inject volatile settings. There is an This is kinda why I was leaning towards making the language client send a notification and be as "dumb" as possible eg.
Then let the Language Server decide when and what to do with it e.g. Side note - This doesn't just affect codelens either, also affects Peek and Goto Definitions and Workspace Symbols. Perhaps |
From @TylerLeonhardt A.. simpler-to-implement option that doesn’t fix everything is having a separate setting: and the default value of the setting is but naturally the user would need to be educated to include what’s in their |
OOo...super interesting...You can also call commands https://code.visualstudio.com/docs/editor/variables-reference#_command-variables |
Right so the default would be the value of I think the UX is that, you would see a box in the settings pane that gives you the default value (rather than starting from an empty box)... So they would just tack on to the list the things they want to ignore. This means that if they change This... Might be the way to go. |
e8689ee
to
5668d22
Compare
4b0aead
to
1dbd530
Compare
impasse surmounted. Language Client can send other settings on the OnDidConfigurationChange notification |
1dbd530
to
c179f45
Compare
c179f45
to
c1eaf1b
Compare
Bouncing the PR due to the flaky debounce tests
|
Look at the code lens call sites for |
cedbd6a
to
2c56c44
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM (+nits) looking forward to getting this in, @glennsarti!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks really good! Thanks @glennsarti!
src/PowerShellEditorServices/Workspace/WorkspaceFileSystemWrapper.cs
Outdated
Show resolved
Hide resolved
8e237c3
to
6ebfa77
Compare
Previously the Workspace.EnumeratePSFiles method could only filter files based on file extension (*.ps1, *.psm1, *.psd1). However editor settings tend to use file glob patterns, but Editor Services did not have a library that could parse them. This commit: * Updates Editor Services to use the Microsoft.Extensions.FileSystemGlobbing library * Updated the build process to include the new FileSystemGlobbing DLL * The FileSystemGlobbing library uses an abstract file system to search, not an actual System.IO.FileSystem object. So to implement the same error handling and maximum depth recursion, a WorkspaceFileSystemWrapperFactory is used to create the Directory and File objects needed for the globbing library The WorkspaceFileSystemWrapperFactory can filter on: - Maximum recursion depth - Reparse points (Note that these aren't strictly Symlinks on windows. There are many other types of filesystem items which are reparse points - File system extension - Gracefully ignores any file access errors * The EnumeratePSFiles has two method signatures. One with no arguments which uses the Workspace object's default values and another where all arguments must be specified when enumerating the files * Adds tests for the EnumeratePSFiles method to ensure that it filters on glob and recursion depth.
…sions Previously the EnumeratePSFiles method was modified to be able to use globbing patterns to filter workspace files. This commit * Modifies the LanguageServerSettings class to capture the 'files' and 'search' Settings in order to determine the correct list of glob patterns to use when searching. Currently the 'files.exclude' and 'search.exclude' are merged together to generate the list of globs and then set the Workspace settings appropriately * Uses the 'search.followSymlinks' setting to determine whether to ignore reparse points Note that the LanguageClient must be configured to send these settings during the didChangeConfiguration events otherwise it will default to include everything.
Previously the paths emitted by `EnumeratePSFiles` were normalised to use the directory path separator appropriate for the platform. In particular on Windows the paths emitted by the Microsoft.Extensions.FileSystemGlobbing library contained both forward and backward slashes. However on inspection this is not required as all the paths are converted to URIs when communicating over LSP, so the normalisation is no longer required. This commit removes the normalisation and updates the tests to reflect the new paths.
6ebfa77
to
19b2703
Compare
@rjmholt @TylerLeonhardt Nits and changes addressed. |
@SeeminglyScience did you want to give this one more look since you requested changes a while back? Otherwise, we can merge. |
Awesome work Glenn :) |
Fixes #879
Code sites
LanguageSevice.cs
:HandleDefinitionRequestAsync
(DefinitionRequest Handler)LanguageSevice.cs
:GetDefinitionOfSymbolAsync
- Calls
EnumeratePSFiles
AFTER it parses currently loaded filesLanguageSevice.cs
:HandleReferencesRequestAsync
(ReferencesRequest Handler)LanguageSevice.cs
:FindReferencesOfSymbolAsync
- Calls
EnumeratePSFiles
This is used in the CodeLensFeature, PesterCodeLensProvider and ReferencesCodeLensProvider
ReferencesCodeLensProvider.cs
:ResolveCodeLensAsync
LanguageSevice.cs
:FindReferencesOfSymbolAsync
- Calls
EnumeratePSFiles
Not used
LanguageSevice.cs
:HandleWorkspaceSymbolRequestAsync
(WorkspaceSymbolRequest Handler)- This is weird. It only looks for symbols in the workspace OPENED files, not ALL files
in the workspace. Seems like an oversight here.
As per ba1c40e this is known broken.
Previously there were no tests for the Workspace.EnumeratePSFiles method. This
commit adds tests for EnumeratePSFiles method using a set of static fixture
test files.
Note that the behaviour of EnumeratePSFiles changes depending on the .Net
Framework edition
Previously the Workspace.EnumeratePSFiles method could only filter files
based on file extension (*.ps1, *.psm1, *.psd1). However editor settings tend
to use file glob patterns, but Editor Services did not have a library that could
parse them.
This commit:
Updates Editor Services to use the Microsoft.Extensions.FileSystemGlobbing
library
Updated the build process to include the new FileSystemGlobbing DLL
The FileSystemGlobbing library uses an abstract file system to search, not
an actual System.IO.FileSystem object. So to implement the same error handling
and maximum depth recursion, a WorkspaceFileSystemWrapperFactory is used to
create the Directory and File objects needed for the globbing library
The WorkspaceFileSystemWrapperFactory can filter on:
are many other types of filesystem items which are reparse points
The EnumeratePSFiles has two method signatures. One with no arguments which
uses the Workspace object's default values and another where all arguments
must be specified when enumerating the files
Adds tests for the EnumeratePSFiles method to ensure that it filters on glob
and recursion depth.
Previously the EnumeratePSFiles method was modified to be able to use globbing
patterns to filter workspace files. This commit
Modifies the LanguageServerSettings class to capture the 'files' and 'search'
Settings in order to determine the correct list of glob patterns to use when
searching. Currently the 'files.exclude' and 'search.exclude' are merged
together to generate the list of globs and then set the Workspace settings
appropriately
Uses the 'search.followSymlinks' setting to determine whether to ignore
reparse points
Note that the LanguageClient must be configured to send these settings during
the didChangeConfiguration events otherwise it will default to include
everything.
Work in Progress
files.exclude