@theia/api-tests 1.26.0-next.0 → 1.26.0-next.5
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/package.json +3 -3
- package/src/monaco-api.spec.js +19 -4
- package/src/saveable.spec.js +1 -1
- package/src/typescript.spec.js +197 -324
- package/src/undo-redo-selectAll.spec.js +1 -1
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theia/api-tests",
|
|
3
|
-
"version": "1.26.0-next.
|
|
3
|
+
"version": "1.26.0-next.5+1ac9da176d6",
|
|
4
4
|
"description": "Theia API tests",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@theia/core": "1.26.0-next.
|
|
6
|
+
"@theia/core": "1.26.0-next.5+1ac9da176d6"
|
|
7
7
|
},
|
|
8
8
|
"license": "EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0",
|
|
9
9
|
"repository": {
|
|
@@ -20,5 +20,5 @@
|
|
|
20
20
|
"publishConfig": {
|
|
21
21
|
"access": "public"
|
|
22
22
|
},
|
|
23
|
-
"gitHead": "
|
|
23
|
+
"gitHead": "1ac9da176d646a400244d9b678d920d9c6a5eee4"
|
|
24
24
|
}
|
package/src/monaco-api.spec.js
CHANGED
|
@@ -29,15 +29,18 @@ describe('Monaco API', async function () {
|
|
|
29
29
|
const { SimpleKeybinding } = require('@theia/monaco-editor-core/esm/vs/base/common/keybindings');
|
|
30
30
|
const { IKeybindingService } = require('@theia/monaco-editor-core/esm/vs/platform/keybinding/common/keybinding');
|
|
31
31
|
const { StandaloneServices } = require('@theia/monaco-editor-core/esm/vs/editor/standalone/browser/standaloneServices');
|
|
32
|
-
const { KeyCode } = require('@theia/monaco-editor-core/esm/vs/base/common/keyCodes');
|
|
33
32
|
const { TokenizationRegistry } = require('@theia/monaco-editor-core/esm/vs/editor/common/languages');
|
|
34
|
-
const {
|
|
33
|
+
const { MonacoContextKeyService } = require('@theia/monaco/lib/browser/monaco-context-key-service');
|
|
34
|
+
const { URI } = require('@theia/monaco-editor-core/esm/vs/base/common/uri');
|
|
35
35
|
|
|
36
36
|
const container = window.theia.container;
|
|
37
37
|
const editorManager = container.get(EditorManager);
|
|
38
38
|
const workspaceService = container.get(WorkspaceService);
|
|
39
39
|
const textmateService = container.get(MonacoTextmateService);
|
|
40
|
+
/** @type {import('@theia/core/src/common/command').CommandRegistry} */
|
|
40
41
|
const commands = container.get(CommandRegistry);
|
|
42
|
+
/** @type {import('@theia/monaco/src/browser/monaco-context-key-service').MonacoContextKeyService} */
|
|
43
|
+
const contextKeys = container.get(MonacoContextKeyService);
|
|
41
44
|
|
|
42
45
|
/** @type {MonacoEditor} */
|
|
43
46
|
let monacoEditor;
|
|
@@ -55,7 +58,7 @@ describe('Monaco API', async function () {
|
|
|
55
58
|
});
|
|
56
59
|
|
|
57
60
|
it('KeybindingService.resolveKeybinding', () => {
|
|
58
|
-
const simpleKeybinding = new SimpleKeybinding(true, true, true, true, KeyCode.KeyK);
|
|
61
|
+
const simpleKeybinding = new SimpleKeybinding(true, true, true, true, 41 /* KeyCode.KeyK */);
|
|
59
62
|
const chordKeybinding = simpleKeybinding.toChord();
|
|
60
63
|
assert.equal(chordKeybinding.parts.length, 1);
|
|
61
64
|
assert.equal(chordKeybinding.parts[0], simpleKeybinding);
|
|
@@ -163,11 +166,23 @@ describe('Monaco API', async function () {
|
|
|
163
166
|
execute: arg => (console.log(arg), opened = arg === 'foo')
|
|
164
167
|
});
|
|
165
168
|
try {
|
|
166
|
-
await openerService.open(
|
|
169
|
+
await openerService.open(URI.parse('command:' + id + '?"foo"'));
|
|
167
170
|
assert.isTrue(opened);
|
|
168
171
|
} finally {
|
|
169
172
|
unregisterCommand.dispose();
|
|
170
173
|
}
|
|
171
174
|
});
|
|
172
175
|
|
|
176
|
+
it('Supports setting contexts using the command registry', async () => {
|
|
177
|
+
const setContext = 'setContext';
|
|
178
|
+
const key = 'monaco-api-test-context';
|
|
179
|
+
const firstValue = 'first setting';
|
|
180
|
+
const secondValue = 'second setting';
|
|
181
|
+
assert.isFalse(contextKeys.match(`${key} == ${firstValue}`));
|
|
182
|
+
await commands.executeCommand(setContext, key, firstValue);
|
|
183
|
+
assert.isTrue(contextKeys.match(`${key} == ${firstValue}`));
|
|
184
|
+
await commands.executeCommand(setContext, key, secondValue);
|
|
185
|
+
assert.isTrue(contextKeys.match(`${key} == ${secondValue}`));
|
|
186
|
+
});
|
|
187
|
+
|
|
173
188
|
});
|
package/src/saveable.spec.js
CHANGED
|
@@ -31,7 +31,7 @@ describe('Saveable', function () {
|
|
|
31
31
|
const { MonacoEditor } = require('@theia/monaco/lib/browser/monaco-editor');
|
|
32
32
|
const { Deferred } = require('@theia/core/lib/common/promise-util');
|
|
33
33
|
const { Disposable, DisposableCollection } = require('@theia/core/lib/common/disposable');
|
|
34
|
-
const { Range } = require('@theia/monaco-editor-core');
|
|
34
|
+
const { Range } = require('@theia/monaco-editor-core/esm/vs/editor/common/core/range');
|
|
35
35
|
|
|
36
36
|
const container = window.theia.container;
|
|
37
37
|
/** @type {EditorManager} */
|
package/src/typescript.spec.js
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
// @ts-check
|
|
18
18
|
describe('TypeScript', function () {
|
|
19
|
-
this.timeout(
|
|
19
|
+
this.timeout(30_000);
|
|
20
20
|
|
|
21
21
|
const { assert } = chai;
|
|
22
22
|
|
|
@@ -36,10 +36,9 @@ describe('TypeScript', function () {
|
|
|
36
36
|
const { animationFrame } = require('@theia/core/lib/browser/browser');
|
|
37
37
|
const { PreferenceService, PreferenceScope } = require('@theia/core/lib/browser/preferences/preference-service');
|
|
38
38
|
const { ProgressStatusBarItem } = require('@theia/core/lib/browser/progress-status-bar-item');
|
|
39
|
-
const { FileService } = require('@theia/filesystem/lib/browser/file-service');
|
|
40
39
|
const { PluginViewRegistry } = require('@theia/plugin-ext/lib/main/browser/view/plugin-view-registry');
|
|
41
|
-
const {
|
|
42
|
-
const {
|
|
40
|
+
const { Range } = require('@theia/monaco-editor-core/esm/vs/editor/common/core/range');
|
|
41
|
+
const { Selection } = require('@theia/monaco-editor-core/esm/vs/editor/common/core/selection');
|
|
43
42
|
|
|
44
43
|
const container = window.theia.container;
|
|
45
44
|
const editorManager = container.get(EditorManager);
|
|
@@ -53,92 +52,25 @@ describe('TypeScript', function () {
|
|
|
53
52
|
/** @type {import('@theia/core/lib/browser/preferences/preference-service').PreferenceService} */
|
|
54
53
|
const preferences = container.get(PreferenceService);
|
|
55
54
|
const progressStatusBarItem = container.get(ProgressStatusBarItem);
|
|
56
|
-
|
|
55
|
+
/** @type {PluginViewRegistry} */
|
|
57
56
|
const pluginViewRegistry = container.get(PluginViewRegistry);
|
|
58
57
|
|
|
59
58
|
const typescriptPluginId = 'vscode.typescript-language-features';
|
|
60
59
|
const referencesPluginId = 'ms-vscode.references-view';
|
|
60
|
+
/** @type Uri.URI */
|
|
61
61
|
const rootUri = workspaceService.tryGetRoots()[0].resource;
|
|
62
|
-
const
|
|
63
|
-
const
|
|
64
|
-
|
|
62
|
+
const demoFileUri = rootUri.resolveToAbsolute('../api-tests/test-ts-workspace/demo-file.ts');
|
|
63
|
+
const definitionFileUri = rootUri.resolveToAbsolute('../api-tests/test-ts-workspace/demo-definitions-file.ts');
|
|
64
|
+
let originalAutoSaveValue = preferences.get('files.autoSave', undefined, rootUri.toString());
|
|
65
65
|
|
|
66
66
|
before(async function () {
|
|
67
|
-
await fileService.create(serverUri, `// @ts-check
|
|
68
|
-
require('reflect-metadata');
|
|
69
|
-
const path = require('path');
|
|
70
|
-
const express = require('express');
|
|
71
|
-
const { Container } = require('inversify');
|
|
72
|
-
const { BackendApplication, CliManager } = require('@theia/core/lib/node');
|
|
73
|
-
const { backendApplicationModule } = require('@theia/core/lib/node/backend-application-module');
|
|
74
|
-
const { messagingBackendModule } = require('@theia/core/lib/node/messaging/messaging-backend-module');
|
|
75
|
-
const { loggerBackendModule } = require('@theia/core/lib/node/logger-backend-module');
|
|
76
|
-
|
|
77
|
-
const container = new Container();
|
|
78
|
-
container.load(backendApplicationModule);
|
|
79
|
-
container.load(messagingBackendModule);
|
|
80
|
-
container.load(loggerBackendModule);
|
|
81
|
-
|
|
82
|
-
function load(raw) {
|
|
83
|
-
return Promise.resolve(raw.default).then(module =>
|
|
84
|
-
container.load(module)
|
|
85
|
-
);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
function start(port, host, argv) {
|
|
89
|
-
if (argv === undefined) {
|
|
90
|
-
argv = process.argv;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
const cliManager = container.get(CliManager);
|
|
94
|
-
return cliManager.initializeCli(argv).then(function () {
|
|
95
|
-
const application = container.get(BackendApplication);
|
|
96
|
-
application.use(express.static(path.join(__dirname, '../../lib')));
|
|
97
|
-
application.use(express.static(path.join(__dirname, '../../lib/index.html')));
|
|
98
|
-
return application.start(port, host);
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
module.exports = (port, host, argv) => Promise.resolve()
|
|
103
|
-
.then(function () { return Promise.resolve(require('@theia/process/lib/node/process-backend-module')).then(load) })
|
|
104
|
-
.then(function () { return Promise.resolve(require('@theia/filesystem/lib/node/filesystem-backend-module')).then(load) })
|
|
105
|
-
.then(function () { return Promise.resolve(require('@theia/filesystem/lib/node/download/file-download-backend-module')).then(load) })
|
|
106
|
-
.then(function () { return Promise.resolve(require('@theia/workspace/lib/node/workspace-backend-module')).then(load) })
|
|
107
|
-
.then(function () { return Promise.resolve(require('@theia/languages/lib/node/languages-backend-module')).then(load) })
|
|
108
|
-
.then(function () { return Promise.resolve(require('@theia/terminal/lib/node/terminal-backend-module')).then(load) })
|
|
109
|
-
.then(function () { return Promise.resolve(require('@theia/task/lib/node/task-backend-module')).then(load) })
|
|
110
|
-
.then(function () { return Promise.resolve(require('@theia/debug/lib/node/debug-backend-module')).then(load) })
|
|
111
|
-
.then(function () { return Promise.resolve(require('@theia/file-search/lib/node/file-search-backend-module')).then(load) })
|
|
112
|
-
.then(function () { return Promise.resolve(require('@theia/git/lib/node/git-backend-module')).then(load) })
|
|
113
|
-
.then(function () { return Promise.resolve(require('@theia/git/lib/node/env/git-env-module')).then(load) })
|
|
114
|
-
.then(function () { return Promise.resolve(require('@theia/json/lib/node/json-backend-module')).then(load) })
|
|
115
|
-
.then(function () { return Promise.resolve(require('@theia/metrics/lib/node/metrics-backend-module')).then(load) })
|
|
116
|
-
.then(function () { return Promise.resolve(require('@theia/mini-browser/lib/node/mini-browser-backend-module')).then(load) })
|
|
117
|
-
.then(function () { return Promise.resolve(require('@theia/search-in-workspace/lib/node/search-in-workspace-backend-module')).then(load) })
|
|
118
|
-
.then(function () { return Promise.resolve(require('@theia/plugin-ext/lib/plugin-ext-backend-module')).then(load) })
|
|
119
|
-
.then(function () { return Promise.resolve(require('@theia/plugin-dev/lib/node/plugin-dev-backend-module')).then(load) })
|
|
120
|
-
.then(function () { return Promise.resolve(require('@theia/plugin-ext-vscode/lib/node/plugin-vscode-backend-module')).then(load) })
|
|
121
|
-
.then(function () { return Promise.resolve(require('@theia/plugin-metrics/lib/node/plugin-metrics-backend-module')).then(load) })
|
|
122
|
-
.then(function () { return Promise.resolve(require('@theia/vsx-registry/lib/node/vsx-registry-backend-module')).then(load) })
|
|
123
|
-
.then(() => start(port, host, argv)).catch(reason => {
|
|
124
|
-
console.error('Failed to start the backend application.');
|
|
125
|
-
if (reason) {
|
|
126
|
-
console.error(reason);
|
|
127
|
-
}
|
|
128
|
-
throw reason;
|
|
129
|
-
});
|
|
130
|
-
`, { fromUserGesture: false, overwrite: true });
|
|
131
67
|
await pluginService.didStart;
|
|
132
68
|
await Promise.all([typescriptPluginId, referencesPluginId].map(async pluginId => {
|
|
133
69
|
if (!pluginService.getPlugin(pluginId)) {
|
|
134
70
|
throw new Error(pluginId + ' should be started');
|
|
135
71
|
}
|
|
136
72
|
await pluginService.activatePlugin(pluginId);
|
|
137
|
-
}));
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
after(async function () {
|
|
141
|
-
await fileService.delete(serverUri, { fromUserGesture: false });
|
|
73
|
+
}).concat(preferences.set('files.autoSave', 'off', PreferenceScope.Workspace)));
|
|
142
74
|
});
|
|
143
75
|
|
|
144
76
|
beforeEach(async function () {
|
|
@@ -151,6 +83,10 @@ module.exports = (port, host, argv) => Promise.resolve()
|
|
|
151
83
|
await editorManager.closeAll({ save: false });
|
|
152
84
|
});
|
|
153
85
|
|
|
86
|
+
after(async () => {
|
|
87
|
+
await preferences.set('files.autoSave', originalAutoSaveValue, PreferenceScope.Workspace);
|
|
88
|
+
})
|
|
89
|
+
|
|
154
90
|
/**
|
|
155
91
|
* @param {Uri.default} uri
|
|
156
92
|
* @param {boolean} preview
|
|
@@ -160,30 +96,36 @@ module.exports = (port, host, argv) => Promise.resolve()
|
|
|
160
96
|
const editorWidget = widget instanceof EditorWidget ? widget : undefined;
|
|
161
97
|
const editor = MonacoEditor.get(editorWidget);
|
|
162
98
|
assert.isDefined(editor);
|
|
163
|
-
|
|
164
99
|
// wait till tsserver is running, see:
|
|
165
100
|
// https://github.com/microsoft/vscode/blob/93cbbc5cae50e9f5f5046343c751b6d010468200/extensions/typescript-language-features/src/extension.ts#L98-L103
|
|
166
101
|
await waitForAnimation(() => contextKeyService.match('typescript.isManagedFile'));
|
|
167
|
-
|
|
168
102
|
// wait till projects are loaded, see:
|
|
169
103
|
// https://github.com/microsoft/vscode/blob/4aac84268c6226d23828cc6a1fe45ee3982927f0/extensions/typescript-language-features/src/typescriptServiceClient.ts#L911
|
|
170
104
|
await waitForAnimation(() => !progressStatusBarItem.currentProgress);
|
|
171
|
-
|
|
172
105
|
return /** @type {MonacoEditor} */ (editor);
|
|
173
106
|
}
|
|
174
107
|
|
|
175
108
|
/**
|
|
176
|
-
* @param {() => Promise<unknown> |
|
|
109
|
+
* @param {() => Promise<unknown> | unknown} condition
|
|
110
|
+
* @param {number | undefined} [timeout]
|
|
177
111
|
* @returns {Promise<void>}
|
|
178
112
|
*/
|
|
179
|
-
function waitForAnimation(condition) {
|
|
180
|
-
|
|
113
|
+
function waitForAnimation(condition, timeout) {
|
|
114
|
+
const success = new Promise(async (resolve, dispose) => {
|
|
181
115
|
toTearDown.push({ dispose });
|
|
182
116
|
do {
|
|
183
117
|
await animationFrame();
|
|
184
118
|
} while (!condition());
|
|
185
119
|
resolve();
|
|
186
120
|
});
|
|
121
|
+
if (timeout !== undefined) {
|
|
122
|
+
const timedOut = new Promise((_, fail) => {
|
|
123
|
+
const toClear = setTimeout(() => fail(new Error('Wait for animation timed out.')), timeout);
|
|
124
|
+
toTearDown.push({ dispose: () => (fail(new Error('Wait for animation timed out.')), clearTimeout(toClear)) });
|
|
125
|
+
});
|
|
126
|
+
return Promise.race([success, timedOut]);
|
|
127
|
+
}
|
|
128
|
+
return success;
|
|
187
129
|
}
|
|
188
130
|
|
|
189
131
|
/**
|
|
@@ -259,7 +201,7 @@ module.exports = (port, host, argv) => Promise.resolve()
|
|
|
259
201
|
}
|
|
260
202
|
|
|
261
203
|
it('document formatting should be visible and enabled', async function () {
|
|
262
|
-
await openEditor(
|
|
204
|
+
await openEditor(demoFileUri);
|
|
263
205
|
const menu = menuFactory.createContextMenu(EDITOR_CONTEXT_MENU);
|
|
264
206
|
const item = menu.items.find(i => i.command === 'editor.action.formatDocument');
|
|
265
207
|
if (item) {
|
|
@@ -274,68 +216,57 @@ module.exports = (port, host, argv) => Promise.resolve()
|
|
|
274
216
|
for (const preview of [false, true]) {
|
|
275
217
|
const from = 'an editor' + (preview ? ' preview' : '');
|
|
276
218
|
it('within ' + from, async function () {
|
|
277
|
-
const editor = await openEditor(
|
|
278
|
-
//
|
|
279
|
-
editor.getControl().setPosition({ lineNumber:
|
|
280
|
-
|
|
281
|
-
assert.equal(editor.getControl().getModel().getWordAtPosition(editor.getControl().getPosition()).word, 'container');
|
|
219
|
+
const editor = await openEditor(demoFileUri, preview);
|
|
220
|
+
// const demoInstance = new Demo|Class('demo');
|
|
221
|
+
editor.getControl().setPosition({ lineNumber: 24, column: 30 });
|
|
222
|
+
assert.equal(editor.getControl().getModel().getWordAtPosition(editor.getControl().getPosition()).word, 'DemoClass');
|
|
282
223
|
|
|
283
224
|
await commands.executeCommand('editor.action.revealDefinition');
|
|
284
225
|
|
|
285
|
-
const activeEditor = /** @type {MonacoEditor} */
|
|
286
|
-
// @ts-ignore
|
|
226
|
+
const activeEditor = /** @type {MonacoEditor} */ MonacoEditor.get(editorManager.activeEditor);
|
|
287
227
|
assert.equal(editorManager.activeEditor.isPreview, preview);
|
|
288
|
-
assert.equal(activeEditor.uri.toString(),
|
|
289
|
-
//
|
|
290
|
-
// @ts-ignore
|
|
228
|
+
assert.equal(activeEditor.uri.toString(), demoFileUri.toString());
|
|
229
|
+
// constructor(someString: string) {
|
|
291
230
|
const { lineNumber, column } = activeEditor.getControl().getPosition();
|
|
292
|
-
assert.deepEqual({ lineNumber, column }, { lineNumber: 11, column:
|
|
293
|
-
|
|
294
|
-
assert.equal(activeEditor.getControl().getModel().getWordAtPosition({ lineNumber, column }).word, 'container');
|
|
231
|
+
assert.deepEqual({ lineNumber, column }, { lineNumber: 11, column: 5 });
|
|
232
|
+
assert.equal(activeEditor.getControl().getModel().getWordAtPosition({ lineNumber, column }).word, 'constructor');
|
|
295
233
|
});
|
|
296
234
|
|
|
297
235
|
it(`from ${from} to another editor`, async function () {
|
|
298
|
-
await editorManager.open(
|
|
236
|
+
await editorManager.open(definitionFileUri, { mode: 'open' });
|
|
299
237
|
|
|
300
|
-
const editor = await openEditor(
|
|
301
|
-
// const
|
|
302
|
-
editor.getControl().setPosition({ lineNumber:
|
|
303
|
-
|
|
304
|
-
assert.equal(editor.getControl().getModel().getWordAtPosition(editor.getControl().getPosition()).word, 'Container');
|
|
238
|
+
const editor = await openEditor(demoFileUri, preview);
|
|
239
|
+
// const bar: Defined|Interface = { coolField: [] };
|
|
240
|
+
editor.getControl().setPosition({ lineNumber: 32, column: 19 });
|
|
241
|
+
assert.equal(editor.getControl().getModel().getWordAtPosition(editor.getControl().getPosition()).word, 'DefinedInterface');
|
|
305
242
|
|
|
306
243
|
await commands.executeCommand('editor.action.revealDefinition');
|
|
307
244
|
|
|
308
|
-
const activeEditor = /** @type {MonacoEditor} */
|
|
309
|
-
// @ts-ignore
|
|
245
|
+
const activeEditor = /** @type {MonacoEditor} */ MonacoEditor.get(editorManager.activeEditor);
|
|
310
246
|
assert.isFalse(editorManager.activeEditor.isPreview);
|
|
311
|
-
assert.equal(activeEditor.uri.toString(),
|
|
312
|
-
|
|
313
|
-
//
|
|
247
|
+
assert.equal(activeEditor.uri.toString(), definitionFileUri.toString());
|
|
248
|
+
|
|
249
|
+
// export interface |DefinedInterface {
|
|
314
250
|
const { lineNumber, column } = activeEditor.getControl().getPosition();
|
|
315
|
-
assert.deepEqual({ lineNumber, column }, { lineNumber:
|
|
316
|
-
|
|
317
|
-
assert.equal(activeEditor.getControl().getModel().getWordAtPosition({ lineNumber, column }).word, 'Container');
|
|
251
|
+
assert.deepEqual({ lineNumber, column }, { lineNumber: 2, column: 18 });
|
|
252
|
+
assert.equal(activeEditor.getControl().getModel().getWordAtPosition({ lineNumber, column }).word, 'DefinedInterface');
|
|
318
253
|
});
|
|
319
254
|
|
|
320
255
|
it(`from ${from} to an editor preview`, async function () {
|
|
321
|
-
const editor = await openEditor(
|
|
322
|
-
// const
|
|
323
|
-
editor.getControl().setPosition({ lineNumber:
|
|
324
|
-
|
|
325
|
-
assert.equal(editor.getControl().getModel().getWordAtPosition(editor.getControl().getPosition()).word, 'Container');
|
|
256
|
+
const editor = await openEditor(demoFileUri);
|
|
257
|
+
// const bar: Defined|Interface = { coolField: [] };
|
|
258
|
+
editor.getControl().setPosition({ lineNumber: 32, column: 19 });
|
|
259
|
+
assert.equal(editor.getControl().getModel().getWordAtPosition(editor.getControl().getPosition()).word, 'DefinedInterface');
|
|
326
260
|
|
|
327
261
|
await commands.executeCommand('editor.action.revealDefinition');
|
|
328
262
|
|
|
329
|
-
const activeEditor = /** @type {MonacoEditor} */
|
|
330
|
-
// @ts-ignore
|
|
263
|
+
const activeEditor = /** @type {MonacoEditor} */ MonacoEditor.get(editorManager.activeEditor);
|
|
331
264
|
assert.isTrue(editorManager.activeEditor.isPreview);
|
|
332
|
-
assert.equal(activeEditor.uri.toString(),
|
|
333
|
-
// export
|
|
334
|
-
// @ts-ignore
|
|
265
|
+
assert.equal(activeEditor.uri.toString(), definitionFileUri.toString());
|
|
266
|
+
// export interface |DefinedInterface {
|
|
335
267
|
const { lineNumber, column } = activeEditor.getControl().getPosition();
|
|
336
|
-
assert.deepEqual({ lineNumber, column }, { lineNumber:
|
|
337
|
-
|
|
338
|
-
assert.equal(activeEditor.getControl().getModel().getWordAtPosition({ lineNumber, column }).word, 'Container');
|
|
268
|
+
assert.deepEqual({ lineNumber, column }, { lineNumber: 2, column: 18 });
|
|
269
|
+
assert.equal(activeEditor.getControl().getModel().getWordAtPosition({ lineNumber, column }).word, 'DefinedInterface');
|
|
339
270
|
});
|
|
340
271
|
}
|
|
341
272
|
});
|
|
@@ -345,75 +276,63 @@ module.exports = (port, host, argv) => Promise.resolve()
|
|
|
345
276
|
for (const preview of [false, true]) {
|
|
346
277
|
const from = 'an editor' + (preview ? ' preview' : '');
|
|
347
278
|
it('within ' + from, async function () {
|
|
348
|
-
const editor = await openEditor(
|
|
349
|
-
//
|
|
350
|
-
editor.getControl().setPosition({ lineNumber:
|
|
351
|
-
|
|
352
|
-
assert.equal(editor.getControl().getModel().getWordAtPosition(editor.getControl().getPosition()).word, 'container');
|
|
279
|
+
const editor = await openEditor(demoFileUri, preview);
|
|
280
|
+
// const demoInstance = new Demo|Class('demo');
|
|
281
|
+
editor.getControl().setPosition({ lineNumber: 24, column: 30 });
|
|
282
|
+
assert.equal(editor.getControl().getModel().getWordAtPosition(editor.getControl().getPosition()).word, 'DemoClass');
|
|
353
283
|
|
|
354
284
|
await openPeek(editor);
|
|
355
285
|
await openReference();
|
|
356
286
|
|
|
357
|
-
const activeEditor = /** @type {MonacoEditor} */
|
|
358
|
-
// @ts-ignore
|
|
287
|
+
const activeEditor = /** @type {MonacoEditor} */ MonacoEditor.get(editorManager.activeEditor);
|
|
359
288
|
assert.equal(editorManager.activeEditor.isPreview, preview);
|
|
360
|
-
assert.equal(activeEditor.uri.toString(),
|
|
361
|
-
//
|
|
362
|
-
// @ts-ignore
|
|
289
|
+
assert.equal(activeEditor.uri.toString(), demoFileUri.toString());
|
|
290
|
+
// constructor(someString: string) {
|
|
363
291
|
const { lineNumber, column } = activeEditor.getControl().getPosition();
|
|
364
|
-
assert.deepEqual({ lineNumber, column }, { lineNumber: 11, column:
|
|
365
|
-
|
|
366
|
-
assert.equal(activeEditor.getControl().getModel().getWordAtPosition({ lineNumber, column }).word, 'container');
|
|
292
|
+
assert.deepEqual({ lineNumber, column }, { lineNumber: 11, column: 5 });
|
|
293
|
+
assert.equal(activeEditor.getControl().getModel().getWordAtPosition({ lineNumber, column }).word, 'constructor');
|
|
367
294
|
|
|
368
295
|
await closePeek(activeEditor);
|
|
369
296
|
});
|
|
370
297
|
|
|
371
298
|
it(`from ${from} to another editor`, async function () {
|
|
372
|
-
await editorManager.open(
|
|
299
|
+
await editorManager.open(definitionFileUri, { mode: 'open' });
|
|
373
300
|
|
|
374
|
-
const editor = await openEditor(
|
|
375
|
-
// const
|
|
376
|
-
editor.getControl().setPosition({ lineNumber:
|
|
377
|
-
|
|
378
|
-
assert.equal(editor.getControl().getModel().getWordAtPosition(editor.getControl().getPosition()).word, 'Container');
|
|
301
|
+
const editor = await openEditor(demoFileUri, preview);
|
|
302
|
+
// const bar: Defined|Interface = { coolField: [] };
|
|
303
|
+
editor.getControl().setPosition({ lineNumber: 32, column: 19 });
|
|
304
|
+
assert.equal(editor.getControl().getModel().getWordAtPosition(editor.getControl().getPosition()).word, 'DefinedInterface');
|
|
379
305
|
|
|
380
306
|
await openPeek(editor);
|
|
381
307
|
await openReference();
|
|
382
308
|
|
|
383
|
-
const activeEditor = /** @type {MonacoEditor} */
|
|
384
|
-
// @ts-ignore
|
|
309
|
+
const activeEditor = /** @type {MonacoEditor} */ MonacoEditor.get(editorManager.activeEditor);
|
|
385
310
|
assert.isFalse(editorManager.activeEditor.isPreview);
|
|
386
|
-
assert.equal(activeEditor.uri.toString(),
|
|
387
|
-
// export
|
|
388
|
-
// @ts-ignore
|
|
311
|
+
assert.equal(activeEditor.uri.toString(), definitionFileUri.toString());
|
|
312
|
+
// export interface |DefinedInterface {
|
|
389
313
|
const { lineNumber, column } = activeEditor.getControl().getPosition();
|
|
390
|
-
assert.deepEqual({ lineNumber, column }, { lineNumber:
|
|
391
|
-
|
|
392
|
-
assert.equal(activeEditor.getControl().getModel().getWordAtPosition({ lineNumber, column }).word, 'Container');
|
|
314
|
+
assert.deepEqual({ lineNumber, column }, { lineNumber: 2, column: 18 });
|
|
315
|
+
assert.equal(activeEditor.getControl().getModel().getWordAtPosition({ lineNumber, column }).word, 'DefinedInterface');
|
|
393
316
|
|
|
394
317
|
await closePeek(activeEditor);
|
|
395
318
|
});
|
|
396
319
|
|
|
397
320
|
it(`from ${from} to an editor preview`, async function () {
|
|
398
|
-
const editor = await openEditor(
|
|
399
|
-
// const
|
|
400
|
-
editor.getControl().setPosition({ lineNumber:
|
|
401
|
-
|
|
402
|
-
assert.equal(editor.getControl().getModel().getWordAtPosition(editor.getControl().getPosition()).word, 'Container');
|
|
321
|
+
const editor = await openEditor(demoFileUri);
|
|
322
|
+
// const bar: Defined|Interface = { coolField: [] };
|
|
323
|
+
editor.getControl().setPosition({ lineNumber: 32, column: 19 });
|
|
324
|
+
assert.equal(editor.getControl().getModel().getWordAtPosition(editor.getControl().getPosition()).word, 'DefinedInterface');
|
|
403
325
|
|
|
404
326
|
await openPeek(editor);
|
|
405
327
|
await openReference();
|
|
406
328
|
|
|
407
|
-
const activeEditor = /** @type {MonacoEditor} */
|
|
408
|
-
// @ts-ignore
|
|
329
|
+
const activeEditor = /** @type {MonacoEditor} */ MonacoEditor.get(editorManager.activeEditor);
|
|
409
330
|
assert.isTrue(editorManager.activeEditor.isPreview);
|
|
410
|
-
assert.equal(activeEditor.uri.toString(),
|
|
411
|
-
// export
|
|
412
|
-
// @ts-ignore
|
|
331
|
+
assert.equal(activeEditor.uri.toString(), definitionFileUri.toString());
|
|
332
|
+
// export interface |DefinedInterface {
|
|
413
333
|
const { lineNumber, column } = activeEditor.getControl().getPosition();
|
|
414
|
-
assert.deepEqual({ lineNumber, column }, { lineNumber:
|
|
415
|
-
|
|
416
|
-
assert.equal(activeEditor.getControl().getModel().getWordAtPosition({ lineNumber, column }).word, 'Container');
|
|
334
|
+
assert.deepEqual({ lineNumber, column }, { lineNumber: 2, column: 18 });
|
|
335
|
+
assert.equal(activeEditor.getControl().getModel().getWordAtPosition({ lineNumber, column }).word, 'DefinedInterface');
|
|
417
336
|
|
|
418
337
|
await closePeek(activeEditor);
|
|
419
338
|
});
|
|
@@ -421,12 +340,11 @@ module.exports = (port, host, argv) => Promise.resolve()
|
|
|
421
340
|
});
|
|
422
341
|
|
|
423
342
|
it('editor.action.triggerSuggest', async function () {
|
|
424
|
-
const editor = await openEditor(
|
|
425
|
-
// const
|
|
426
|
-
editor.getControl().setPosition({ lineNumber:
|
|
427
|
-
editor.getControl().setSelection(
|
|
428
|
-
|
|
429
|
-
assert.equal(editor.getControl().getModel().getWordAtPosition(editor.getControl().getPosition()).word, 'Container');
|
|
343
|
+
const editor = await openEditor(demoFileUri);
|
|
344
|
+
// const demoVariable = demoInstance.[stringField];
|
|
345
|
+
editor.getControl().setPosition({ lineNumber: 26, column: 46 });
|
|
346
|
+
editor.getControl().setSelection(new Selection(26, 46, 26, 35));
|
|
347
|
+
assert.equal(editor.getControl().getModel().getWordAtPosition(editor.getControl().getPosition()).word, 'stringField');
|
|
430
348
|
|
|
431
349
|
assert.isTrue(contextKeyService.match('editorTextFocus'));
|
|
432
350
|
assert.isFalse(contextKeyService.match('suggestWidgetVisible'));
|
|
@@ -443,25 +361,22 @@ module.exports = (port, host, argv) => Promise.resolve()
|
|
|
443
361
|
assert.isTrue(contextKeyService.match('editorTextFocus'));
|
|
444
362
|
assert.isFalse(contextKeyService.match('suggestWidgetVisible'));
|
|
445
363
|
|
|
446
|
-
const activeEditor = /** @type {MonacoEditor} */
|
|
447
|
-
assert.equal(activeEditor.uri.toString(),
|
|
448
|
-
//
|
|
449
|
-
// @ts-ignore
|
|
364
|
+
const activeEditor = /** @type {MonacoEditor} */ MonacoEditor.get(editorManager.activeEditor);
|
|
365
|
+
assert.equal(activeEditor.uri.toString(), demoFileUri.toString());
|
|
366
|
+
// demoInstance.stringField;
|
|
450
367
|
const { lineNumber, column } = activeEditor.getControl().getPosition();
|
|
451
|
-
assert.deepEqual({ lineNumber, column }, { lineNumber:
|
|
452
|
-
|
|
453
|
-
assert.equal(activeEditor.getControl().getModel().getWordAtPosition({ lineNumber, column }).word, 'Container');
|
|
368
|
+
assert.deepEqual({ lineNumber, column }, { lineNumber: 26, column: 46 });
|
|
369
|
+
assert.equal(activeEditor.getControl().getModel().getWordAtPosition({ lineNumber, column }).word, 'doSomething');
|
|
454
370
|
});
|
|
455
371
|
|
|
456
372
|
it('editor.action.triggerSuggest navigate', async function () {
|
|
457
|
-
const editor = await openEditor(
|
|
458
|
-
//
|
|
459
|
-
editor.getControl().setPosition({ lineNumber:
|
|
460
|
-
editor.getControl().setSelection(
|
|
461
|
-
|
|
462
|
-
assert.equal(editor.getControl().getModel().getWordAtPosition(editor.getControl().getPosition()).word, 'Container');
|
|
373
|
+
const editor = await openEditor(demoFileUri);
|
|
374
|
+
// demoInstance.[|stringField];
|
|
375
|
+
editor.getControl().setPosition({ lineNumber: 26, column: 46 });
|
|
376
|
+
editor.getControl().setSelection(new Selection(26, 46, 26, 35));
|
|
377
|
+
assert.equal(editor.getControl().getModel().getWordAtPosition(editor.getControl().getPosition()).word, 'stringField');
|
|
463
378
|
|
|
464
|
-
/** @type
|
|
379
|
+
/** @type {import('@theia/monaco-editor-core/src/vs/editor/contrib/suggest/browser/suggestController').SuggestController} */
|
|
465
380
|
const suggest = editor.getControl().getContribution('editor.contrib.suggestController');
|
|
466
381
|
const getFocusedLabel = () => {
|
|
467
382
|
const focusedItem = suggest.widget.value.getFocusedItem();
|
|
@@ -472,36 +387,35 @@ module.exports = (port, host, argv) => Promise.resolve()
|
|
|
472
387
|
assert.isFalse(contextKeyService.match('suggestWidgetVisible'));
|
|
473
388
|
|
|
474
389
|
await commands.executeCommand('editor.action.triggerSuggest');
|
|
475
|
-
await waitForAnimation(() => contextKeyService.match('suggestWidgetVisible') && getFocusedLabel() === '
|
|
390
|
+
await waitForAnimation(() => contextKeyService.match('suggestWidgetVisible') && getFocusedLabel() === 'doSomething', 5000);
|
|
476
391
|
|
|
477
|
-
assert.equal(getFocusedLabel(), '
|
|
392
|
+
assert.equal(getFocusedLabel(), 'doSomething');
|
|
478
393
|
assert.isTrue(contextKeyService.match('suggestWidgetVisible'));
|
|
479
394
|
|
|
480
395
|
keybindings.dispatchKeyDown('ArrowDown');
|
|
481
|
-
await waitForAnimation(() => contextKeyService.match('suggestWidgetVisible') && getFocusedLabel() === '
|
|
396
|
+
await waitForAnimation(() => contextKeyService.match('suggestWidgetVisible') && getFocusedLabel() === 'numberField', 2000);
|
|
482
397
|
|
|
483
|
-
assert.equal(getFocusedLabel(), '
|
|
398
|
+
assert.equal(getFocusedLabel(), 'numberField');
|
|
484
399
|
assert.isTrue(contextKeyService.match('suggestWidgetVisible'));
|
|
485
400
|
|
|
486
401
|
keybindings.dispatchKeyDown('ArrowUp');
|
|
487
|
-
await waitForAnimation(() => contextKeyService.match('suggestWidgetVisible') && getFocusedLabel() === '
|
|
402
|
+
await waitForAnimation(() => contextKeyService.match('suggestWidgetVisible') && getFocusedLabel() === 'doSomething', 2000);
|
|
488
403
|
|
|
489
|
-
assert.equal(getFocusedLabel(), '
|
|
404
|
+
assert.equal(getFocusedLabel(), 'doSomething');
|
|
490
405
|
assert.isTrue(contextKeyService.match('suggestWidgetVisible'));
|
|
491
406
|
|
|
492
407
|
keybindings.dispatchKeyDown('Escape');
|
|
493
|
-
await waitForAnimation(() => !contextKeyService.match('suggestWidgetVisible') && getFocusedLabel() === undefined);
|
|
408
|
+
await waitForAnimation(() => !contextKeyService.match('suggestWidgetVisible') && getFocusedLabel() === undefined, 5000);
|
|
494
409
|
|
|
495
410
|
assert.isUndefined(getFocusedLabel());
|
|
496
411
|
assert.isFalse(contextKeyService.match('suggestWidgetVisible'));
|
|
497
412
|
});
|
|
498
413
|
|
|
499
414
|
it('editor.action.rename', async function () {
|
|
500
|
-
const editor = await openEditor(
|
|
501
|
-
// const |
|
|
502
|
-
editor.getControl().setPosition({ lineNumber:
|
|
503
|
-
|
|
504
|
-
assert.equal(editor.getControl().getModel().getWordAtPosition(editor.getControl().getPosition()).word, 'container');
|
|
415
|
+
const editor = await openEditor(demoFileUri);
|
|
416
|
+
// const |demoVariable = demoInstance.stringField;
|
|
417
|
+
editor.getControl().setPosition({ lineNumber: 26, column: 7 });
|
|
418
|
+
assert.equal(editor.getControl().getModel().getWordAtPosition(editor.getControl().getPosition()).word, 'demoVariable');
|
|
505
419
|
|
|
506
420
|
assert.isTrue(contextKeyService.match('editorTextFocus'));
|
|
507
421
|
assert.isFalse(contextKeyService.match('renameInputVisible'));
|
|
@@ -509,7 +423,7 @@ module.exports = (port, host, argv) => Promise.resolve()
|
|
|
509
423
|
commands.executeCommand('editor.action.rename');
|
|
510
424
|
await waitForAnimation(() => contextKeyService.match('renameInputVisible')
|
|
511
425
|
&& document.activeElement instanceof HTMLInputElement
|
|
512
|
-
&& document.activeElement.selectionEnd === '
|
|
426
|
+
&& document.activeElement.selectionEnd === 'demoVariable'.length);
|
|
513
427
|
assert.isFalse(contextKeyService.match('editorTextFocus'));
|
|
514
428
|
assert.isTrue(contextKeyService.match('renameInputVisible'));
|
|
515
429
|
|
|
@@ -523,29 +437,24 @@ module.exports = (port, host, argv) => Promise.resolve()
|
|
|
523
437
|
keybindings.dispatchKeyDown('Enter', input);
|
|
524
438
|
|
|
525
439
|
// all rename edits should be grouped in one edit operation and applied in the same tick
|
|
526
|
-
|
|
527
|
-
editor.getControl().onDidChangeModelContent(() => waitForApplyRenameEdits.resolve());
|
|
528
|
-
await waitForApplyRenameEdits.promise;
|
|
440
|
+
await new Promise(resolve => editor.getControl().onDidChangeModelContent(resolve));
|
|
529
441
|
|
|
530
442
|
assert.isTrue(contextKeyService.match('editorTextFocus'));
|
|
531
443
|
assert.isFalse(contextKeyService.match('renameInputVisible'));
|
|
532
444
|
|
|
533
|
-
const activeEditor = /** @type {MonacoEditor} */
|
|
534
|
-
assert.equal(activeEditor.uri.toString(),
|
|
445
|
+
const activeEditor = /** @type {MonacoEditor} */ MonacoEditor.get(editorManager.activeEditor);
|
|
446
|
+
assert.equal(activeEditor.uri.toString(), demoFileUri.toString());
|
|
535
447
|
// const |foo = new Container();
|
|
536
|
-
// @ts-ignore
|
|
537
448
|
const { lineNumber, column } = activeEditor.getControl().getPosition();
|
|
538
|
-
assert.deepEqual({ lineNumber, column }, { lineNumber:
|
|
539
|
-
|
|
540
|
-
assert.equal(activeEditor.getControl().getModel().getWordAtPosition({ lineNumber, column }).word, 'foo');
|
|
449
|
+
assert.deepEqual({ lineNumber, column }, { lineNumber: 26, column: 7 });
|
|
450
|
+
assert.equal(activeEditor.getControl().getModel().getWordAtPosition({ lineNumber: 28, column: 1 }).word, 'foo');
|
|
541
451
|
});
|
|
542
452
|
|
|
543
453
|
it('editor.action.triggerParameterHints', async function () {
|
|
544
|
-
const editor = await openEditor(
|
|
545
|
-
//
|
|
546
|
-
editor.getControl().setPosition({ lineNumber:
|
|
547
|
-
|
|
548
|
-
assert.equal(editor.getControl().getModel().getWordAtPosition(editor.getControl().getPosition()).word, 'backendApplicationModule');
|
|
454
|
+
const editor = await openEditor(demoFileUri);
|
|
455
|
+
// const demoInstance = new DemoClass('|demo');
|
|
456
|
+
editor.getControl().setPosition({ lineNumber: 24, column: 37 });
|
|
457
|
+
assert.equal(editor.getControl().getModel().getWordAtPosition(editor.getControl().getPosition()).word, "demo");
|
|
549
458
|
|
|
550
459
|
assert.isTrue(contextKeyService.match('editorTextFocus'));
|
|
551
460
|
assert.isFalse(contextKeyService.match('parameterHintsVisible'));
|
|
@@ -564,25 +473,22 @@ module.exports = (port, host, argv) => Promise.resolve()
|
|
|
564
473
|
});
|
|
565
474
|
|
|
566
475
|
it('editor.action.showHover', async function () {
|
|
567
|
-
const editor = await openEditor(
|
|
568
|
-
//
|
|
569
|
-
editor.getControl().setPosition({ lineNumber:
|
|
570
|
-
|
|
571
|
-
assert.equal(editor.getControl().getModel().getWordAtPosition(editor.getControl().getPosition()).word, 'backendApplicationModule');
|
|
476
|
+
const editor = await openEditor(demoFileUri);
|
|
477
|
+
// class |DemoClass);
|
|
478
|
+
editor.getControl().setPosition({ lineNumber: 8, column: 7 });
|
|
479
|
+
assert.equal(editor.getControl().getModel().getWordAtPosition(editor.getControl().getPosition()).word, 'DemoClass');
|
|
572
480
|
|
|
573
|
-
/** @type
|
|
481
|
+
/** @type {import('@theia/monaco-editor-core/src/vs/editor/contrib/hover/browser/hover').ModesHoverController} */
|
|
574
482
|
const hover = editor.getControl().getContribution('editor.contrib.hover');
|
|
575
483
|
|
|
576
484
|
assert.isTrue(contextKeyService.match('editorTextFocus'));
|
|
577
|
-
assert.isFalse(
|
|
578
|
-
|
|
485
|
+
assert.isFalse(Boolean(hover['_contentWidget']?.['_widget']?.['_visibleData']));
|
|
579
486
|
await commands.executeCommand('editor.action.showHover');
|
|
580
|
-
|
|
581
|
-
|
|
487
|
+
let doLog = true;
|
|
488
|
+
await waitForAnimation(() => hover['_contentWidget']?.['_widget']?.['_visibleData']);
|
|
582
489
|
assert.isTrue(contextKeyService.match('editorTextFocus'));
|
|
583
|
-
assert.isTrue(
|
|
584
|
-
|
|
585
|
-
assert.deepEqual(hover._contentWidget && nodeAsString(hover._contentWidget._hover.contentsDomNode), `
|
|
490
|
+
assert.isTrue(Boolean(hover['_contentWidget']?.['_widget']?.['_visibleData']));
|
|
491
|
+
assert.deepEqual(nodeAsString(hover['_contentWidget']?.['_widget']?.['_hover']?.['contentsDomNode']).trim(), `
|
|
586
492
|
DIV {
|
|
587
493
|
DIV {
|
|
588
494
|
DIV {
|
|
@@ -591,19 +497,13 @@ DIV {
|
|
|
591
497
|
SPAN {
|
|
592
498
|
DIV {
|
|
593
499
|
SPAN {
|
|
594
|
-
"
|
|
500
|
+
"class"
|
|
595
501
|
}
|
|
596
502
|
SPAN {
|
|
597
503
|
" "
|
|
598
504
|
}
|
|
599
505
|
SPAN {
|
|
600
|
-
"
|
|
601
|
-
}
|
|
602
|
-
SPAN {
|
|
603
|
-
": "
|
|
604
|
-
}
|
|
605
|
-
SPAN {
|
|
606
|
-
"ContainerModule"
|
|
506
|
+
"DemoClass"
|
|
607
507
|
}
|
|
608
508
|
}
|
|
609
509
|
}
|
|
@@ -611,25 +511,21 @@ DIV {
|
|
|
611
511
|
}
|
|
612
512
|
}
|
|
613
513
|
}
|
|
614
|
-
}
|
|
615
|
-
`);
|
|
616
|
-
|
|
514
|
+
}`.trim());
|
|
617
515
|
keybindings.dispatchKeyDown('Escape');
|
|
618
|
-
await waitForAnimation(() => !hover
|
|
619
|
-
|
|
516
|
+
await waitForAnimation(() => !hover['_contentWidget']?.['_widget']?.['_visibleData']);
|
|
620
517
|
assert.isTrue(contextKeyService.match('editorTextFocus'));
|
|
621
|
-
assert.isFalse(
|
|
518
|
+
assert.isFalse(Boolean(hover['_contentWidget']?.['_widget']?.['_visibleData']));
|
|
622
519
|
});
|
|
623
520
|
|
|
624
|
-
it('
|
|
625
|
-
const editor = await openEditor(
|
|
521
|
+
it('highlight semantic (write) occurrences', async function () {
|
|
522
|
+
const editor = await openEditor(demoFileUri);
|
|
626
523
|
// const |container = new Container();
|
|
627
|
-
const lineNumber =
|
|
524
|
+
const lineNumber = 24;
|
|
628
525
|
const column = 7;
|
|
629
|
-
const endColumn = column + '
|
|
526
|
+
const endColumn = column + 'demoInstance'.length;
|
|
630
527
|
|
|
631
528
|
const hasWriteDecoration = () => {
|
|
632
|
-
// @ts-ignore
|
|
633
529
|
for (const decoration of editor.getControl().getModel().getLineDecorations(lineNumber)) {
|
|
634
530
|
if (decoration.range.startColumn === column && decoration.range.endColumn === endColumn && decoration.options.className === 'wordHighlightStrong') {
|
|
635
531
|
return true;
|
|
@@ -640,8 +536,7 @@ DIV {
|
|
|
640
536
|
assert.isFalse(hasWriteDecoration());
|
|
641
537
|
|
|
642
538
|
editor.getControl().setPosition({ lineNumber, column });
|
|
643
|
-
|
|
644
|
-
assert.equal(editor.getControl().getModel().getWordAtPosition(editor.getControl().getPosition()).word, 'container');
|
|
539
|
+
assert.equal(editor.getControl().getModel().getWordAtPosition(editor.getControl().getPosition()).word, 'demoInstance');
|
|
645
540
|
// highlight occurrences is not trigged on the explicit position change, so move a cursor as a user
|
|
646
541
|
keybindings.dispatchKeyDown('ArrowRight');
|
|
647
542
|
await waitForAnimation(() => hasWriteDecoration());
|
|
@@ -650,51 +545,44 @@ DIV {
|
|
|
650
545
|
});
|
|
651
546
|
|
|
652
547
|
it('editor.action.goToImplementation', async function () {
|
|
653
|
-
const editor = await openEditor(
|
|
654
|
-
//
|
|
655
|
-
editor.getControl().setPosition({ lineNumber:
|
|
656
|
-
|
|
657
|
-
assert.equal(editor.getControl().getModel().getWordAtPosition(editor.getControl().getPosition()).word, 'container');
|
|
548
|
+
const editor = await openEditor(demoFileUri);
|
|
549
|
+
// const demoInstance = new Demo|Class('demo');
|
|
550
|
+
editor.getControl().setPosition({ lineNumber: 24, column: 30 });
|
|
551
|
+
assert.equal(editor.getControl().getModel().getWordAtPosition(editor.getControl().getPosition()).word, 'DemoClass');
|
|
658
552
|
|
|
659
553
|
await commands.executeCommand('editor.action.goToImplementation');
|
|
660
554
|
|
|
661
|
-
const activeEditor = /** @type {MonacoEditor} */
|
|
662
|
-
assert.equal(activeEditor.uri.toString(),
|
|
663
|
-
//
|
|
664
|
-
// @ts-ignore
|
|
555
|
+
const activeEditor = /** @type {MonacoEditor} */ MonacoEditor.get(editorManager.activeEditor);
|
|
556
|
+
assert.equal(activeEditor.uri.toString(), demoFileUri.toString());
|
|
557
|
+
// class |DemoClass implements DemoInterface {
|
|
665
558
|
const { lineNumber, column } = activeEditor.getControl().getPosition();
|
|
666
|
-
assert.deepEqual({ lineNumber, column }, { lineNumber:
|
|
667
|
-
|
|
668
|
-
assert.equal(activeEditor.getControl().getModel().getWordAtPosition({ lineNumber, column }).word, 'container');
|
|
559
|
+
assert.deepEqual({ lineNumber, column }, { lineNumber: 8, column: 7 });
|
|
560
|
+
assert.equal(activeEditor.getControl().getModel().getWordAtPosition({ lineNumber, column }).word, 'DemoClass');
|
|
669
561
|
});
|
|
670
562
|
|
|
671
563
|
it('editor.action.goToTypeDefinition', async function () {
|
|
672
|
-
const editor = await openEditor(
|
|
673
|
-
//
|
|
674
|
-
editor.getControl().setPosition({ lineNumber:
|
|
675
|
-
|
|
676
|
-
assert.equal(editor.getControl().getModel().getWordAtPosition(editor.getControl().getPosition()).word, 'container');
|
|
564
|
+
const editor = await openEditor(demoFileUri);
|
|
565
|
+
// const demoVariable = demo|Instance.stringField;
|
|
566
|
+
editor.getControl().setPosition({ lineNumber: 26, column: 26 });
|
|
567
|
+
assert.equal(editor.getControl().getModel().getWordAtPosition(editor.getControl().getPosition()).word, 'demoInstance');
|
|
677
568
|
|
|
678
569
|
await commands.executeCommand('editor.action.goToTypeDefinition');
|
|
679
570
|
|
|
680
|
-
const activeEditor = /** @type {MonacoEditor} */
|
|
681
|
-
assert.equal(activeEditor.uri.toString(),
|
|
682
|
-
//
|
|
683
|
-
// @ts-ignore
|
|
571
|
+
const activeEditor = /** @type {MonacoEditor} */ MonacoEditor.get(editorManager.activeEditor);
|
|
572
|
+
assert.equal(activeEditor.uri.toString(), demoFileUri.toString());
|
|
573
|
+
// class |DemoClass implements DemoInterface {
|
|
684
574
|
const { lineNumber, column } = activeEditor.getControl().getPosition();
|
|
685
|
-
assert.deepEqual({ lineNumber, column }, { lineNumber:
|
|
686
|
-
|
|
687
|
-
assert.equal(activeEditor.getControl().getModel().getWordAtPosition({ lineNumber, column }).word, 'Container');
|
|
575
|
+
assert.deepEqual({ lineNumber, column }, { lineNumber: 8, column: 7 });
|
|
576
|
+
assert.equal(activeEditor.getControl().getModel().getWordAtPosition({ lineNumber, column }).word, 'DemoClass');
|
|
688
577
|
});
|
|
689
578
|
|
|
690
579
|
// TODO: FIXME! As of 28/01/2022 this test is failing or timing out for unknown reasons.
|
|
691
580
|
it.skip('run reference code lens', async function () {
|
|
692
581
|
this.timeout(300_000); // 5 min (give time to `tsserver` to initialize and then respond to make this test pass.)
|
|
693
|
-
// @ts-ignore
|
|
694
582
|
const globalValue = preferences.inspect('javascript.referencesCodeLens.enabled').globalValue;
|
|
695
583
|
toTearDown.push({ dispose: () => preferences.set('javascript.referencesCodeLens.enabled', globalValue, PreferenceScope.User) });
|
|
696
584
|
|
|
697
|
-
const editor = await openEditor(
|
|
585
|
+
const editor = await openEditor(demoFileUri);
|
|
698
586
|
|
|
699
587
|
/** @type any */
|
|
700
588
|
const codeLens = editor.getControl().getContribution('css.editor.codeLens');
|
|
@@ -708,7 +596,6 @@ DIV {
|
|
|
708
596
|
|
|
709
597
|
// [export ]function load(raw) {
|
|
710
598
|
const position = { lineNumber: 16, column: 1 };
|
|
711
|
-
// @ts-ignore
|
|
712
599
|
editor.getControl().getModel().applyEdits([{
|
|
713
600
|
range: Range.fromPositions(position, position),
|
|
714
601
|
forceMoveMarkers: false,
|
|
@@ -717,7 +604,6 @@ DIV {
|
|
|
717
604
|
await preferences.set('javascript.referencesCodeLens.enabled', true, PreferenceScope.User);
|
|
718
605
|
|
|
719
606
|
// Recall `applyEdits` to workaround `vscode` bug, See: https://github.com/eclipse-theia/theia/issues/9714#issuecomment-876582947.
|
|
720
|
-
// @ts-ignore
|
|
721
607
|
editor.getControl().getModel().applyEdits([{
|
|
722
608
|
range: Range.fromPositions(position, position),
|
|
723
609
|
forceMoveMarkers: false,
|
|
@@ -751,32 +637,32 @@ SPAN {
|
|
|
751
637
|
});
|
|
752
638
|
|
|
753
639
|
it('editor.action.quickFix', async function () {
|
|
754
|
-
const column =
|
|
755
|
-
const lineNumber =
|
|
756
|
-
const editor = await openEditor(
|
|
640
|
+
const column = 45;
|
|
641
|
+
const lineNumber = 26;
|
|
642
|
+
const editor = await openEditor(demoFileUri);
|
|
757
643
|
const currentChar = () => editor.getControl().getModel().getLineContent(lineNumber).charAt(column - 1);
|
|
758
644
|
|
|
759
|
-
//
|
|
645
|
+
// const demoVariable = demoInstance.stringField; --> const demoVariable = demoInstance.stringFiel;
|
|
760
646
|
editor.getControl().getModel().applyEdits([{
|
|
761
647
|
range: {
|
|
762
648
|
startLineNumber: lineNumber,
|
|
763
649
|
endLineNumber: lineNumber,
|
|
764
|
-
startColumn:
|
|
765
|
-
endColumn:
|
|
650
|
+
startColumn: 45,
|
|
651
|
+
endColumn: 46
|
|
766
652
|
},
|
|
767
653
|
forceMoveMarkers: false,
|
|
768
654
|
text: ''
|
|
769
655
|
}]);
|
|
770
656
|
editor.getControl().setPosition({ lineNumber, column });
|
|
771
657
|
editor.getControl().revealPosition({ lineNumber, column });
|
|
772
|
-
assert.equal(currentChar(), '
|
|
658
|
+
assert.equal(currentChar(), ';');
|
|
773
659
|
|
|
774
|
-
/** @type
|
|
660
|
+
/** @type {import('@theia/monaco-editor-core/src/vs/editor/contrib/codeAction/browser/codeActionCommands').QuickFixController} */
|
|
775
661
|
const quickFixController = editor.getControl().getContribution('editor.contrib.quickFixController');
|
|
776
662
|
const lightBulbNode = () => {
|
|
777
|
-
const ui = quickFixController
|
|
778
|
-
const lightBulb = ui && ui
|
|
779
|
-
return lightBulb && lightBulb
|
|
663
|
+
const ui = quickFixController['_ui'].rawValue;
|
|
664
|
+
const lightBulb = ui && ui['_lightBulbWidget'].rawValue;
|
|
665
|
+
return lightBulb && lightBulb['_domNode'];
|
|
780
666
|
};
|
|
781
667
|
const lightBulbVisible = () => {
|
|
782
668
|
const node = lightBulbNode();
|
|
@@ -787,14 +673,14 @@ SPAN {
|
|
|
787
673
|
await waitForAnimation(() => lightBulbVisible());
|
|
788
674
|
|
|
789
675
|
await commands.executeCommand('editor.action.quickFix');
|
|
790
|
-
await waitForAnimation(() => !!document.querySelector('.p-Widget.p-Menu'));
|
|
676
|
+
await waitForAnimation(() => !!document.querySelector('.p-Widget.p-Menu'), 5000);
|
|
791
677
|
await animationFrame();
|
|
792
678
|
|
|
793
679
|
keybindings.dispatchKeyDown('ArrowDown');
|
|
794
680
|
keybindings.dispatchKeyDown('Enter');
|
|
795
681
|
|
|
796
|
-
await waitForAnimation(() => currentChar() === '
|
|
797
|
-
assert.equal(currentChar(), '
|
|
682
|
+
await waitForAnimation(() => currentChar() === 'd', 5000);
|
|
683
|
+
assert.equal(currentChar(), 'd');
|
|
798
684
|
|
|
799
685
|
await waitForAnimation(() => !lightBulbVisible());
|
|
800
686
|
assert.isFalse(lightBulbVisible());
|
|
@@ -802,76 +688,63 @@ SPAN {
|
|
|
802
688
|
|
|
803
689
|
it('editor.action.formatDocument', async function () {
|
|
804
690
|
const lineNumber = 5;
|
|
805
|
-
const editor = await openEditor(
|
|
806
|
-
// @ts-ignore
|
|
691
|
+
const editor = await openEditor(demoFileUri);
|
|
807
692
|
const originalLength = editor.getControl().getModel().getLineLength(lineNumber);
|
|
808
693
|
|
|
809
|
-
//
|
|
810
|
-
// @ts-ignore
|
|
694
|
+
// doSomething(): number; --> doSomething() : number;
|
|
811
695
|
editor.getControl().getModel().applyEdits([{
|
|
812
696
|
range: Range.fromPositions({ lineNumber, column: 18 }, { lineNumber, column: 18 }),
|
|
813
697
|
forceMoveMarkers: false,
|
|
814
698
|
text: ' '
|
|
815
699
|
}]);
|
|
816
700
|
|
|
817
|
-
// @ts-ignore
|
|
818
701
|
assert.equal(editor.getControl().getModel().getLineLength(lineNumber), originalLength + 1);
|
|
819
702
|
|
|
820
703
|
await commands.executeCommand('editor.action.formatDocument');
|
|
821
704
|
|
|
822
|
-
// @ts-ignore
|
|
823
705
|
assert.equal(editor.getControl().getModel().getLineLength(lineNumber), originalLength);
|
|
824
706
|
});
|
|
825
707
|
|
|
826
708
|
it('editor.action.formatSelection', async function () {
|
|
827
|
-
|
|
828
|
-
const
|
|
829
|
-
|
|
830
|
-
const originalLength = editor.getControl().getModel().getLineLength(lineNumber);
|
|
709
|
+
// doSomething(): number {
|
|
710
|
+
const lineNumber = 15;
|
|
711
|
+
const editor = await openEditor(demoFileUri);
|
|
712
|
+
const originalLength /* 28 */ = editor.getControl().getModel().getLineLength(lineNumber);
|
|
831
713
|
|
|
832
|
-
//
|
|
833
|
-
// @ts-ignore
|
|
714
|
+
// doSomething( ) : number {
|
|
834
715
|
editor.getControl().getModel().applyEdits([{
|
|
835
|
-
range: Range.fromPositions({ lineNumber, column:
|
|
716
|
+
range: Range.fromPositions({ lineNumber, column: 17 }, { lineNumber, column: 18 }),
|
|
836
717
|
forceMoveMarkers: false,
|
|
837
|
-
text: '
|
|
718
|
+
text: ' ) '
|
|
838
719
|
}]);
|
|
839
720
|
|
|
840
|
-
|
|
841
|
-
assert.equal(editor.getControl().getModel().getLineLength(lineNumber), originalLength + 2);
|
|
721
|
+
assert.equal(editor.getControl().getModel().getLineLength(lineNumber), originalLength + 4);
|
|
842
722
|
|
|
843
723
|
// [const { Container }] = require('inversify');
|
|
844
|
-
editor.getControl().setSelection({ startLineNumber: lineNumber, startColumn: 1, endLineNumber: lineNumber, endColumn:
|
|
724
|
+
editor.getControl().setSelection({ startLineNumber: lineNumber, startColumn: 1, endLineNumber: lineNumber, endColumn: 32 });
|
|
845
725
|
|
|
846
726
|
await commands.executeCommand('editor.action.formatSelection');
|
|
847
727
|
|
|
848
728
|
// [const { Container }] = require('inversify');
|
|
849
|
-
|
|
850
|
-
assert.equal(editor.getControl().getModel().getLineLength(lineNumber), originalLength + 1);
|
|
729
|
+
assert.equal(editor.getControl().getModel().getLineLength(lineNumber), originalLength);
|
|
851
730
|
});
|
|
852
731
|
|
|
853
732
|
for (const referenceViewCommand of ['references-view.find', 'references-view.findImplementations']) {
|
|
854
733
|
it(referenceViewCommand, async function () {
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
assert.equal(editor.getControl().getModel().getWordAtPosition(editor.getControl().getPosition()).word, '
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
assert.isDefined(view);
|
|
864
|
-
return;
|
|
865
|
-
}
|
|
866
|
-
|
|
734
|
+
let steps = 0;
|
|
735
|
+
const editor = await openEditor(demoFileUri);
|
|
736
|
+
// const demo|Instance = new DemoClass('demo');
|
|
737
|
+
editor.getControl().setPosition({ lineNumber: 24, column: 11 });
|
|
738
|
+
assert.equal(editor.getControl().getModel().getWordAtPosition(editor.getControl().getPosition()).word, 'demoInstance');
|
|
739
|
+
const view = await pluginViewRegistry.openView('references-view.tree', { reveal: true });
|
|
740
|
+
assert.isDefined(view);
|
|
741
|
+
assert.isTrue(view.isVisible);
|
|
867
742
|
await commands.executeCommand('references-view.clear');
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
743
|
+
const expectedMessage = referenceViewCommand === 'references-view.find' ? '2 results in 1 file' : '1 result in 1 file';
|
|
744
|
+
const getResultText = () => view.node.getElementsByClassName('theia-TreeViewInfo').item(0)?.textContent;
|
|
871
745
|
await commands.executeCommand(referenceViewCommand);
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
assert.notEqual(view.title.label.toLowerCase(), 'results');
|
|
746
|
+
await waitForAnimation(() => getResultText() === expectedMessage, 5000);
|
|
747
|
+
assert.equal(getResultText(), expectedMessage);
|
|
875
748
|
});
|
|
876
749
|
}
|
|
877
750
|
|
|
@@ -31,7 +31,7 @@ describe('Undo, Redo and Select All', function () {
|
|
|
31
31
|
const { ApplicationShell } = require('@theia/core/lib/browser/shell/application-shell');
|
|
32
32
|
const { MonacoEditor } = require('@theia/monaco/lib/browser/monaco-editor');
|
|
33
33
|
const { ScmContribution } = require('@theia/scm/lib/browser/scm-contribution');
|
|
34
|
-
const { Range } = require('@theia/monaco-editor-core');
|
|
34
|
+
const { Range } = require('@theia/monaco-editor-core/esm/vs/editor/common/core/range');
|
|
35
35
|
|
|
36
36
|
const container = window.theia.container;
|
|
37
37
|
const editorManager = container.get(EditorManager);
|