|
|
|
|
@@ -9,11 +9,13 @@ import * as assert from 'assert';
|
|
|
|
|
import {setUnexpectedErrorHandler, errorHandler} from 'vs/base/common/errors';
|
|
|
|
|
import {create} from 'vs/base/common/types';
|
|
|
|
|
import URI from 'vs/base/common/uri';
|
|
|
|
|
import {URL} from 'vs/base/common/network';
|
|
|
|
|
import {TPromise} from 'vs/base/common/winjs.base';
|
|
|
|
|
import {PluginHostDocument} from 'vs/workbench/api/common/pluginHostDocuments';
|
|
|
|
|
import * as types from 'vs/workbench/api/common/pluginHostTypes';
|
|
|
|
|
import {Range as CodeEditorRange} from 'vs/editor/common/core/range';
|
|
|
|
|
import * as EditorCommon from 'vs/editor/common/editorCommon';
|
|
|
|
|
import {Model as EditorModel} from 'vs/editor/common/model/model';
|
|
|
|
|
import threadService from './testThreadService'
|
|
|
|
|
import {ExtHostLanguageFeatures, MainThreadLanguageFeatures} from 'vs/workbench/api/common/extHostLanguageFeatures';
|
|
|
|
|
import {PluginHostCommands, MainThreadCommands} from 'vs/workbench/api/common/pluginHostCommands';
|
|
|
|
|
@@ -24,8 +26,19 @@ import {OutlineRegistry, getOutlineEntries} from 'vs/editor/contrib/quickOpen/co
|
|
|
|
|
import {CodeLensRegistry, getCodeLensData} from 'vs/editor/contrib/codelens/common/codelens';
|
|
|
|
|
import {DeclarationRegistry, getDeclarationsAtPosition} from 'vs/editor/contrib/goToDeclaration/common/goToDeclaration';
|
|
|
|
|
import {ExtraInfoRegistry, getExtraInfoAtPosition} from 'vs/editor/contrib/hover/common/hover';
|
|
|
|
|
import {OccurrencesRegistry, getOccurrencesAtPosition} from 'vs/editor/contrib/wordHighlighter/common/wordHighlighter';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const defaultSelector = { scheme: 'far' };
|
|
|
|
|
const model: EditorCommon.IModel = new EditorModel(
|
|
|
|
|
[
|
|
|
|
|
'This is the first line',
|
|
|
|
|
'This is the second line',
|
|
|
|
|
'This is the third line',
|
|
|
|
|
].join('\n'),
|
|
|
|
|
undefined,
|
|
|
|
|
URL.fromUri(URI.parse('far://testing/file.a')));
|
|
|
|
|
|
|
|
|
|
let model: ModelLike;
|
|
|
|
|
let extHost: ExtHostLanguageFeatures;
|
|
|
|
|
let mainThread: MainThreadLanguageFeatures;
|
|
|
|
|
let disposables: vscode.Disposable[] = [];
|
|
|
|
|
@@ -38,27 +51,18 @@ suite('ExtHostLanguageFeatures', function() {
|
|
|
|
|
originalErrorHandler = errorHandler.getUnexpectedErrorHandler();
|
|
|
|
|
setUnexpectedErrorHandler(() => { });
|
|
|
|
|
|
|
|
|
|
model = {
|
|
|
|
|
language: 'far',
|
|
|
|
|
uri: URI.parse('far://testing/file.a')
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
threadService.getRemotable(PluginHostModelService)._acceptModelAdd({
|
|
|
|
|
isDirty: false,
|
|
|
|
|
versionId: 1,
|
|
|
|
|
modeId: 'far',
|
|
|
|
|
url: model.uri,
|
|
|
|
|
versionId: model.getVersionId(),
|
|
|
|
|
modeId: model.getModeId(),
|
|
|
|
|
url: model.getAssociatedResource(),
|
|
|
|
|
value: {
|
|
|
|
|
EOL: '\n',
|
|
|
|
|
lines: [
|
|
|
|
|
'This is the first line',
|
|
|
|
|
'This is the second line',
|
|
|
|
|
'This is the third line',
|
|
|
|
|
],
|
|
|
|
|
EOL: model.getEOL(),
|
|
|
|
|
lines: model.getValue().split(model.getEOL()),
|
|
|
|
|
BOM: '',
|
|
|
|
|
length: -1
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
threadService.getRemotable(PluginHostCommands);
|
|
|
|
|
threadService.getRemotable(MainThreadCommands);
|
|
|
|
|
@@ -82,7 +86,7 @@ suite('ExtHostLanguageFeatures', function() {
|
|
|
|
|
|
|
|
|
|
test('DocumentSymbols, register/deregister', function(done) {
|
|
|
|
|
assert.equal(OutlineRegistry.all(model).length, 0);
|
|
|
|
|
let d1 = extHost.registerDocumentSymbolProvider('far', <vscode.DocumentSymbolProvider>{
|
|
|
|
|
let d1 = extHost.registerDocumentSymbolProvider(defaultSelector, <vscode.DocumentSymbolProvider>{
|
|
|
|
|
provideDocumentSymbols() {
|
|
|
|
|
return [];
|
|
|
|
|
}
|
|
|
|
|
@@ -99,12 +103,12 @@ suite('ExtHostLanguageFeatures', function() {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('DocumentSymbols, evil provider', function(done) {
|
|
|
|
|
disposables.push(extHost.registerDocumentSymbolProvider('far', <vscode.DocumentSymbolProvider>{
|
|
|
|
|
disposables.push(extHost.registerDocumentSymbolProvider(defaultSelector, <vscode.DocumentSymbolProvider>{
|
|
|
|
|
provideDocumentSymbols(): any {
|
|
|
|
|
throw new Error('evil document symbol provider');
|
|
|
|
|
}
|
|
|
|
|
}));
|
|
|
|
|
disposables.push(extHost.registerDocumentSymbolProvider('far', <vscode.DocumentSymbolProvider>{
|
|
|
|
|
disposables.push(extHost.registerDocumentSymbolProvider(defaultSelector, <vscode.DocumentSymbolProvider>{
|
|
|
|
|
provideDocumentSymbols(): any {
|
|
|
|
|
return [new types.SymbolInformation('test', types.SymbolKind.Field, new types.Range(0, 0, 0, 0))];
|
|
|
|
|
}
|
|
|
|
|
@@ -122,7 +126,7 @@ suite('ExtHostLanguageFeatures', function() {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('DocumentSymbols, data conversion', function(done) {
|
|
|
|
|
disposables.push(extHost.registerDocumentSymbolProvider('far', <vscode.DocumentSymbolProvider>{
|
|
|
|
|
disposables.push(extHost.registerDocumentSymbolProvider(defaultSelector, <vscode.DocumentSymbolProvider>{
|
|
|
|
|
provideDocumentSymbols(): any {
|
|
|
|
|
return [new types.SymbolInformation('test', types.SymbolKind.Field, new types.Range(0, 0, 0, 0))];
|
|
|
|
|
}
|
|
|
|
|
@@ -148,19 +152,19 @@ suite('ExtHostLanguageFeatures', function() {
|
|
|
|
|
|
|
|
|
|
test('CodeLens, evil provider', function(done) {
|
|
|
|
|
|
|
|
|
|
disposables.push(extHost.registerCodeLensProvider('far', <vscode.CodeLensProvider>{
|
|
|
|
|
disposables.push(extHost.registerCodeLensProvider(defaultSelector, <vscode.CodeLensProvider>{
|
|
|
|
|
provideCodeLenses():any {
|
|
|
|
|
throw new Error('evil')
|
|
|
|
|
}
|
|
|
|
|
}));
|
|
|
|
|
disposables.push(extHost.registerCodeLensProvider('far', <vscode.CodeLensProvider>{
|
|
|
|
|
disposables.push(extHost.registerCodeLensProvider(defaultSelector, <vscode.CodeLensProvider>{
|
|
|
|
|
provideCodeLenses() {
|
|
|
|
|
return [new types.CodeLens(new types.Range(0, 0, 0, 0))];
|
|
|
|
|
}
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
threadService.sync().then(() => {
|
|
|
|
|
getCodeLensData(model.uri, model.language).then(value => {
|
|
|
|
|
getCodeLensData(model).then(value => {
|
|
|
|
|
assert.equal(value.length, 1);
|
|
|
|
|
done();
|
|
|
|
|
});
|
|
|
|
|
@@ -169,7 +173,7 @@ suite('ExtHostLanguageFeatures', function() {
|
|
|
|
|
|
|
|
|
|
test('CodeLens, do not resolve a resolved lens', function(done) {
|
|
|
|
|
|
|
|
|
|
disposables.push(extHost.registerCodeLensProvider('far', <vscode.CodeLensProvider>{
|
|
|
|
|
disposables.push(extHost.registerCodeLensProvider(defaultSelector, <vscode.CodeLensProvider>{
|
|
|
|
|
provideCodeLenses():any {
|
|
|
|
|
return [new types.CodeLens(
|
|
|
|
|
new types.Range(0, 0, 0, 0),
|
|
|
|
|
@@ -182,11 +186,11 @@ suite('ExtHostLanguageFeatures', function() {
|
|
|
|
|
|
|
|
|
|
threadService.sync().then(() => {
|
|
|
|
|
|
|
|
|
|
getCodeLensData(model.uri, model.language).then(value => {
|
|
|
|
|
getCodeLensData(model).then(value => {
|
|
|
|
|
assert.equal(value.length, 1);
|
|
|
|
|
let data = value[0];
|
|
|
|
|
|
|
|
|
|
data.support.resolveCodeLensSymbol(model.uri, data.symbol).then(command => {
|
|
|
|
|
data.support.resolveCodeLensSymbol(model.getAssociatedResource(), data.symbol).then(command => {
|
|
|
|
|
assert.equal(command.id, 'id');
|
|
|
|
|
assert.equal(command.title, 'Title');
|
|
|
|
|
done();
|
|
|
|
|
@@ -197,7 +201,7 @@ suite('ExtHostLanguageFeatures', function() {
|
|
|
|
|
|
|
|
|
|
test('CodeLens, missing command', function(done) {
|
|
|
|
|
|
|
|
|
|
disposables.push(extHost.registerCodeLensProvider('far', <vscode.CodeLensProvider>{
|
|
|
|
|
disposables.push(extHost.registerCodeLensProvider(defaultSelector, <vscode.CodeLensProvider>{
|
|
|
|
|
provideCodeLenses() {
|
|
|
|
|
return [new types.CodeLens(new types.Range(0, 0, 0, 0))];
|
|
|
|
|
}
|
|
|
|
|
@@ -205,11 +209,11 @@ suite('ExtHostLanguageFeatures', function() {
|
|
|
|
|
|
|
|
|
|
threadService.sync().then(() => {
|
|
|
|
|
|
|
|
|
|
getCodeLensData(model.uri, model.language).then(value => {
|
|
|
|
|
getCodeLensData(model).then(value => {
|
|
|
|
|
assert.equal(value.length, 1);
|
|
|
|
|
|
|
|
|
|
let data = value[0];
|
|
|
|
|
data.support.resolveCodeLensSymbol(model.uri, data.symbol).then(command => {
|
|
|
|
|
data.support.resolveCodeLensSymbol(model.getAssociatedResource(), data.symbol).then(command => {
|
|
|
|
|
|
|
|
|
|
assert.equal(command.id, 'missing');
|
|
|
|
|
assert.equal(command.title, '<<MISSING COMMAND>>');
|
|
|
|
|
@@ -223,19 +227,19 @@ suite('ExtHostLanguageFeatures', function() {
|
|
|
|
|
|
|
|
|
|
test('Definition, data conversion', function(done) {
|
|
|
|
|
|
|
|
|
|
disposables.push(extHost.registerDefinitionProvider('far', <vscode.DefinitionProvider>{
|
|
|
|
|
disposables.push(extHost.registerDefinitionProvider(defaultSelector, <vscode.DefinitionProvider>{
|
|
|
|
|
provideDefinition(): any {
|
|
|
|
|
return [new types.Location(model.uri, new types.Range(1, 2, 3, 4))];
|
|
|
|
|
return [new types.Location(model.getAssociatedResource(), new types.Range(1, 2, 3, 4))];
|
|
|
|
|
}
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
threadService.sync().then(() => {
|
|
|
|
|
|
|
|
|
|
getDeclarationsAtPosition(model.uri, 'far', { lineNumber: 1, column: 1 }).then(value => {
|
|
|
|
|
getDeclarationsAtPosition(model, { lineNumber: 1, column: 1 }).then(value => {
|
|
|
|
|
assert.equal(value.length, 1);
|
|
|
|
|
let [entry] = value;
|
|
|
|
|
assert.deepEqual(entry.range, { startLineNumber: 2, startColumn: 3, endLineNumber: 4, endColumn: 5 });
|
|
|
|
|
assert.equal(entry.resource.toString(), model.uri.toString());
|
|
|
|
|
assert.equal(entry.resource.toString(), model.getAssociatedResource().toString());
|
|
|
|
|
done();
|
|
|
|
|
}, err => {
|
|
|
|
|
done(err);
|
|
|
|
|
@@ -245,20 +249,20 @@ suite('ExtHostLanguageFeatures', function() {
|
|
|
|
|
|
|
|
|
|
test('Definition, one or many', function(done) {
|
|
|
|
|
|
|
|
|
|
disposables.push(extHost.registerDefinitionProvider('far', <vscode.DefinitionProvider>{
|
|
|
|
|
disposables.push(extHost.registerDefinitionProvider(defaultSelector, <vscode.DefinitionProvider>{
|
|
|
|
|
provideDefinition(): any {
|
|
|
|
|
return [new types.Location(model.uri, new types.Range(1, 1, 1, 1))];
|
|
|
|
|
return [new types.Location(model.getAssociatedResource(), new types.Range(1, 1, 1, 1))];
|
|
|
|
|
}
|
|
|
|
|
}));
|
|
|
|
|
disposables.push(extHost.registerDefinitionProvider('far', <vscode.DefinitionProvider>{
|
|
|
|
|
disposables.push(extHost.registerDefinitionProvider(defaultSelector, <vscode.DefinitionProvider>{
|
|
|
|
|
provideDefinition(): any {
|
|
|
|
|
return new types.Location(model.uri, new types.Range(1, 1, 1, 1));
|
|
|
|
|
return new types.Location(model.getAssociatedResource(), new types.Range(1, 1, 1, 1));
|
|
|
|
|
}
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
threadService.sync().then(() => {
|
|
|
|
|
|
|
|
|
|
getDeclarationsAtPosition(model.uri, 'far', { lineNumber: 1, column: 1 }).then(value => {
|
|
|
|
|
getDeclarationsAtPosition(model, { lineNumber: 1, column: 1 }).then(value => {
|
|
|
|
|
assert.equal(value.length, 2);
|
|
|
|
|
done();
|
|
|
|
|
}, err => {
|
|
|
|
|
@@ -269,14 +273,14 @@ suite('ExtHostLanguageFeatures', function() {
|
|
|
|
|
|
|
|
|
|
test('Definition, registration order', function(done) {
|
|
|
|
|
|
|
|
|
|
disposables.push(extHost.registerDefinitionProvider('far', <vscode.DefinitionProvider>{
|
|
|
|
|
disposables.push(extHost.registerDefinitionProvider(defaultSelector, <vscode.DefinitionProvider>{
|
|
|
|
|
provideDefinition(): any {
|
|
|
|
|
return [new types.Location(URI.parse('far://first'), new types.Range(2, 3, 4, 5))];
|
|
|
|
|
}
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
setTimeout(function() { // registration time matters
|
|
|
|
|
disposables.push(extHost.registerDefinitionProvider('far', <vscode.DefinitionProvider>{
|
|
|
|
|
disposables.push(extHost.registerDefinitionProvider(defaultSelector, <vscode.DefinitionProvider>{
|
|
|
|
|
provideDefinition(): any {
|
|
|
|
|
return new types.Location(URI.parse('far://second'), new types.Range(1, 2, 3, 4));
|
|
|
|
|
}
|
|
|
|
|
@@ -284,7 +288,7 @@ suite('ExtHostLanguageFeatures', function() {
|
|
|
|
|
|
|
|
|
|
threadService.sync().then(() => {
|
|
|
|
|
|
|
|
|
|
getDeclarationsAtPosition(model.uri, 'far', { lineNumber: 1, column: 1 }).then(value => {
|
|
|
|
|
getDeclarationsAtPosition(model, { lineNumber: 1, column: 1 }).then(value => {
|
|
|
|
|
assert.equal(value.length, 2);
|
|
|
|
|
// let [first, second] = value;
|
|
|
|
|
|
|
|
|
|
@@ -301,20 +305,20 @@ suite('ExtHostLanguageFeatures', function() {
|
|
|
|
|
|
|
|
|
|
test('Definition, evil provider', function(done) {
|
|
|
|
|
|
|
|
|
|
disposables.push(extHost.registerDefinitionProvider('far', <vscode.DefinitionProvider>{
|
|
|
|
|
disposables.push(extHost.registerDefinitionProvider(defaultSelector, <vscode.DefinitionProvider>{
|
|
|
|
|
provideDefinition(): any {
|
|
|
|
|
throw new Error('evil provider')
|
|
|
|
|
}
|
|
|
|
|
}));
|
|
|
|
|
disposables.push(extHost.registerDefinitionProvider('far', <vscode.DefinitionProvider>{
|
|
|
|
|
disposables.push(extHost.registerDefinitionProvider(defaultSelector, <vscode.DefinitionProvider>{
|
|
|
|
|
provideDefinition(): any {
|
|
|
|
|
return new types.Location(model.uri, new types.Range(1, 1, 1, 1));
|
|
|
|
|
return new types.Location(model.getAssociatedResource(), new types.Range(1, 1, 1, 1));
|
|
|
|
|
}
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
threadService.sync().then(() => {
|
|
|
|
|
|
|
|
|
|
getDeclarationsAtPosition(model.uri, 'far', { lineNumber: 1, column: 1 }).then(value => {
|
|
|
|
|
getDeclarationsAtPosition(model, { lineNumber: 1, column: 1 }).then(value => {
|
|
|
|
|
assert.equal(value.length, 1);
|
|
|
|
|
done();
|
|
|
|
|
}, err => {
|
|
|
|
|
@@ -327,7 +331,7 @@ suite('ExtHostLanguageFeatures', function() {
|
|
|
|
|
|
|
|
|
|
test('ExtraInfo, word range at pos', function(done) {
|
|
|
|
|
|
|
|
|
|
disposables.push(extHost.registerHoverProvider('far', <vscode.HoverProvider>{
|
|
|
|
|
disposables.push(extHost.registerHoverProvider(defaultSelector, <vscode.HoverProvider>{
|
|
|
|
|
provideHover(): any {
|
|
|
|
|
return new types.Hover('Hello')
|
|
|
|
|
}
|
|
|
|
|
@@ -335,7 +339,7 @@ suite('ExtHostLanguageFeatures', function() {
|
|
|
|
|
|
|
|
|
|
threadService.sync().then(() => {
|
|
|
|
|
|
|
|
|
|
getExtraInfoAtPosition(model.uri, 'far', { lineNumber: 1, column: 1 }).then(value => {
|
|
|
|
|
getExtraInfoAtPosition(model, { lineNumber: 1, column: 1 }).then(value => {
|
|
|
|
|
|
|
|
|
|
assert.equal(value.length, 1);
|
|
|
|
|
let [entry] = value;
|
|
|
|
|
@@ -347,7 +351,7 @@ suite('ExtHostLanguageFeatures', function() {
|
|
|
|
|
|
|
|
|
|
test('ExtraInfo, given range', function(done) {
|
|
|
|
|
|
|
|
|
|
disposables.push(extHost.registerHoverProvider('far', <vscode.HoverProvider>{
|
|
|
|
|
disposables.push(extHost.registerHoverProvider(defaultSelector, <vscode.HoverProvider>{
|
|
|
|
|
provideHover(): any {
|
|
|
|
|
return new types.Hover('Hello', new types.Range(3, 0, 8, 7));
|
|
|
|
|
}
|
|
|
|
|
@@ -355,7 +359,7 @@ suite('ExtHostLanguageFeatures', function() {
|
|
|
|
|
|
|
|
|
|
threadService.sync().then(() => {
|
|
|
|
|
|
|
|
|
|
getExtraInfoAtPosition(model.uri, 'far', { lineNumber: 1, column: 1 }).then(value => {
|
|
|
|
|
getExtraInfoAtPosition(model, { lineNumber: 1, column: 1 }).then(value => {
|
|
|
|
|
assert.equal(value.length, 1);
|
|
|
|
|
let [entry] = value;
|
|
|
|
|
assert.deepEqual(entry.range, { startLineNumber: 4, startColumn: 1, endLineNumber: 9, endColumn: 8 });
|
|
|
|
|
@@ -366,14 +370,14 @@ suite('ExtHostLanguageFeatures', function() {
|
|
|
|
|
|
|
|
|
|
test('ExtraInfo, registration order', function(done) {
|
|
|
|
|
|
|
|
|
|
disposables.push(extHost.registerHoverProvider('far', <vscode.HoverProvider>{
|
|
|
|
|
disposables.push(extHost.registerHoverProvider(defaultSelector, <vscode.HoverProvider>{
|
|
|
|
|
provideHover(): any {
|
|
|
|
|
return new types.Hover('registered first');
|
|
|
|
|
}
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
setTimeout(function() {
|
|
|
|
|
disposables.push(extHost.registerHoverProvider('far', <vscode.HoverProvider>{
|
|
|
|
|
disposables.push(extHost.registerHoverProvider(defaultSelector, <vscode.HoverProvider>{
|
|
|
|
|
provideHover(): any {
|
|
|
|
|
return new types.Hover('registered second');
|
|
|
|
|
}
|
|
|
|
|
@@ -381,7 +385,7 @@ suite('ExtHostLanguageFeatures', function() {
|
|
|
|
|
|
|
|
|
|
threadService.sync().then(() => {
|
|
|
|
|
|
|
|
|
|
getExtraInfoAtPosition(model.uri, 'far', { lineNumber: 1, column: 1 }).then(value => {
|
|
|
|
|
getExtraInfoAtPosition(model, { lineNumber: 1, column: 1 }).then(value => {
|
|
|
|
|
assert.equal(value.length, 2);
|
|
|
|
|
let [first, second] = value;
|
|
|
|
|
assert.equal(first.htmlContent[0].formattedText, 'registered second');
|
|
|
|
|
@@ -396,12 +400,12 @@ suite('ExtHostLanguageFeatures', function() {
|
|
|
|
|
|
|
|
|
|
test('ExtraInfo, evil provider', function(done) {
|
|
|
|
|
|
|
|
|
|
disposables.push(extHost.registerHoverProvider('far', <vscode.HoverProvider>{
|
|
|
|
|
disposables.push(extHost.registerHoverProvider(defaultSelector, <vscode.HoverProvider>{
|
|
|
|
|
provideHover(): any {
|
|
|
|
|
throw new Error('evil')
|
|
|
|
|
}
|
|
|
|
|
}));
|
|
|
|
|
disposables.push(extHost.registerHoverProvider('far', <vscode.HoverProvider>{
|
|
|
|
|
disposables.push(extHost.registerHoverProvider(defaultSelector, <vscode.HoverProvider>{
|
|
|
|
|
provideHover(): any {
|
|
|
|
|
return new types.Hover('Hello')
|
|
|
|
|
}
|
|
|
|
|
@@ -409,12 +413,106 @@ suite('ExtHostLanguageFeatures', function() {
|
|
|
|
|
|
|
|
|
|
threadService.sync().then(() => {
|
|
|
|
|
|
|
|
|
|
getExtraInfoAtPosition(model.uri, 'far', { lineNumber: 1, column: 1 }).then(value => {
|
|
|
|
|
getExtraInfoAtPosition(model, { lineNumber: 1, column: 1 }).then(value => {
|
|
|
|
|
|
|
|
|
|
assert.equal(value.length, 1);
|
|
|
|
|
done();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// --- occurrences
|
|
|
|
|
|
|
|
|
|
test('Occurrences, data conversion', function(done) {
|
|
|
|
|
|
|
|
|
|
disposables.push(extHost.registerDocumentHighlightProvider(defaultSelector, <vscode.DocumentHighlightProvider>{
|
|
|
|
|
provideDocumentHighlights(): any {
|
|
|
|
|
return [new types.DocumentHighlight(new types.Range(0, 0, 0, 4))]
|
|
|
|
|
}
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
threadService.sync().then(() => {
|
|
|
|
|
|
|
|
|
|
getOccurrencesAtPosition(model, { lineNumber: 1, column: 2 }).then(value => {
|
|
|
|
|
assert.equal(value.length, 1);
|
|
|
|
|
let [entry] = value;
|
|
|
|
|
assert.deepEqual(entry.range, { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 5 });
|
|
|
|
|
assert.equal(entry.kind, 'text');
|
|
|
|
|
done();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('Occurrences, order 1/2', function(done) {
|
|
|
|
|
|
|
|
|
|
disposables.push(extHost.registerDocumentHighlightProvider(defaultSelector, <vscode.DocumentHighlightProvider>{
|
|
|
|
|
provideDocumentHighlights(): any {
|
|
|
|
|
return []
|
|
|
|
|
}
|
|
|
|
|
}));
|
|
|
|
|
disposables.push(extHost.registerDocumentHighlightProvider('*', <vscode.DocumentHighlightProvider>{
|
|
|
|
|
provideDocumentHighlights(): any {
|
|
|
|
|
return [new types.DocumentHighlight(new types.Range(0, 0, 0, 4))]
|
|
|
|
|
}
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
threadService.sync().then(() => {
|
|
|
|
|
|
|
|
|
|
getOccurrencesAtPosition(model, { lineNumber: 1, column: 2 }).then(value => {
|
|
|
|
|
assert.equal(value.length, 1);
|
|
|
|
|
let [entry] = value;
|
|
|
|
|
assert.deepEqual(entry.range, { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 5 });
|
|
|
|
|
assert.equal(entry.kind, 'text');
|
|
|
|
|
done();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('Occurrences, order 2/2', function(done) {
|
|
|
|
|
|
|
|
|
|
disposables.push(extHost.registerDocumentHighlightProvider(defaultSelector, <vscode.DocumentHighlightProvider>{
|
|
|
|
|
provideDocumentHighlights(): any {
|
|
|
|
|
return [new types.DocumentHighlight(new types.Range(0, 0, 0, 2))]
|
|
|
|
|
}
|
|
|
|
|
}));
|
|
|
|
|
disposables.push(extHost.registerDocumentHighlightProvider('*', <vscode.DocumentHighlightProvider>{
|
|
|
|
|
provideDocumentHighlights(): any {
|
|
|
|
|
return [new types.DocumentHighlight(new types.Range(0, 0, 0, 4))]
|
|
|
|
|
}
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
threadService.sync().then(() => {
|
|
|
|
|
|
|
|
|
|
getOccurrencesAtPosition(model, { lineNumber: 1, column: 2 }).then(value => {
|
|
|
|
|
assert.equal(value.length, 1);
|
|
|
|
|
let [entry] = value;
|
|
|
|
|
assert.deepEqual(entry.range, { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 3 });
|
|
|
|
|
assert.equal(entry.kind, 'text');
|
|
|
|
|
done();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('Occurrences, evil provider', function(done) {
|
|
|
|
|
|
|
|
|
|
disposables.push(extHost.registerDocumentHighlightProvider(defaultSelector, <vscode.DocumentHighlightProvider>{
|
|
|
|
|
provideDocumentHighlights(): any {
|
|
|
|
|
throw new Error('evil');
|
|
|
|
|
}
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
disposables.push(extHost.registerDocumentHighlightProvider(defaultSelector, <vscode.DocumentHighlightProvider>{
|
|
|
|
|
provideDocumentHighlights(): any {
|
|
|
|
|
return [new types.DocumentHighlight(new types.Range(0, 0, 0, 4))]
|
|
|
|
|
}
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
threadService.sync().then(() => {
|
|
|
|
|
|
|
|
|
|
getOccurrencesAtPosition(model, { lineNumber: 1, column: 2 }).then(value => {
|
|
|
|
|
assert.equal(value.length, 1);
|
|
|
|
|
done();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|