Skip to content
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

Update languageserver-client #1662

Merged
merged 6 commits into from
Nov 29, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
91 changes: 39 additions & 52 deletions extensions/ql-vscode/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions extensions/ql-vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"url": "https://github.com/github/vscode-codeql"
},
"engines": {
"vscode": "^1.59.0",
"vscode": "^1.67.0",
"node": "^16.13.0",
"npm": ">=7.20.6"
},
Expand Down Expand Up @@ -1295,8 +1295,8 @@
"tree-kill": "~1.2.2",
"unzipper": "~0.10.5",
"vscode-extension-telemetry": "^0.1.6",
"vscode-jsonrpc": "^5.0.1",
"vscode-languageclient": "^6.1.3",
"vscode-jsonrpc": "^8.0.2",
"vscode-languageclient": "^8.0.2",
"vscode-test-adapter-api": "~1.7.0",
"vscode-test-adapter-util": "~0.7.0",
"zip-a-folder": "~1.1.3"
Expand Down
8 changes: 5 additions & 3 deletions extensions/ql-vscode/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
workspace,
ProviderResult
} from 'vscode';
import { LanguageClient } from 'vscode-languageclient';
import { LanguageClient } from 'vscode-languageclient/node';
import * as os from 'os';
import * as fs from 'fs-extra';
import * as path from 'path';
Expand Down Expand Up @@ -1130,8 +1130,10 @@ async function activateWithInstalledDistribution(
ctx.subscriptions.push(new SummaryLanguageSupport());

void logger.log('Starting language server.');
ctx.subscriptions.push(client.start());

await client.start();
ctx.subscriptions.push({
dispose: () => { void client.stop(); }
});
// Jump-to-definition and find-references
void logger.log('Registering jump-to-definition handlers.');

Expand Down
2 changes: 1 addition & 1 deletion extensions/ql-vscode/src/ide-server.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ProgressLocation, window } from 'vscode';
import { StreamInfo } from 'vscode-languageclient';
import { StreamInfo } from 'vscode-languageclient/node';
import * as cli from './cli';
import { QueryServerConfig } from './config';
import { ideServerLogger } from './logging';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as fs from 'fs-extra';

import { DisposableObject } from '../pure/disposable-object';
import { CancellationToken, commands } from 'vscode';
import { createMessageConnection, RequestType } from 'vscode-jsonrpc';
import { createMessageConnection, RequestType } from 'vscode-jsonrpc/node';
import * as cli from '../cli';
import { QueryServerConfig } from '../config';
import { Logger, ProgressReporter } from '../logging';
Expand Down Expand Up @@ -201,7 +201,7 @@ export class QueryServerClient extends DisposableObject {
return this.serverProcess!.child.pid || 0;
}

async sendRequest<P, R, E, RO>(type: RequestType<WithProgressId<P>, R, E, RO>, parameter: P, token?: CancellationToken, progress?: (res: ProgressMessage) => void): Promise<R> {
async sendRequest<P, R, E>(type: RequestType<WithProgressId<P>, R, E>, parameter: P, token?: CancellationToken, progress?: (res: ProgressMessage) => void): Promise<R> {
const id = this.nextProgress++;
this.progressCallbacks[id] = progress;

Expand Down
4 changes: 2 additions & 2 deletions extensions/ql-vscode/src/legacy-query-server/run-queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
CancellationToken,
Uri,
} from 'vscode';
import { ErrorCodes, ResponseError } from 'vscode-languageclient';
import { LSPErrorCodes, ResponseError } from 'vscode-languageclient';

import * as cli from '../cli';
import { DatabaseItem, } from '../databases';
Expand Down Expand Up @@ -400,7 +400,7 @@ export async function compileAndRunQueryAgainstDatabase(
try {
errors = await query.compile(qs, qlProgram, progress, token);
} catch (e) {
if (e instanceof ResponseError && e.code == ErrorCodes.RequestCancelled) {
if (e instanceof ResponseError && e.code == LSPErrorCodes.RequestCancelled) {
return createSyntheticResult(query, 'Query cancelled');
} else {
throw e;
Expand Down
28 changes: 13 additions & 15 deletions extensions/ql-vscode/src/pure/legacy-messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -977,77 +977,75 @@ export type ProgressMessage = shared.ProgressMessage;
/**
* Check a Ql query for errors without compiling it
*/
export const checkQuery = new rpc.RequestType<WithProgressId<CheckQueryParams>, CheckQueryResult, void, void>('compilation/checkQuery');
export const checkQuery = new rpc.RequestType<WithProgressId<CheckQueryParams>, CheckQueryResult, void>('compilation/checkQuery');
/**
* Compile a Ql query into a qlo
*/
export const compileQuery = new rpc.RequestType<WithProgressId<CompileQueryParams>, CheckQueryResult, void, void>('compilation/compileQuery');
export const compileQuery = new rpc.RequestType<WithProgressId<CompileQueryParams>, CheckQueryResult, void>('compilation/compileQuery');
/**
* Compile a dil query into a qlo
*/
export const compileDilQuery = new rpc.RequestType<WithProgressId<CompileDilParams>, CheckQueryResult, void, void>('compilation/compileDilQuery');
export const compileDilQuery = new rpc.RequestType<WithProgressId<CompileDilParams>, CheckQueryResult, void>('compilation/compileDilQuery');


/**
* Check if there is a valid upgrade path between two dbschemes.
*/
export const checkUpgrade = new rpc.RequestType<WithProgressId<UpgradeParams>, CheckUpgradeResult, void, void>('compilation/checkUpgrade');
export const checkUpgrade = new rpc.RequestType<WithProgressId<UpgradeParams>, CheckUpgradeResult, void>('compilation/checkUpgrade');
/**
* Compile an upgrade script to upgrade a dataset.
*/
export const compileUpgrade = new rpc.RequestType<WithProgressId<CompileUpgradeParams>, CompileUpgradeResult, void, void>('compilation/compileUpgrade');
export const compileUpgrade = new rpc.RequestType<WithProgressId<CompileUpgradeParams>, CompileUpgradeResult, void>('compilation/compileUpgrade');
/**
* Compile an upgrade script to upgrade a dataset.
*/
export const compileUpgradeSequence = new rpc.RequestType<WithProgressId<CompileUpgradeSequenceParams>, CompileUpgradeSequenceResult, void, void>('compilation/compileUpgradeSequence');
export const compileUpgradeSequence = new rpc.RequestType<WithProgressId<CompileUpgradeSequenceParams>, CompileUpgradeSequenceResult, void>('compilation/compileUpgradeSequence');

/**
* Start a new structured log in the evaluator, terminating the previous one if it exists
*/
export const startLog = new rpc.RequestType<WithProgressId<StartLogParams>, StartLogResult, void, void>('evaluation/startLog');
export const startLog = new rpc.RequestType<WithProgressId<StartLogParams>, StartLogResult, void>('evaluation/startLog');

/**
* Terminate a structured log in the evaluator. Is a no-op if we aren't logging to the given location
*/
export const endLog = new rpc.RequestType<WithProgressId<EndLogParams>, EndLogResult, void, void>('evaluation/endLog');
export const endLog = new rpc.RequestType<WithProgressId<EndLogParams>, EndLogResult, void>('evaluation/endLog');

/**
* Clear the cache of a dataset
*/
export const clearCache = new rpc.RequestType<WithProgressId<ClearCacheParams>, ClearCacheResult, void, void>('evaluation/clearCache');
export const clearCache = new rpc.RequestType<WithProgressId<ClearCacheParams>, ClearCacheResult, void>('evaluation/clearCache');
/**
* Trim the cache of a dataset
*/
export const trimCache = new rpc.RequestType<WithProgressId<TrimCacheParams>, ClearCacheResult, void, void>('evaluation/trimCache');
export const trimCache = new rpc.RequestType<WithProgressId<TrimCacheParams>, ClearCacheResult, void>('evaluation/trimCache');

/**
* Run some queries on a dataset
*/
export const runQueries = new rpc.RequestType<WithProgressId<EvaluateQueriesParams>, EvaluationComplete, void, void>('evaluation/runQueries');
export const runQueries = new rpc.RequestType<WithProgressId<EvaluateQueriesParams>, EvaluationComplete, void>('evaluation/runQueries');

/**
* Run upgrades on a dataset
*/
export const runUpgrade = new rpc.RequestType<WithProgressId<RunUpgradeParams>, RunUpgradeResult, void, void>('evaluation/runUpgrade');
export const runUpgrade = new rpc.RequestType<WithProgressId<RunUpgradeParams>, RunUpgradeResult, void>('evaluation/runUpgrade');

export const registerDatabases = new rpc.RequestType<
WithProgressId<RegisterDatabasesParams>,
RegisterDatabasesResult,
void,
void
>('evaluation/registerDatabases');

export const deregisterDatabases = new rpc.RequestType<
WithProgressId<DeregisterDatabasesParams>,
DeregisterDatabasesResult,
void,
void
>('evaluation/deregisterDatabases');

/**
* Request returned to the client to notify completion of a query.
* The full runQueries job is completed when all queries are acknowledged.
*/
export const completeQuery = new rpc.RequestType<EvaluationResult, Record<string, any>, void, void>('evaluation/queryCompleted');
export const completeQuery = new rpc.RequestType<EvaluationResult, Record<string, any>, void>('evaluation/queryCompleted');

export const progress = shared.progress;
2 changes: 1 addition & 1 deletion extensions/ql-vscode/src/pure/messages-shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,4 @@ export interface ProgressMessage {
/**
* A notification that the progress has been changed.
*/
export const progress = new rpc.NotificationType<ProgressMessage, void>('ql/progressUpdated');
export const progress = new rpc.NotificationType<ProgressMessage>('ql/progressUpdated');
11 changes: 4 additions & 7 deletions extensions/ql-vscode/src/pure/new-messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,41 +171,38 @@ export type ProgressMessage = shared.ProgressMessage;
/**
* Clear the cache of a dataset
*/
export const clearCache = new rpc.RequestType<WithProgressId<ClearCacheParams>, ClearCacheResult, void, void>('evaluation/clearCache');
export const clearCache = new rpc.RequestType<WithProgressId<ClearCacheParams>, ClearCacheResult, void>('evaluation/clearCache');
/**
* Trim the cache of a dataset
*/
export const trimCache = new rpc.RequestType<WithProgressId<TrimCacheParams>, ClearCacheResult, void, void>('evaluation/trimCache');
export const trimCache = new rpc.RequestType<WithProgressId<TrimCacheParams>, ClearCacheResult, void>('evaluation/trimCache');

/**
* Clear the pack cache
*/
export const clearPackCache = new rpc.RequestType<WithProgressId<ClearPackCacheParams>, ClearPackCacheResult, void, void>('evaluation/clearPackCache');
export const clearPackCache = new rpc.RequestType<WithProgressId<ClearPackCacheParams>, ClearPackCacheResult, void>('evaluation/clearPackCache');

/**
* Run a query on a database
*/
export const runQuery = new rpc.RequestType<WithProgressId<RunQueryParams>, RunQueryResult, void, void>('evaluation/runQuery');
export const runQuery = new rpc.RequestType<WithProgressId<RunQueryParams>, RunQueryResult, void>('evaluation/runQuery');

export const registerDatabases = new rpc.RequestType<
WithProgressId<RegisterDatabasesParams>,
RegisterDatabasesResult,
void,
void
>('evaluation/registerDatabases');

export const deregisterDatabases = new rpc.RequestType<
WithProgressId<DeregisterDatabasesParams>,
DeregisterDatabasesResult,
void,
void
>('evaluation/deregisterDatabases');


export const upgradeDatabase = new rpc.RequestType<
WithProgressId<UpgradeParams>,
UpgradeResult,
void,
void
>('evaluation/runUpgrade');

Expand Down
4 changes: 2 additions & 2 deletions extensions/ql-vscode/src/query-server/queryserver-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as fs from 'fs-extra';

import { DisposableObject } from '../pure/disposable-object';
import { CancellationToken, commands } from 'vscode';
import { createMessageConnection, RequestType } from 'vscode-jsonrpc';
import { createMessageConnection, RequestType } from 'vscode-jsonrpc/node';
import * as cli from '../cli';
import { QueryServerConfig } from '../config';
import { Logger, ProgressReporter } from '../logging';
Expand Down Expand Up @@ -174,7 +174,7 @@ export class QueryServerClient extends DisposableObject {
return this.serverProcess!.child.pid || 0;
}

async sendRequest<P, R, E, RO>(type: RequestType<WithProgressId<P>, R, E, RO>, parameter: P, token?: CancellationToken, progress?: (res: ProgressMessage) => void): Promise<R> {
async sendRequest<P, R, E>(type: RequestType<WithProgressId<P>, R, E>, parameter: P, token?: CancellationToken, progress?: (res: ProgressMessage) => void): Promise<R> {
const id = this.nextProgress++;
this.progressCallbacks[id] = progress;

Expand Down
Loading