Rename IDE server to language client
This commit is contained in:
@@ -1657,7 +1657,7 @@ function isEnvTrue(name: string): boolean {
|
||||
);
|
||||
}
|
||||
|
||||
export function shouldDebugIdeServer() {
|
||||
export function shouldDebugLanguageServer() {
|
||||
return isEnvTrue("IDE_SERVER_JAVA_DEBUG");
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ export const extLogger = new OutputChannelLogger("CodeQL Extension Log");
|
||||
export const queryServerLogger = new OutputChannelLogger("CodeQL Query Server");
|
||||
|
||||
// Logger for messages from the language server.
|
||||
export const ideServerLogger = new OutputChannelLogger(
|
||||
export const languageServerLogger = new OutputChannelLogger(
|
||||
"CodeQL Language Server",
|
||||
);
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ import {
|
||||
} from "./config";
|
||||
import {
|
||||
AstViewer,
|
||||
createIDEServer,
|
||||
createLanguageClient,
|
||||
getQueryEditorCommands,
|
||||
install,
|
||||
TemplatePrintAstProvider,
|
||||
@@ -84,7 +84,7 @@ import {
|
||||
import type { ProgressReporter } from "./common/logging/vscode";
|
||||
import {
|
||||
extLogger,
|
||||
ideServerLogger,
|
||||
languageServerLogger,
|
||||
queryServerLogger,
|
||||
} from "./common/logging/vscode";
|
||||
import { QueryHistoryManager } from "./query-history/query-history-manager";
|
||||
@@ -171,7 +171,7 @@ function getCommands(
|
||||
app: App,
|
||||
cliServer: CodeQLCliServer,
|
||||
queryRunner: QueryRunner,
|
||||
ideServer: LanguageClient,
|
||||
languageClient: LanguageClient,
|
||||
): BaseCommands {
|
||||
const getCliVersion = async () => {
|
||||
try {
|
||||
@@ -189,10 +189,10 @@ function getCommands(
|
||||
await Promise.all([
|
||||
queryRunner.restartQueryServer(progress, token),
|
||||
async () => {
|
||||
if (ideServer.isRunning()) {
|
||||
await ideServer.restart();
|
||||
if (languageClient.isRunning()) {
|
||||
await languageClient.restart();
|
||||
} else {
|
||||
await ideServer.start();
|
||||
await languageClient.start();
|
||||
}
|
||||
},
|
||||
]);
|
||||
@@ -942,7 +942,7 @@ async function activateWithInstalledDistribution(
|
||||
ctx.subscriptions.push(tmpDirDisposal);
|
||||
|
||||
void extLogger.log("Initializing CodeQL language server.");
|
||||
const ideServer = createIDEServer(qlConfigurationListener);
|
||||
const languageClient = createLanguageClient(qlConfigurationListener);
|
||||
|
||||
const localQueries = new LocalQueries(
|
||||
app,
|
||||
@@ -1008,7 +1008,7 @@ async function activateWithInstalledDistribution(
|
||||
void extLogger.log("Registering top-level command palette commands.");
|
||||
|
||||
const allCommands: AllExtensionCommands = {
|
||||
...getCommands(app, cliServer, qs, ideServer),
|
||||
...getCommands(app, cliServer, qs, languageClient),
|
||||
...getQueryEditorCommands({
|
||||
commandManager: app.commands,
|
||||
queryRunner: qs,
|
||||
@@ -1055,21 +1055,21 @@ async function activateWithInstalledDistribution(
|
||||
}
|
||||
|
||||
void extLogger.log("Starting language server.");
|
||||
await ideServer.start();
|
||||
await languageClient.start();
|
||||
ctx.subscriptions.push({
|
||||
dispose: () => {
|
||||
void ideServer.stop();
|
||||
void languageClient.stop();
|
||||
},
|
||||
});
|
||||
|
||||
// Handle visibility changes in the ideserver
|
||||
// Handle visibility changes in the CodeQL language client.
|
||||
if (await cliServer.cliConstraints.supportsVisibilityNotifications()) {
|
||||
Window.onDidChangeVisibleTextEditors((editors) => {
|
||||
ideServer.notifyVisibilityChange(editors);
|
||||
languageClient.notifyVisibilityChange(editors);
|
||||
});
|
||||
// Send an inital notification to the language server
|
||||
// to set the initial state of the visible editors.
|
||||
ideServer.notifyVisibilityChange(Window.visibleTextEditors);
|
||||
languageClient.notifyVisibilityChange(Window.visibleTextEditors);
|
||||
}
|
||||
|
||||
// Jump-to-definition and find-references
|
||||
@@ -1251,7 +1251,7 @@ function getContextStoragePath(ctx: ExtensionContext) {
|
||||
async function initializeLogging(ctx: ExtensionContext): Promise<void> {
|
||||
ctx.subscriptions.push(extLogger);
|
||||
ctx.subscriptions.push(queryServerLogger);
|
||||
ctx.subscriptions.push(ideServerLogger);
|
||||
ctx.subscriptions.push(languageServerLogger);
|
||||
}
|
||||
|
||||
const checkForUpdatesCommand: keyof PreActivationCommands =
|
||||
|
||||
@@ -2,32 +2,32 @@ import type { TextEditor } from "vscode";
|
||||
import { ProgressLocation, window } from "vscode";
|
||||
import type { StreamInfo } from "vscode-languageclient/node";
|
||||
import { LanguageClient, NotificationType } from "vscode-languageclient/node";
|
||||
import { shouldDebugIdeServer, spawnServer } from "../codeql-cli/cli";
|
||||
import { shouldDebugLanguageServer, spawnServer } from "../codeql-cli/cli";
|
||||
import type { QueryServerConfig } from "../config";
|
||||
import { ideServerLogger } from "../common/logging/vscode";
|
||||
import { languageServerLogger } from "../common/logging/vscode";
|
||||
|
||||
/**
|
||||
* Managing the language server for CodeQL.
|
||||
* Managing the language client and corresponding server process for CodeQL.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Create a new CodeQL language server.
|
||||
* Create a new CodeQL language client connected to a language server.
|
||||
*/
|
||||
export function createIDEServer(
|
||||
export function createLanguageClient(
|
||||
config: QueryServerConfig,
|
||||
): CodeQLLanguageClient {
|
||||
return new CodeQLLanguageClient(config);
|
||||
}
|
||||
|
||||
/**
|
||||
* CodeQL language server.
|
||||
* CodeQL language client.
|
||||
*/
|
||||
export class CodeQLLanguageClient extends LanguageClient {
|
||||
constructor(config: QueryServerConfig) {
|
||||
super(
|
||||
"codeQL.lsp",
|
||||
"CodeQL Language Server",
|
||||
() => spawnIdeServer(config),
|
||||
() => spawnLanguageServer(config),
|
||||
{
|
||||
documentSelector: [
|
||||
{ language: "ql", scheme: "file" },
|
||||
@@ -38,7 +38,7 @@ export class CodeQLLanguageClient extends LanguageClient {
|
||||
configurationSection: "codeQL",
|
||||
},
|
||||
// Ensure that language server exceptions are logged to the same channel as its output.
|
||||
outputChannel: ideServerLogger.outputChannel,
|
||||
outputChannel: languageServerLogger.outputChannel,
|
||||
},
|
||||
true,
|
||||
);
|
||||
@@ -55,12 +55,14 @@ export class CodeQLLanguageClient extends LanguageClient {
|
||||
}
|
||||
|
||||
/** Starts a new CodeQL language server process, sending progress messages to the status bar. */
|
||||
async function spawnIdeServer(config: QueryServerConfig): Promise<StreamInfo> {
|
||||
async function spawnLanguageServer(
|
||||
config: QueryServerConfig,
|
||||
): Promise<StreamInfo> {
|
||||
return window.withProgress(
|
||||
{ title: "CodeQL language server", location: ProgressLocation.Window },
|
||||
async (progressReporter, _) => {
|
||||
const args = ["--check-errors", "ON_CHANGE"];
|
||||
if (shouldDebugIdeServer()) {
|
||||
if (shouldDebugLanguageServer()) {
|
||||
args.push(
|
||||
"-J=-agentlib:jdwp=transport=dt_socket,address=localhost:9009,server=y,suspend=n,quiet=y",
|
||||
);
|
||||
@@ -70,11 +72,11 @@ async function spawnIdeServer(config: QueryServerConfig): Promise<StreamInfo> {
|
||||
"CodeQL language server",
|
||||
["execute", "language-server"],
|
||||
args,
|
||||
ideServerLogger,
|
||||
languageServerLogger,
|
||||
(data) =>
|
||||
ideServerLogger.log(data.toString(), { trailingNewline: false }),
|
||||
languageServerLogger.log(data.toString(), { trailingNewline: false }),
|
||||
(data) =>
|
||||
ideServerLogger.log(data.toString(), { trailingNewline: false }),
|
||||
languageServerLogger.log(data.toString(), { trailingNewline: false }),
|
||||
progressReporter,
|
||||
);
|
||||
return { writer: child.stdin!, reader: child.stdout! };
|
||||
|
||||
Reference in New Issue
Block a user