Skip to content
Merged
Changes from all 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
78 changes: 78 additions & 0 deletions packages/client/src/monaco-language-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,33 @@ import { IConnectionProvider } from './connection';
export * from 'vscode-languageclient/lib/common/client';
import type * as vscode from 'vscode'
import { MonacoC2PConverter, MonacoP2CConverter } from "./converters";
import { ConfigurationFeature, SyncConfigurationFeature } from "vscode-languageclient/lib/common/configuration";
import { DidChangeTextDocumentFeature, DidCloseTextDocumentFeature, DidOpenTextDocumentFeature, DidSaveTextDocumentFeature, WillSaveFeature, WillSaveWaitUntilFeature } from "vscode-languageclient/lib/common/textSynchronization";
import { CompletionItemFeature } from "vscode-languageclient/lib/common/completion";
import { HoverFeature } from "vscode-languageclient/lib/common/hover";
import { SignatureHelpFeature } from "vscode-languageclient/lib/common/signatureHelp";
import { DefinitionFeature } from "vscode-languageclient/lib/common/definition";
import { ReferencesFeature } from "vscode-languageclient/lib/common/reference";
import { DocumentHighlightFeature } from "vscode-languageclient/lib/common/documentHighlight";
import { DocumentSymbolFeature } from "vscode-languageclient/lib/common/documentSymbol";
import { CodeActionFeature } from "vscode-languageclient/lib/common/codeAction";
import { CodeLensFeature } from "vscode-languageclient/lib/common/codeLens";
import { DocumentFormattingFeature, DocumentOnTypeFormattingFeature, DocumentRangeFormattingFeature } from "vscode-languageclient/lib/common/formatting";
import { RenameFeature } from "vscode-languageclient/lib/common/rename";
import { DocumentLinkFeature } from "vscode-languageclient/lib/common/documentLink";
import { ExecuteCommandFeature } from "vscode-languageclient/lib/common/executeCommand";
import { TypeDefinitionFeature } from "vscode-languageclient/lib/common/typeDefinition";
import { ImplementationFeature } from "vscode-languageclient/lib/common/implementation";
import { ColorProviderFeature } from "vscode-languageclient/lib/common/colorProvider";
import { WorkspaceFoldersFeature } from "vscode-languageclient/lib/common/workspaceFolder";
import { FoldingRangeFeature } from "vscode-languageclient/lib/common/foldingRange";
import { DeclarationFeature } from "vscode-languageclient/lib/common/declaration";
import { SelectionRangeFeature } from "vscode-languageclient/lib/common/selectionRange";
import { SemanticTokensFeature } from "vscode-languageclient/lib/common/semanticTokens";
import { LinkedEditingFeature } from "vscode-languageclient/lib/common/linkedEditingRange";
import { InlayHintsFeature } from "vscode-languageclient/lib/common/inlayHint";
import { DiagnosticFeature } from "vscode-languageclient/lib/common/diagnostic";
import { ProgressFeature } from "vscode-languageclient/lib/common/progress";

export class MonacoLanguageClient extends BaseLanguageClient {

Expand Down Expand Up @@ -39,6 +66,57 @@ export class MonacoLanguageClient extends BaseLanguageClient {
protected getLocale(): string {
return navigator.language || 'en-US'
}

protected override registerBuiltinFeatures() {
this.registerFeature(new DidOpenTextDocumentFeature(this, this['_syncedDocuments']));
this.registerFeature(new DidChangeTextDocumentFeature(this));
this.registerFeature(new DidCloseTextDocumentFeature(this, this['_syncedDocuments']));
this.registerFeature(new CompletionItemFeature(this));
this.registerFeature(new HoverFeature(this));
this.registerFeature(new SignatureHelpFeature(this));
this.registerFeature(new DefinitionFeature(this));
this.registerFeature(new ReferencesFeature(this));
this.registerFeature(new DocumentHighlightFeature(this));
this.registerFeature(new DocumentSymbolFeature(this));
this.registerFeature(new CodeActionFeature(this));
this.registerFeature(new CodeLensFeature(this));
this.registerFeature(new DocumentFormattingFeature(this));
this.registerFeature(new DocumentRangeFormattingFeature(this));
this.registerFeature(new DocumentOnTypeFormattingFeature(this));
this.registerFeature(new RenameFeature(this));
this.registerFeature(new DocumentLinkFeature(this));
this.registerFeature(new ExecuteCommandFeature(this));
this.registerFeature(new TypeDefinitionFeature(this));
this.registerFeature(new ImplementationFeature(this));
this.registerFeature(new ColorProviderFeature(this));
// We only register the workspace folder feature if the client is not locked
// to a specific workspace folder.
if (this.clientOptions.workspaceFolder === undefined) {
this.registerFeature(new WorkspaceFoldersFeature(this));
}
this.registerFeature(new FoldingRangeFeature(this));
this.registerFeature(new DeclarationFeature(this));
this.registerFeature(new SelectionRangeFeature(this));
this.registerFeature(new SemanticTokensFeature(this));
this.registerFeature(new LinkedEditingFeature(this));
this.registerFeature(new InlayHintsFeature(this));
this.registerFeature(new DiagnosticFeature(this));
}

public registerTextDocumentSaveFeatures() {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Who is responsible for calling three methods (registerTextDocumentSaveFeatures, registerConfigurationFeatures, registerProgressFeatures)?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The user who is using the MonacoLanguageClient, aka,

const languageClient = new MonacoLanguageClient(...)
languageClient.registerTextDocumentSaveFeatures()

Since these feature are builtin in vscode but NOT builtin in monaco (they require some additional code), I don't thing they belong in the registerBuiltinFeatures method

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, thank you.

this.registerFeature(new WillSaveFeature(this));
this.registerFeature(new WillSaveWaitUntilFeature(this));
this.registerFeature(new DidSaveTextDocumentFeature(this));
}

public registerConfigurationFeatures() {
this.registerFeature(new ConfigurationFeature(this));
this.registerFeature(new SyncConfigurationFeature(this));
}

public registerProgressFeatures() {
this.registerFeature(new ProgressFeature(this));
}
}
export namespace MonacoLanguageClient {
export interface Options {
Expand Down