mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-11 10:38:31 -05:00
Merge from vscode 2e5312cd61ff99c570299ecc122c52584265eda2
This commit is contained in:
committed by
Anthony Dresser
parent
3603f55d97
commit
7f1d8fc32f
@@ -70,6 +70,11 @@ function assertRejects(fn: () => Promise<any>, message: string = 'Expected rejec
|
||||
return fn().then(() => assert.ok(false, message), _err => assert.ok(true));
|
||||
}
|
||||
|
||||
function isLocation(value: vscode.Location | vscode.LocationLink): value is vscode.Location {
|
||||
const candidate = value as vscode.Location;
|
||||
return candidate && candidate.uri instanceof URI && candidate.range instanceof types.Range;
|
||||
}
|
||||
|
||||
suite('ExtHostLanguageFeatureCommands', function () {
|
||||
|
||||
suiteSetup(() => {
|
||||
@@ -268,6 +273,34 @@ suite('ExtHostLanguageFeatureCommands', function () {
|
||||
});
|
||||
});
|
||||
|
||||
test('Definition Link', () => {
|
||||
disposables.push(extHost.registerDefinitionProvider(nullExtensionDescription, defaultSelector, <vscode.DefinitionProvider>{
|
||||
provideDefinition(doc: any): (vscode.Location | vscode.LocationLink)[] {
|
||||
return [
|
||||
new types.Location(doc.uri, new types.Range(0, 0, 0, 0)),
|
||||
{ targetUri: doc.uri, targetRange: new types.Range(0, 0, 0, 0), targetSelectionRange: new types.Range(1, 1, 1, 1), originSelectionRange: new types.Range(2, 2, 2, 2) }
|
||||
];
|
||||
}
|
||||
}));
|
||||
|
||||
return rpcProtocol.sync().then(() => {
|
||||
return commands.executeCommand<(vscode.Location | vscode.LocationLink)[]>('vscode.executeDefinitionProvider', model.uri, new types.Position(0, 0)).then(values => {
|
||||
assert.equal(values.length, 2);
|
||||
for (let v of values) {
|
||||
if (isLocation(v)) {
|
||||
assert.ok(v.uri instanceof URI);
|
||||
assert.ok(v.range instanceof types.Range);
|
||||
} else {
|
||||
assert.ok(v.targetUri instanceof URI);
|
||||
assert.ok(v.targetRange instanceof types.Range);
|
||||
assert.ok(v.targetSelectionRange instanceof types.Range);
|
||||
assert.ok(v.originSelectionRange instanceof types.Range);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// --- declaration
|
||||
|
||||
test('Declaration, back and forth', function () {
|
||||
@@ -298,6 +331,34 @@ suite('ExtHostLanguageFeatureCommands', function () {
|
||||
});
|
||||
});
|
||||
|
||||
test('Declaration Link', () => {
|
||||
disposables.push(extHost.registerDeclarationProvider(nullExtensionDescription, defaultSelector, <vscode.DeclarationProvider>{
|
||||
provideDeclaration(doc: any): (vscode.Location | vscode.LocationLink)[] {
|
||||
return [
|
||||
new types.Location(doc.uri, new types.Range(0, 0, 0, 0)),
|
||||
{ targetUri: doc.uri, targetRange: new types.Range(0, 0, 0, 0), targetSelectionRange: new types.Range(1, 1, 1, 1), originSelectionRange: new types.Range(2, 2, 2, 2) }
|
||||
];
|
||||
}
|
||||
}));
|
||||
|
||||
return rpcProtocol.sync().then(() => {
|
||||
return commands.executeCommand<(vscode.Location | vscode.LocationLink)[]>('vscode.executeDeclarationProvider', model.uri, new types.Position(0, 0)).then(values => {
|
||||
assert.equal(values.length, 2);
|
||||
for (let v of values) {
|
||||
if (isLocation(v)) {
|
||||
assert.ok(v.uri instanceof URI);
|
||||
assert.ok(v.range instanceof types.Range);
|
||||
} else {
|
||||
assert.ok(v.targetUri instanceof URI);
|
||||
assert.ok(v.targetRange instanceof types.Range);
|
||||
assert.ok(v.targetSelectionRange instanceof types.Range);
|
||||
assert.ok(v.originSelectionRange instanceof types.Range);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// --- type definition
|
||||
|
||||
test('Type Definition, invalid arguments', function () {
|
||||
@@ -339,6 +400,103 @@ suite('ExtHostLanguageFeatureCommands', function () {
|
||||
});
|
||||
});
|
||||
|
||||
test('Type Definition Link', () => {
|
||||
disposables.push(extHost.registerTypeDefinitionProvider(nullExtensionDescription, defaultSelector, <vscode.TypeDefinitionProvider>{
|
||||
provideTypeDefinition(doc: any): (vscode.Location | vscode.LocationLink)[] {
|
||||
return [
|
||||
new types.Location(doc.uri, new types.Range(0, 0, 0, 0)),
|
||||
{ targetUri: doc.uri, targetRange: new types.Range(0, 0, 0, 0), targetSelectionRange: new types.Range(1, 1, 1, 1), originSelectionRange: new types.Range(2, 2, 2, 2) }
|
||||
];
|
||||
}
|
||||
}));
|
||||
|
||||
return rpcProtocol.sync().then(() => {
|
||||
return commands.executeCommand<(vscode.Location | vscode.LocationLink)[]>('vscode.executeTypeDefinitionProvider', model.uri, new types.Position(0, 0)).then(values => {
|
||||
assert.equal(values.length, 2);
|
||||
for (let v of values) {
|
||||
if (isLocation(v)) {
|
||||
assert.ok(v.uri instanceof URI);
|
||||
assert.ok(v.range instanceof types.Range);
|
||||
} else {
|
||||
assert.ok(v.targetUri instanceof URI);
|
||||
assert.ok(v.targetRange instanceof types.Range);
|
||||
assert.ok(v.targetSelectionRange instanceof types.Range);
|
||||
assert.ok(v.originSelectionRange instanceof types.Range);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// --- implementation
|
||||
|
||||
test('Implementation, invalid arguments', function () {
|
||||
const promises = [
|
||||
assertRejects(() => commands.executeCommand('vscode.executeImplementationProvider')),
|
||||
assertRejects(() => commands.executeCommand('vscode.executeImplementationProvider', null)),
|
||||
assertRejects(() => commands.executeCommand('vscode.executeImplementationProvider', undefined)),
|
||||
assertRejects(() => commands.executeCommand('vscode.executeImplementationProvider', true, false))
|
||||
];
|
||||
|
||||
return Promise.all(promises);
|
||||
});
|
||||
|
||||
test('Implementation, back and forth', function () {
|
||||
|
||||
disposables.push(extHost.registerImplementationProvider(nullExtensionDescription, defaultSelector, <vscode.ImplementationProvider>{
|
||||
provideImplementation(doc: any): any {
|
||||
return new types.Location(doc.uri, new types.Range(0, 0, 0, 0));
|
||||
}
|
||||
}));
|
||||
disposables.push(extHost.registerImplementationProvider(nullExtensionDescription, defaultSelector, <vscode.ImplementationProvider>{
|
||||
provideImplementation(doc: any): any {
|
||||
return [
|
||||
new types.Location(doc.uri, new types.Range(0, 0, 0, 0)),
|
||||
new types.Location(doc.uri, new types.Range(0, 0, 0, 0)),
|
||||
new types.Location(doc.uri, new types.Range(0, 0, 0, 0)),
|
||||
];
|
||||
}
|
||||
}));
|
||||
|
||||
return rpcProtocol.sync().then(() => {
|
||||
return commands.executeCommand<vscode.Location[]>('vscode.executeImplementationProvider', model.uri, new types.Position(0, 0)).then(values => {
|
||||
assert.equal(values.length, 4);
|
||||
for (const v of values) {
|
||||
assert.ok(v.uri instanceof URI);
|
||||
assert.ok(v.range instanceof types.Range);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test('Implementation Definition Link', () => {
|
||||
disposables.push(extHost.registerImplementationProvider(nullExtensionDescription, defaultSelector, <vscode.ImplementationProvider>{
|
||||
provideImplementation(doc: any): (vscode.Location | vscode.LocationLink)[] {
|
||||
return [
|
||||
new types.Location(doc.uri, new types.Range(0, 0, 0, 0)),
|
||||
{ targetUri: doc.uri, targetRange: new types.Range(0, 0, 0, 0), targetSelectionRange: new types.Range(1, 1, 1, 1), originSelectionRange: new types.Range(2, 2, 2, 2) }
|
||||
];
|
||||
}
|
||||
}));
|
||||
|
||||
return rpcProtocol.sync().then(() => {
|
||||
return commands.executeCommand<(vscode.Location | vscode.LocationLink)[]>('vscode.executeImplementationProvider', model.uri, new types.Position(0, 0)).then(values => {
|
||||
assert.equal(values.length, 2);
|
||||
for (let v of values) {
|
||||
if (isLocation(v)) {
|
||||
assert.ok(v.uri instanceof URI);
|
||||
assert.ok(v.range instanceof types.Range);
|
||||
} else {
|
||||
assert.ok(v.targetUri instanceof URI);
|
||||
assert.ok(v.targetRange instanceof types.Range);
|
||||
assert.ok(v.targetSelectionRange instanceof types.Range);
|
||||
assert.ok(v.originSelectionRange instanceof types.Range);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// --- references
|
||||
|
||||
test('reference search, back and forth', function () {
|
||||
@@ -585,6 +743,33 @@ suite('ExtHostLanguageFeatureCommands', function () {
|
||||
assert.equal(b.commitCharacters, undefined);
|
||||
});
|
||||
|
||||
test('vscode.executeCompletionItemProvider returns the wrong CompletionItemKinds in insiders #95715', async function () {
|
||||
disposables.push(extHost.registerCompletionItemProvider(nullExtensionDescription, defaultSelector, <vscode.CompletionItemProvider>{
|
||||
provideCompletionItems(): any {
|
||||
return [
|
||||
new types.CompletionItem('My Method', types.CompletionItemKind.Method),
|
||||
new types.CompletionItem('My Property', types.CompletionItemKind.Property),
|
||||
];
|
||||
}
|
||||
}, []));
|
||||
|
||||
await rpcProtocol.sync();
|
||||
|
||||
let list = await commands.executeCommand<vscode.CompletionList>(
|
||||
'vscode.executeCompletionItemProvider',
|
||||
model.uri,
|
||||
new types.Position(0, 4),
|
||||
undefined
|
||||
);
|
||||
|
||||
assert.ok(list instanceof types.CompletionList);
|
||||
assert.equal(list.items.length, 2);
|
||||
|
||||
const [a, b] = list.items;
|
||||
assert.equal(a.kind, types.CompletionItemKind.Method);
|
||||
assert.equal(b.kind, types.CompletionItemKind.Property);
|
||||
});
|
||||
|
||||
// --- signatureHelp
|
||||
|
||||
test('Parameter Hints, back and forth', async () => {
|
||||
|
||||
Reference in New Issue
Block a user