Skip to content

Add "Restart Phan Language Server" command #103

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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());
}
}