Skip to content

Commit

Permalink
squash!
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolaRHristov committed Dec 15, 2023
1 parent 451c8c3 commit 3ac4181
Show file tree
Hide file tree
Showing 193 changed files with 166 additions and 40,296 deletions.
33 changes: 17 additions & 16 deletions client/Source/common/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -711,24 +711,25 @@ export abstract class BaseLanguageClient implements FeatureClient<Middleware, La
await this.sendPendingFullTextDocumentChanges(connection);
}

const _sendRequest = this._clientOptions.middleware?.sendRequest;
if (_sendRequest !== undefined) {
let param: any | undefined = undefined;
let token: CancellationToken | undefined = undefined;

// Separate cancellation tokens from other parameters for a better client interface
if (params.length === 1) {
// CancellationToken is an interface, so we need to check if the first param complies to it
if (ProtocolCancellationToken.is(params[0])) {
token = params[0];
} else {
param = params[0];
}
} else if (params.length === 2) {
let param: any | undefined = undefined;
let token: CancellationToken | undefined = undefined;
// Separate cancellation tokens from other parameters for a better client interface
if (params.length === 1) {
// CancellationToken is an interface, so we need to check if the first param complies to it
if (ProtocolCancellationToken.is(params[0])) {
token = params[0];
} else {
param = params[0];
token = params[1];
}

} else if (params.length === 2) {
param = params[0];
token = params[1];
}
if (token !== undefined && token.isCancellationRequested) {
return Promise.reject(new ResponseError(LSPErrorCodes.RequestCancelled, 'Request got cancelled'));
}
const _sendRequest = this._clientOptions.middleware?.sendRequest;
if (_sendRequest !== undefined) {
// Return the general middleware invocation defining `next` as a utility function that reorganizes parameters to
// pass them to the original sendRequest function.
return _sendRequest(type, param, token, (type, param, token) => {
Expand Down
18 changes: 13 additions & 5 deletions client/Source/common/codeAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import {
languages as Languages, Disposable, TextDocument, ProviderResult, Range as VRange, Command as VCommand, CodeAction as VCodeAction,
CodeActionContext as VCodeActionContext, CodeActionProvider
CodeActionContext as VCodeActionContext, CodeActionProvider, CodeActionProviderMetadata
} from 'vscode';

import {
Expand Down Expand Up @@ -60,6 +60,7 @@ export class CodeActionFeature extends TextDocumentLanguageFeature<boolean | Cod
}
};
cap.honorsChangeAnnotations = true;
cap.documentationSupport = true;
}

public initialize(capabilities: ServerCapabilities, documentSelector: DocumentSelector): void {
Expand Down Expand Up @@ -115,9 +116,16 @@ export class CodeActionFeature extends TextDocumentLanguageFeature<boolean | Cod
}
: undefined
};
return [Languages.registerCodeActionsProvider(this._client.protocol2CodeConverter.asDocumentSelector(selector), provider,
(options.codeActionKinds
? { providedCodeActionKinds: this._client.protocol2CodeConverter.asCodeActionKinds(options.codeActionKinds) }
: undefined)), provider];
return [Languages.registerCodeActionsProvider(this._client.protocol2CodeConverter.asDocumentSelector(selector), provider, this.getMetadata(options)), provider];
}

private getMetadata(options: CodeActionRegistrationOptions): CodeActionProviderMetadata | undefined {
if (options.codeActionKinds === undefined && options.documentation === undefined) {
return undefined;
}
return {
providedCodeActionKinds: this._client.protocol2CodeConverter.asCodeActionKinds(options.codeActionKinds),
documentation: this._client.protocol2CodeConverter.asCodeActionDocumentations(options.documentation)
};
}
}
1 change: 1 addition & 0 deletions client/Source/common/codeConverter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -835,6 +835,7 @@ export function createConverter(uriConverter?: URIConverter): Converter {

function asCommand(item: code.Command): proto.Command {
const result = proto.Command.create(item.title, item.command);
if (item.tooltip) { result.tooltip = item.tooltip; }
if (item.arguments) { result.arguments = item.arguments; }
return result;
}
Expand Down
16 changes: 16 additions & 0 deletions client/Source/common/protocolConverter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ export interface Converter {
asCodeActionKinds(items: ls.CodeActionKind[]): code.CodeActionKind[];
asCodeActionKinds(item: ls.CodeActionKind[] | null | undefined): code.CodeActionKind[] | undefined;

asCodeActionDocumentations(items: null | undefined): undefined;
asCodeActionDocumentations(items: ls.CodeActionKindDocumentation[]): code.CodeActionProviderMetadata['documentation'];
asCodeActionDocumentations(items: ls.CodeActionKindDocumentation[] | null | undefined): code.CodeActionProviderMetadata['documentation'] | undefined;

asCodeActionResult(items: (ls.Command | ls.CodeAction)[], token?: code.CancellationToken): Promise<(code.Command | code.CodeAction)[]>;

asCodeLens(item: ls.CodeLens): code.CodeLens;
Expand Down Expand Up @@ -932,6 +936,7 @@ export function createConverter(uriConverter: URIConverter | undefined, trustMar

function asCommand(item: ls.Command): code.Command {
const result: code.Command = { title: item.title, command: item.command };
if (item.tooltip) { result.tooltip = item.tooltip; }
if (item.arguments) { result.arguments = item.arguments; }
return result;
}
Expand Down Expand Up @@ -985,6 +990,16 @@ export function createConverter(uriConverter: URIConverter | undefined, trustMar
return items.map(kind => asCodeActionKind(kind));
}

function asCodeActionDocumentations(items: null | undefined): undefined;
function asCodeActionDocumentations(items: ls.CodeActionKindDocumentation[]): code.CodeActionProviderMetadata['documentation'];
function asCodeActionDocumentations(items: ls.CodeActionKindDocumentation[] | null | undefined): code.CodeActionProviderMetadata['documentation'] | undefined;
function asCodeActionDocumentations(items: ls.CodeActionKindDocumentation[] | null | undefined): code.CodeActionProviderMetadata['documentation'] | undefined {
if (items === undefined || items === null) {
return undefined;
}
return items.map(doc => ({ kind: asCodeActionKind(doc.kind), command: asCommand(doc.command) }));
}

function asCodeAction(item: undefined | null, token?: code.CancellationToken): Promise<undefined>;
function asCodeAction(item: ls.CodeAction, token?: code.CancellationToken): Promise<code.CodeAction>;
function asCodeAction(item: ls.CodeAction | undefined | null, token?: code.CancellationToken): Promise<code.CodeAction | undefined>;
Expand Down Expand Up @@ -1504,6 +1519,7 @@ export function createConverter(uriConverter: URIConverter | undefined, trustMar
asCodeAction,
asCodeActionKind,
asCodeActionKinds,
asCodeActionDocumentations,
asCodeActionResult,
asCodeLens,
asCodeLenses,
Expand Down
26 changes: 0 additions & 26 deletions client/src/browser/main.ts

This file was deleted.

35 changes: 0 additions & 35 deletions client/src/browser/tsconfig.json

This file was deleted.

35 changes: 0 additions & 35 deletions client/src/browser/tsconfig.publish.json

This file was deleted.

36 changes: 0 additions & 36 deletions client/src/browser/tsconfig.watch.json

This file was deleted.

46 changes: 0 additions & 46 deletions client/src/common/api.ts

This file was deleted.

Loading

0 comments on commit 3ac4181

Please sign in to comment.