-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
53bba94
commit ce2756d
Showing
24 changed files
with
733 additions
and
190 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import type { LanguageClient } from 'vscode-languageclient/node'; | ||
import { phpstanProNotification } from './notificationChannels'; | ||
import type { Disposable } from 'vscode'; | ||
import { env, window } from 'vscode'; | ||
import { Uri } from 'vscode'; | ||
|
||
export class PHPStanProManager implements Disposable { | ||
private _disposables: Disposable[] = []; | ||
public port: number | null = null; | ||
|
||
public constructor(client: LanguageClient) { | ||
this._disposables.push( | ||
// eslint-disable-next-line @typescript-eslint/no-misused-promises | ||
client.onNotification(phpstanProNotification, async (message) => { | ||
if (message.type === 'setPort') { | ||
this.port = message.port; | ||
} else if (message.type === 'requireLogin') { | ||
const choice = await window.showInformationMessage( | ||
'Please log in to PHPStan Pro', | ||
'Log in' | ||
); | ||
if (choice === 'Log in') { | ||
if (!this.port) { | ||
void window.showErrorMessage( | ||
'PHPStan Pro port is unknown' | ||
); | ||
} else { | ||
void env.openExternal( | ||
Uri.parse(`http://127.0.0.1:${this.port}`) | ||
); | ||
} | ||
} | ||
} | ||
}) | ||
); | ||
} | ||
|
||
public dispose(): void { | ||
for (const disposable of this._disposables) { | ||
disposable.dispose(); | ||
} | ||
} | ||
} |
Oops, something went wrong.