diff --git a/src/vs/workbench/api/node/extHostApiCommands.ts b/src/vs/workbench/api/node/extHostApiCommands.ts index 8ef2a032d8c2ee7c08620810fa8eaaff02522ddd..e64a0836a7c2cf6a0f6db2f5c68208a8674c3aac 100644 --- a/src/vs/workbench/api/node/extHostApiCommands.ts +++ b/src/vs/workbench/api/node/extHostApiCommands.ts @@ -245,7 +245,7 @@ class ExtHostApiCommands { resource, position: position && typeConverters.fromPosition(position) }; - return this._commands.executeCommand('_executeDocumentHighlights', args).then(value => { + return this._commands.executeCommand('_executeReferenceProvider', args).then(value => { if (Array.isArray(value)) { return value.map(typeConverters.location.to); } diff --git a/src/vs/workbench/test/node/api/extHostApiCommands.test.ts b/src/vs/workbench/test/node/api/extHostApiCommands.test.ts index ff8ce9bae27d0b28f694f2d52371c92e5821e392..0bf70db68bec115dc7a3d93bcae069860409bb24 100644 --- a/src/vs/workbench/test/node/api/extHostApiCommands.test.ts +++ b/src/vs/workbench/test/node/api/extHostApiCommands.test.ts @@ -190,7 +190,7 @@ suite('ExtHostLanguageFeatureCommands', function() { // }); }); - test('Definition, back and forth', function(done) { + test('Definition, back and forth', function() { disposables.push(extHost.registerDefinitionProvider(defaultSelector, { provideDefinition(doc: any): any { @@ -207,12 +207,38 @@ suite('ExtHostLanguageFeatureCommands', function() { } })); - threadService.sync().then(() => { - commands.executeCommand('vscode.executeDefinitionProvider', model.getAssociatedResource(), new types.Position(0, 0)).then(values => { + return threadService.sync().then(() => { + return commands.executeCommand('vscode.executeDefinitionProvider', model.getAssociatedResource(), new types.Position(0, 0)).then(values => { assert.equal(values.length, 4); - done(); - }, done); - }, done); + for (let v of values) { + assert.ok(v.uri instanceof URI); + assert.ok(v.range instanceof types.Range); + } + }); + }); + }); + + // --- references + + test('reference search, back and forth', function () { + + disposables.push(extHost.registerReferenceProvider(defaultSelector, { + provideReferences(doc: any) { + return [ + new types.Location(URI.parse('some:uri/path'), new types.Range(0, 1, 0, 5)) + ]; + } + })); + + return commands.executeCommand('vscode.executeReferenceProvider', model.getAssociatedResource(), new types.Position(0, 0)).then(values => { + assert.equal(values.length, 1); + let [first] = values; + assert.equal(first.uri.toString(), 'some:uri/path'); + assert.equal(first.range.start.line, 0); + assert.equal(first.range.start.character, 1); + assert.equal(first.range.end.line, 0); + assert.equal(first.range.end.character, 5); + }); }); // --- outline