Skip to content

Commit

Permalink
Add forget method and fix clean script (#1439)
Browse files Browse the repository at this point in the history
  • Loading branch information
dbaeumer authored Mar 1, 2024
1 parent 808df63 commit 46f6f90
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 10 deletions.
2 changes: 1 addition & 1 deletion client-node-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"main": "./extension.js",
"contributes": {},
"scripts": {
"clean": "node ../node_modules/.bin/rimraf lib",
"clean": "node ../node_modules/rimraf/dist/esm/bin.mjs lib",
"compile": "node ../build/bin/tsc -b ./tsconfig.json",
"watch": "node ../build/bin/tsc -b ./tsconfig.watch.json -w",
"lint": "node ../node_modules/eslint/bin/eslint.js --ext ts src",
Expand Down
2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"watch": "node ../build/bin/tsc -b ./tsconfig.watch.json -w",
"lint": "node ../node_modules/eslint/bin/eslint.js --ext ts src",
"test": "cd ../client-node-tests && npm test && cd ../client",
"clean": "node ../node_modules/.bin/rimraf lib",
"clean": "node ../node_modules/rimraf/dist/esm/bin.mjs lib",
"all": "npm run clean && npm run compile && npm run lint && npm test",
"compile:publish": "node ../build/bin/tsc -b ./tsconfig.publish.json && shx cp src/node/terminateProcess.sh lib/node/terminateProcess.sh",
"all:publish": "git clean -xfd . && npm install && npm run updateVSCodeVersion && npm run compile:publish && npm run lint && cd ../client-node-tests && npm run all:publish && cd ..",
Expand Down
21 changes: 20 additions & 1 deletion client/src/common/diagnostic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -728,8 +728,23 @@ class DiagnosticRequestor implements Disposable {
}

export type DiagnosticProviderShape = {
/**
* An event that signals that the diagnostics should be refreshed for
* all documents.
*/
onDidChangeDiagnosticsEmitter: EventEmitter<void>;

/**
* The provider of diagnostics.
*/
diagnostics: vsdiag.DiagnosticProvider;

/**
* Forget the given document and remove all diagnostics.
*
* @param document The document to forget.
*/
forget(document: TextDocument): void;
};

class BackgroundScheduler implements Disposable {
Expand Down Expand Up @@ -823,7 +838,7 @@ class DiagnosticFeatureProviderImpl implements DiagnosticProviderShape {
private readonly backgroundScheduler: BackgroundScheduler;

constructor(client: FeatureClient<DiagnosticProviderMiddleware, $DiagnosticPullOptions>, tabs: Tabs, options: DiagnosticRegistrationOptions) {
const diagnosticPullOptions = client.clientOptions.diagnosticPullOptions ?? { onChange: true, onSave: false, onFocus: false };
const diagnosticPullOptions = Object.assign({ onChange: true, onSave: false, onFocus: false }, client.clientOptions.diagnosticPullOptions);
const documentSelector = client.protocol2CodeConverter.asDocumentSelector(options.documentSelector!);
const disposables: Disposable[] = [];

Expand Down Expand Up @@ -1029,6 +1044,10 @@ class DiagnosticFeatureProviderImpl implements DiagnosticProviderShape {
return this.diagnosticRequestor.provider;
}

public forget(document: TextDocument): void {
this.cleanUpDocument(document);
}

private cleanUpDocument(document: TextDocument | Uri): void {
if (this.diagnosticRequestor.knows(PullState.document, document)) {
this.diagnosticRequestor.forgetDocument(document);
Expand Down
2 changes: 1 addition & 1 deletion jsonrpc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"preversion": "npm test",
"compile": "node ../build/bin/tsc -b ./tsconfig.json",
"watch": "node ../build/bin/tsc -b ./tsconfig.watch.json -w",
"clean": "node ../node_modules/.bin/rimraf lib && node ../node_modules/.bin/rimraf dist",
"clean": "node ../node_modules/rimraf/dist/esm/bin.mjs lib && node ../node_modules/rimraf/dist/esm/bin.mjs dist",
"lint": "node ../node_modules/eslint/bin/eslint.js --ext ts src",
"test": "npm run test:node && npm run test:browser",
"test:node": "node ../node_modules/mocha/bin/_mocha",
Expand Down
2 changes: 1 addition & 1 deletion protocol/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"preversion": "npm test",
"compile": "node ../build/bin/tsc -b ./tsconfig.json",
"watch": "node ../build/bin/tsc -b ./tsconfig.watch.json -w",
"clean": "node ../node_modules/.bin/rimraf lib && node ../node_modules/.bin/rimraf dist",
"clean": "node ../node_modules/rimraf/dist/esm/bin.mjs lib && node ../node_modules/rimraf/dist/esm/bin.mjs dist",
"lint": "node ../node_modules/eslint/bin/eslint.js --ext ts src",
"test": "npm run test:node && npm run test:browser",
"test:node": "node ../node_modules/mocha/bin/_mocha",
Expand Down
2 changes: 1 addition & 1 deletion server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"prepack": "npm run all:publish",
"compile": "node ../build/bin/tsc -b ./tsconfig.json",
"watch": "node ../build/bin/tsc -b ./tsconfig.watch.json -w",
"clean": "node ../node_modules/.bin/rimraf lib",
"clean": "node ../node_modules/rimraf/dist/esm/bin.mjs lib",
"lint": "node ../node_modules/eslint/bin/eslint.js --ext ts src",
"test": "node ../node_modules/mocha/bin/_mocha",
"all": "npm run clean && npm run compile && npm run lint && npm test",
Expand Down
2 changes: 1 addition & 1 deletion textDocument/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"prepublishOnly": "echo \"⛔ Can only publish from a secure pipeline ⛔\" && node ../build/npm/fail",
"prepack": "npm run all:publish",
"compile": "node ../build/bin/tsc -b ./tsconfig.json",
"clean": "node ../node_modules/.bin/rimraf lib",
"clean": "node ../node_modules/rimraf/dist/esm/bin.mjs lib",
"watch": "node ../build/bin/tsc -b ./tsconfig.watch.json -w",
"lint": "node ../node_modules/eslint/bin/eslint.js --ext ts src",
"test": "node ../node_modules/mocha/bin/_mocha",
Expand Down
2 changes: 1 addition & 1 deletion tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"scripts": {
"compile": "node ../build/bin/tsc -b ./tsconfig.json",
"watch": "node ../build/bin/tsc -b ./tsconfig-watch.json -w",
"clean": "node ../node_modules/.bin/rimraf lib && node ../node_modules/.bin/rimraf dist",
"clean": "node ../node_modules/rimraf/dist/esm/bin.mjs lib && node ../node_modules/rimraf/dist/esm/bin.mjs dist",
"lint": "node ../node_modules/eslint/bin/eslint.js --ext ts src"
}
}
2 changes: 1 addition & 1 deletion tsconfig-gen/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"prepublishOnly": "echo \"⛔ Can only publish from a secure pipeline ⛔\" && node ../build/npm/fail",
"prepack": "git clean -xfd . && npm install && npm run all",
"compile": "node ../build/bin/tsc -b ./tsconfig.json",
"clean": "node ../node_modules/.bin/rimraf lib",
"clean": "node ../node_modules/rimraf/dist/esm/bin.mjs lib",
"watch": "node ../build/bin/tsc -b ./tsconfig.watch.json -w",
"lint": "node ../node_modules/eslint/bin/eslint.js --ext ts src",
"all": "npm run compile && npm run lint",
Expand Down
2 changes: 1 addition & 1 deletion types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"prepublishOnly": "echo \"⛔ Can only publish from a secure pipeline ⛔\" && node ../build/npm/fail",
"prepack": "npm run all:publish",
"compile": "node ../build/bin/tsc -b ./tsconfig.json",
"clean": "node ../node_modules/.bin/rimraf lib",
"clean": "node ../node_modules/rimraf/dist/esm/bin.mjs lib",
"watch": "node ../build/bin/tsc -b ./tsconfig.watch.json -w",
"lint": "node ../node_modules/eslint/bin/eslint.js --ext ts src",
"test": "node ../node_modules/mocha/bin/_mocha",
Expand Down

0 comments on commit 46f6f90

Please sign in to comment.