Skip to content

Commit 5cfaf7c

Browse files
use enums with serde_repr instead of u32
1 parent 7b833dd commit 5cfaf7c

File tree

3 files changed

+66
-1
lines changed

3 files changed

+66
-1
lines changed

wasm-demo/Cargo.lock

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

wasm-demo/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ console_log = "0.1"
1313
log = "0.4"
1414
wasm-bindgen = "0.2.50"
1515
serde = { version = "1.0", features = ["derive"] }
16+
serde_repr = "0.1"
1617
serde-wasm-bindgen = "0.1"
1718

1819
ra_ide_api = { git = "https://github.com/rust-analyzer/rust-analyzer", features = ["wasm"] }

wasm-demo/src/return_types.rs

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use serde::{Deserialize, Serialize};
2+
use serde_repr::Serialize_repr;
23

34
#[derive(Serialize)]
45
pub struct Hover {
@@ -70,7 +71,58 @@ pub struct RenameLocation {
7071
pub struct CompletionItem {
7172
pub label: String,
7273
pub range: Range,
73-
pub kind: u32,
74+
pub kind: CompletionItemKind,
7475
pub detail: Option<String>,
7576
pub insertText: String,
77+
pub insertTextRules: CompletionItemInsertTextRule,
78+
pub documentation: Option<MarkdownString>,
79+
pub filterText: String,
80+
}
81+
82+
#[allow(dead_code)]
83+
#[derive(Serialize_repr)]
84+
#[repr(u8)]
85+
pub enum CompletionItemKind {
86+
Method = 0,
87+
Function = 1,
88+
Constructor = 2,
89+
Field = 3,
90+
Variable = 4,
91+
Class = 5,
92+
Struct = 6,
93+
Interface = 7,
94+
Module = 8,
95+
Property = 9,
96+
Event = 10,
97+
Operator = 11,
98+
Unit = 12,
99+
Value = 13,
100+
Constant = 14,
101+
Enum = 15,
102+
EnumMember = 16,
103+
Keyword = 17,
104+
Text = 18,
105+
Color = 19,
106+
File = 20,
107+
Reference = 21,
108+
Customcolor = 22,
109+
Folder = 23,
110+
TypeParameter = 24,
111+
Snippet = 25
112+
}
113+
114+
#[allow(dead_code)]
115+
#[derive(Serialize_repr)]
116+
#[repr(u8)]
117+
pub enum CompletionItemInsertTextRule {
118+
None = 0,
119+
/**
120+
* Adjust whitespace/indentation of multiline insert texts to
121+
* match the current line indentation.
122+
*/
123+
KeepWhitespace = 1,
124+
/**
125+
* `insertText` is a snippet.
126+
*/
127+
InsertAsSnippet = 4,
76128
}

0 commit comments

Comments
 (0)