Skip to content

Commit

Permalink
Revert "Add "scan project for errors" command (fixes #9)"
Browse files Browse the repository at this point in the history
This reverts commit d5c0c6e.
  • Loading branch information
SanderRonde committed Jul 20, 2022
1 parent ba4e5bf commit 1a26fac
Show file tree
Hide file tree
Showing 18 changed files with 170 additions and 577 deletions.
4 changes: 1 addition & 3 deletions client/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { DocumentManager } from './lib/documentManager';
import { registerConfigListeners } from './lib/config';
import { log, registerLogMessager } from './lib/log';
import { registerListeners } from './lib/commands';
import { ErrorManager } from './lib/errorManager';
import type { ExtensionContext } from 'vscode';
import { StatusBar } from './lib/statusBar';
import { workspace } from 'vscode';
Expand Down Expand Up @@ -65,12 +64,11 @@ export async function activate(context: ExtensionContext): Promise<void> {
const client = await startLanguageServer(context);
const statusBar = new StatusBar(context, client);
const watcher = new DocumentManager(client);
const errorManager = new ErrorManager(client);

registerListeners(context, client);
registerConfigListeners();
registerLogMessager(context, client);
context.subscriptions.push(statusBar, watcher, errorManager);
context.subscriptions.push(statusBar, watcher);

context.subscriptions.push(
client.onNotification(readyNotification, ({ ready }) => {
Expand Down
12 changes: 0 additions & 12 deletions client/src/lib/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,6 @@ export function registerListeners(
)
);

context.subscriptions.push(
autoRegisterCommand(
Commands.SCAN_PROJECT,
async () => {
await client.sendNotification(watcherNotification, {
operation: 'checkProject',
});
},
commands
)
);

context.subscriptions.push(
autoRegisterCommand(
Commands.RELOAD,
Expand Down
14 changes: 2 additions & 12 deletions client/src/lib/documentManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,13 @@ export class DocumentManager implements Disposable {
});
}

private async _onDocumentOpen(
e: vscode.TextDocument,
check: boolean
): Promise<void> {
private async _onDocumentOpen(e: vscode.TextDocument): Promise<void> {
if (!this._shouldSyncDocument(e)) {
return;
}
await this._client.sendNotification(watcherNotification, {
operation: 'open',
file: this._toSendData(e),
check,
});
}

Expand All @@ -88,7 +84,7 @@ export class DocumentManager implements Disposable {
public async watch(): Promise<void> {
await Promise.all(
vscode.workspace.textDocuments.map((doc) => {
return this._onDocumentOpen(doc, false);
return this._onDocumentOpen(doc);
})
);

Expand Down Expand Up @@ -124,12 +120,6 @@ export class DocumentManager implements Disposable {
})
);

this._disposables.push(
vscode.workspace.onDidCloseTextDocument((e) => {
void this._onDocumentOpen(e, true);
})
);

if (vscode.window.activeTextEditor) {
void this._onDocumentActive(
vscode.window.activeTextEditor.document
Expand Down
92 changes: 0 additions & 92 deletions client/src/lib/errorManager.ts

This file was deleted.

5 changes: 0 additions & 5 deletions client/src/lib/notificationChannels.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type {
CommandNotificationType,
ErrorNotificationType,
LogNotificationType,
ReadyNotificationType,
StatusBarNotificationType,
Expand All @@ -27,7 +26,3 @@ export const statusBarNotification =
export const readyNotification = new NotificationType<ReadyNotificationType>(
NotificationChannel.READY
);

export const errorNotification = new NotificationType<ErrorNotificationType>(
NotificationChannel.ERROR
);
23 changes: 9 additions & 14 deletions client/src/lib/statusBar.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type { StatusBarProgress } from '../../../shared/notificationChannels';
import type { LanguageClient } from 'vscode-languageclient/node';
import { statusBarNotification } from './notificationChannels';
import { OperationStatus } from '../../../shared/statusBar';
Expand All @@ -25,15 +24,16 @@ export class StatusBar implements Disposable {
(lastResult: OperationStatus) => this._hideStatusBar(lastResult)
);
context.subscriptions.push(
client.onNotification(statusBarNotification, (params) => {
if (params.progress) {
this.operationProgress(params.progress);
} else if (!params.result) {
this.startOperation(params.opId);
} else {
this.finishOperation(params.opId, params.result);
client.onNotification(
statusBarNotification,
(params: { opId: number; result?: OperationStatus }) => {
if (!params.result) {
this.startOperation(params.opId);
} else {
this.finishOperation(params.opId, params.result);
}
}
})
)
);
}

Expand Down Expand Up @@ -74,11 +74,6 @@ export class StatusBar implements Disposable {
this._opTracker.startOperation(operationId);
}

private operationProgress(progress: StatusBarProgress): void {
this._statusBar.text = `PHPStan checking project ${progress.done}/${progress.total} - ${progress.percentage}% $(loading~spin)`;
this._statusBar.show();
}

private finishOperation(
operationId: number,
result: OperationStatus
Expand Down
29 changes: 1 addition & 28 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
"activationEvents": [
"onLanguage:php",
"onCommand:cmd.phpstan.scanFileForErrors",
"onCommand:cmd.phpstan.scanProjectForErrors",
"onCommand:cmd.phpstan.reload"
],
"main": "./out/extension.js",
Expand Down Expand Up @@ -100,23 +99,13 @@
},
"phpstan.timeout": {
"type": "number",
"description": "Timeout in milliseconds for a single file check. After this time the checking process is canceled",
"description": "Timeout in milliseconds. After this time the checking process is canceled",
"default": 10000
},
"phpstan.projectTimeout": {
"type": "number",
"description": "Timeout in milliseconds for a full project check. After this time the checking process is canceled",
"default": 60000
},
"phpstan.suppressTimeoutMessage": {
"type": "boolean",
"description": "Stop showing an error when the operation times out",
"default": false
},
"phpstan.showProgress": {
"type": "boolean",
"description": "Show checking progress for single-file checks",
"default": true
}
}
}
Expand All @@ -126,10 +115,6 @@
"command": "phpstan.scanFileForErrors",
"title": "Scan current file for errors"
},
{
"command": "phpstan.scanProjectForErrors",
"title": "Scan project for errors"
},
{
"command": "phpstan.reload",
"title": "Reload language server"
Expand All @@ -138,10 +123,6 @@
"command": "cmd.phpstan.scanFileForErrors",
"title": "PHPStan: Scan current file for errors"
},
{
"command": "cmd.phpstan.scanProjectForErrors",
"title": "PHPStan: Scan project for errors"
},
{
"command": "cmd.phpstan.reload",
"title": "PHPStan: Reload language server"
Expand All @@ -153,10 +134,6 @@
"command": "phpstan.scanFileForErrors",
"when": "false"
},
{
"command": "phpstan.scanProjectForErrors",
"when": "false"
},
{
"command": "phpstan.reload",
"when": "false"
Expand All @@ -165,10 +142,6 @@
"command": "cmd.phpstan.scanFileForErrors",
"when": "true"
},
{
"command": "cmd.phpstan.scanProjectForErrors",
"when": "true"
},
{
"command": "cmd.phpstan.reload",
"when": "true"
Expand Down
17 changes: 2 additions & 15 deletions server/src/lib/documentManager.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { WatcherNotificationFileData } from '../../../shared/notificationChannels';
import type { Disposable, _Connection } from 'vscode-languageserver';
import { watcherNotification } from './notificationChannels';
import { assertUnreachable } from '../../../shared/util';
import type { Debouncer } from '../../../shared/util';
import type { Watcher } from './watcher';

Expand Down Expand Up @@ -30,7 +29,7 @@ export class DocumentManager implements Disposable {
case 'change':
return this._onDocumentChange(data.file);
case 'open':
return this._onDocumentOpen(data.file, data.check);
return this._onDocumentOpen(data.file);
case 'save':
return this._onDocumentSave(data.file);
case 'setActive':
Expand All @@ -41,10 +40,6 @@ export class DocumentManager implements Disposable {
return this._onDocumentCheck(data.file);
case 'clear':
return this._watcher.clearData();
case 'checkProject':
return this._watcher.onScanProject();
default:
assertUnreachable(data);
}
})
);
Expand Down Expand Up @@ -78,16 +73,8 @@ export class DocumentManager implements Disposable {
await this._watcher.onDocumentActive(e);
}

private async _onDocumentOpen(
e: WatcherNotificationFileData,
check: boolean
): Promise<void> {
private _onDocumentOpen(e: WatcherNotificationFileData): void {
this._documents.set(e.uri, e);
if (check) {
await this._watcher.onDocumentCheck(e);
} else {
await this._watcher.onDocumentOpen(e);
}
}

private async _onDocumentClose(
Expand Down
5 changes: 0 additions & 5 deletions server/src/lib/notificationChannels.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type {
CommandNotificationType,
ErrorNotificationType,
LogNotificationType,
ReadyNotificationType,
StatusBarNotificationType,
Expand All @@ -27,7 +26,3 @@ export const statusBarNotification =
export const readyNotification = new NotificationType<ReadyNotificationType>(
NotificationChannel.READY
);

export const errorNotification = new NotificationType<ErrorNotificationType>(
NotificationChannel.ERROR
);
Loading

0 comments on commit 1a26fac

Please sign in to comment.