-
Notifications
You must be signed in to change notification settings - Fork 543
Fix #4167: use java.projects context for explorer actions #4450
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -120,7 +120,7 @@ export class StandardLanguageClient { | |
|
|
||
| public registerLanguageClientActions(context: ExtensionContext, hasImported: boolean, jdtEventEmitter: EventEmitter<Uri>) { | ||
| activationProgressNotification.showProgress(); | ||
| this.languageClient.onNotification(StatusNotification.type, (report) => { | ||
| this.languageClient.onNotification(StatusNotification.type, async (report) => { | ||
| // Resolve serverRunning on the first status notification from the server, | ||
| // indicating the server process is alive and can accept requests. | ||
| apiManager.resolveServerRunningPromise(); | ||
|
|
@@ -152,6 +152,13 @@ export class StandardLanguageClient { | |
| // Disable the client-side snippet provider since LS is ready. | ||
| snippetCompletionProvider.dispose(); | ||
| registerDocumentValidationListener(context, this.languageClient); | ||
| try { | ||
| const projectUris = await getAllJavaProjects(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| const projectPaths = projectUris.map((uriString) => Uri.parse(uriString).fsPath.replace(/[\\/]$/, '')); | ||
| await commands.executeCommand('setContext', 'java.projects', projectPaths); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is only set once, on Worth extracting a small helper and also calling it from |
||
| } catch (error) { | ||
| logger.error(error); | ||
| } | ||
| commands.executeCommand('setContext', 'javaLSReady', true); | ||
| break; | ||
| case 'Started': | ||
|
|
||
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.
java.projectsonly holds project root paths, andinis an exact-membership check (no prefix/descendant matching). So this only matches when you right-click the project root itself.But Add/Remove Source Path are mostly used on subfolders (e.g. marking
src/testas a source root) — those will now stop showing the action entirely, which is the opposite of what we want. Same applies to theremoveFromSourcePathwhenjust below.For remove, what you probably want is a separate
java.sourceFolderscontext (the actual source paths) and gate onresourcePath in java.sourceFolders. Add is trickier, since "folder is inside a project" can't really be expressed with exact membership.