forked from redhat-developer/vscode-quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
See redhat-developer/quarkus-ls#595 Signed-off-by: azerr <azerr@redhat.com>
- Loading branch information
1 parent
7d70d6b
commit 6231a1d
Showing
4 changed files
with
108 additions
and
6 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
import { LanguageClient, RequestType, TextDocumentPositionParams } from "vscode-languageclient/node"; | ||
|
||
import * as code from 'vscode'; | ||
import * as ls from 'vscode-languageserver-protocol'; | ||
|
||
/** | ||
* A parameter literal used in inlay hints requests. | ||
* | ||
* @since 3.17.0 - proposed state | ||
*/ | ||
export type InlayHintParams = /*WorkDoneProgressParams &*/ { | ||
/** | ||
* The text document. | ||
*/ | ||
textDocument: ls.TextDocumentIdentifier; | ||
|
||
/** | ||
* The document range for which inlay hints should be computed. | ||
*/ | ||
range: ls.Range; | ||
}; | ||
|
||
/** | ||
* Inlay hint information. | ||
* | ||
* @since 3.17.0 - proposed state | ||
*/ | ||
export type LSInlayHint = { | ||
|
||
/** | ||
* The position of this hint. | ||
*/ | ||
position: ls.Position; | ||
|
||
/** | ||
* The label of this hint. A human readable string or an array of | ||
* InlayHintLabelPart label parts. | ||
* | ||
* *Note* that neither the string nor the label part can be empty. | ||
*/ | ||
label: string; | ||
//label: string | InlayHintLabelPart[]; | ||
}; | ||
|
||
namespace InlayHintRequest { | ||
export const type: RequestType<InlayHintParams, LSInlayHint[], any> = new RequestType('textDocument/inlayHint'); | ||
} | ||
|
||
export class QuteInlayHintsProvider implements code.InlayHintsProvider { | ||
onDidChangeInlayHints?: code.Event<void>; | ||
converter: any; | ||
|
||
constructor(private client: LanguageClient) { | ||
|
||
} | ||
async provideInlayHints(document: code.TextDocument, range: code.Range, token: code.CancellationToken): Promise<code.InlayHint[]> { | ||
const requestParams: InlayHintParams = { | ||
textDocument: this.client.code2ProtocolConverter.asTextDocumentIdentifier(document), | ||
range: this.client.code2ProtocolConverter.asRange(range) | ||
}; | ||
|
||
try { | ||
const values = await this.client.sendRequest(InlayHintRequest.type, requestParams, token); | ||
if (token.isCancellationRequested) { | ||
return null; | ||
} | ||
return asInlayHints(values, this.client, token); | ||
} catch (error) { | ||
return this.client.handleFailedRequest(InlayHintRequest.type, token, error); | ||
} | ||
} | ||
async resolveInlayHint?(hint: code.InlayHint, token: code.CancellationToken): Promise<code.InlayHint> { | ||
throw new Error("Method not implemented."); | ||
} | ||
} | ||
|
||
async function asInlayHints(values: LSInlayHint[] | undefined | null, client: LanguageClient, token?: code.CancellationToken): Promise<code.InlayHint[] | undefined> { | ||
if (!Array.isArray(values)) { | ||
return undefined; | ||
} | ||
return values.map(lsHint => asInlayHint(lsHint, client, token)); | ||
//return async.mapAsync(values, asInlayHint, token); | ||
} | ||
|
||
function asInlayHint(value: LSInlayHint, client: LanguageClient, token?: code.CancellationToken): code.InlayHint { | ||
//const label = typeof value.label === 'string' | ||
// ? value.label | ||
// : await async.map(value.label, asInlayHintLabelPart, token); | ||
const label = value.label; | ||
const result = new code.InlayHint(client.protocol2CodeConverter.asPosition(value.position), label); | ||
/*if (value.kind !== undefined) { result.kind = value.kind; } | ||
if (value.textEdits !== undefined) { result.textEdits = await asTextEdits(value.textEdits, token); } | ||
if (value.tooltip !== undefined) { result.tooltip = asTooltip(value.tooltip); } | ||
if (value.paddingLeft !== undefined) { result.paddingLeft = value.paddingLeft; } | ||
if (value.paddingRight !== undefined) { result.paddingRight = value.paddingRight; } | ||
if (value.data !== undefined) { result.data = value.data; }*/ | ||
return result; | ||
} |