mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-24 20:26:08 +00:00
@@ -9,7 +9,7 @@ import * as fs from 'fs';
|
||||
import * as nls from 'vscode-nls';
|
||||
const localize = nls.loadMessageBundle();
|
||||
|
||||
import { languages, window, commands, ExtensionContext, Range, Position, CompletionItem, CompletionItemKind, TextEdit, SnippetString, workspace, TextDocument, SelectionRange } from 'vscode';
|
||||
import { languages, window, commands, ExtensionContext, Range, Position, CompletionItem, CompletionItemKind, TextEdit, SnippetString, workspace } from 'vscode';
|
||||
import { LanguageClient, LanguageClientOptions, ServerOptions, TransportKind, Disposable } from 'vscode-languageclient';
|
||||
import { getCustomDataPathsInAllWorkspaces, getCustomDataPathsFromAllExtensions } from './customData';
|
||||
|
||||
@@ -78,26 +78,6 @@ 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, positions: Position[]): Promise<SelectionRange[]> {
|
||||
const textDocument = client.code2ProtocolConverter.asTextDocumentIdentifier(document);
|
||||
const rawResult = await client.sendRequest<SelectionRange[][]>('$/textDocument/selectionRanges', { textDocument, positions: positions.map(client.code2ProtocolConverter.asPosition) });
|
||||
if (Array.isArray(rawResult)) {
|
||||
return rawResult.map(rawSelectionRanges => {
|
||||
return rawSelectionRanges.reduceRight((parent: SelectionRange | undefined, selectionRange: SelectionRange) => {
|
||||
return {
|
||||
range: client.protocol2CodeConverter.asRange(selectionRange.range),
|
||||
parent
|
||||
};
|
||||
}, undefined)!;
|
||||
});
|
||||
}
|
||||
return [];
|
||||
}
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
||||
function initCompletionProvider(): Disposable {
|
||||
|
||||
@@ -374,7 +374,7 @@ connection.onFoldingRanges((params, token) => {
|
||||
}, null, `Error while computing folding ranges for ${params.textDocument.uri}`, token);
|
||||
});
|
||||
|
||||
connection.onRequest('$/textDocument/selectionRanges', async (params, token) => {
|
||||
connection.onSelectionRanges((params, token) => {
|
||||
return runSafe(() => {
|
||||
const document = documents.get(params.textDocument.uri);
|
||||
const positions: Position[] = params.positions;
|
||||
@@ -383,8 +383,8 @@ connection.onRequest('$/textDocument/selectionRanges', async (params, token) =>
|
||||
const stylesheet = stylesheets.get(document);
|
||||
return getLanguageService(document).getSelectionRanges(document, positions, stylesheet);
|
||||
}
|
||||
return Promise.resolve(null);
|
||||
}, null, `Error while computing selection ranges for ${params.textDocument.uri}`, token);
|
||||
return [];
|
||||
}, [], `Error while computing selection ranges for ${params.textDocument.uri}`, token);
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import * as fs from 'fs';
|
||||
import * as nls from 'vscode-nls';
|
||||
const localize = nls.loadMessageBundle();
|
||||
|
||||
import { languages, ExtensionContext, IndentAction, Position, TextDocument, Range, CompletionItem, CompletionItemKind, SnippetString, workspace, SelectionRange } from 'vscode';
|
||||
import { languages, ExtensionContext, IndentAction, Position, TextDocument, Range, CompletionItem, CompletionItemKind, SnippetString, workspace } from 'vscode';
|
||||
import { LanguageClient, LanguageClientOptions, ServerOptions, TransportKind, RequestType, TextDocumentPositionParams } from 'vscode-languageclient';
|
||||
import { EMPTY_ELEMENTS } from './htmlEmptyTagsShared';
|
||||
import { activateTagClosing } from './tagClosing';
|
||||
@@ -87,26 +87,6 @@ export function activate(context: ExtensionContext) {
|
||||
}
|
||||
});
|
||||
toDispose.push(disposable);
|
||||
|
||||
documentSelector.forEach(selector => {
|
||||
context.subscriptions.push(languages.registerSelectionRangeProvider(selector, {
|
||||
async provideSelectionRanges(document: TextDocument, positions: Position[]): Promise<SelectionRange[]> {
|
||||
const textDocument = client.code2ProtocolConverter.asTextDocumentIdentifier(document);
|
||||
const rawResult = await client.sendRequest<SelectionRange[][]>('$/textDocument/selectionRanges', { textDocument, positions: positions.map(client.code2ProtocolConverter.asPosition) });
|
||||
if (Array.isArray(rawResult)) {
|
||||
return rawResult.map(rawSelectionRanges => {
|
||||
return rawSelectionRanges.reduceRight((parent: SelectionRange | undefined, selectionRange: SelectionRange) => {
|
||||
return {
|
||||
range: client.protocol2CodeConverter.asRange(selectionRange.range),
|
||||
parent
|
||||
};
|
||||
}, undefined)!;
|
||||
});
|
||||
}
|
||||
return [];
|
||||
}
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
||||
languages.setLanguageConfiguration('html', {
|
||||
|
||||
@@ -454,7 +454,7 @@ connection.onFoldingRanges((params, token) => {
|
||||
}, null, `Error while computing folding regions for ${params.textDocument.uri}`, token);
|
||||
});
|
||||
|
||||
connection.onRequest('$/textDocument/selectionRanges', async (params, token) => {
|
||||
connection.onSelectionRanges((params, token) => {
|
||||
return runSafe(() => {
|
||||
const document = documents.get(params.textDocument.uri);
|
||||
const positions: Position[] = params.positions;
|
||||
@@ -465,8 +465,8 @@ connection.onRequest('$/textDocument/selectionRanges', async (params, token) =>
|
||||
return htmlMode.getSelectionRanges(document, positions);
|
||||
}
|
||||
}
|
||||
return Promise.resolve(null);
|
||||
}, null, `Error while computing selection ranges for ${params.textDocument.uri}`, token);
|
||||
return [];
|
||||
}, [], `Error while computing selection ranges for ${params.textDocument.uri}`, token);
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import { xhr, XHRResponse, getErrorStatusDescription } from 'request-light';
|
||||
|
||||
const localize = nls.loadMessageBundle();
|
||||
|
||||
import { workspace, window, languages, commands, ExtensionContext, extensions, Uri, LanguageConfiguration, Diagnostic, StatusBarAlignment, TextEditor, TextDocument, Position, SelectionRange } from 'vscode';
|
||||
import { workspace, window, languages, commands, ExtensionContext, extensions, Uri, LanguageConfiguration, Diagnostic, StatusBarAlignment, TextEditor } from 'vscode';
|
||||
import { LanguageClient, LanguageClientOptions, RequestType, ServerOptions, TransportKind, NotificationType, DidChangeConfigurationNotification, HandleDiagnosticsSignature, ResponseError } from 'vscode-languageclient';
|
||||
import TelemetryReporter from 'vscode-extension-telemetry';
|
||||
|
||||
@@ -216,26 +216,6 @@ export function activate(context: ExtensionContext) {
|
||||
extensions.onDidChange(_ => {
|
||||
client.sendNotification(SchemaAssociationNotification.type, getSchemaAssociation(context));
|
||||
});
|
||||
|
||||
documentSelector.forEach(selector => {
|
||||
toDispose.push(languages.registerSelectionRangeProvider(selector, {
|
||||
async provideSelectionRanges(document: TextDocument, positions: Position[]): Promise<SelectionRange[]> {
|
||||
const textDocument = client.code2ProtocolConverter.asTextDocumentIdentifier(document);
|
||||
const rawResult = await client.sendRequest<SelectionRange[][]>('$/textDocument/selectionRanges', { textDocument, positions: positions.map(client.code2ProtocolConverter.asPosition) });
|
||||
if (Array.isArray(rawResult)) {
|
||||
return rawResult.map(rawSelectionRanges => {
|
||||
return rawSelectionRanges.reduceRight((parent: SelectionRange | undefined, selectionRange: SelectionRange) => {
|
||||
return {
|
||||
range: client.protocol2CodeConverter.asRange(selectionRange.range),
|
||||
parent,
|
||||
};
|
||||
}, undefined)!;
|
||||
});
|
||||
}
|
||||
return [];
|
||||
}
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -433,7 +433,8 @@ connection.onFoldingRanges((params, token) => {
|
||||
}, null, `Error while computing folding ranges for ${params.textDocument.uri}`, token);
|
||||
});
|
||||
|
||||
connection.onRequest('$/textDocument/selectionRanges', async (params, token) => {
|
||||
|
||||
connection.onSelectionRanges((params, token) => {
|
||||
return runSafe(() => {
|
||||
const document = documents.get(params.textDocument.uri);
|
||||
if (document) {
|
||||
|
||||
Reference in New Issue
Block a user