mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-11-17 02:42:54 +00:00
Fixes
This commit is contained in:
parent
5a49dbd2e0
commit
0b69717ab6
3 changed files with 5 additions and 5 deletions
|
|
@ -247,7 +247,6 @@ pub struct InlayHintsParams {
|
||||||
pub struct InlayHintKind(u8);
|
pub struct InlayHintKind(u8);
|
||||||
|
|
||||||
impl InlayHintKind {
|
impl InlayHintKind {
|
||||||
pub const OTHER: InlayHintKind = InlayHintKind(0);
|
|
||||||
pub const TYPE: InlayHintKind = InlayHintKind(1);
|
pub const TYPE: InlayHintKind = InlayHintKind(1);
|
||||||
pub const PARAMETER: InlayHintKind = InlayHintKind(2);
|
pub const PARAMETER: InlayHintKind = InlayHintKind(2);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -413,11 +413,11 @@ pub(crate) fn signature_help(
|
||||||
pub(crate) fn inlay_hint(line_index: &LineIndex, inlay_hint: InlayHint) -> lsp_ext::InlayHint {
|
pub(crate) fn inlay_hint(line_index: &LineIndex, inlay_hint: InlayHint) -> lsp_ext::InlayHint {
|
||||||
lsp_ext::InlayHint {
|
lsp_ext::InlayHint {
|
||||||
label: inlay_hint.label.to_string(),
|
label: inlay_hint.label.to_string(),
|
||||||
position: position(line_index, inlay_hint.range.start()),
|
position: position(line_index, inlay_hint.range.end()),
|
||||||
kind: Some(match inlay_hint.kind {
|
kind: Some(match inlay_hint.kind {
|
||||||
InlayKind::ParameterHint => lsp_ext::InlayHintKind::PARAMETER,
|
InlayKind::ParameterHint => lsp_ext::InlayHintKind::PARAMETER,
|
||||||
InlayKind::TypeHint => lsp_ext::InlayHintKind::TYPE,
|
InlayKind::TypeHint => lsp_ext::InlayHintKind::TYPE,
|
||||||
InlayKind::ChainingHint => lsp_ext::InlayHintKind::OTHER,
|
InlayKind::ChainingHint => lsp_ext::InlayHintKind::TYPE,
|
||||||
}),
|
}),
|
||||||
tooltip: Some("test description".to_string()),
|
tooltip: Some("test description".to_string()),
|
||||||
padding_left: Some(true),
|
padding_left: Some(true),
|
||||||
|
|
|
||||||
|
|
@ -22,13 +22,14 @@ export function activateInlayHints(ctx: Ctx) {
|
||||||
this.hintsProvider = vscode.languages.registerInlayHintsProvider({ scheme: 'file', language: 'rust' }, new class implements vscode.InlayHintsProvider {
|
this.hintsProvider = vscode.languages.registerInlayHintsProvider({ scheme: 'file', language: 'rust' }, new class implements vscode.InlayHintsProvider {
|
||||||
onDidChangeInlayHints = event;
|
onDidChangeInlayHints = event;
|
||||||
async provideInlayHints(document: vscode.TextDocument, range: vscode.Range, token: vscode.CancellationToken): Promise<vscode.InlayHint[]> {
|
async provideInlayHints(document: vscode.TextDocument, range: vscode.Range, token: vscode.CancellationToken): Promise<vscode.InlayHint[]> {
|
||||||
console.log(document.uri.toString());
|
|
||||||
const request = { textDocument: { uri: document.uri.toString() }, range: { start: range.start, end: range.end } };
|
const request = { textDocument: { uri: document.uri.toString() }, range: { start: range.start, end: range.end } };
|
||||||
const hints = await sendRequestWithRetry(ctx.client, ra.inlayHints, request, token).catch(_ => null);
|
const hints = await sendRequestWithRetry(ctx.client, ra.inlayHints, request, token).catch(_ => null);
|
||||||
console.log(hints);
|
|
||||||
if (hints == null) {
|
if (hints == null) {
|
||||||
return [];
|
return [];
|
||||||
} else {
|
} else {
|
||||||
|
for (let hint of hints) {
|
||||||
|
hint.position = new vscode.Position(hint.position.line, hint.position.character);
|
||||||
|
}
|
||||||
return hints;
|
return hints;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue