Skip to content

Commit

Permalink
Add "Restart Phan Language Server" command
Browse files Browse the repository at this point in the history
This is handy when the language server crashes.
  • Loading branch information
blm768 committed Feb 6, 2023
1 parent 4a61b24 commit 2fef6f0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@
"vscode-languageclient": "^6.1.4"
},
"contributes": {
"commands": [
{
"command": "phan.restartLanguageServer",
"title": "Restart Phan Language Server",
"category": "Phan"
}
],
"configuration": {
"type": "object",
"title": "PHP - Phan Analyzer",
Expand Down
12 changes: 9 additions & 3 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -430,11 +430,17 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
return new LanguageClient('Phan Language Server', serverOptions, clientOptions);
};

const languageClients = analyzedProjectDirectories.map(createClient);

function restartLanguageClients() {
return Promise.all(languageClients.map((c: LanguageClient) => c.stop().then(() => c.start())));
}
context.subscriptions.push(vscode.commands.registerCommand('phan.restartLanguageServer', restartLanguageClients));

console.log('starting PHP Phan language server');
// Create the language client and start the client.
for (const dirToAnalyze of analyzedProjectDirectories) {
for (const client of languageClients) {
// Push the disposable to the context's subscriptions so that the
// client can be deactivated on extension deactivation
context.subscriptions.push(createClient(dirToAnalyze).start());
context.subscriptions.push(client.start());
}
}

0 comments on commit 2fef6f0

Please sign in to comment.