Merge from vscode 2f984aad710215f4e4684a035bb02f55d1a9e2cc (#9819)

This commit is contained in:
Anthony Dresser
2020-04-01 00:44:39 -07:00
committed by GitHub
parent 0e27aaa61f
commit 0bfbdc62ed
247 changed files with 5402 additions and 3311 deletions

View File

@@ -566,4 +566,64 @@ suite('ExtHostTypes', function () {
assert.ok(!types.CodeActionKind.RefactorExtract.intersects(types.CodeActionKind.Empty.append('other').append('refactor')));
assert.ok(!types.CodeActionKind.RefactorExtract.intersects(types.CodeActionKind.Empty.append('refactory')));
});
function toArr(uint32Arr: Uint32Array): number[] {
const r = [];
for (let i = 0, len = uint32Arr.length; i < len; i++) {
r[i] = uint32Arr[i];
}
return r;
}
test('SemanticTokensBuilder simple', () => {
const builder = new types.SemanticTokensBuilder();
builder.push(1, 0, 5, 1, 1);
builder.push(1, 10, 4, 2, 2);
builder.push(2, 2, 3, 2, 2);
assert.deepEqual(toArr(builder.build().data), [
1, 0, 5, 1, 1,
0, 10, 4, 2, 2,
1, 2, 3, 2, 2
]);
});
test('SemanticTokensBuilder out of order 1', () => {
const builder = new types.SemanticTokensBuilder();
builder.push(2, 0, 5, 1, 1);
builder.push(2, 10, 1, 2, 2);
builder.push(2, 15, 2, 3, 3);
builder.push(1, 0, 4, 4, 4);
assert.deepEqual(toArr(builder.build().data), [
1, 0, 4, 4, 4,
1, 0, 5, 1, 1,
0, 10, 1, 2, 2,
0, 5, 2, 3, 3
]);
});
test('SemanticTokensBuilder out of order 2', () => {
const builder = new types.SemanticTokensBuilder();
builder.push(2, 10, 5, 1, 1);
builder.push(2, 2, 4, 2, 2);
assert.deepEqual(toArr(builder.build().data), [
2, 2, 4, 2, 2,
0, 8, 5, 1, 1
]);
});
test('SemanticTokensBuilder with legend', () => {
const legend = new types.SemanticTokensLegend(
['aType', 'bType', 'cType', 'dType'],
['mod0', 'mod1', 'mod2', 'mod3', 'mod4', 'mod5']
);
const builder = new types.SemanticTokensBuilder(legend);
builder.push(new types.Range(1, 0, 1, 5), 'bType');
builder.push(new types.Range(2, 0, 2, 4), 'cType', ['mod0', 'mod5']);
builder.push(new types.Range(3, 0, 3, 3), 'dType', ['mod2', 'mod4']);
assert.deepEqual(toArr(builder.build().data), [
1, 0, 5, 1, 0,
1, 0, 4, 2, 1 | (1 << 5),
1, 0, 3, 3, (1 << 2) | (1 << 4)
]);
});
});

View File

@@ -0,0 +1,110 @@
/*---------------------------------------------------------------------------------------------
* 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 { IFullSemanticTokensDto, IDeltaSemanticTokensDto, encodeSemanticTokensDto, ISemanticTokensDto, decodeSemanticTokensDto } from 'vs/workbench/api/common/shared/semanticTokensDto';
suite('SemanticTokensDto', () => {
function toArr(arr: Uint32Array): number[] {
const result: number[] = [];
for (let i = 0, len = arr.length; i < len; i++) {
result[i] = arr[i];
}
return result;
}
function assertEqualFull(actual: IFullSemanticTokensDto, expected: IFullSemanticTokensDto): void {
const convert = (dto: IFullSemanticTokensDto) => {
return {
id: dto.id,
type: dto.type,
data: toArr(dto.data)
};
};
assert.deepEqual(convert(actual), convert(expected));
}
function assertEqualDelta(actual: IDeltaSemanticTokensDto, expected: IDeltaSemanticTokensDto): void {
const convertOne = (delta: { start: number; deleteCount: number; data?: Uint32Array; }) => {
if (!delta.data) {
return delta;
}
return {
start: delta.start,
deleteCount: delta.deleteCount,
data: toArr(delta.data)
};
};
const convert = (dto: IDeltaSemanticTokensDto) => {
return {
id: dto.id,
type: dto.type,
deltas: dto.deltas.map(convertOne)
};
};
assert.deepEqual(convert(actual), convert(expected));
}
function testRoundTrip(value: ISemanticTokensDto): void {
const decoded = decodeSemanticTokensDto(encodeSemanticTokensDto(value));
if (value.type === 'full' && decoded.type === 'full') {
assertEqualFull(decoded, value);
} else if (value.type === 'delta' && decoded.type === 'delta') {
assertEqualDelta(decoded, value);
} else {
assert.fail('wrong type');
}
}
test('full encoding', () => {
testRoundTrip({
id: 12,
type: 'full',
data: new Uint32Array([(1 << 24) + (2 << 16) + (3 << 8) + 4])
});
});
test('delta encoding', () => {
testRoundTrip({
id: 12,
type: 'delta',
deltas: [{
start: 0,
deleteCount: 4,
data: undefined
}, {
start: 15,
deleteCount: 0,
data: new Uint32Array([(1 << 24) + (2 << 16) + (3 << 8) + 4])
}, {
start: 27,
deleteCount: 5,
data: new Uint32Array([(1 << 24) + (2 << 16) + (3 << 8) + 4, 1, 2, 3, 4, 5, 6, 7, 8, 9])
}]
});
});
test('partial array buffer', () => {
const sharedArr = new Uint32Array([
(1 << 24) + (2 << 16) + (3 << 8) + 4,
1, 2, 3, 4, 5, (1 << 24) + (2 << 16) + (3 << 8) + 4
]);
testRoundTrip({
id: 12,
type: 'delta',
deltas: [{
start: 0,
deleteCount: 4,
data: sharedArr.subarray(0, 1)
}, {
start: 15,
deleteCount: 0,
data: sharedArr.subarray(1, sharedArr.length)
}]
});
});
});

View File

@@ -13,7 +13,7 @@ import { ISearchService } from 'vs/workbench/services/search/common/search';
import { ITelemetryService, ITelemetryInfo } from 'vs/platform/telemetry/common/telemetry';
import { IUntitledTextEditorService, UntitledTextEditorService } from 'vs/workbench/services/untitled/common/untitledTextEditorService';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import * as minimist from 'vscode-minimist';
import * as minimist from 'minimist';
import * as path from 'vs/base/common/path';
import { LocalSearchService } from 'vs/workbench/services/search/node/searchService';
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';

View File

@@ -27,7 +27,7 @@ import { IReadTextFileOptions, ITextFileStreamContent, ITextFileService } from '
import { createTextBufferFactoryFromStream } from 'vs/editor/common/model/textModel';
import { IOpenedWindow, IOpenEmptyWindowOptions, IWindowOpenable, IOpenWindowOptions } from 'vs/platform/windows/common/windows';
import { parseArgs, OPTIONS } from 'vs/platform/environment/node/argv';
import { LogLevel } from 'vs/platform/log/common/log';
import { LogLevel, ILogService } from 'vs/platform/log/common/log';
import { IRemotePathService } from 'vs/workbench/services/path/common/remotePathService';
import { IWorkingCopyFileService } from 'vs/workbench/services/workingCopy/common/workingCopyFileService';
import { UTF16le, UTF16be, UTF8_with_bom } from 'vs/base/node/encoding';
@@ -74,7 +74,8 @@ export class TestTextFileService extends NativeTextFileService {
@ITextModelService textModelService: ITextModelService,
@ICodeEditorService codeEditorService: ICodeEditorService,
@IRemotePathService remotePathService: IRemotePathService,
@IWorkingCopyFileService workingCopyFileService: IWorkingCopyFileService
@IWorkingCopyFileService workingCopyFileService: IWorkingCopyFileService,
@ILogService logService: ILogService
) {
super(
fileService,
@@ -91,7 +92,8 @@ export class TestTextFileService extends NativeTextFileService {
textModelService,
codeEditorService,
remotePathService,
workingCopyFileService
workingCopyFileService,
logService
);
}