Merge from vscode 0a7364f00514c46c9caceece15e1f82f82e3712f

This commit is contained in:
ADS Merger
2020-07-22 03:06:57 +00:00
parent 53ec7585a9
commit 1b7b54ce14
229 changed files with 5099 additions and 3188 deletions

View File

@@ -47,6 +47,7 @@ import 'vs/editor/contrib/links/getLinks';
import 'vs/editor/contrib/parameterHints/provideSignatureHelp';
import 'vs/editor/contrib/smartSelect/smartSelect';
import 'vs/editor/contrib/suggest/suggest';
import 'vs/editor/contrib/rename/rename';
const defaultSelector = { scheme: 'far' };
const model: ITextModel = createTextModel(
@@ -232,6 +233,27 @@ suite('ExtHostLanguageFeatureCommands', function () {
});
// --- rename
test('vscode.executeDocumentRenameProvider', async function () {
disposables.push(extHost.registerRenameProvider(nullExtensionDescription, defaultSelector, new class implements vscode.RenameProvider {
provideRenameEdits(document: vscode.TextDocument, position: vscode.Position, newName: string) {
const edit = new types.WorkspaceEdit();
edit.insert(document.uri, <types.Position>position, newName);
return edit;
}
}));
await rpcProtocol.sync();
const edit = await commands.executeCommand<vscode.WorkspaceEdit>('vscode.executeDocumentRenameProvider', model.uri, new types.Position(0, 12), 'newNameOfThis');
assert.ok(edit);
assert.equal(edit.has(model.uri), true);
const textEdits = edit.get(model.uri);
assert.equal(textEdits.length, 1);
assert.equal(textEdits[0].newText, 'newNameOfThis');
});
// --- definition
test('Definition, invalid arguments', function () {

View File

@@ -0,0 +1,151 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as assert from 'assert';
import { ExtHostDocumentsAndEditors } from 'vs/workbench/api/common/extHostDocumentsAndEditors';
import { TestRPCProtocol } from 'vs/workbench/test/browser/api/testRPCProtocol';
import { DisposableStore } from 'vs/base/common/lifecycle';
import { NullLogService } from 'vs/platform/log/common/log';
import { mock } from 'vs/base/test/common/mock';
import { MainThreadNotebookShape } from 'vs/workbench/api/common/extHost.protocol';
import { ExtHostNotebookDocument, ExtHostCell } from 'vs/workbench/api/common/extHostNotebook';
import { CellKind } from 'vs/workbench/contrib/notebook/common/notebookCommon';
import { URI } from 'vs/base/common/uri';
import { ExtHostDocuments } from 'vs/workbench/api/common/extHostDocuments';
suite('NotebookCell', function () {
let rpcProtocol: TestRPCProtocol;
let extHostDocumentsAndEditors: ExtHostDocumentsAndEditors;
const disposables = new DisposableStore();
const fakeNotebookProxy = new class extends mock<MainThreadNotebookShape>() { };
const fakeNotebook = new class extends mock<ExtHostNotebookDocument>() { };
setup(async function () {
disposables.clear();
rpcProtocol = new TestRPCProtocol();
extHostDocumentsAndEditors = new ExtHostDocumentsAndEditors(rpcProtocol, new NullLogService());
});
test('Document is real', function () {
const dto = {
cellKind: CellKind.Code,
eol: '\n',
source: ['aaaa', 'bbbb', 'cccc'],
handle: 0,
language: 'fooLang',
outputs: [],
uri: URI.parse('test:/path')
};
const cell = new ExtHostCell(fakeNotebookProxy, fakeNotebook, extHostDocumentsAndEditors, dto);
assert.ok(cell.document);
assert.strictEqual(cell.document.version, 0);
assert.strictEqual(cell.document.languageId, dto.language);
assert.strictEqual(cell.document.uri.toString(), dto.uri.toString());
assert.strictEqual(cell.uri.toString(), dto.uri.toString());
});
test('Document is uses actual document when possible', function () {
const dto = {
cellKind: CellKind.Code,
eol: '\n',
source: ['aaaa', 'bbbb', 'cccc'],
handle: 0,
language: 'fooLang',
outputs: [],
uri: URI.parse('test:/path')
};
const cell = new ExtHostCell(fakeNotebookProxy, fakeNotebook, extHostDocumentsAndEditors, dto);
// this is the "default document" which is used when the real
// document isn't open
const documentNow = cell.document;
extHostDocumentsAndEditors.$acceptDocumentsAndEditorsDelta({
addedDocuments: [{
isDirty: false,
versionId: 12,
modeId: dto.language,
uri: dto.uri,
lines: dto.source,
EOL: dto.eol
}]
});
// the real document
assert.ok(documentNow !== cell.document);
assert.strictEqual(cell.document.languageId, dto.language);
assert.strictEqual(cell.document.uri.toString(), dto.uri.toString());
assert.strictEqual(cell.uri.toString(), dto.uri.toString());
// back to "default document"
extHostDocumentsAndEditors.$acceptDocumentsAndEditorsDelta({ removedDocuments: [dto.uri] });
assert.ok(documentNow === cell.document);
});
test('Document can change language (1/2)', function () {
const dto = {
cellKind: CellKind.Code,
eol: '\n',
source: ['aaaa', 'bbbb', 'cccc'],
handle: 0,
language: 'fooLang',
outputs: [],
uri: URI.parse('test:/path')
};
const cell = new ExtHostCell(fakeNotebookProxy, fakeNotebook, extHostDocumentsAndEditors, dto);
assert.strictEqual(cell.document.languageId, dto.language);
cell.defaultDocument._acceptLanguageId('barLang');
assert.strictEqual(cell.document.languageId, 'barLang');
});
test('Document can change language (1/2)', function () {
const dto = {
cellKind: CellKind.Code,
eol: '\n',
source: ['aaaa', 'bbbb', 'cccc'],
handle: 0,
language: 'fooLang',
outputs: [],
uri: URI.parse('test:/path')
};
extHostDocumentsAndEditors.$acceptDocumentsAndEditorsDelta({
addedDocuments: [{
isDirty: false,
versionId: 12,
modeId: dto.language,
uri: dto.uri,
lines: dto.source,
EOL: dto.eol
}]
});
const extHostDocuments = new ExtHostDocuments(rpcProtocol, extHostDocumentsAndEditors);
const cell = new ExtHostCell(fakeNotebookProxy, fakeNotebook, extHostDocumentsAndEditors, dto);
// a real document already exists and therefore
// the "default document" doesn't count
assert.strictEqual(cell.document.languageId, dto.language);
cell.defaultDocument._acceptLanguageId('barLang');
assert.strictEqual(cell.document.languageId, dto.language);
extHostDocuments.$acceptModelModeChanged(dto.uri, dto.language, 'barLang');
assert.strictEqual(cell.document.languageId, 'barLang');
});
});

View File

@@ -57,6 +57,7 @@ suite('NotebookConcatDocument', function () {
handle: 0,
uri: CellUri.generate(notebookUri, 0),
source: ['### Heading'],
eol: '\n',
language: 'markdown',
cellKind: CellKind.Markdown,
outputs: [],
@@ -123,6 +124,7 @@ suite('NotebookConcatDocument', function () {
handle: 1,
uri: cellUri1,
source: ['Hello', 'World', 'Hello World!'],
eol: '\n',
language: 'test',
cellKind: CellKind.Code,
outputs: [],
@@ -130,6 +132,7 @@ suite('NotebookConcatDocument', function () {
handle: 2,
uri: cellUri2,
source: ['Hallo', 'Welt', 'Hallo Welt!'],
eol: '\n',
language: 'test',
cellKind: CellKind.Code,
outputs: [],
@@ -155,6 +158,7 @@ suite('NotebookConcatDocument', function () {
handle: 1,
uri: CellUri.generate(notebook.uri, 1),
source: ['Hello', 'World', 'Hello World!'],
eol: '\n',
language: 'test',
cellKind: CellKind.Code,
outputs: [],
@@ -162,6 +166,7 @@ suite('NotebookConcatDocument', function () {
handle: 2,
uri: CellUri.generate(notebook.uri, 2),
source: ['Hallo', 'Welt', 'Hallo Welt!'],
eol: '\n',
language: 'test',
cellKind: CellKind.Code,
outputs: [],
@@ -194,6 +199,7 @@ suite('NotebookConcatDocument', function () {
handle: 1,
uri: CellUri.generate(notebook.uri, 1),
source: ['Hello', 'World', 'Hello World!'],
eol: '\n',
language: 'test',
cellKind: CellKind.Code,
outputs: [],
@@ -216,6 +222,7 @@ suite('NotebookConcatDocument', function () {
handle: 2,
uri: CellUri.generate(notebook.uri, 2),
source: ['Hallo', 'Welt', 'Hallo Welt!'],
eol: '\n',
language: 'test',
cellKind: CellKind.Code,
outputs: [],
@@ -257,6 +264,7 @@ suite('NotebookConcatDocument', function () {
handle: 1,
uri: CellUri.generate(notebook.uri, 1),
source: ['Hello', 'World', 'Hello World!'],
eol: '\n',
language: 'test',
cellKind: CellKind.Code,
outputs: [],
@@ -264,6 +272,7 @@ suite('NotebookConcatDocument', function () {
handle: 2,
uri: CellUri.generate(notebook.uri, 2),
source: ['Hallo', 'Welt', 'Hallo Welt!'],
eol: '\n',
language: 'test',
cellKind: CellKind.Code,
outputs: [],
@@ -320,6 +329,7 @@ suite('NotebookConcatDocument', function () {
handle: 1,
uri: CellUri.generate(notebook.uri, 1),
source: ['fooLang-document'],
eol: '\n',
language: 'fooLang',
cellKind: CellKind.Code,
outputs: [],
@@ -327,6 +337,7 @@ suite('NotebookConcatDocument', function () {
handle: 2,
uri: CellUri.generate(notebook.uri, 2),
source: ['barLang-document'],
eol: '\n',
language: 'barLang',
cellKind: CellKind.Code,
outputs: [],
@@ -348,6 +359,7 @@ suite('NotebookConcatDocument', function () {
handle: 3,
uri: CellUri.generate(notebook.uri, 3),
source: ['barLang-document2'],
eol: '\n',
language: 'barLang',
cellKind: CellKind.Code,
outputs: [],
@@ -381,6 +393,7 @@ suite('NotebookConcatDocument', function () {
handle: 1,
uri: CellUri.generate(notebook.uri, 1),
source: ['Hello', 'World', 'Hello World!'],
eol: '\n',
language: 'test',
cellKind: CellKind.Code,
outputs: [],
@@ -388,6 +401,7 @@ suite('NotebookConcatDocument', function () {
handle: 2,
uri: CellUri.generate(notebook.uri, 2),
source: ['Hallo', 'Welt', 'Hallo Welt!'],
eol: '\n',
language: 'test',
cellKind: CellKind.Code,
outputs: [],
@@ -432,6 +446,7 @@ suite('NotebookConcatDocument', function () {
handle: 1,
uri: CellUri.generate(notebook.uri, 1),
source: ['Hello', 'World', 'Hello World!'],
eol: '\n',
language: 'test',
cellKind: CellKind.Code,
outputs: [],
@@ -439,6 +454,7 @@ suite('NotebookConcatDocument', function () {
handle: 2,
uri: CellUri.generate(notebook.uri, 2),
source: ['Hallo', 'Welt', 'Hallo Welt!'],
eol: '\n',
language: 'test',
cellKind: CellKind.Code,
outputs: [],
@@ -467,6 +483,7 @@ suite('NotebookConcatDocument', function () {
handle: 1,
uri: CellUri.generate(notebook.uri, 1),
source: ['Hello', 'World', 'Hello World!'],
eol: '\n',
language: 'test',
cellKind: CellKind.Code,
outputs: [],
@@ -474,6 +491,7 @@ suite('NotebookConcatDocument', function () {
handle: 2,
uri: CellUri.generate(notebook.uri, 2),
source: ['Hallo', 'Welt', 'Hallo Welt!'],
eol: '\n',
language: 'test',
cellKind: CellKind.Code,
outputs: [],
@@ -499,6 +517,7 @@ suite('NotebookConcatDocument', function () {
handle: 1,
uri: CellUri.generate(notebook.uri, 1),
source: ['Hello', 'World', 'Hello World!'],
eol: '\n',
language: 'test',
cellKind: CellKind.Code,
outputs: [],
@@ -506,6 +525,7 @@ suite('NotebookConcatDocument', function () {
handle: 2,
uri: CellUri.generate(notebook.uri, 2),
source: ['Hallo', 'Welt', 'Hallo Welt!'],
eol: '\n',
language: 'test',
cellKind: CellKind.Code,
outputs: [],