Skip to content

Commit

Permalink
Merge pull request #67261 from Microsoft/aeschli/json-semantic-selection
Browse files Browse the repository at this point in the history
[json] semantic selection
  • Loading branch information
aeschli committed Jan 28, 2019
2 parents 43c36fb + 1972f79 commit 7ff3173
Show file tree
Hide file tree
Showing 13 changed files with 82 additions and 2,311 deletions.
24 changes: 21 additions & 3 deletions extensions/css-language-features/client/src/cssMain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,24 @@ export function activate(context: ExtensionContext) {

client.onReady().then(() => {
context.subscriptions.push(initCompletionProvider());

documentSelector.forEach(selector => {
context.subscriptions.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 = {
Expand All @@ -94,9 +112,9 @@ export function activate(context: ExtensionContext) {
});
}
};
languages.registerSelectionRangeProvider('css', selectionRangeProvider);
languages.registerSelectionRangeProvider('less', selectionRangeProvider);
languages.registerSelectionRangeProvider('scss', selectionRangeProvider);
documentSelector.forEach(selector => {
languages.registerSelectionRangeProvider(selector, selectionRangeProvider);
});

function initCompletionProvider(): Disposable {
const regionCompletionRegExpr = /^(\s*)(\/(\*\s*(#\w*)?)?)?$/;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

/// <reference path='../../../../../src/vs/vscode.d.ts'/>
/// <reference path="../../../../../src/vs/vscode.proposed.d.ts" />
Loading

0 comments on commit 7ff3173

Please sign in to comment.