mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-11 18:48:33 -05:00
Merge from vscode 8e0f348413f4f616c23a88ae30030efa85811973 (#6381)
* Merge from vscode 8e0f348413f4f616c23a88ae30030efa85811973 * disable strict null check
This commit is contained in:
@@ -16,10 +16,8 @@ import { ICommandService, CommandsRegistry } from 'vs/platform/commands/common/c
|
||||
import { IModelService } from 'vs/editor/common/services/modelService';
|
||||
import { ExtHostLanguageFeatures } from 'vs/workbench/api/common/extHostLanguageFeatures';
|
||||
import { MainThreadLanguageFeatures } from 'vs/workbench/api/browser/mainThreadLanguageFeatures';
|
||||
import { IHeapService, NullHeapService } from 'vs/workbench/services/heap/common/heap';
|
||||
import { ExtHostApiCommands } from 'vs/workbench/api/common/extHostApiCommands';
|
||||
import { ExtHostCommands } from 'vs/workbench/api/common/extHostCommands';
|
||||
import { ExtHostHeapService } from 'vs/workbench/api/common/extHostHeapService';
|
||||
import { MainThreadCommands } from 'vs/workbench/api/browser/mainThreadCommands';
|
||||
import { ExtHostDocuments } from 'vs/workbench/api/common/extHostDocuments';
|
||||
import { ExtHostDocumentsAndEditors } from 'vs/workbench/api/common/extHostDocumentsAndEditors';
|
||||
@@ -67,14 +65,14 @@ suite('ExtHostLanguageFeatureCommands', function () {
|
||||
{
|
||||
let instantiationService = new TestInstantiationService();
|
||||
rpcProtocol = new TestRPCProtocol();
|
||||
instantiationService.stub(IHeapService, NullHeapService);
|
||||
instantiationService.stub(ICommandService, {
|
||||
_serviceBrand: undefined,
|
||||
executeCommand(id: string, args: any): any {
|
||||
if (!CommandsRegistry.getCommands()[id]) {
|
||||
const command = CommandsRegistry.getCommands().get(id);
|
||||
if (!command) {
|
||||
return Promise.reject(new Error(id + ' NOT known'));
|
||||
}
|
||||
let { handler } = CommandsRegistry.getCommands()[id];
|
||||
const { handler } = command;
|
||||
return Promise.resolve(instantiationService.invokeFunction(handler, args));
|
||||
}
|
||||
});
|
||||
@@ -109,9 +107,7 @@ suite('ExtHostLanguageFeatureCommands', function () {
|
||||
const extHostDocuments = new ExtHostDocuments(rpcProtocol, extHostDocumentsAndEditors);
|
||||
rpcProtocol.set(ExtHostContext.ExtHostDocuments, extHostDocuments);
|
||||
|
||||
const heapService = new ExtHostHeapService();
|
||||
|
||||
commands = new ExtHostCommands(rpcProtocol, heapService, new NullLogService());
|
||||
commands = new ExtHostCommands(rpcProtocol, new NullLogService());
|
||||
rpcProtocol.set(ExtHostContext.ExtHostCommands, commands);
|
||||
rpcProtocol.set(MainContext.MainThreadCommands, inst.createInstance(MainThreadCommands, rpcProtocol));
|
||||
ExtHostApiCommands.register(commands);
|
||||
@@ -119,7 +115,7 @@ suite('ExtHostLanguageFeatureCommands', function () {
|
||||
const diagnostics = new ExtHostDiagnostics(rpcProtocol);
|
||||
rpcProtocol.set(ExtHostContext.ExtHostDiagnostics, diagnostics);
|
||||
|
||||
extHost = new ExtHostLanguageFeatures(rpcProtocol, null, extHostDocuments, commands, heapService, diagnostics, new NullLogService());
|
||||
extHost = new ExtHostLanguageFeatures(rpcProtocol, null, extHostDocuments, commands, diagnostics, new NullLogService());
|
||||
rpcProtocol.set(ExtHostContext.ExtHostLanguageFeatures, extHost);
|
||||
|
||||
mainThread = rpcProtocol.set(MainContext.MainThreadLanguageFeatures, inst.createInstance(MainThreadLanguageFeatures, rpcProtocol));
|
||||
@@ -801,9 +797,9 @@ suite('ExtHostLanguageFeatureCommands', function () {
|
||||
}));
|
||||
|
||||
await rpcProtocol.sync();
|
||||
let value = await commands.executeCommand<vscode.SelectionRange[][]>('vscode.executeSelectionRangeProvider', model.uri, [new types.Position(0, 10)]);
|
||||
let value = await commands.executeCommand<vscode.SelectionRange[]>('vscode.executeSelectionRangeProvider', model.uri, [new types.Position(0, 10)]);
|
||||
assert.equal(value.length, 1);
|
||||
assert.ok(value[0].length >= 2);
|
||||
assert.ok(value[0].parent);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -26,7 +26,7 @@ suite('ExtHostCommands', function () {
|
||||
}
|
||||
};
|
||||
|
||||
const commands = new ExtHostCommands(SingleProxyRPCProtocol(shape), undefined!, new NullLogService());
|
||||
const commands = new ExtHostCommands(SingleProxyRPCProtocol(shape), new NullLogService());
|
||||
commands.registerCommand(true, 'foo', (): any => { }).dispose();
|
||||
assert.equal(lastUnregister!, 'foo');
|
||||
assert.equal(CommandsRegistry.getCommand('foo'), undefined);
|
||||
@@ -46,7 +46,7 @@ suite('ExtHostCommands', function () {
|
||||
}
|
||||
};
|
||||
|
||||
const commands = new ExtHostCommands(SingleProxyRPCProtocol(shape), undefined!, new NullLogService());
|
||||
const commands = new ExtHostCommands(SingleProxyRPCProtocol(shape), new NullLogService());
|
||||
const reg = commands.registerCommand(true, 'foo', (): any => { });
|
||||
reg.dispose();
|
||||
reg.dispose();
|
||||
|
||||
@@ -40,7 +40,7 @@ suite('ExtHostConfiguration', function () {
|
||||
user: new ConfigurationModel(contents),
|
||||
workspace: new ConfigurationModel(),
|
||||
folders: Object.create(null),
|
||||
configurationScopes: {}
|
||||
configurationScopes: []
|
||||
};
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ suite('ExtHostConfiguration', function () {
|
||||
|
||||
testObject = all.getConfiguration('workbench');
|
||||
actual = testObject.get('colorCustomizations')!;
|
||||
delete actual['statusBar.foreground'];
|
||||
actual['statusBar.foreground'] = undefined;
|
||||
assert.equal(actual['statusBar.foreground'], undefined);
|
||||
testObject = all.getConfiguration('workbench');
|
||||
actual = testObject.get('colorCustomizations')!;
|
||||
@@ -278,7 +278,7 @@ suite('ExtHostConfiguration', function () {
|
||||
}, ['editor.wordWrap']),
|
||||
workspace: new ConfigurationModel({}, []),
|
||||
folders: Object.create(null),
|
||||
configurationScopes: {}
|
||||
configurationScopes: []
|
||||
}
|
||||
);
|
||||
|
||||
@@ -326,7 +326,7 @@ suite('ExtHostConfiguration', function () {
|
||||
}, ['editor.wordWrap']),
|
||||
workspace,
|
||||
folders,
|
||||
configurationScopes: {}
|
||||
configurationScopes: []
|
||||
}
|
||||
);
|
||||
|
||||
@@ -402,7 +402,7 @@ suite('ExtHostConfiguration', function () {
|
||||
}, ['editor.wordWrap']),
|
||||
workspace,
|
||||
folders,
|
||||
configurationScopes: {}
|
||||
configurationScopes: []
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@@ -91,18 +91,18 @@ suite('ExtHostDiagnostics', () => {
|
||||
new Diagnostic(new Range(0, 0, 1, 1), 'message-2')
|
||||
]);
|
||||
|
||||
let array = collection.get(URI.parse('foo:bar'));
|
||||
let array = collection.get(URI.parse('foo:bar')) as Diagnostic[];
|
||||
assert.throws(() => array.length = 0);
|
||||
assert.throws(() => array.pop());
|
||||
assert.throws(() => array[0] = new Diagnostic(new Range(0, 0, 0, 0), 'evil'));
|
||||
|
||||
collection.forEach((uri, array) => {
|
||||
collection.forEach((uri, array: Diagnostic[]) => {
|
||||
assert.throws(() => array.length = 0);
|
||||
assert.throws(() => array.pop());
|
||||
assert.throws(() => array[0] = new Diagnostic(new Range(0, 0, 0, 0), 'evil'));
|
||||
});
|
||||
|
||||
array = collection.get(URI.parse('foo:bar'));
|
||||
array = collection.get(URI.parse('foo:bar')) as Diagnostic[];
|
||||
assert.equal(array.length, 2);
|
||||
|
||||
collection.dispose();
|
||||
|
||||
@@ -85,7 +85,7 @@ suite('ExtHostDocumentSaveParticipant', () => {
|
||||
sub.dispose();
|
||||
|
||||
assert.ok(event);
|
||||
assert.throws(() => { event.document = null!; });
|
||||
assert.throws(() => { (event.document as any) = null!; });
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@ import { ExtHostLanguageFeatures } from 'vs/workbench/api/common/extHostLanguage
|
||||
import { MainThreadLanguageFeatures } from 'vs/workbench/api/browser/mainThreadLanguageFeatures';
|
||||
import { ExtHostCommands } from 'vs/workbench/api/common/extHostCommands';
|
||||
import { MainThreadCommands } from 'vs/workbench/api/browser/mainThreadCommands';
|
||||
import { IHeapService, NullHeapService } from 'vs/workbench/services/heap/common/heap';
|
||||
import { ExtHostDocuments } from 'vs/workbench/api/common/extHostDocuments';
|
||||
import { ExtHostDocumentsAndEditors } from 'vs/workbench/api/common/extHostDocumentsAndEditors';
|
||||
import { getDocumentSymbols } from 'vs/editor/contrib/quickOpen/quickOpen';
|
||||
@@ -37,7 +36,6 @@ import { getDocumentFormattingEditsUntilResult, getDocumentRangeFormattingEditsU
|
||||
import { getLinks } from 'vs/editor/contrib/links/getLinks';
|
||||
import { MainContext, ExtHostContext } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { ExtHostDiagnostics } from 'vs/workbench/api/common/extHostDiagnostics';
|
||||
import { ExtHostHeapService } from 'vs/workbench/api/common/extHostHeapService';
|
||||
import * as vscode from 'vscode';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { NullLogService } from 'vs/platform/log/common/log';
|
||||
@@ -81,7 +79,6 @@ suite('ExtHostLanguageFeatures', function () {
|
||||
{
|
||||
let instantiationService = new TestInstantiationService();
|
||||
instantiationService.stub(IMarkerService, MarkerService);
|
||||
instantiationService.stub(IHeapService, NullHeapService);
|
||||
inst = instantiationService;
|
||||
}
|
||||
|
||||
@@ -102,16 +99,14 @@ suite('ExtHostLanguageFeatures', function () {
|
||||
const extHostDocuments = new ExtHostDocuments(rpcProtocol, extHostDocumentsAndEditors);
|
||||
rpcProtocol.set(ExtHostContext.ExtHostDocuments, extHostDocuments);
|
||||
|
||||
const heapService = new ExtHostHeapService();
|
||||
|
||||
const commands = new ExtHostCommands(rpcProtocol, heapService, new NullLogService());
|
||||
const commands = new ExtHostCommands(rpcProtocol, new NullLogService());
|
||||
rpcProtocol.set(ExtHostContext.ExtHostCommands, commands);
|
||||
rpcProtocol.set(MainContext.MainThreadCommands, inst.createInstance(MainThreadCommands, rpcProtocol));
|
||||
|
||||
const diagnostics = new ExtHostDiagnostics(rpcProtocol);
|
||||
rpcProtocol.set(ExtHostContext.ExtHostDiagnostics, diagnostics);
|
||||
|
||||
extHost = new ExtHostLanguageFeatures(rpcProtocol, null, extHostDocuments, commands, heapService, diagnostics, new NullLogService());
|
||||
extHost = new ExtHostLanguageFeatures(rpcProtocol, null, extHostDocuments, commands, diagnostics, new NullLogService());
|
||||
rpcProtocol.set(ExtHostContext.ExtHostLanguageFeatures, extHost);
|
||||
|
||||
mainThread = rpcProtocol.set(MainContext.MainThreadLanguageFeatures, inst.createInstance(MainThreadLanguageFeatures, rpcProtocol));
|
||||
@@ -194,7 +189,7 @@ suite('ExtHostLanguageFeatures', function () {
|
||||
|
||||
await rpcProtocol.sync();
|
||||
const value = await getCodeLensData(model, CancellationToken.None);
|
||||
assert.equal(value.length, 1);
|
||||
assert.equal(value.lenses.length, 1);
|
||||
});
|
||||
|
||||
test('CodeLens, do not resolve a resolved lens', async () => {
|
||||
@@ -212,8 +207,8 @@ suite('ExtHostLanguageFeatures', function () {
|
||||
|
||||
await rpcProtocol.sync();
|
||||
const value = await getCodeLensData(model, CancellationToken.None);
|
||||
assert.equal(value.length, 1);
|
||||
const data = value[0];
|
||||
assert.equal(value.lenses.length, 1);
|
||||
const [data] = value.lenses;
|
||||
const symbol = await Promise.resolve(data.provider.resolveCodeLens!(model, data.symbol, CancellationToken.None));
|
||||
assert.equal(symbol!.command!.id, 'id');
|
||||
assert.equal(symbol!.command!.title, 'Title');
|
||||
@@ -229,8 +224,8 @@ suite('ExtHostLanguageFeatures', function () {
|
||||
|
||||
await rpcProtocol.sync();
|
||||
const value = await getCodeLensData(model, CancellationToken.None);
|
||||
assert.equal(value.length, 1);
|
||||
let data = value[0];
|
||||
assert.equal(value.lenses.length, 1);
|
||||
let [data] = value.lenses;
|
||||
const symbol = await Promise.resolve(data.provider.resolveCodeLens!(model, data.symbol, CancellationToken.None));
|
||||
assert.equal(symbol!.command!.id, 'missing');
|
||||
assert.equal(symbol!.command!.title, '!!MISSING: command!!');
|
||||
@@ -1041,7 +1036,9 @@ suite('ExtHostLanguageFeatures', function () {
|
||||
|
||||
disposables.push(extHost.registerDocumentLinkProvider(defaultExtension, defaultSelector, new class implements vscode.DocumentLinkProvider {
|
||||
provideDocumentLinks() {
|
||||
return [new types.DocumentLink(new types.Range(0, 0, 1, 1), URI.parse('foo:bar#3'))];
|
||||
const link = new types.DocumentLink(new types.Range(0, 0, 1, 1), URI.parse('foo:bar#3'));
|
||||
link.tooltip = 'tooltip';
|
||||
return [link];
|
||||
}
|
||||
}));
|
||||
|
||||
@@ -1051,6 +1048,7 @@ suite('ExtHostLanguageFeatures', function () {
|
||||
let [first] = links;
|
||||
assert.equal(first.url, 'foo:bar#3');
|
||||
assert.deepEqual(first.range, { startLineNumber: 1, startColumn: 1, endLineNumber: 2, endColumn: 2 });
|
||||
assert.equal(first.tooltip, 'tooltip');
|
||||
});
|
||||
|
||||
test('Links, evil provider', async () => {
|
||||
|
||||
@@ -6,9 +6,11 @@
|
||||
import * as assert from 'assert';
|
||||
import { MainThreadMessageService } from 'vs/workbench/api/browser/mainThreadMessageService';
|
||||
import { IDialogService } from 'vs/platform/dialogs/common/dialogs';
|
||||
import { INotificationService, INotification, NoOpNotification, INotificationHandle, Severity, IPromptChoice, IPromptOptions } from 'vs/platform/notification/common/notification';
|
||||
import { INotificationService, INotification, NoOpNotification, INotificationHandle, Severity, IPromptChoice, IPromptOptions, IStatusMessageOptions } from 'vs/platform/notification/common/notification';
|
||||
import { ICommandService } from 'vs/platform/commands/common/commands';
|
||||
import { mock } from 'vs/workbench/test/electron-browser/api/mock';
|
||||
import { ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IDisposable, Disposable } from 'vs/base/common/lifecycle';
|
||||
|
||||
const emptyDialogService = new class implements IDialogService {
|
||||
_serviceBrand: 'dialogService';
|
||||
@@ -30,7 +32,7 @@ const emptyCommandService: ICommandService = {
|
||||
};
|
||||
|
||||
const emptyNotificationService = new class implements INotificationService {
|
||||
_serviceBrand: 'notificiationService';
|
||||
_serviceBrand: ServiceIdentifier<INotificationService>;
|
||||
notify(...args: any[]): never {
|
||||
throw new Error('not implemented');
|
||||
}
|
||||
@@ -46,11 +48,13 @@ const emptyNotificationService = new class implements INotificationService {
|
||||
prompt(severity: Severity, message: string, choices: IPromptChoice[], options?: IPromptOptions): INotificationHandle {
|
||||
throw new Error('not implemented');
|
||||
}
|
||||
status(message: string | Error, options?: IStatusMessageOptions): IDisposable {
|
||||
return Disposable.None;
|
||||
}
|
||||
};
|
||||
|
||||
class EmptyNotificationService implements INotificationService {
|
||||
|
||||
_serviceBrand: any;
|
||||
_serviceBrand: ServiceIdentifier<INotificationService>;
|
||||
|
||||
constructor(private withNotify: (notification: INotification) => void) {
|
||||
}
|
||||
@@ -72,6 +76,9 @@ class EmptyNotificationService implements INotificationService {
|
||||
prompt(severity: Severity, message: string, choices: IPromptChoice[], options?: IPromptOptions): INotificationHandle {
|
||||
throw new Error('not implemented');
|
||||
}
|
||||
status(message: string, options?: IStatusMessageOptions): IDisposable {
|
||||
return Disposable.None;
|
||||
}
|
||||
}
|
||||
|
||||
suite('ExtHostMessageService', function () {
|
||||
|
||||
@@ -7,7 +7,7 @@ import * as assert from 'assert';
|
||||
import { mapArrayOrNot } from 'vs/base/common/arrays';
|
||||
import { CancellationTokenSource } from 'vs/base/common/cancellation';
|
||||
import { isPromiseCanceledError } from 'vs/base/common/errors';
|
||||
import { dispose } from 'vs/base/common/lifecycle';
|
||||
import { DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { joinPath } from 'vs/base/common/resources';
|
||||
import { URI, UriComponents } from 'vs/base/common/uri';
|
||||
import * as pfs from 'vs/base/node/pfs';
|
||||
@@ -16,12 +16,12 @@ import { ExtHostSearch } from 'vs/workbench/api/node/extHostSearch';
|
||||
import { Range } from 'vs/workbench/api/common/extHostTypes';
|
||||
import { IFileMatch, IFileQuery, IPatternInfo, IRawFileMatch2, ISearchCompleteStats, ISearchQuery, ITextQuery, QueryType, resultIsMatch } from 'vs/workbench/services/search/common/search';
|
||||
import { TestRPCProtocol } from 'vs/workbench/test/electron-browser/api/testRPCProtocol';
|
||||
import { TestLogService } from 'vs/workbench/test/workbenchTestServices';
|
||||
import * as vscode from 'vscode';
|
||||
import { NullLogService } from 'vs/platform/log/common/log';
|
||||
|
||||
let rpcProtocol: TestRPCProtocol;
|
||||
let extHostSearch: ExtHostSearch;
|
||||
let disposables: vscode.Disposable[] = [];
|
||||
const disposables = new DisposableStore();
|
||||
|
||||
let mockMainThreadSearch: MockMainThreadSearch;
|
||||
class MockMainThreadSearch implements MainThreadSearchShape {
|
||||
@@ -63,12 +63,12 @@ export function extensionResultIsMatch(data: vscode.TextSearchResult): data is v
|
||||
|
||||
suite('ExtHostSearch', () => {
|
||||
async function registerTestTextSearchProvider(provider: vscode.TextSearchProvider, scheme = 'file'): Promise<void> {
|
||||
disposables.push(extHostSearch.registerTextSearchProvider(scheme, provider));
|
||||
disposables.add(extHostSearch.registerTextSearchProvider(scheme, provider));
|
||||
await rpcProtocol.sync();
|
||||
}
|
||||
|
||||
async function registerTestFileSearchProvider(provider: vscode.FileSearchProvider, scheme = 'file'): Promise<void> {
|
||||
disposables.push(extHostSearch.registerFileSearchProvider(scheme, provider));
|
||||
disposables.add(extHostSearch.registerFileSearchProvider(scheme, provider));
|
||||
await rpcProtocol.sync();
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ suite('ExtHostSearch', () => {
|
||||
rpcProtocol = new TestRPCProtocol();
|
||||
|
||||
mockMainThreadSearch = new MockMainThreadSearch();
|
||||
const logService = new TestLogService();
|
||||
const logService = new NullLogService();
|
||||
|
||||
rpcProtocol.set(MainContext.MainThreadSearch, mockMainThreadSearch);
|
||||
|
||||
@@ -139,7 +139,7 @@ suite('ExtHostSearch', () => {
|
||||
});
|
||||
|
||||
teardown(() => {
|
||||
dispose(disposables);
|
||||
disposables.clear();
|
||||
return rpcProtocol.sync();
|
||||
});
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@ import { ExtHostCommands } from 'vs/workbench/api/common/extHostCommands';
|
||||
import { MainThreadTreeViewsShape, MainContext } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { TreeDataProvider, TreeItem } from 'vscode';
|
||||
import { TestRPCProtocol } from './testRPCProtocol';
|
||||
import { ExtHostHeapService } from 'vs/workbench/api/common/extHostHeapService';
|
||||
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
|
||||
import { MainThreadCommands } from 'vs/workbench/api/browser/mainThreadCommands';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
@@ -72,7 +71,7 @@ suite('ExtHostTreeView', function () {
|
||||
|
||||
rpcProtocol.set(MainContext.MainThreadCommands, inst.createInstance(MainThreadCommands, rpcProtocol));
|
||||
target = new RecordingShape();
|
||||
testObject = new ExtHostTreeViews(target, new ExtHostCommands(rpcProtocol, new ExtHostHeapService(), new NullLogService()), new NullLogService());
|
||||
testObject = new ExtHostTreeViews(target, new ExtHostCommands(rpcProtocol, new NullLogService()), new NullLogService());
|
||||
onDidChangeTreeNode = new Emitter<{ key: string }>();
|
||||
onDidChangeTreeNodeWithId = new Emitter<{ key: string }>();
|
||||
testObject.createTreeView('testNodeTreeProvider', { treeDataProvider: aNodeTreeDataProvider() }, { enableProposedApi: true } as IExtensionDescription);
|
||||
|
||||
@@ -31,6 +31,7 @@ suite('ExtHostTypes', function () {
|
||||
scheme: 'file',
|
||||
path: '/path/test.file',
|
||||
fsPath: '/path/test.file'.replace(/\//g, isWindows ? '\\' : '/'),
|
||||
_sep: isWindows ? 1 : undefined,
|
||||
});
|
||||
|
||||
assert.ok(uri.toString());
|
||||
@@ -39,6 +40,7 @@ suite('ExtHostTypes', function () {
|
||||
scheme: 'file',
|
||||
path: '/path/test.file',
|
||||
fsPath: '/path/test.file'.replace(/\//g, isWindows ? '\\' : '/'),
|
||||
_sep: isWindows ? 1 : undefined,
|
||||
external: 'file:///path/test.file'
|
||||
});
|
||||
});
|
||||
|
||||
@@ -4,20 +4,21 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { MainThreadWebviews } from 'vs/workbench/api/electron-browser/mainThreadWebview';
|
||||
import { MainThreadWebviews } from 'vs/workbench/api/browser/mainThreadWebview';
|
||||
import { ExtHostWebviews } from 'vs/workbench/api/common/extHostWebview';
|
||||
import { mock } from 'vs/workbench/test/electron-browser/api/mock';
|
||||
import * as vscode from 'vscode';
|
||||
import { SingleProxyRPCProtocol } from './testRPCProtocol';
|
||||
import { EditorViewColumn } from 'vs/workbench/api/common/shared/editor';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
|
||||
suite('ExtHostWebview', function () {
|
||||
suite('ExtHostWebview', () => {
|
||||
|
||||
test('Cannot register multiple serializers for the same view type', async () => {
|
||||
const viewType = 'view.type';
|
||||
|
||||
const shape = createNoopMainThreadWebviews();
|
||||
const extHostWebviews = new ExtHostWebviews(SingleProxyRPCProtocol(shape));
|
||||
const extHostWebviews = new ExtHostWebviews(SingleProxyRPCProtocol(shape), { webviewCspSource: '', webviewResourceRoot: '' });
|
||||
|
||||
let lastInvokedDeserializer: vscode.WebviewPanelSerializer | undefined = undefined;
|
||||
|
||||
@@ -46,11 +47,95 @@ suite('ExtHostWebview', function () {
|
||||
await extHostWebviews.$deserializeWebviewPanel('x', viewType, 'title', {}, 0 as EditorViewColumn, {});
|
||||
assert.strictEqual(lastInvokedDeserializer, serializerB);
|
||||
});
|
||||
|
||||
test('toWebviewResource for desktop vscode-resource scheme', () => {
|
||||
const shape = createNoopMainThreadWebviews();
|
||||
const extHostWebviews = new ExtHostWebviews(SingleProxyRPCProtocol(shape), {
|
||||
webviewCspSource: '',
|
||||
webviewResourceRoot: 'vscode-resource:{{resource}}'
|
||||
});
|
||||
const webview = extHostWebviews.createWebviewPanel({} as any, 'type', 'title', 1, {});
|
||||
|
||||
assert.strictEqual(
|
||||
webview.webview.toWebviewResource(URI.parse('file:///Users/codey/file.html')).toString(),
|
||||
'vscode-resource:/Users/codey/file.html',
|
||||
'Unix basic'
|
||||
);
|
||||
|
||||
assert.strictEqual(
|
||||
webview.webview.toWebviewResource(URI.parse('file:///Users/codey/file.html#frag')).toString(),
|
||||
'vscode-resource:/Users/codey/file.html#frag',
|
||||
'Unix should preserve fragment'
|
||||
);
|
||||
|
||||
assert.strictEqual(
|
||||
webview.webview.toWebviewResource(URI.parse('file:///Users/codey/f%20ile.html')).toString(),
|
||||
'vscode-resource:/Users/codey/f%20ile.html',
|
||||
'Unix with encoding'
|
||||
);
|
||||
|
||||
assert.strictEqual(
|
||||
webview.webview.toWebviewResource(URI.parse('file://localhost/Users/codey/file.html')).toString(),
|
||||
'vscode-resource://localhost/Users/codey/file.html',
|
||||
'Unix should preserve authority'
|
||||
);
|
||||
|
||||
assert.strictEqual(
|
||||
webview.webview.toWebviewResource(URI.parse('file:///c:/codey/file.txt')).toString(),
|
||||
'vscode-resource:/c%3A/codey/file.txt',
|
||||
'Windows C drive'
|
||||
);
|
||||
});
|
||||
|
||||
test('toWebviewResource for web endpoint', () => {
|
||||
const shape = createNoopMainThreadWebviews();
|
||||
|
||||
const extHostWebviews = new ExtHostWebviews(SingleProxyRPCProtocol(shape), {
|
||||
webviewCspSource: '',
|
||||
webviewResourceRoot: `https://{{uuid}}.webview.contoso.com/commit{{resource}}`
|
||||
});
|
||||
const webview = extHostWebviews.createWebviewPanel({} as any, 'type', 'title', 1, {});
|
||||
|
||||
function stripEndpointUuid(input: string) {
|
||||
return input.replace(/^https:\/\/[^\.]+?\./, '');
|
||||
}
|
||||
|
||||
assert.strictEqual(
|
||||
stripEndpointUuid(webview.webview.toWebviewResource(URI.parse('file:///Users/codey/file.html')).toString()),
|
||||
'webview.contoso.com/commit///Users/codey/file.html',
|
||||
'Unix basic'
|
||||
);
|
||||
|
||||
assert.strictEqual(
|
||||
stripEndpointUuid(webview.webview.toWebviewResource(URI.parse('file:///Users/codey/file.html#frag')).toString()),
|
||||
'webview.contoso.com/commit///Users/codey/file.html#frag',
|
||||
'Unix should preserve fragment'
|
||||
);
|
||||
|
||||
assert.strictEqual(
|
||||
stripEndpointUuid(webview.webview.toWebviewResource(URI.parse('file:///Users/codey/f%20ile.html')).toString()),
|
||||
'webview.contoso.com/commit///Users/codey/f%20ile.html',
|
||||
'Unix with encoding'
|
||||
);
|
||||
|
||||
assert.strictEqual(
|
||||
stripEndpointUuid(webview.webview.toWebviewResource(URI.parse('file://localhost/Users/codey/file.html')).toString()),
|
||||
'webview.contoso.com/commit//localhost/Users/codey/file.html',
|
||||
'Unix should preserve authority'
|
||||
);
|
||||
|
||||
assert.strictEqual(
|
||||
stripEndpointUuid(webview.webview.toWebviewResource(URI.parse('file:///c:/codey/file.txt')).toString()),
|
||||
'webview.contoso.com/commit///c%3A/codey/file.txt',
|
||||
'Windows C drive'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
function createNoopMainThreadWebviews() {
|
||||
return new class extends mock<MainThreadWebviews>() {
|
||||
$createWebviewPanel() { /* noop */ }
|
||||
$registerSerializer() { /* noop */ }
|
||||
$unregisterSerializer() { /* noop */ }
|
||||
};
|
||||
|
||||
@@ -62,7 +62,7 @@ suite('MainThreadEditors', () => {
|
||||
}
|
||||
move(source: URI, target: URI) {
|
||||
movedResources.set(source, target);
|
||||
return Promise.resolve(undefined);
|
||||
return Promise.resolve(Object.create(null));
|
||||
}
|
||||
models = <any>{
|
||||
onModelSaved: Event.None,
|
||||
|
||||
@@ -12,12 +12,15 @@ import { debugExceptionWidgetBackground } from 'vs/workbench/contrib/debug/brows
|
||||
import { debugToolBarBackground } from 'vs/workbench/contrib/debug/browser/debugToolBar';
|
||||
import { buttonBackground } from 'vs/workbench/contrib/welcome/page/browser/welcomePage';
|
||||
import { embeddedEditorBackground } from 'vs/workbench/contrib/welcome/walkThrough/browser/walkThroughPart';
|
||||
import { request, asText } from 'vs/base/node/request';
|
||||
import { asText } from 'vs/platform/request/common/request';
|
||||
import * as pfs from 'vs/base/node/pfs';
|
||||
import * as path from 'vs/base/common/path';
|
||||
import * as assert from 'assert';
|
||||
import { getPathFromAmdModule } from 'vs/base/common/amd';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
import { RequestService } from 'vs/platform/request/node/requestService';
|
||||
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
|
||||
import { NullLogService } from 'vs/platform/log/common/log';
|
||||
|
||||
|
||||
interface ColorInfo {
|
||||
@@ -40,7 +43,7 @@ export const experimental: string[] = []; // 'settings.modifiedItemForeground',
|
||||
suite('Color Registry', function () {
|
||||
|
||||
test('all colors documented', async function () {
|
||||
const reqContext = await request({ url: 'https://raw.githubusercontent.com/Microsoft/vscode-docs/vnext/docs/getstarted/theme-color-reference.md' }, CancellationToken.None);
|
||||
const reqContext = await new RequestService(new TestConfigurationService(), new NullLogService()).request({ url: 'https://raw.githubusercontent.com/Microsoft/vscode-docs/vnext/docs/getstarted/theme-color-reference.md' }, CancellationToken.None);
|
||||
const content = (await asText(reqContext))!;
|
||||
|
||||
const expression = /\-\s*\`([\w\.]+)\`: (.*)/g;
|
||||
|
||||
@@ -26,9 +26,10 @@ import { Extensions, IQuickOpenRegistry } from 'vs/workbench/browser/quickopen';
|
||||
import 'vs/workbench/contrib/search/browser/search.contribution'; // load contributions
|
||||
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
|
||||
import { SearchService } from 'vs/workbench/services/search/node/searchService';
|
||||
import { LocalSearchService } from 'vs/workbench/services/search/node/searchService';
|
||||
import { IUntitledEditorService, UntitledEditorService } from 'vs/workbench/services/untitled/common/untitledEditorService';
|
||||
import { TestContextService, TestEditorGroupsService, TestEditorService, TestEnvironmentService, TestTextResourcePropertiesService } from 'vs/workbench/test/workbenchTestServices';
|
||||
import { ClassifiedEvent, StrictPropertyCheck, GDPRClassification } from 'vs/platform/telemetry/common/gdprTypings';
|
||||
|
||||
namespace Timer {
|
||||
export interface ITimerEvent {
|
||||
@@ -78,7 +79,7 @@ suite.skip('QuickOpen performance (integration)', () => {
|
||||
[IEditorGroupsService, new TestEditorGroupsService()],
|
||||
[IEnvironmentService, TestEnvironmentService],
|
||||
[IUntitledEditorService, createSyncDescriptor(UntitledEditorService)],
|
||||
[ISearchService, createSyncDescriptor(SearchService)]
|
||||
[ISearchService, createSyncDescriptor(LocalSearchService)]
|
||||
));
|
||||
|
||||
const registry = Registry.as<IQuickOpenRegistry>(Extensions.Quickopen);
|
||||
@@ -172,6 +173,10 @@ class TestTelemetryService implements ITelemetryService {
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
|
||||
public publicLog2<E extends ClassifiedEvent<T> = never, T extends GDPRClassification<T> = never>(eventName: string, data?: StrictPropertyCheck<T, E>) {
|
||||
return this.publicLog(eventName, data as any);
|
||||
}
|
||||
|
||||
public getTelemetryInfo(): Promise<ITelemetryInfo> {
|
||||
return Promise.resolve({
|
||||
instanceId: 'someValue.instanceId',
|
||||
|
||||
@@ -15,7 +15,7 @@ import { IUntitledEditorService, UntitledEditorService } from 'vs/workbench/serv
|
||||
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import * as minimist from 'minimist';
|
||||
import * as path from 'vs/base/common/path';
|
||||
import { SearchService } from 'vs/workbench/services/search/node/searchService';
|
||||
import { LocalSearchService } from 'vs/workbench/services/search/node/searchService';
|
||||
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
|
||||
import { TestEnvironmentService, TestContextService, TestEditorService, TestEditorGroupsService, TestTextResourcePropertiesService } from 'vs/workbench/test/workbenchTestServices';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
@@ -33,6 +33,7 @@ import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { testWorkspace } from 'vs/platform/workspace/test/common/testWorkspace';
|
||||
import { NullLogService, ILogService } from 'vs/platform/log/common/log';
|
||||
import { ITextResourcePropertiesService } from 'vs/editor/common/services/resourceConfiguration';
|
||||
import { ClassifiedEvent, StrictPropertyCheck, GDPRClassification } from 'vs/platform/telemetry/common/gdprTypings';
|
||||
|
||||
declare var __dirname: string;
|
||||
|
||||
@@ -68,7 +69,7 @@ suite.skip('TextSearch performance (integration)', () => {
|
||||
[IEditorGroupsService, new TestEditorGroupsService()],
|
||||
[IEnvironmentService, TestEnvironmentService],
|
||||
[IUntitledEditorService, createSyncDescriptor(UntitledEditorService)],
|
||||
[ISearchService, createSyncDescriptor(SearchService)],
|
||||
[ISearchService, createSyncDescriptor(LocalSearchService)],
|
||||
[ILogService, new NullLogService()]
|
||||
));
|
||||
|
||||
@@ -165,6 +166,10 @@ class TestTelemetryService implements ITelemetryService {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
public publicLog2<E extends ClassifiedEvent<T> = never, T extends GDPRClassification<T> = never>(eventName: string, data?: StrictPropertyCheck<T, E>) {
|
||||
return this.publicLog(eventName, data as any);
|
||||
}
|
||||
|
||||
public getTelemetryInfo(): Promise<ITelemetryInfo> {
|
||||
return Promise.resolve({
|
||||
instanceId: 'someValue.instanceId',
|
||||
|
||||
Reference in New Issue
Block a user