vscode-languageclient
Advanced tools
Comparing version 8.2.0-next.1 to 8.2.0-next.2
@@ -1,3 +0,3 @@ | ||
import { TextDocument, Disposable, OutputChannel, DiagnosticCollection, Diagnostic as VDiagnostic, Uri, CancellationToken, WorkspaceFolder as VWorkspaceFolder, FileCreateEvent, FileRenameEvent, FileDeleteEvent, FileWillCreateEvent, FileWillRenameEvent, FileWillDeleteEvent, CompletionItemProvider, HoverProvider, SignatureHelpProvider, DefinitionProvider, ReferenceProvider, DocumentHighlightProvider, CodeActionProvider, DocumentFormattingEditProvider, DocumentRangeFormattingEditProvider, OnTypeFormattingEditProvider, RenameProvider, DocumentSymbolProvider, DocumentLinkProvider, DeclarationProvider, FoldingRangeProvider, ImplementationProvider, DocumentColorProvider, SelectionRangeProvider, TypeDefinitionProvider, CallHierarchyProvider, LinkedEditingRangeProvider, TypeHierarchyProvider, WorkspaceSymbolProvider, ProviderResult, TextEdit as VTextEdit } from 'vscode'; | ||
import { Message, MessageSignature, ResponseError, RequestType0, RequestType, NotificationType0, NotificationType, ProtocolRequestType, ProtocolRequestType0, RequestHandler, RequestHandler0, GenericRequestHandler, ProtocolNotificationType, ProtocolNotificationType0, NotificationHandler, NotificationHandler0, GenericNotificationHandler, MessageReader, MessageWriter, Trace, Event, RegistrationRequest, RegistrationParams, UnregistrationRequest, UnregistrationParams, InitializeParams, InitializeResult, DocumentSelector, DidChangeTextDocumentNotification, FileEvent, ProgressType, ProgressToken, ShowDocumentRequest, ShowDocumentParams, ShowDocumentResult, CancellationStrategy, InitializeError, WorkDoneProgressBegin, WorkDoneProgressReport, WorkDoneProgressEnd, DidOpenTextDocumentNotification, WillSaveTextDocumentNotification, WillSaveTextDocumentWaitUntilRequest, DidSaveTextDocumentNotification, DidCloseTextDocumentNotification, DidCreateFilesNotification, DidRenameFilesNotification, DidDeleteFilesNotification, WillRenameFilesRequest, WillCreateFilesRequest, WillDeleteFilesRequest, CompletionRequest, HoverRequest, SignatureHelpRequest, DefinitionRequest, ReferencesRequest, DocumentHighlightRequest, CodeActionRequest, CodeLensRequest, DocumentFormattingRequest, DocumentRangeFormattingRequest, DocumentOnTypeFormattingRequest, RenameRequest, DocumentSymbolRequest, DocumentLinkRequest, DocumentColorRequest, DeclarationRequest, FoldingRangeRequest, ImplementationRequest, SelectionRangeRequest, TypeDefinitionRequest, CallHierarchyPrepareRequest, SemanticTokensRegistrationType, LinkedEditingRangeRequest, TypeHierarchyPrepareRequest, InlineValueRequest, InlayHintRequest, WorkspaceSymbolRequest, TextDocumentRegistrationOptions, FileOperationRegistrationOptions, DocumentDiagnosticRequest, NotebookDocumentSyncRegistrationType, NotebookDocumentSyncRegistrationOptions, MessageStrategy } from 'vscode-languageserver-protocol'; | ||
import { TextDocument, Disposable, OutputChannel, DiagnosticCollection, Diagnostic as VDiagnostic, Uri, CancellationToken, WorkspaceFolder as VWorkspaceFolder, FileCreateEvent, FileRenameEvent, FileDeleteEvent, FileWillCreateEvent, FileWillRenameEvent, FileWillDeleteEvent, CompletionItemProvider, HoverProvider, SignatureHelpProvider, DefinitionProvider, ReferenceProvider, DocumentHighlightProvider, CodeActionProvider, DocumentFormattingEditProvider, DocumentRangeFormattingEditProvider, OnTypeFormattingEditProvider, RenameProvider, DocumentSymbolProvider, DocumentLinkProvider, DeclarationProvider, FoldingRangeProvider, ImplementationProvider, DocumentColorProvider, SelectionRangeProvider, TypeDefinitionProvider, CallHierarchyProvider, LinkedEditingRangeProvider, TypeHierarchyProvider, WorkspaceSymbolProvider, ProviderResult, TextEdit as VTextEdit, InlineCompletionItemProvider } from 'vscode'; | ||
import { Message, MessageSignature, ResponseError, RequestType0, RequestType, NotificationType0, NotificationType, ProtocolRequestType, ProtocolRequestType0, RequestHandler, RequestHandler0, GenericRequestHandler, ProtocolNotificationType, ProtocolNotificationType0, NotificationHandler, NotificationHandler0, GenericNotificationHandler, MessageReader, MessageWriter, Trace, Event, RegistrationRequest, RegistrationParams, UnregistrationRequest, UnregistrationParams, InitializeParams, InitializeResult, DocumentSelector, DidChangeTextDocumentNotification, FileEvent, ProgressType, ProgressToken, ShowDocumentRequest, ShowDocumentParams, ShowDocumentResult, CancellationStrategy, InitializeError, WorkDoneProgressBegin, WorkDoneProgressReport, WorkDoneProgressEnd, DidOpenTextDocumentNotification, WillSaveTextDocumentNotification, WillSaveTextDocumentWaitUntilRequest, DidSaveTextDocumentNotification, DidCloseTextDocumentNotification, DidCreateFilesNotification, DidRenameFilesNotification, DidDeleteFilesNotification, WillRenameFilesRequest, WillCreateFilesRequest, WillDeleteFilesRequest, CompletionRequest, HoverRequest, SignatureHelpRequest, DefinitionRequest, ReferencesRequest, DocumentHighlightRequest, CodeActionRequest, CodeLensRequest, DocumentFormattingRequest, DocumentRangeFormattingRequest, DocumentOnTypeFormattingRequest, RenameRequest, DocumentSymbolRequest, DocumentLinkRequest, DocumentColorRequest, DeclarationRequest, FoldingRangeRequest, ImplementationRequest, SelectionRangeRequest, TypeDefinitionRequest, CallHierarchyPrepareRequest, SemanticTokensRegistrationType, LinkedEditingRangeRequest, TypeHierarchyPrepareRequest, InlineValueRequest, InlayHintRequest, WorkspaceSymbolRequest, TextDocumentRegistrationOptions, FileOperationRegistrationOptions, DocumentDiagnosticRequest, NotebookDocumentSyncRegistrationType, NotebookDocumentSyncRegistrationOptions, MessageStrategy, InlineCompletionRequest, InlineCompletionRegistrationOptions } from 'vscode-languageserver-protocol'; | ||
import * as c2p from './codeConverter'; | ||
@@ -38,2 +38,3 @@ import * as p2c from './protocolConverter'; | ||
import { FileOperationsMiddleware } from './fileOperations'; | ||
import { InlineCompletionMiddleware } from './inlineCompletion'; | ||
/** | ||
@@ -230,3 +231,3 @@ * Controls when the output channel is revealed. | ||
*/ | ||
export declare type Middleware = _Middleware & TextDocumentSynchronizationMiddleware & CompletionMiddleware & HoverMiddleware & DefinitionMiddleware & SignatureHelpMiddleware & DocumentHighlightMiddleware & DocumentSymbolMiddleware & WorkspaceSymbolMiddleware & ReferencesMiddleware & TypeDefinitionMiddleware & ImplementationMiddleware & ColorProviderMiddleware & CodeActionMiddleware & CodeLensMiddleware & FormattingMiddleware & RenameMiddleware & DocumentLinkMiddleware & ExecuteCommandMiddleware & FoldingRangeProviderMiddleware & DeclarationMiddleware & SelectionRangeProviderMiddleware & CallHierarchyMiddleware & SemanticTokensMiddleware & LinkedEditingRangeMiddleware & TypeHierarchyMiddleware & InlineValueMiddleware & InlayHintsMiddleware & NotebookDocumentMiddleware & DiagnosticProviderMiddleware & GeneralMiddleware; | ||
export declare type Middleware = _Middleware & TextDocumentSynchronizationMiddleware & CompletionMiddleware & HoverMiddleware & DefinitionMiddleware & SignatureHelpMiddleware & DocumentHighlightMiddleware & DocumentSymbolMiddleware & WorkspaceSymbolMiddleware & ReferencesMiddleware & TypeDefinitionMiddleware & ImplementationMiddleware & ColorProviderMiddleware & CodeActionMiddleware & CodeLensMiddleware & FormattingMiddleware & RenameMiddleware & DocumentLinkMiddleware & ExecuteCommandMiddleware & FoldingRangeProviderMiddleware & DeclarationMiddleware & SelectionRangeProviderMiddleware & CallHierarchyMiddleware & SemanticTokensMiddleware & LinkedEditingRangeMiddleware & TypeHierarchyMiddleware & InlineValueMiddleware & InlayHintsMiddleware & NotebookDocumentMiddleware & DiagnosticProviderMiddleware & InlineCompletionMiddleware & GeneralMiddleware; | ||
export declare type LanguageClientOptions = { | ||
@@ -260,3 +261,5 @@ documentSelector?: DocumentSelector | string[]; | ||
markdown?: { | ||
isTrusted?: boolean; | ||
isTrusted?: boolean | { | ||
readonly enabledCommands: readonly string[]; | ||
}; | ||
supportHtml?: boolean; | ||
@@ -452,2 +455,3 @@ }; | ||
getFeature(request: typeof NotebookDocumentSyncRegistrationType.method): DynamicFeature<NotebookDocumentSyncRegistrationOptions> & NotebookDocumentProviderShape | undefined; | ||
getFeature(request: typeof InlineCompletionRequest.method): DynamicFeature<InlineCompletionRegistrationOptions> & TextDocumentProviderFeature<InlineCompletionItemProvider>; | ||
hasDedicatedTextSynchronizationFeature(textDocument: TextDocument): boolean; | ||
@@ -454,0 +458,0 @@ protected registerBuiltinFeatures(): void; |
@@ -39,2 +39,3 @@ import * as code from 'vscode'; | ||
asRange(value: code.Range | undefined | null): proto.Range | undefined | null; | ||
asRanges(values: readonly code.Range[]): proto.Range[]; | ||
asLocation(value: null): null; | ||
@@ -73,2 +74,3 @@ asLocation(value: undefined): undefined; | ||
asInlayHint(value: code.InlayHint): proto.InlayHint; | ||
asInlineCompletionParams(document: code.TextDocument, position: code.Position, context: code.InlineCompletionContext): proto.InlineCompletionParams; | ||
} | ||
@@ -75,0 +77,0 @@ export interface URIConverter { |
@@ -279,2 +279,5 @@ "use strict"; | ||
} | ||
function asRanges(values) { | ||
return values.map(asRange); | ||
} | ||
function asLocation(value) { | ||
@@ -655,2 +658,6 @@ if (value === undefined || value === null) { | ||
} | ||
function asInlineCompletionParams(document, position, context) { | ||
return { context: proto.InlineCompletionContext.create(context.triggerKind, context.selectedCompletionInfo), | ||
textDocument: asTextDocumentIdentifier(document), position: asPosition(position) }; | ||
} | ||
function asCommand(item) { | ||
@@ -836,2 +843,3 @@ let result = proto.Command.create(item.title, item.command); | ||
asRange, | ||
asRanges, | ||
asPosition, | ||
@@ -867,5 +875,6 @@ asPositions, | ||
asInlayHint, | ||
asWorkspaceSymbol | ||
asWorkspaceSymbol, | ||
asInlineCompletionParams | ||
}; | ||
} | ||
exports.createConverter = createConverter; |
@@ -671,2 +671,29 @@ "use strict"; | ||
})); | ||
disposables.push(tabs.onOpen((opened) => { | ||
for (const resource of opened) { | ||
// We already know about this document. This can happen via a document open. | ||
if (this.diagnosticRequestor.knows(PullState.document, resource)) { | ||
continue; | ||
} | ||
const uriStr = resource.toString(); | ||
let textDocument; | ||
for (const item of vscode_1.workspace.textDocuments) { | ||
if (uriStr === item.uri.toString()) { | ||
textDocument = item; | ||
break; | ||
} | ||
} | ||
// In VS Code the event timing is as follows: | ||
// 1. tab events are fired. | ||
// 2. open document events are fired and internal data structures like | ||
// workspace.textDocuments and Window.activeTextEditor are updated. | ||
// | ||
// This means: for newly created tab/editors we don't find the underlying | ||
// document yet. So we do nothing an rely on the underlying open document event | ||
// to be fired. | ||
if (textDocument !== undefined && matches(textDocument)) { | ||
this.diagnosticRequestor.pull(textDocument, () => { addToBackgroundIfNeeded(textDocument); }); | ||
} | ||
} | ||
})); | ||
// Pull all diagnostics for documents that are already open | ||
@@ -673,0 +700,0 @@ const pulledTextDocuments = new Set(); |
@@ -0,1 +1,2 @@ | ||
/// <reference path="../../typings/vscode.proposed.formatMultipleRanges.d.ts" /> | ||
import { Disposable, TextDocument, ProviderResult, Range as VRange, Position as VPosition, TextEdit as VTextEdit, FormattingOptions as VFormattingOptions, DocumentFormattingEditProvider, DocumentRangeFormattingEditProvider, OnTypeFormattingEditProvider } from 'vscode'; | ||
@@ -10,2 +11,5 @@ import { ClientCapabilities, CancellationToken, ServerCapabilities, DocumentSelector, DocumentHighlightRegistrationOptions, DocumentFormattingOptions, TextDocumentRegistrationOptions, DocumentRangeFormattingRegistrationOptions, DocumentRangeFormattingOptions, DocumentOnTypeFormattingOptions, DocumentOnTypeFormattingRegistrationOptions } from 'vscode-languageserver-protocol'; | ||
} | ||
export interface ProvideDocumentRangesFormattingEditsSignature { | ||
(this: void, document: TextDocument, ranges: VRange[], options: VFormattingOptions, token: CancellationToken): ProviderResult<VTextEdit[]>; | ||
} | ||
export interface ProvideOnTypeFormattingEditsSignature { | ||
@@ -17,2 +21,3 @@ (this: void, document: TextDocument, position: VPosition, ch: string, options: VFormattingOptions, token: CancellationToken): ProviderResult<VTextEdit[]>; | ||
provideDocumentRangeFormattingEdits?: (this: void, document: TextDocument, range: VRange, options: VFormattingOptions, token: CancellationToken, next: ProvideDocumentRangeFormattingEditsSignature) => ProviderResult<VTextEdit[]>; | ||
provideDocumentRangesFormattingEdits?: (this: void, document: TextDocument, range: VRange[], options: VFormattingOptions, token: CancellationToken, next: ProvideDocumentRangesFormattingEditsSignature) => ProviderResult<VTextEdit[]>; | ||
provideOnTypeFormattingEdits?: (this: void, document: TextDocument, position: VPosition, ch: string, options: VFormattingOptions, token: CancellationToken, next: ProvideOnTypeFormattingEditsSignature) => ProviderResult<VTextEdit[]>; | ||
@@ -30,3 +35,3 @@ } | ||
initialize(capabilities: ServerCapabilities, documentSelector: DocumentSelector): void; | ||
protected registerLanguageProvider(options: TextDocumentRegistrationOptions): [Disposable, DocumentRangeFormattingEditProvider]; | ||
protected registerLanguageProvider(options: DocumentRangeFormattingRegistrationOptions): [Disposable, DocumentRangeFormattingEditProvider]; | ||
} | ||
@@ -33,0 +38,0 @@ export declare class DocumentOnTypeFormattingFeature extends TextDocumentLanguageFeature<DocumentOnTypeFormattingOptions, DocumentOnTypeFormattingRegistrationOptions, OnTypeFormattingEditProvider, FormattingMiddleware> { |
@@ -6,2 +6,3 @@ "use strict"; | ||
* ------------------------------------------------------------------------------------------ */ | ||
/// <reference path="../../typings/vscode.proposed.formatMultipleRanges.d.ts" /> | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -73,3 +74,5 @@ exports.DocumentOnTypeFormattingFeature = exports.DocumentRangeFormattingFeature = exports.DocumentFormattingFeature = void 0; | ||
fillClientCapabilities(capabilities) { | ||
(0, features_1.ensure)((0, features_1.ensure)(capabilities, 'textDocument'), 'rangeFormatting').dynamicRegistration = true; | ||
const capability = (0, features_1.ensure)((0, features_1.ensure)(capabilities, 'textDocument'), 'rangeFormatting'); | ||
capability.dynamicRegistration = true; | ||
capability.rangesSupport = true; | ||
} | ||
@@ -109,2 +112,26 @@ initialize(capabilities, documentSelector) { | ||
}; | ||
if (options.rangesSupport) { | ||
provider.provideDocumentRangesFormattingEdits = (document, ranges, options, token) => { | ||
const client = this._client; | ||
const provideDocumentRangesFormattingEdits = (document, ranges, options, token) => { | ||
const params = { | ||
textDocument: client.code2ProtocolConverter.asTextDocumentIdentifier(document), | ||
ranges: client.code2ProtocolConverter.asRanges(ranges), | ||
options: client.code2ProtocolConverter.asFormattingOptions(options, FileFormattingOptions.fromConfiguration(document)) | ||
}; | ||
return client.sendRequest(vscode_languageserver_protocol_1.DocumentRangesFormattingRequest.type, params, token).then((result) => { | ||
if (token.isCancellationRequested) { | ||
return null; | ||
} | ||
return client.protocol2CodeConverter.asTextEdits(result, token); | ||
}, (error) => { | ||
return client.handleFailedRequest(vscode_languageserver_protocol_1.DocumentRangesFormattingRequest.type, token, error, null); | ||
}); | ||
}; | ||
const middleware = client.middleware; | ||
return middleware.provideDocumentRangesFormattingEdits | ||
? middleware.provideDocumentRangesFormattingEdits(document, ranges, options, token, provideDocumentRangesFormattingEdits) | ||
: provideDocumentRangesFormattingEdits(document, ranges, options, token); | ||
}; | ||
} | ||
return [vscode_1.languages.registerDocumentRangeFormattingEditProvider(this._client.protocol2CodeConverter.asDocumentSelector(selector), provider), provider]; | ||
@@ -111,0 +138,0 @@ } |
@@ -156,2 +156,7 @@ import * as code from 'vscode'; | ||
asGlobPattern(pattern: ls.GlobPattern): code.GlobPattern | undefined; | ||
asInlineCompletionResult(value: undefined | null, token?: code.CancellationToken): Promise<undefined>; | ||
asInlineCompletionResult(value: ls.InlineCompletionList, token?: code.CancellationToken): Promise<code.InlineCompletionList>; | ||
asInlineCompletionResult(value: ls.InlineCompletionItem[], token?: code.CancellationToken): Promise<code.InlineCompletionItem[]>; | ||
asInlineCompletionResult(value: ls.InlineCompletionItem[] | ls.InlineCompletionList | undefined | null, token?: code.CancellationToken): Promise<code.InlineCompletionItem[] | code.InlineCompletionList | undefined>; | ||
asInlineCompletionItem(item: ls.InlineCompletionItem): code.InlineCompletionItem; | ||
} | ||
@@ -161,2 +166,4 @@ export interface URIConverter { | ||
} | ||
export declare function createConverter(uriConverter: URIConverter | undefined, trustMarkdown: boolean, supportHtml: boolean): Converter; | ||
export declare function createConverter(uriConverter: URIConverter | undefined, trustMarkdown: boolean | { | ||
readonly enabledCommands: readonly string[]; | ||
}, supportHtml: boolean): Converter; |
@@ -1026,2 +1026,33 @@ "use strict"; | ||
} | ||
async function asInlineCompletionResult(value, token) { | ||
if (!value) { | ||
return undefined; | ||
} | ||
if (Array.isArray(value)) { | ||
return async.map(value, (item) => asInlineCompletionItem(item), token); | ||
} | ||
const list = value; | ||
const converted = await async.map(list.items, (item) => { | ||
return asInlineCompletionItem(item); | ||
}, token); | ||
return new code.InlineCompletionList(converted); | ||
} | ||
function asInlineCompletionItem(item) { | ||
let insertText; | ||
if (typeof item.insertText === 'string') { | ||
insertText = item.insertText; | ||
} | ||
else { | ||
insertText = new code.SnippetString(item.insertText.value); | ||
} | ||
let command = undefined; | ||
if (item.command) { | ||
command = asCommand(item.command); | ||
} | ||
const inlineCompletionItem = new code.InlineCompletionItem(insertText, asRange(item.range), command); | ||
if (item.filterText) { | ||
inlineCompletionItem.filterText = item.filterText; | ||
} | ||
return inlineCompletionItem; | ||
} | ||
return { | ||
@@ -1099,5 +1130,7 @@ asUri, | ||
asTypeHierarchyItems, | ||
asGlobPattern | ||
asGlobPattern, | ||
asInlineCompletionResult, | ||
asInlineCompletionItem | ||
}; | ||
} | ||
exports.createConverter = createConverter; |
@@ -35,3 +35,3 @@ "use strict"; | ||
__exportStar(require("../common/api"), exports); | ||
const REQUIRED_VSCODE_VERSION = '^1.77.0'; // do not change format, updated by `updateVSCode` script | ||
const REQUIRED_VSCODE_VERSION = '^1.79.0'; // do not change format, updated by `updateVSCode` script | ||
var TransportKind; | ||
@@ -38,0 +38,0 @@ (function (TransportKind) { |
{ | ||
"name": "vscode-languageclient", | ||
"description": "VSCode Language client implementation", | ||
"version": "8.2.0-next.1", | ||
"version": "8.2.0-next.2", | ||
"author": "Microsoft Corporation", | ||
"license": "MIT", | ||
"engines": { | ||
"vscode": "^1.77.0" | ||
"vscode": "^1.79.0" | ||
}, | ||
@@ -18,3 +18,3 @@ "repository": { | ||
}, | ||
"enabledApiProposals": [], | ||
"enabledApiProposals": ["formatMultipleRanges"], | ||
"main": "./lib/node/main.js", | ||
@@ -28,3 +28,3 @@ "browser": { | ||
"@types/semver": "^7.3.10", | ||
"@types/vscode": "1.67.0", | ||
"@types/vscode": "1.79.0", | ||
"shx": "^0.3.4" | ||
@@ -34,4 +34,4 @@ }, | ||
"minimatch": "^5.1.0", | ||
"semver": "^7.3.7", | ||
"vscode-languageserver-protocol": "3.17.4-next.1" | ||
"semver": "^7.5.4", | ||
"vscode-languageserver-protocol": "3.17.4-next.2" | ||
}, | ||
@@ -38,0 +38,0 @@ "scripts": { |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
652417
122
12987
+ Addedvscode-jsonrpc@8.2.0-next.1(transitive)
+ Addedvscode-languageserver-protocol@3.17.4-next.2(transitive)
+ Addedvscode-languageserver-types@3.17.4-next.1(transitive)
- Removedvscode-jsonrpc@8.2.0-next.0(transitive)
- Removedvscode-languageserver-protocol@3.17.4-next.1(transitive)
- Removedvscode-languageserver-types@3.17.4-next.0(transitive)
Updatedsemver@^7.5.4