Merge from vscode 64980ea1f3f532c82bb6c28d27bba9ef2c5b4463 (#7206)

* Merge from vscode 64980ea1f3f532c82bb6c28d27bba9ef2c5b4463

* fix config changes

* fix strictnull checks
This commit is contained in:
Anthony Dresser
2019-09-15 22:38:26 -07:00
committed by GitHub
parent fa6c52699e
commit ea0f9e6ce9
1226 changed files with 21541 additions and 17633 deletions

View File

@@ -78,7 +78,7 @@ suite('ExtHostLanguageFeatureCommands', function () {
});
instantiationService.stub(IMarkerService, new MarkerService());
instantiationService.stub(IModelService, <IModelService>{
_serviceBrand: IModelService,
_serviceBrand: undefined,
getModel(): any { return model; },
createModel() { throw new Error(); },
updateModel() { throw new Error(); },
@@ -857,4 +857,33 @@ suite('ExtHostLanguageFeatureCommands', function () {
assert.ok(value[0].parent);
});
// --- call hierarcht
test('Call Hierarchy, back and forth', async function () {
disposables.push(extHost.registerCallHierarchyProvider(nullExtensionDescription, defaultSelector, new class implements vscode.CallHierarchyItemProvider {
provideCallHierarchyIncomingCalls(document: vscode.TextDocument, position: vscode.Position, token: vscode.CancellationToken): vscode.ProviderResult<vscode.CallHierarchyIncomingCall[]> {
return [
new types.CallHierarchyIncomingCall(new types.CallHierarchyItem(types.SymbolKind.Array, 'IN', '', document.uri, new types.Range(0, 0, 2, 0), new types.Range(0, 0, 2, 0)), [new types.Range(0, 0, 0, 0)]),
];
}
provideCallHierarchyOutgoingCalls(document: vscode.TextDocument, position: vscode.Position, token: vscode.CancellationToken): vscode.ProviderResult<vscode.CallHierarchyOutgoingCall[]> {
return [
new types.CallHierarchyOutgoingCall(new types.CallHierarchyItem(types.SymbolKind.Array, 'OUT', '', document.uri, new types.Range(0, 0, 2, 0), new types.Range(0, 0, 2, 0)), [new types.Range(0, 0, 0, 0)]),
];
}
}));
await rpcProtocol.sync();
let incoming = await commands.executeCommand<vscode.CallHierarchyIncomingCall[]>('vscode.executeCallHierarchyProviderIncomingCalls', model.uri, new types.Position(0, 10));
assert.equal(incoming.length, 1);
assert.ok(incoming[0].source instanceof types.CallHierarchyItem);
assert.equal(incoming[0].source.name, 'IN');
let outgoing = await commands.executeCommand<vscode.CallHierarchyOutgoingCall[]>('vscode.executeCallHierarchyProviderOutgoingCalls', model.uri, new types.Position(0, 10));
assert.equal(outgoing.length, 1);
assert.ok(outgoing[0].target instanceof types.CallHierarchyItem);
assert.equal(outgoing[0].target.name, 'OUT');
});
});

View File

@@ -59,4 +59,35 @@ suite('ExtHostCommands', function () {
reg.dispose();
assert.equal(unregisterCounter, 1);
});
test('execute with retry', async function () {
let count = 0;
const shape = new class extends mock<MainThreadCommandsShape>() {
$registerCommand(id: string): void {
//
}
async $executeCommand<T>(id: string, args: any[], retry: boolean): Promise<T | undefined> {
count++;
assert.equal(retry, count === 1);
if (count === 1) {
assert.equal(retry, true);
throw new Error('$executeCommand:retry');
} else {
assert.equal(retry, false);
return <any>17;
}
}
};
const commands = new ExtHostCommands(
SingleProxyRPCProtocol(shape),
new NullLogService()
);
const result = await commands.executeCommand('fooo', [this, true]);
assert.equal(result, 17);
assert.equal(count, 2);
});
});

View File

@@ -9,11 +9,10 @@ import { IDialogService } from 'vs/platform/dialogs/common/dialogs';
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';
_serviceBrand: undefined;
show(): never {
throw new Error('not implemented');
}
@@ -33,7 +32,7 @@ const emptyCommandService: ICommandService = {
};
const emptyNotificationService = new class implements INotificationService {
_serviceBrand: ServiceIdentifier<INotificationService>;
_serviceBrand: undefined;
notify(...args: any[]): never {
throw new Error('not implemented');
}
@@ -55,7 +54,7 @@ const emptyNotificationService = new class implements INotificationService {
};
class EmptyNotificationService implements INotificationService {
_serviceBrand: ServiceIdentifier<INotificationService>;
_serviceBrand: undefined;
constructor(private withNotify: (notification: INotification) => void) {
}
@@ -103,7 +102,7 @@ suite('ExtHostMessageService', function () {
assert.equal(message, 'h');
assert.equal(buttons.length, 2);
assert.equal(buttons[1], 'Cancel');
return Promise.resolve(0);
return Promise.resolve({ choice: 0 });
}
} as IDialogService);
@@ -114,7 +113,7 @@ suite('ExtHostMessageService', function () {
test('returns undefined when cancelled', async () => {
const service = new MainThreadMessageService(null!, emptyNotificationService, emptyCommandService, new class extends mock<IDialogService>() {
show() {
return Promise.resolve(1);
return Promise.resolve({ choice: 1 });
}
} as IDialogService);
@@ -126,7 +125,7 @@ suite('ExtHostMessageService', function () {
const service = new MainThreadMessageService(null!, emptyNotificationService, emptyCommandService, new class extends mock<IDialogService>() {
show(severity: Severity, message: string, buttons: string[]) {
assert.equal(buttons.length, 1);
return Promise.resolve(0);
return Promise.resolve({ choice: 0 });
}
} as IDialogService);

View File

@@ -5,14 +5,16 @@
import * as assert from 'assert';
import { MainThreadCommands } from 'vs/workbench/api/browser/mainThreadCommands';
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
import { CommandsRegistry, ICommandService } from 'vs/platform/commands/common/commands';
import { SingleProxyRPCProtocol } from './testRPCProtocol';
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
import { mock } from 'vs/workbench/test/electron-browser/api/mock';
suite('MainThreadCommands', function () {
test('dispose on unregister', function () {
const commands = new MainThreadCommands(SingleProxyRPCProtocol(null), undefined!);
const commands = new MainThreadCommands(SingleProxyRPCProtocol(null), undefined!, new class extends mock<IExtensionService>() { });
assert.equal(CommandsRegistry.getCommand('foo'), undefined);
// register
@@ -26,7 +28,7 @@ suite('MainThreadCommands', function () {
test('unregister all on dispose', function () {
const commands = new MainThreadCommands(SingleProxyRPCProtocol(null), undefined!);
const commands = new MainThreadCommands(SingleProxyRPCProtocol(null), undefined!, new class extends mock<IExtensionService>() { });
assert.equal(CommandsRegistry.getCommand('foo'), undefined);
commands.$registerCommand('foo');
@@ -40,4 +42,46 @@ suite('MainThreadCommands', function () {
assert.equal(CommandsRegistry.getCommand('foo'), undefined);
assert.equal(CommandsRegistry.getCommand('bar'), undefined);
});
test('activate and throw when needed', async function () {
const activations: string[] = [];
const runs: string[] = [];
const commands = new MainThreadCommands(
SingleProxyRPCProtocol(null),
new class extends mock<ICommandService>() {
executeCommand<T>(id: string): Promise<T | undefined> {
runs.push(id);
return Promise.resolve(undefined);
}
},
new class extends mock<IExtensionService>() {
activateByEvent(id: string) {
activations.push(id);
return Promise.resolve();
}
}
);
// case 1: arguments and retry
try {
activations.length = 0;
await commands.$executeCommand('bazz', [1, 2, { n: 3 }], true);
assert.ok(false);
} catch (e) {
assert.deepEqual(activations, ['onCommand:bazz']);
assert.equal((<Error>e).message, '$executeCommand:retry');
}
// case 2: no arguments and retry
runs.length = 0;
await commands.$executeCommand('bazz', [], true);
assert.deepEqual(runs, ['bazz']);
// case 3: arguments and no retry
runs.length = 0;
await commands.$executeCommand('bazz', [1, 2, true], false);
assert.deepEqual(runs, ['bazz']);
});
});

View File

@@ -75,7 +75,7 @@ suite('MainThreadDocumentsAndEditors', () => {
editorGroupService,
null!,
new class extends mock<IPanelService>() implements IPanelService {
_serviceBrand: any;
_serviceBrand: undefined;
onDidPanelOpen = Event.None;
onDidPanelClose = Event.None;
getActivePanel() {

View File

@@ -107,7 +107,7 @@ suite('MainThreadEditors', () => {
editorGroupService,
bulkEditService,
new class extends mock<IPanelService>() implements IPanelService {
_serviceBrand: any;
_serviceBrand: undefined;
onDidPanelOpen = Event.None;
onDidPanelClose = Event.None;
getActivePanel() {

View File

@@ -25,7 +25,7 @@ export function SingleProxyRPCProtocol(thing: any): IExtHostContext & IExtHostRp
export class TestRPCProtocol implements IExtHostContext, IExtHostRpcService {
public _serviceBrand = undefined;
public _serviceBrand: undefined;
public remoteAuthority = null!;
private _callCountValue: number = 0;

View File

@@ -5,13 +5,7 @@
import { Registry } from 'vs/platform/registry/common/platform';
import { IColorRegistry, Extensions, ColorContribution } from 'vs/platform/theme/common/colorRegistry';
import { editorMarkerNavigationError } from 'vs/editor/contrib/gotoError/gotoErrorWidget';
import { overviewRulerModifiedForeground } from 'vs/workbench/contrib/scm/browser/dirtydiffDecorator';
import { STATUS_BAR_DEBUGGING_BACKGROUND } from 'vs/workbench/contrib/debug/browser/statusbarColorProvider';
import { debugExceptionWidgetBackground } from 'vs/workbench/contrib/debug/browser/exceptionWidget';
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 { asText } from 'vs/platform/request/common/request';
import * as pfs from 'vs/base/node/pfs';
import * as path from 'vs/base/common/path';
@@ -20,6 +14,7 @@ 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 'vs/workbench/workbench.desktop.main';
import { NullLogService } from 'vs/platform/log/common/log';
@@ -34,25 +29,25 @@ interface DescriptionDiff {
specDescription: string;
}
// add artificial dependencies to some files that are not loaded yet
export const forceColorLoad = [editorMarkerNavigationError, overviewRulerModifiedForeground, STATUS_BAR_DEBUGGING_BACKGROUND,
debugExceptionWidgetBackground, debugToolBarBackground, buttonBackground, embeddedEditorBackground];
export const experimental: string[] = []; // 'settings.modifiedItemForeground', 'editorUnnecessary.foreground' ];
suite('Color Registry', function () {
test('all colors documented', async function () {
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);
test('all colors documented in theme-color.md', async function () {
const reqContext = await new RequestService(new TestConfigurationService(), new NullLogService()).request({ url: 'https://raw.githubusercontent.com/microsoft/vscode-docs/vnext/api/references/theme-color.md' }, CancellationToken.None);
const content = (await asText(reqContext))!;
const expression = /\-\s*\`([\w\.]+)\`: (.*)/g;
let m: RegExpExecArray | null;
let colorsInDoc: { [id: string]: ColorInfo } = Object.create(null);
let nColorsInDoc = 0;
while (m = expression.exec(content)) {
colorsInDoc[m[1]] = { description: m[2], offset: m.index, length: m.length };
nColorsInDoc++;
}
assert.ok(nColorsInDoc > 0, 'theme-color.md contains to color descriptions');
let missing = Object.create(null);
let descriptionDiffs: { [id: string]: DescriptionDiff } = Object.create(null);
@@ -88,7 +83,7 @@ suite('Color Registry', function () {
}
}
let undocumentedKeys = Object.keys(missing).map(k => `${k}: ${missing[k]}`);
let undocumentedKeys = Object.keys(missing).map(k => `\`${k}\`: ${missing[k]}`);
assert.deepEqual(undocumentedKeys, [], 'Undocumented colors ids');
let superfluousKeys = Object.keys(colorsInDoc);
@@ -106,7 +101,7 @@ function getDescription(color: ColorContribution) {
}
async function getColorsFromExtension(): Promise<{ [id: string]: string }> {
let extPath = getPathFromAmdModule(require, '../../../../../../extensions');
let extPath = getPathFromAmdModule(require, '../../../../../extensions');
let extFolders = await pfs.readDirsInDir(extPath);
let result: { [id: string]: string } = Object.create(null);
for (let folder of extFolders) {

View File

@@ -160,7 +160,7 @@ suite.skip('QuickOpen performance (integration)', () => {
class TestTelemetryService implements ITelemetryService {
public _serviceBrand: any;
public _serviceBrand: undefined;
public isOptedIn = true;
public events: any[] = [];

View File

@@ -145,7 +145,7 @@ suite.skip('TextSearch performance (integration)', () => {
});
class TestTelemetryService implements ITelemetryService {
public _serviceBrand: any;
public _serviceBrand: undefined;
public isOptedIn = true;
public events: any[] = [];