-
Notifications
You must be signed in to change notification settings - Fork 77
Add Re-Index Project Command #964
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
Add Re-Index Project Command #964
Conversation
Adds a command to trigger a re-indexing of the open project. Should only be needed when background indexing is enabled and it gets out of sync. While that is a bug, this can act as a temporary workaround. Blocked By: swiftlang/sourcekit-lsp#1561 Issue: swiftlang#939
const error = err as { code: number; message: string }; | ||
// methodNotFound, version of sourcekit-lsp is likely too old. | ||
if (error.code === -32601) { | ||
vscode.window.showWarningMessage( |
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.
Is there a way to check this in advance so that we can only show the command in the command palette if background indexing is enabled?
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.
SourceKit-LSP should report this capability
src/commands.ts
Outdated
@@ -817,6 +837,9 @@ export function register(ctx: WorkspaceContext): vscode.Disposable[] { | |||
vscode.commands.registerCommand("swift.debugSnippet", () => debugSnippet(ctx)), | |||
vscode.commands.registerCommand("swift.runPluginTask", () => runPluginTask()), | |||
vscode.commands.registerCommand("swift.restartLSPServer", () => restartLSPServer(ctx)), | |||
...(ctx.swiftVersion.isGreaterThanOrEqual(new Version(6, 0, 0)) | |||
? [vscode.commands.registerCommand("swift.reindexProject", () => reindexProject(ctx))] |
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.
You can actually add a "when"
clause to the package.json to hide the command under certain circumstances. Otherwise, the command will still show up in the command palette and give an ugly error message if the user tries to run it. Take a look at contextKeys.ts
to see how to add a new context key. There are a bunch of examples for the "when"
clause in the package.json already.
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.
Ideally we'd solve both these comments with a context key called supportsReindexing
. It would be set by languageClient.initializeResult.capatiblities.experimental['workspace/triggerReindex']
which would be returned when you initialize the language server. However this capability doesn't exist.
@ahoppen Is this possible to add? If you agree I can work up a PR.
I've updated the PR to check if the |
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.
👍
Do you think it would also be possible to address this from #939?
|
Show a warning informing the user that they shouldn't have to reindex the project, and doing so indicates a bug in SourceKit-LSP. Show a button that links out to the SourceKit-LSP issue creation page, prepopulating the issue title as "Symbol Indexing Issue". Requested by @ahoppen in swiftlang#964 (comment)
Show a warning informing the user that they shouldn't have to reindex the project, and doing so indicates a bug in SourceKit-LSP. Show a button that links out to the SourceKit-LSP issue creation page, prepopulating the issue title as "Symbol Indexing Issue". Requested by @ahoppen in swiftlang#964 (comment)
Show a warning informing the user that they shouldn't have to reindex the project, and doing so indicates a bug in SourceKit-LSP. Show a button that links out to the SourceKit-LSP issue creation page, prepopulating the issue title as "Symbol Indexing Issue". Requested by @ahoppen in #964 (comment)
Adds a command to trigger a re-indexing of the open project. Should only be needed when background indexing is enabled and it gets out of sync. While that is a bug, this can act as a temporary workaround.
Blocked By: swiftlang/sourcekit-lsp#1561, swiftlang/sourcekit-lsp#1563
Issue: #939