client: semantic selection registration

This commit is contained in:
Martin Aeschlimann
2019-01-28 18:24:12 +01:00
parent 21585312c2
commit 1972f79077
3 changed files with 54 additions and 33 deletions

View File

@@ -194,26 +194,26 @@ export function activate(context: ExtensionContext) {
client.sendNotification(SchemaAssociationNotification.type, getSchemaAssociation(context));
documentSelector.forEach(selector => {
toDispose.push(languages.registerSelectionRangeProvider(selector, {
async provideSelectionRanges(document: TextDocument, position: Position): Promise<SelectionRange[]> {
const textDocument = client.code2ProtocolConverter.asTextDocumentIdentifier(document);
const rawRanges = await client.sendRequest<Range[]>('$/textDocument/selectionRange', { textDocument, position });
if (Array.isArray(rawRanges)) {
return rawRanges.map(r => {
return {
range: client.protocol2CodeConverter.asRange(r),
kind: SelectionRangeKind.Declaration
};
});
}
return [];
}
}));
});
});
const selectionRangeProvider = {
async provideSelectionRanges(document: TextDocument, position: Position): Promise<SelectionRange[]> {
const textDocument = client.code2ProtocolConverter.asTextDocumentIdentifier(document);
const rawRanges = await client.sendRequest<Range[]>('$/textDocument/selectionRange', { textDocument, position });
if (Array.isArray(rawRanges)) {
return rawRanges.map(r => {
return {
range: client.protocol2CodeConverter.asRange(r),
kind: SelectionRangeKind.Declaration
};
});
}
return [];
}
};
documentSelector.forEach(selector => {
languages.registerSelectionRangeProvider(selector, selectionRangeProvider);
});
let languageConfiguration: LanguageConfiguration = {
wordPattern: /("(?:[^\\\"]*(?:\\.)?)*"?)|[^\s{}\[\],:]+/,