Skip to content

Commit d90d304

Browse files
committed
add static values for token types
1 parent c2923ec commit d90d304

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

fume-server/src/capabilities/semantic_tokens.rs

+18-8
Original file line numberDiff line numberDiff line change
@@ -74,19 +74,29 @@ fn create_semantic_token(next_token: &Token, prev_token: Option<&Token>) -> Sema
7474
}
7575
}
7676

77+
// these values should reflect indexes in `token_types`
78+
static FUNCTION: u32 = 1;
79+
static LIBRARY: u32 = 3;
80+
static VARIABLE: u32 = 9;
81+
static ENUM: u32 = 10;
82+
static STRUCT: u32 = 11;
83+
static TRAIT: u32 = 12;
84+
85+
7786
fn get_type(content_type: &ContentType) -> u32 {
7887
if let ContentType::Declaration(dec) = content_type {
7988
match dec {
80-
DeclarationType::Function => 1,
81-
DeclarationType::Library => 3,
82-
DeclarationType::Variable => 9,
83-
DeclarationType::Enum => 10,
84-
DeclarationType::Struct => 11,
85-
DeclarationType::Trait => 12,
86-
_ => 9,
89+
DeclarationType::Function => FUNCTION,
90+
DeclarationType::Library => LIBRARY,
91+
DeclarationType::Variable => VARIABLE,
92+
DeclarationType::Enum => ENUM,
93+
DeclarationType::Struct => STRUCT,
94+
DeclarationType::Trait => TRAIT,
95+
_ => VARIABLE,
8796
}
8897
} else {
89-
9
98+
// currently we return `variable` type as default
99+
VARIABLE
90100
}
91101
}
92102

0 commit comments

Comments
 (0)