vscode-languageclient#Trace TypeScript Examples
The following examples show how to use
vscode-languageclient#Trace.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: languageServerClient.ts From vscode-stripe with MIT License | 4 votes |
static async activateDotNetServer(
context: ExtensionContext,
outputChannel: OutputChannel,
projectFile: string,
telemetry: Telemetry,
) {
outputChannel.appendLine('Detected C# Project file: ' + projectFile);
// Applie Silicon is not supported for dotnet < 6.0:
// https://github.com/dotnet/core/issues/4879#issuecomment-729046912
if (getOSType() === OSType.macOSarm) {
outputChannel.appendLine(
`.NET runtime v${REQUIRED_DOTNET_RUNTIME_VERSION} is not supported for M1`,
);
telemetry.sendEvent('dotnetRuntimeAcquisitionSkippedForM1');
return;
}
const result = await commands.executeCommand<{dotnetPath: string}>('dotnet.acquire', {
version: REQUIRED_DOTNET_RUNTIME_VERSION,
requestingExtensionId: 'stripe.vscode-stripe',
});
if (!result) {
outputChannel.appendLine(
`Failed to install .NET runtime v${REQUIRED_DOTNET_RUNTIME_VERSION}. Unable to start language server`,
);
telemetry.sendEvent('dotnetRuntimeAcquisitionFailed');
return;
}
const dotNetExecutable = path.resolve(result.dotnetPath);
outputChannel.appendLine('dotnet runtime acquired: ' + dotNetExecutable);
const serverAssembly = context.asAbsolutePath(
'dist/stripeDotnetLanguageServer/stripe.LanguageServer.dll',
);
const serverOptions: ServerOptions = {
command: dotNetExecutable,
args: [serverAssembly, projectFile],
};
// Options to control the language client
const clientOptions: LanguageClientOptions = {
// Register the server for plain text documents
documentSelector: [{scheme: 'file', language: 'csharp'}],
synchronize: {
configurationSection: 'stripeCsharpLangaugeServer',
fileEvents: workspace.createFileSystemWatcher('**/*.cs'),
},
diagnosticCollectionName: 'Stripe C# language server',
errorHandler: {
error: (error, message, count) => {
console.log(message);
console.log(error);
return ErrorAction.Continue;
},
closed: () => CloseAction.DoNotRestart,
},
};
// Create the language client and start the client.
// We are overriding the show notification for the dotnet client.
const dotnetClient = new (class extends LanguageClient {
error(message: string, data: any, showNotification: boolean) {
super.error(message, data, false);
}
})('stripeCsharpLanguageServer', 'Stripe C# Server', serverOptions, clientOptions);
dotnetClient.trace = Trace.Verbose;
outputChannel.appendLine('Starting C# language service for ' + projectFile);
const disposable = dotnetClient.start();
// Push the disposable to the context's subscriptions so that the
// client can be deactivated on extension deactivation
context.subscriptions.push(disposable);
await dotnetClient.onReady();
outputChannel.appendLine('C# language service is running.');
telemetry.sendEvent('dotnetServerStarted');
}