@theia/plugin-ext 1.33.0-next.8 → 1.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/common/plugin-api-rpc-model.d.ts +78 -0
- package/lib/common/plugin-api-rpc-model.d.ts.map +1 -1
- package/lib/common/plugin-api-rpc-model.js +17 -1
- package/lib/common/plugin-api-rpc-model.js.map +1 -1
- package/lib/common/plugin-api-rpc.d.ts +11 -1
- package/lib/common/plugin-api-rpc.d.ts.map +1 -1
- package/lib/common/plugin-api-rpc.js.map +1 -1
- package/lib/common/reference-map.d.ts +8 -0
- package/lib/common/reference-map.d.ts.map +1 -0
- package/lib/common/reference-map.js +40 -0
- package/lib/common/reference-map.js.map +1 -0
- package/lib/main/browser/custom-editors/custom-editors-main.d.ts.map +1 -1
- package/lib/main/browser/custom-editors/custom-editors-main.js +2 -2
- package/lib/main/browser/custom-editors/custom-editors-main.js.map +1 -1
- package/lib/main/browser/file-system-main-impl.d.ts +1 -0
- package/lib/main/browser/file-system-main-impl.d.ts.map +1 -1
- package/lib/main/browser/file-system-main-impl.js +9 -2
- package/lib/main/browser/file-system-main-impl.js.map +1 -1
- package/lib/main/browser/languages-main.d.ts +1 -0
- package/lib/main/browser/languages-main.d.ts.map +1 -1
- package/lib/main/browser/languages-main.js +10 -0
- package/lib/main/browser/languages-main.js.map +1 -1
- package/lib/main/browser/terminal-main.d.ts +1 -1
- package/lib/main/browser/terminal-main.d.ts.map +1 -1
- package/lib/main/browser/terminal-main.js +2 -2
- package/lib/main/browser/terminal-main.js.map +1 -1
- package/lib/main/browser/webview/webview.d.ts +1 -0
- package/lib/main/browser/webview/webview.d.ts.map +1 -1
- package/lib/main/browser/webview/webview.js.map +1 -1
- package/lib/main/browser/webviews-main.d.ts.map +1 -1
- package/lib/main/browser/webviews-main.js +6 -6
- package/lib/main/browser/webviews-main.js.map +1 -1
- package/lib/plugin/file-system-ext-impl.d.ts +2 -0
- package/lib/plugin/file-system-ext-impl.d.ts.map +1 -1
- package/lib/plugin/file-system-ext-impl.js +22 -5
- package/lib/plugin/file-system-ext-impl.js.map +1 -1
- package/lib/plugin/languages/inline-completion.d.ts +21 -0
- package/lib/plugin/languages/inline-completion.d.ts.map +1 -0
- package/lib/plugin/languages/inline-completion.js +94 -0
- package/lib/plugin/languages/inline-completion.js.map +1 -0
- package/lib/plugin/languages.d.ts +5 -2
- package/lib/plugin/languages.d.ts.map +1 -1
- package/lib/plugin/languages.js +16 -1
- package/lib/plugin/languages.js.map +1 -1
- package/lib/plugin/plugin-context.d.ts.map +1 -1
- package/lib/plugin/plugin-context.js +107 -3
- package/lib/plugin/plugin-context.js.map +1 -1
- package/lib/plugin/theming.d.ts.map +1 -1
- package/lib/plugin/theming.js +3 -0
- package/lib/plugin/theming.js.map +1 -1
- package/lib/plugin/types-impl.d.ts +145 -1
- package/lib/plugin/types-impl.d.ts.map +1 -1
- package/lib/plugin/types-impl.js +200 -6
- package/lib/plugin/types-impl.js.map +1 -1
- package/package.json +26 -26
- package/src/common/plugin-api-rpc-model.ts +96 -0
- package/src/common/plugin-api-rpc.ts +16 -1
- package/src/common/reference-map.ts +38 -0
- package/src/main/browser/custom-editors/custom-editors-main.ts +2 -1
- package/src/main/browser/file-system-main-impl.ts +12 -3
- package/src/main/browser/languages-main.ts +18 -1
- package/src/main/browser/terminal-main.ts +2 -2
- package/src/main/browser/webview/pre/main.js +8 -1
- package/src/main/browser/webview/webview.ts +1 -0
- package/src/main/browser/webviews-main.ts +6 -3
- package/src/plugin/file-system-ext-impl.ts +21 -5
- package/src/plugin/languages/inline-completion.ts +126 -0
- package/src/plugin/languages.ts +30 -3
- package/src/plugin/plugin-context.ts +142 -4
- package/src/plugin/theming.ts +3 -0
- package/src/plugin/types-impl.ts +247 -1
|
@@ -34,7 +34,8 @@ import {
|
|
|
34
34
|
WorkspaceTextEditDto,
|
|
35
35
|
PluginInfo,
|
|
36
36
|
LanguageStatus as LanguageStatusDTO,
|
|
37
|
-
InlayHintDto
|
|
37
|
+
InlayHintDto,
|
|
38
|
+
IdentifiableInlineCompletions
|
|
38
39
|
} from '../../common/plugin-api-rpc';
|
|
39
40
|
import { injectable, inject } from '@theia/core/shared/inversify';
|
|
40
41
|
import {
|
|
@@ -868,6 +869,22 @@ export class LanguagesMainImpl implements LanguagesMain, Disposable {
|
|
|
868
869
|
}
|
|
869
870
|
}
|
|
870
871
|
|
|
872
|
+
$registerInlineCompletionsSupport(handle: number, selector: SerializedDocumentFilter[]): void {
|
|
873
|
+
const languageSelector = this.toLanguageSelector(selector);
|
|
874
|
+
const provider: monaco.languages.InlineCompletionsProvider<IdentifiableInlineCompletions> = {
|
|
875
|
+
provideInlineCompletions: async (
|
|
876
|
+
model: monaco.editor.ITextModel,
|
|
877
|
+
position: monaco.Position,
|
|
878
|
+
context: monaco.languages.InlineCompletionContext,
|
|
879
|
+
token: CancellationToken
|
|
880
|
+
): Promise<IdentifiableInlineCompletions | undefined> => this.proxy.$provideInlineCompletions(handle, model.uri, position, context, token),
|
|
881
|
+
freeInlineCompletions: (completions: IdentifiableInlineCompletions): void => {
|
|
882
|
+
this.proxy.$freeInlineCompletionsList(handle, completions.pid);
|
|
883
|
+
}
|
|
884
|
+
};
|
|
885
|
+
this.register(handle, (monaco.languages.registerInlineCompletionsProvider as RegistrationFunction<monaco.languages.InlineCompletionsProvider>)(languageSelector, provider));
|
|
886
|
+
}
|
|
887
|
+
|
|
871
888
|
$registerQuickFixProvider(
|
|
872
889
|
handle: number,
|
|
873
890
|
pluginInfo: PluginInfo,
|
|
@@ -260,11 +260,11 @@ export class TerminalServiceMainImpl implements TerminalServiceMain, TerminalLin
|
|
|
260
260
|
}
|
|
261
261
|
}
|
|
262
262
|
|
|
263
|
-
async provideLinks(line: string, terminal: TerminalWidget,
|
|
263
|
+
async provideLinks(line: string, terminal: TerminalWidget, cancellationToken?: CancellationToken | undefined): Promise<TerminalLink[]> {
|
|
264
264
|
if (this.terminalLinkProviders.length < 1) {
|
|
265
265
|
return [];
|
|
266
266
|
}
|
|
267
|
-
const links = await this.extProxy.$provideTerminalLinks(line, terminal.id,
|
|
267
|
+
const links = await this.extProxy.$provideTerminalLinks(line, terminal.id, cancellationToken ?? CancellationToken.None);
|
|
268
268
|
return links.map(link => ({ ...link, handle: () => this.extProxy.$handleTerminalLink(link) }));
|
|
269
269
|
}
|
|
270
270
|
|
|
@@ -479,7 +479,14 @@
|
|
|
479
479
|
const newFrame = document.createElement('iframe');
|
|
480
480
|
newFrame.setAttribute('id', 'pending-frame');
|
|
481
481
|
newFrame.setAttribute('frameborder', '0');
|
|
482
|
-
|
|
482
|
+
const sandboxOptions = ['allow-same-origin'];
|
|
483
|
+
if (options.allowScripts) {
|
|
484
|
+
sandboxOptions.push('allow-scripts', 'allow-downloads');
|
|
485
|
+
}
|
|
486
|
+
if (options.allowForms ?? options.allowScripts) {
|
|
487
|
+
sandboxOptions.push('allow-forms');
|
|
488
|
+
}
|
|
489
|
+
newFrame.setAttribute('sandbox', sandboxOptions.join(' '));
|
|
483
490
|
if (host.fakeLoad) {
|
|
484
491
|
// We should just be able to use srcdoc, but I wasn't
|
|
485
492
|
// seeing the service worker applying properly.
|
|
@@ -73,6 +73,7 @@ export const enum WebviewMessageChannels {
|
|
|
73
73
|
|
|
74
74
|
export interface WebviewContentOptions {
|
|
75
75
|
readonly allowScripts?: boolean;
|
|
76
|
+
readonly allowForms?: boolean;
|
|
76
77
|
readonly localResourceRoots?: ReadonlyArray<string>;
|
|
77
78
|
readonly portMapping?: ReadonlyArray<WebviewPortMapping>;
|
|
78
79
|
readonly enableCommandUris?: boolean;
|
|
@@ -67,10 +67,11 @@ export class WebviewsMainImpl implements WebviewsMain, Disposable {
|
|
|
67
67
|
this.hookWebview(view);
|
|
68
68
|
view.viewType = viewType;
|
|
69
69
|
view.title.label = title;
|
|
70
|
-
const { enableFindWidget, retainContextWhenHidden, enableScripts, localResourceRoots, ...contentOptions } = options;
|
|
70
|
+
const { enableFindWidget, retainContextWhenHidden, enableScripts, enableForms, localResourceRoots, ...contentOptions } = options;
|
|
71
71
|
view.options = { enableFindWidget, retainContextWhenHidden };
|
|
72
72
|
view.setContentOptions({
|
|
73
73
|
allowScripts: enableScripts,
|
|
74
|
+
allowForms: enableForms,
|
|
74
75
|
localResourceRoots: localResourceRoots && localResourceRoots.map(root => root.toString()),
|
|
75
76
|
...contentOptions
|
|
76
77
|
});
|
|
@@ -171,9 +172,10 @@ export class WebviewsMainImpl implements WebviewsMain, Disposable {
|
|
|
171
172
|
|
|
172
173
|
async $setOptions(handle: string, options: WebviewOptions): Promise<void> {
|
|
173
174
|
const webview = await this.getWebview(handle);
|
|
174
|
-
const { enableScripts, localResourceRoots, ...contentOptions } = options;
|
|
175
|
+
const { enableScripts, enableForms, localResourceRoots, ...contentOptions } = options;
|
|
175
176
|
webview.setContentOptions({
|
|
176
177
|
allowScripts: enableScripts,
|
|
178
|
+
allowForms: enableForms,
|
|
177
179
|
localResourceRoots: localResourceRoots && localResourceRoots.map(root => root.toString()),
|
|
178
180
|
...contentOptions
|
|
179
181
|
});
|
|
@@ -210,10 +212,11 @@ export class WebviewsMainImpl implements WebviewsMain, Disposable {
|
|
|
210
212
|
}
|
|
211
213
|
|
|
212
214
|
const options = widget.options;
|
|
213
|
-
const { allowScripts, localResourceRoots, ...contentOptions } = widget.contentOptions;
|
|
215
|
+
const { allowScripts, allowForms, localResourceRoots, ...contentOptions } = widget.contentOptions;
|
|
214
216
|
this.updateViewState(widget);
|
|
215
217
|
await this.proxy.$deserializeWebviewPanel(handle, widget.viewType, title, state, widget.viewState, {
|
|
216
218
|
enableScripts: allowScripts,
|
|
219
|
+
enableForms: allowForms,
|
|
217
220
|
localResourceRoots: localResourceRoots && localResourceRoots.map(root => URI.parse(root)),
|
|
218
221
|
...contentOptions,
|
|
219
222
|
...options
|
|
@@ -137,7 +137,7 @@ class FsLinkProvider {
|
|
|
137
137
|
|
|
138
138
|
class ConsumerFileSystem implements vscode.FileSystem {
|
|
139
139
|
|
|
140
|
-
constructor(private _proxy: FileSystemMain) { }
|
|
140
|
+
constructor(private _proxy: FileSystemMain, private _capabilities: Map<string, number>) { }
|
|
141
141
|
|
|
142
142
|
stat(uri: vscode.Uri): Promise<vscode.FileStat> {
|
|
143
143
|
return this._proxy.$stat(uri).catch(ConsumerFileSystem._handleError);
|
|
@@ -148,7 +148,7 @@ class ConsumerFileSystem implements vscode.FileSystem {
|
|
|
148
148
|
createDirectory(uri: vscode.Uri): Promise<void> {
|
|
149
149
|
return this._proxy.$mkdir(uri).catch(ConsumerFileSystem._handleError);
|
|
150
150
|
}
|
|
151
|
-
|
|
151
|
+
readFile(uri: vscode.Uri): Promise<Uint8Array> {
|
|
152
152
|
return this._proxy.$readFile(uri).then(buff => buff.buffer).catch(ConsumerFileSystem._handleError);
|
|
153
153
|
}
|
|
154
154
|
writeFile(uri: vscode.Uri, content: Uint8Array): Promise<void> {
|
|
@@ -163,6 +163,13 @@ class ConsumerFileSystem implements vscode.FileSystem {
|
|
|
163
163
|
copy(source: vscode.Uri, destination: vscode.Uri, options?: { overwrite?: boolean }): Promise<void> {
|
|
164
164
|
return this._proxy.$copy(source, destination, { ...{ overwrite: false }, ...options }).catch(ConsumerFileSystem._handleError);
|
|
165
165
|
}
|
|
166
|
+
isWritableFileSystem(scheme: string): boolean | undefined {
|
|
167
|
+
const capabilities = this._capabilities.get(scheme);
|
|
168
|
+
if (typeof capabilities === 'number') {
|
|
169
|
+
return (capabilities & files.FileSystemProviderCapabilities.Readonly) === 0;
|
|
170
|
+
}
|
|
171
|
+
return undefined;
|
|
172
|
+
}
|
|
166
173
|
private static _handleError(err: any): never {
|
|
167
174
|
// generic error
|
|
168
175
|
if (!(err instanceof Error)) {
|
|
@@ -193,6 +200,7 @@ export class FileSystemExtImpl implements FileSystemExt {
|
|
|
193
200
|
private readonly _proxy: FileSystemMain;
|
|
194
201
|
private readonly _linkProvider = new FsLinkProvider();
|
|
195
202
|
private readonly _fsProvider = new Map<number, vscode.FileSystemProvider>();
|
|
203
|
+
private readonly _capabilities = new Map<string, number>();
|
|
196
204
|
private readonly _usedSchemes = new Set<string>();
|
|
197
205
|
private readonly _watches = new Map<number, IDisposable>();
|
|
198
206
|
|
|
@@ -203,7 +211,7 @@ export class FileSystemExtImpl implements FileSystemExt {
|
|
|
203
211
|
|
|
204
212
|
constructor(rpc: RPCProtocol, private _extHostLanguageFeatures: LanguagesExtImpl) {
|
|
205
213
|
this._proxy = rpc.getProxy(PLUGIN_RPC_CONTEXT.FILE_SYSTEM_MAIN);
|
|
206
|
-
this.fileSystem = new ConsumerFileSystem(this._proxy);
|
|
214
|
+
this.fileSystem = new ConsumerFileSystem(this._proxy, this._capabilities);
|
|
207
215
|
|
|
208
216
|
// register used schemes
|
|
209
217
|
Object.keys(Schemas).forEach(scheme => this._usedSchemes.add(scheme));
|
|
@@ -295,8 +303,16 @@ export class FileSystemExtImpl implements FileSystemExt {
|
|
|
295
303
|
}
|
|
296
304
|
|
|
297
305
|
private static _asIStat(stat: vscode.FileStat): files.Stat {
|
|
298
|
-
const { type, ctime, mtime, size } = stat;
|
|
299
|
-
return { type, ctime, mtime, size };
|
|
306
|
+
const { type, ctime, mtime, size, permissions } = stat;
|
|
307
|
+
return { type, ctime, mtime, size, permissions };
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
$acceptProviderInfos(scheme: string, capabilities?: files.FileSystemProviderCapabilities): void {
|
|
311
|
+
if (typeof capabilities === 'number') {
|
|
312
|
+
this._capabilities.set(scheme, capabilities);
|
|
313
|
+
} else {
|
|
314
|
+
this._capabilities.delete(scheme);
|
|
315
|
+
}
|
|
300
316
|
}
|
|
301
317
|
|
|
302
318
|
$stat(handle: number, resource: UriComponents): Promise<files.Stat> {
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2022 Ericsson and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
// copied from https://github.com/microsoft/vscode/blob/6261075646f055b99068d3688932416f2346dd3b/src/vs/workbench/api/common/extHostLanguageFeatures.ts#L1069-L1185.
|
|
18
|
+
|
|
19
|
+
import * as theia from '@theia/plugin';
|
|
20
|
+
import * as Converter from '../type-converters';
|
|
21
|
+
import { DocumentsExtImpl } from '../documents';
|
|
22
|
+
import { URI } from '@theia/core/shared/vscode-uri';
|
|
23
|
+
import { CommandRegistryImpl } from '../command-registry';
|
|
24
|
+
import { ReferenceMap } from '../../common/reference-map';
|
|
25
|
+
import { DisposableCollection } from '@theia/core/lib/common/disposable';
|
|
26
|
+
import { InlineCompletionTriggerKind as TriggerKind } from '../../plugin/types-impl';
|
|
27
|
+
import { Command, InlineCompletionContext, InlineCompletionTriggerKind } from '../../common/plugin-api-rpc-model';
|
|
28
|
+
import { IdentifiableInlineCompletion, IdentifiableInlineCompletions, Position } from '../../common/plugin-api-rpc';
|
|
29
|
+
|
|
30
|
+
export class InlineCompletionAdapterBase {
|
|
31
|
+
|
|
32
|
+
async provideInlineCompletions(
|
|
33
|
+
_resource: URI,
|
|
34
|
+
_position: Position,
|
|
35
|
+
_context: InlineCompletionContext,
|
|
36
|
+
_token: theia.CancellationToken
|
|
37
|
+
): Promise<IdentifiableInlineCompletions | undefined> {
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
disposeCompletions(pid: number): void { return; };
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export class InlineCompletionAdapter extends InlineCompletionAdapterBase {
|
|
45
|
+
|
|
46
|
+
private readonly references = new ReferenceMap<{
|
|
47
|
+
dispose(): void;
|
|
48
|
+
items: readonly theia.InlineCompletionItem[];
|
|
49
|
+
}>();
|
|
50
|
+
|
|
51
|
+
constructor(
|
|
52
|
+
private readonly documents: DocumentsExtImpl,
|
|
53
|
+
private readonly provider: theia.InlineCompletionItemProvider,
|
|
54
|
+
private readonly commands: CommandRegistryImpl,
|
|
55
|
+
) {
|
|
56
|
+
super();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
private readonly languageTriggerKindToVSCodeTriggerKind: Record<InlineCompletionTriggerKind, TriggerKind> = {
|
|
60
|
+
[InlineCompletionTriggerKind.Automatic]: TriggerKind.Automatic,
|
|
61
|
+
[InlineCompletionTriggerKind.Explicit]: TriggerKind.Invoke,
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
override async provideInlineCompletions(
|
|
65
|
+
resource: URI,
|
|
66
|
+
position: Position,
|
|
67
|
+
context: InlineCompletionContext,
|
|
68
|
+
token: theia.CancellationToken
|
|
69
|
+
): Promise<IdentifiableInlineCompletions | undefined> {
|
|
70
|
+
const doc = this.documents.getDocument(resource);
|
|
71
|
+
const pos = Converter.toPosition(position);
|
|
72
|
+
|
|
73
|
+
const result = await this.provider.provideInlineCompletionItems(doc, pos, {
|
|
74
|
+
selectedCompletionInfo:
|
|
75
|
+
context.selectedSuggestionInfo
|
|
76
|
+
? {
|
|
77
|
+
range: Converter.toRange(context.selectedSuggestionInfo.range),
|
|
78
|
+
text: context.selectedSuggestionInfo.text
|
|
79
|
+
}
|
|
80
|
+
: undefined,
|
|
81
|
+
triggerKind: this.languageTriggerKindToVSCodeTriggerKind[context.triggerKind]
|
|
82
|
+
}, token);
|
|
83
|
+
|
|
84
|
+
if (!result || token.isCancellationRequested) {
|
|
85
|
+
return undefined;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const normalizedResult = Array.isArray(result) ? result : result.items;
|
|
89
|
+
|
|
90
|
+
let disposableCollection: DisposableCollection | undefined = undefined;
|
|
91
|
+
const pid = this.references.createReferenceId({
|
|
92
|
+
dispose(): void {
|
|
93
|
+
disposableCollection?.dispose();
|
|
94
|
+
},
|
|
95
|
+
items: normalizedResult
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
return {
|
|
99
|
+
pid,
|
|
100
|
+
items: normalizedResult.map<IdentifiableInlineCompletion>((item, idx) => {
|
|
101
|
+
let command: Command | undefined = undefined;
|
|
102
|
+
if (item.command) {
|
|
103
|
+
if (!disposableCollection) {
|
|
104
|
+
disposableCollection = new DisposableCollection();
|
|
105
|
+
}
|
|
106
|
+
command = this.commands.converter.toSafeCommand(item.command, disposableCollection);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const insertText = item.insertText;
|
|
110
|
+
return ({
|
|
111
|
+
insertText: typeof insertText === 'string' ? insertText : { snippet: insertText.value },
|
|
112
|
+
filterText: item.filterText,
|
|
113
|
+
range: item.range ? Converter.fromRange(item.range) : undefined,
|
|
114
|
+
command,
|
|
115
|
+
idx: idx
|
|
116
|
+
});
|
|
117
|
+
})
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
override disposeCompletions(pid: number): void {
|
|
122
|
+
const data = this.references.disposeReferenceId(pid);
|
|
123
|
+
data?.dispose();
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
}
|
package/src/plugin/languages.ts
CHANGED
|
@@ -27,6 +27,7 @@ import {
|
|
|
27
27
|
Plugin,
|
|
28
28
|
InlayHintsDto,
|
|
29
29
|
InlayHintDto,
|
|
30
|
+
IdentifiableInlineCompletions,
|
|
30
31
|
} from '../common/plugin-api-rpc';
|
|
31
32
|
import { RPCProtocol } from '../common/rpc-protocol';
|
|
32
33
|
import * as theia from '@theia/plugin';
|
|
@@ -67,7 +68,8 @@ import {
|
|
|
67
68
|
EvaluatableExpression,
|
|
68
69
|
InlineValue,
|
|
69
70
|
InlineValueContext,
|
|
70
|
-
TypeHierarchyItem
|
|
71
|
+
TypeHierarchyItem,
|
|
72
|
+
InlineCompletionContext
|
|
71
73
|
} from '../common/plugin-api-rpc-model';
|
|
72
74
|
import { CompletionAdapter } from './languages/completion';
|
|
73
75
|
import { Diagnostics } from './languages/diagnostics';
|
|
@@ -106,6 +108,7 @@ import { Severity } from '@theia/core/lib/common/severity';
|
|
|
106
108
|
import { LinkedEditingRangeAdapter } from './languages/linked-editing-range';
|
|
107
109
|
import { serializeEnterRules, serializeIndentation, serializeRegExp } from './languages-utils';
|
|
108
110
|
import { InlayHintsAdapter } from './languages/inlay-hints';
|
|
111
|
+
import { InlineCompletionAdapter, InlineCompletionAdapterBase } from './languages/inline-completion';
|
|
109
112
|
|
|
110
113
|
type Adapter = CompletionAdapter |
|
|
111
114
|
SignatureHelpAdapter |
|
|
@@ -135,7 +138,8 @@ type Adapter = CompletionAdapter |
|
|
|
135
138
|
DocumentRangeSemanticTokensAdapter |
|
|
136
139
|
DocumentSemanticTokensAdapter |
|
|
137
140
|
LinkedEditingRangeAdapter |
|
|
138
|
-
TypeHierarchyAdapter
|
|
141
|
+
TypeHierarchyAdapter |
|
|
142
|
+
InlineCompletionAdapter;
|
|
139
143
|
|
|
140
144
|
export class LanguagesExtImpl implements LanguagesExt {
|
|
141
145
|
|
|
@@ -246,7 +250,8 @@ export class LanguagesExtImpl implements LanguagesExt {
|
|
|
246
250
|
$serialized: true,
|
|
247
251
|
language: selector.language,
|
|
248
252
|
scheme: selector.scheme,
|
|
249
|
-
pattern: selector.pattern
|
|
253
|
+
pattern: selector.pattern,
|
|
254
|
+
notebookType: selector.notebookType
|
|
250
255
|
};
|
|
251
256
|
}
|
|
252
257
|
|
|
@@ -275,6 +280,28 @@ export class LanguagesExtImpl implements LanguagesExt {
|
|
|
275
280
|
}
|
|
276
281
|
// ### Completion end
|
|
277
282
|
|
|
283
|
+
// ### Inline completion provider begin
|
|
284
|
+
registerInlineCompletionsProvider(selector: theia.DocumentSelector, provider: theia.InlineCompletionItemProvider): theia.Disposable {
|
|
285
|
+
const callId = this.addNewAdapter(new InlineCompletionAdapter(this.documents, provider, this.commands));
|
|
286
|
+
this.proxy.$registerInlineCompletionsSupport(callId, this.transformDocumentSelector(selector));
|
|
287
|
+
return this.createDisposable(callId);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
$provideInlineCompletions(
|
|
291
|
+
handle: number,
|
|
292
|
+
resource: UriComponents,
|
|
293
|
+
position: Position,
|
|
294
|
+
context: InlineCompletionContext,
|
|
295
|
+
token: theia.CancellationToken
|
|
296
|
+
): Promise<IdentifiableInlineCompletions | undefined> {
|
|
297
|
+
return this.withAdapter(handle, InlineCompletionAdapterBase, adapter => adapter.provideInlineCompletions(URI.revive(resource), position, context, token), undefined);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
$freeInlineCompletionsList(handle: number, pid: number): void {
|
|
301
|
+
this.withAdapter(handle, InlineCompletionAdapterBase, async adapter => { adapter.disposeCompletions(pid); }, undefined);
|
|
302
|
+
}
|
|
303
|
+
// ### Inline completion provider end
|
|
304
|
+
|
|
278
305
|
// ### Definition provider begin
|
|
279
306
|
$provideDefinition(handle: number, resource: UriComponents, position: Position, token: theia.CancellationToken): Promise<Definition | undefined> {
|
|
280
307
|
return this.withAdapter(handle, DefinitionAdapter, adapter => adapter.provideDefinition(URI.revive(resource), position, token), undefined);
|
|
@@ -155,11 +155,27 @@ import {
|
|
|
155
155
|
InlayHint,
|
|
156
156
|
InlayHintKind,
|
|
157
157
|
InlayHintLabelPart,
|
|
158
|
+
NotebookCell,
|
|
159
|
+
NotebookCellKind,
|
|
160
|
+
NotebookCellStatusBarAlignment,
|
|
161
|
+
NotebookEditorRevealType,
|
|
162
|
+
NotebookControllerAffinity,
|
|
163
|
+
NotebookCellData,
|
|
164
|
+
NotebookCellOutput,
|
|
165
|
+
NotebookCellOutputItem,
|
|
166
|
+
NotebookData,
|
|
167
|
+
NotebookDocument,
|
|
168
|
+
NotebookRange,
|
|
169
|
+
NotebookCellStatusBarItem,
|
|
170
|
+
NotebookEdit,
|
|
158
171
|
TestRunProfileKind,
|
|
159
172
|
TestTag,
|
|
160
173
|
TestRunRequest,
|
|
161
174
|
TestMessage,
|
|
162
|
-
ExtensionKind
|
|
175
|
+
ExtensionKind,
|
|
176
|
+
InlineCompletionItem,
|
|
177
|
+
InlineCompletionList,
|
|
178
|
+
InlineCompletionTriggerKind
|
|
163
179
|
} from './types-impl';
|
|
164
180
|
import { AuthenticationExtImpl } from './authentication-ext';
|
|
165
181
|
import { SymbolKind } from '../common/plugin-api-rpc-model';
|
|
@@ -201,6 +217,7 @@ import { CustomEditorsExtImpl } from './custom-editors';
|
|
|
201
217
|
import { WebviewViewsExtImpl } from './webview-views';
|
|
202
218
|
import { PluginPackage } from '../common';
|
|
203
219
|
import { Endpoint } from '@theia/core/lib/browser/endpoint';
|
|
220
|
+
import { FilePermission } from '@theia/filesystem/lib/common/files';
|
|
204
221
|
|
|
205
222
|
export function createAPIFactory(
|
|
206
223
|
rpc: RPCProtocol,
|
|
@@ -381,6 +398,26 @@ export function createAPIFactory(
|
|
|
381
398
|
throw new Error(`Failed to show text document ${documentArg.toString()}`);
|
|
382
399
|
}
|
|
383
400
|
},
|
|
401
|
+
get visibleNotebookEditors(): theia.NotebookEditor[] {
|
|
402
|
+
return [] as theia.NotebookEditor[];
|
|
403
|
+
},
|
|
404
|
+
onDidChangeVisibleNotebookEditors(listener, thisArg?, disposables?) {
|
|
405
|
+
return Disposable.NULL;
|
|
406
|
+
},
|
|
407
|
+
get activeNotebookEditor(): theia.NotebookEditor | undefined {
|
|
408
|
+
return undefined;
|
|
409
|
+
}, onDidChangeActiveNotebookEditor(listener, thisArg?, disposables?) {
|
|
410
|
+
return Disposable.NULL;
|
|
411
|
+
},
|
|
412
|
+
onDidChangeNotebookEditorSelection(listener, thisArg?, disposables?) {
|
|
413
|
+
return Disposable.NULL;
|
|
414
|
+
},
|
|
415
|
+
onDidChangeNotebookEditorVisibleRanges(listener, thisArg?, disposables?) {
|
|
416
|
+
return Disposable.NULL;
|
|
417
|
+
},
|
|
418
|
+
showNotebookDocument(document: NotebookDocument, options?: theia.NotebookDocumentShowOptions) {
|
|
419
|
+
return Promise.resolve({} as theia.NotebookEditor);
|
|
420
|
+
},
|
|
384
421
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
385
422
|
showQuickPick(items: any, options?: theia.QuickPickOptions, token?: theia.CancellationToken): any {
|
|
386
423
|
return quickOpenExt.showQuickPick(items, options, token);
|
|
@@ -528,6 +565,9 @@ export function createAPIFactory(
|
|
|
528
565
|
onDidChangeWorkspaceFolders(listener, thisArg?, disposables?): theia.Disposable {
|
|
529
566
|
return workspaceExt.onDidChangeWorkspaceFolders(listener, thisArg, disposables);
|
|
530
567
|
},
|
|
568
|
+
get notebookDocuments(): theia.NotebookDocument[] {
|
|
569
|
+
return [] as theia.NotebookDocument[];
|
|
570
|
+
},
|
|
531
571
|
get textDocuments(): theia.TextDocument[] {
|
|
532
572
|
return documents.getAllDocumentData().map(data => data.document);
|
|
533
573
|
},
|
|
@@ -537,6 +577,18 @@ export function createAPIFactory(
|
|
|
537
577
|
onDidCloseTextDocument(listener, thisArg?, disposables?) {
|
|
538
578
|
return documents.onDidRemoveDocument(listener, thisArg, disposables);
|
|
539
579
|
},
|
|
580
|
+
onDidOpenNotebookDocument(listener, thisArg?, disposables?) {
|
|
581
|
+
return Disposable.NULL;
|
|
582
|
+
},
|
|
583
|
+
onDidCloseNotebookDocument(listener, thisArg?, disposables?) {
|
|
584
|
+
return Disposable.NULL;
|
|
585
|
+
},
|
|
586
|
+
onDidChangeNotebookDocument(listener, thisArg?, disposables?) {
|
|
587
|
+
return Disposable.NULL;
|
|
588
|
+
},
|
|
589
|
+
onDidSaveNotebookDocument(listener, thisArg?, disposables?) {
|
|
590
|
+
return Disposable.NULL;
|
|
591
|
+
},
|
|
540
592
|
onDidOpenTextDocument(listener, thisArg?, disposables?) {
|
|
541
593
|
return documents.onDidAddDocument(listener, thisArg, disposables);
|
|
542
594
|
},
|
|
@@ -581,6 +633,9 @@ export function createAPIFactory(
|
|
|
581
633
|
const data = await documents.openDocument(uri);
|
|
582
634
|
return data && data.document;
|
|
583
635
|
},
|
|
636
|
+
openNotebookDocument(uriOrString: theia.Uri | string, content?: NotebookData): Promise<theia.NotebookDocument | undefined> {
|
|
637
|
+
return Promise.reject(new Error('Notebook API is stubbed'));
|
|
638
|
+
},
|
|
584
639
|
createFileSystemWatcher: (pattern, ignoreCreate, ignoreChange, ignoreDelete): theia.FileSystemWatcher =>
|
|
585
640
|
extHostFileSystemEvent.createFileSystemWatcher(fromGlobPattern(pattern), ignoreCreate, ignoreChange, ignoreDelete),
|
|
586
641
|
findFiles(include: theia.GlobPattern, exclude?: theia.GlobPattern | null, maxResults?: number, token?: CancellationToken): PromiseLike<URI[]> {
|
|
@@ -599,8 +654,8 @@ export function createAPIFactory(
|
|
|
599
654
|
registerTextDocumentContentProvider(scheme: string, provider: theia.TextDocumentContentProvider): theia.Disposable {
|
|
600
655
|
return workspaceExt.registerTextDocumentContentProvider(scheme, provider);
|
|
601
656
|
},
|
|
602
|
-
registerFileSystemProvider(scheme: string, provider: theia.FileSystemProvider): theia.Disposable {
|
|
603
|
-
return fileSystemExt.registerFileSystemProvider(scheme, provider);
|
|
657
|
+
registerFileSystemProvider(scheme: string, provider: theia.FileSystemProvider, options?: { isCaseSensitive?: boolean, isReadonly?: boolean }): theia.Disposable {
|
|
658
|
+
return fileSystemExt.registerFileSystemProvider(scheme, provider, options);
|
|
604
659
|
},
|
|
605
660
|
getWorkspaceFolder(uri: theia.Uri): theia.WorkspaceFolder | undefined {
|
|
606
661
|
return workspaceExt.getWorkspaceFolder(uri);
|
|
@@ -620,6 +675,9 @@ export function createAPIFactory(
|
|
|
620
675
|
registerTimelineProvider(scheme: string | string[], provider: theia.TimelineProvider): theia.Disposable {
|
|
621
676
|
return timelineExt.registerTimelineProvider(plugin, scheme, provider);
|
|
622
677
|
},
|
|
678
|
+
registerNotebookSerializer(notebookType: string, serializer: theia.NotebookSerializer, options?: theia.NotebookDocumentContentOptions): theia.Disposable {
|
|
679
|
+
return Disposable.NULL;
|
|
680
|
+
},
|
|
623
681
|
get isTrusted(): boolean {
|
|
624
682
|
return workspaceExt.trusted;
|
|
625
683
|
},
|
|
@@ -715,6 +773,9 @@ export function createAPIFactory(
|
|
|
715
773
|
registerCompletionItemProvider(selector: theia.DocumentSelector, provider: theia.CompletionItemProvider, ...triggerCharacters: string[]): theia.Disposable {
|
|
716
774
|
return languagesExt.registerCompletionItemProvider(selector, provider, triggerCharacters, pluginToPluginInfo(plugin));
|
|
717
775
|
},
|
|
776
|
+
registerInlineCompletionItemProvider(selector: theia.DocumentSelector, provider: theia.InlineCompletionItemProvider): theia.Disposable {
|
|
777
|
+
return languagesExt.registerInlineCompletionsProvider(selector, provider);
|
|
778
|
+
},
|
|
718
779
|
registerDefinitionProvider(selector: theia.DocumentSelector, provider: theia.DefinitionProvider): theia.Disposable {
|
|
719
780
|
return languagesExt.registerDefinitionProvider(selector, provider, pluginToPluginInfo(plugin));
|
|
720
781
|
},
|
|
@@ -981,6 +1042,66 @@ export function createAPIFactory(
|
|
|
981
1042
|
}
|
|
982
1043
|
};
|
|
983
1044
|
|
|
1045
|
+
// notebooks API (@stubbed)
|
|
1046
|
+
// The following implementation is temporarily `@stubbed` and marked as such under `theia.d.ts`
|
|
1047
|
+
const notebooks: typeof theia.notebooks = {
|
|
1048
|
+
createNotebookController(
|
|
1049
|
+
id,
|
|
1050
|
+
notebookType,
|
|
1051
|
+
label,
|
|
1052
|
+
handler?: (cells: theia.NotebookCell[],
|
|
1053
|
+
notebook: theia.NotebookDocument,
|
|
1054
|
+
controller: theia.NotebookController) => void | Thenable<void>
|
|
1055
|
+
) {
|
|
1056
|
+
return {
|
|
1057
|
+
id,
|
|
1058
|
+
notebookType,
|
|
1059
|
+
label,
|
|
1060
|
+
handler,
|
|
1061
|
+
createNotebookCellExecution: (cell: NotebookCell) => ({
|
|
1062
|
+
cell,
|
|
1063
|
+
token: CancellationToken.None,
|
|
1064
|
+
executionOrder: undefined,
|
|
1065
|
+
start: () => undefined,
|
|
1066
|
+
end: () => undefined,
|
|
1067
|
+
clearOutput: () => ({} as Thenable<void>),
|
|
1068
|
+
replaceOutput: () => ({} as Thenable<void>),
|
|
1069
|
+
appendOutput: () => ({} as Thenable<void>),
|
|
1070
|
+
replaceOutputItems: () => ({} as Thenable<void>),
|
|
1071
|
+
appendOutputItems: () => ({} as Thenable<void>)
|
|
1072
|
+
}),
|
|
1073
|
+
executeHandler(
|
|
1074
|
+
cells: theia.NotebookCell[],
|
|
1075
|
+
notebook: theia.NotebookDocument,
|
|
1076
|
+
controller: theia.NotebookController
|
|
1077
|
+
): (void | Thenable<void>) { },
|
|
1078
|
+
onDidChangeSelectedNotebooks: () => Disposable.create(() => {}),
|
|
1079
|
+
updateNotebookAffinity: (notebook: theia.NotebookDocument, affinity: theia.NotebookControllerAffinity) => undefined,
|
|
1080
|
+
dispose: () => undefined,
|
|
1081
|
+
};
|
|
1082
|
+
|
|
1083
|
+
},
|
|
1084
|
+
createRendererMessaging(
|
|
1085
|
+
rendererId
|
|
1086
|
+
) {
|
|
1087
|
+
return {
|
|
1088
|
+
rendererId,
|
|
1089
|
+
onDidReceiveMessage: () => Disposable.create(() => {} ),
|
|
1090
|
+
postMessage: () => Promise.resolve({}),
|
|
1091
|
+
};
|
|
1092
|
+
},
|
|
1093
|
+
registerNotebookCellStatusBarItemProvider(
|
|
1094
|
+
notebookType,
|
|
1095
|
+
provider
|
|
1096
|
+
) {
|
|
1097
|
+
return {
|
|
1098
|
+
notebookType,
|
|
1099
|
+
provider,
|
|
1100
|
+
dispose: () => undefined,
|
|
1101
|
+
};
|
|
1102
|
+
}
|
|
1103
|
+
};
|
|
1104
|
+
|
|
984
1105
|
return <typeof theia>{
|
|
985
1106
|
version: require('../../package.json').version,
|
|
986
1107
|
authentication,
|
|
@@ -995,6 +1116,7 @@ export function createAPIFactory(
|
|
|
995
1116
|
debug,
|
|
996
1117
|
tasks,
|
|
997
1118
|
scm,
|
|
1119
|
+
notebooks,
|
|
998
1120
|
tests,
|
|
999
1121
|
// Types
|
|
1000
1122
|
StatusBarAlignment: StatusBarAlignment,
|
|
@@ -1065,6 +1187,7 @@ export function createAPIFactory(
|
|
|
1065
1187
|
WorkspaceEdit,
|
|
1066
1188
|
SymbolInformation,
|
|
1067
1189
|
FileType,
|
|
1190
|
+
FilePermission,
|
|
1068
1191
|
FileChangeType,
|
|
1069
1192
|
ShellQuoting,
|
|
1070
1193
|
ShellExecution,
|
|
@@ -1120,11 +1243,26 @@ export function createAPIFactory(
|
|
|
1120
1243
|
InlayHint,
|
|
1121
1244
|
InlayHintKind,
|
|
1122
1245
|
InlayHintLabelPart,
|
|
1246
|
+
NotebookCellData,
|
|
1247
|
+
NotebookCellKind,
|
|
1248
|
+
NotebookCellOutput,
|
|
1249
|
+
NotebookCellOutputItem,
|
|
1250
|
+
NotebookCellStatusBarAlignment,
|
|
1251
|
+
NotebookCellStatusBarItem,
|
|
1252
|
+
NotebookControllerAffinity,
|
|
1253
|
+
NotebookData,
|
|
1254
|
+
NotebookEditorRevealType,
|
|
1255
|
+
NotebookDocument,
|
|
1256
|
+
NotebookRange,
|
|
1257
|
+
NotebookEdit,
|
|
1123
1258
|
TestRunProfileKind,
|
|
1124
1259
|
TestTag,
|
|
1125
1260
|
TestRunRequest,
|
|
1126
1261
|
TestMessage,
|
|
1127
|
-
ExtensionKind
|
|
1262
|
+
ExtensionKind,
|
|
1263
|
+
InlineCompletionItem,
|
|
1264
|
+
InlineCompletionList,
|
|
1265
|
+
InlineCompletionTriggerKind
|
|
1128
1266
|
};
|
|
1129
1267
|
};
|
|
1130
1268
|
}
|