Skip to content

Commit e101d6d

Browse files
committed
refactor: disable language server code actions and command execution
1 parent 1e08c1c commit e101d6d

File tree

2 files changed

+64
-64
lines changed

2 files changed

+64
-64
lines changed

packages/client/src/extension.ts

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616

1717
export function activate(context: ExtensionContext): void {
1818
const serverModule = context.asAbsolutePath(
19-
path.join('dist', 'packages', 'server', 'server.js')
19+
path.join('dist', 'packages', 'server', 'src', 'sampleServer.js')
2020
);
2121
const serverOptions: ServerOptions = {
2222
run: {
@@ -32,24 +32,10 @@ export function activate(context: ExtensionContext): void {
3232
};
3333

3434
const clientOptions: LanguageClientOptions = {
35-
documentSelector: [{ scheme: 'file', language: 'plaintext' }],
35+
documentSelector: [{ scheme: 'file', language: 'ccini' }],
3636
diagnosticCollectionName: 'sample',
3737
revealOutputChannelOn: RevealOutputChannelOn.Never,
3838
progressOnInitialization: true,
39-
middleware: {
40-
executeCommand: async (command, args, next) => {
41-
const selected = await Window.showQuickPick([
42-
'Visual Studio',
43-
'Visual Studio Code',
44-
]);
45-
if (selected === undefined) {
46-
return next(command, args);
47-
}
48-
args = args.slice(0);
49-
args.push(selected);
50-
return next(command, args);
51-
},
52-
},
5339
};
5440

5541
let client: LanguageClient;

packages/server/src/sampleServer.ts

Lines changed: 62 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,18 @@
55
'use strict';
66

77
import {
8-
CodeAction, CodeActionKind, Command, createConnection, Diagnostic, DiagnosticSeverity, Position, Range, TextDocumentEdit,
9-
TextDocuments, TextDocumentSyncKind, TextEdit
8+
CodeAction,
9+
CodeActionKind,
10+
Command,
11+
createConnection,
12+
Diagnostic,
13+
DiagnosticSeverity,
14+
Position,
15+
Range,
16+
TextDocumentEdit,
17+
TextDocuments,
18+
TextDocumentSyncKind,
19+
TextEdit,
1020
} from 'vscode-languageserver/node';
1121
import { TextDocument } from 'vscode-languageserver-textdocument';
1222

@@ -17,64 +27,68 @@ const documents: TextDocuments<TextDocument> = new TextDocuments(TextDocument);
1727
documents.listen(connection);
1828

1929
connection.onInitialize(() => {
20-
return {
21-
capabilities: {
22-
codeActionProvider: true,
23-
textDocumentSync: {
24-
openClose: true,
25-
change: TextDocumentSyncKind.Incremental
26-
},
27-
executeCommandProvider: {
28-
commands: ['sample.fixMe']
29-
}
30-
}
31-
};
30+
return {
31+
capabilities: {
32+
codeActionProvider: true,
33+
textDocumentSync: {
34+
openClose: true,
35+
change: TextDocumentSyncKind.Incremental,
36+
},
37+
executeCommandProvider: {
38+
commands: ['sample.fixMe'],
39+
},
40+
},
41+
};
3242
});
3343

3444
function validate(document: TextDocument): void {
35-
connection.sendDiagnostics({
36-
uri: document.uri,
37-
version: document.version,
38-
diagnostics: [
39-
Diagnostic.create(Range.create(0,0,0, 10), 'Something is wrong here', DiagnosticSeverity.Warning)
40-
]
41-
});
45+
connection.sendDiagnostics({
46+
uri: document.uri,
47+
version: document.version,
48+
diagnostics: [
49+
Diagnostic.create(
50+
Range.create(0, 0, 0, 10),
51+
'Something is wrong here',
52+
DiagnosticSeverity.Warning
53+
),
54+
],
55+
});
4256
}
4357

4458
documents.onDidOpen((event) => {
45-
validate(event.document);
59+
validate(event.document);
4660
});
4761

4862
documents.onDidChangeContent((event) => {
49-
validate(event.document);
63+
validate(event.document);
5064
});
5165

52-
connection.onCodeAction((params) => {
53-
const textDocument = documents.get(params.textDocument.uri);
54-
if (textDocument === undefined) {
55-
return undefined;
56-
}
57-
const title = 'With User Input';
58-
return [CodeAction.create(title, Command.create(title, 'sample.fixMe', textDocument.uri), CodeActionKind.QuickFix)];
59-
});
66+
// connection.onCodeAction((params) => {
67+
// const textDocument = documents.get(params.textDocument.uri);
68+
// if (textDocument === undefined) {
69+
// return undefined;
70+
// }
71+
// const title = 'With User Input';
72+
// return [CodeAction.create(title, Command.create(title, 'sample.fixMe', textDocument.uri), CodeActionKind.QuickFix)];
73+
// });
6074

61-
connection.onExecuteCommand(async (params) => {
62-
if (params.command !== 'sample.fixMe' || params.arguments === undefined) {
63-
return;
64-
}
75+
// connection.onExecuteCommand(async (params) => {
76+
// if (params.command !== 'sample.fixMe' || params.arguments === undefined) {
77+
// return;
78+
// }
6579

66-
const textDocument = documents.get(params.arguments[0]);
67-
if (textDocument === undefined) {
68-
return;
69-
}
70-
const newText = typeof params.arguments[1] === 'string' ? params.arguments[1] : 'Eclipse';
71-
connection.workspace.applyEdit({
72-
documentChanges: [
73-
TextDocumentEdit.create({ uri: textDocument.uri, version: textDocument.version }, [
74-
TextEdit.insert(Position.create(0, 0), newText)
75-
])
76-
]
77-
});
78-
});
80+
// const textDocument = documents.get(params.arguments[0]);
81+
// if (textDocument === undefined) {
82+
// return;
83+
// }
84+
// const newText = typeof params.arguments[1] === 'string' ? params.arguments[1] : 'Eclipse';
85+
// connection.workspace.applyEdit({
86+
// documentChanges: [
87+
// TextDocumentEdit.create({ uri: textDocument.uri, version: textDocument.version }, [
88+
// TextEdit.insert(Position.create(0, 0), newText)
89+
// ])
90+
// ]
91+
// });
92+
// });
7993

8094
connection.listen();

0 commit comments

Comments
 (0)