Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions assets/settings/default_semantic_token_rules.json
Original file line number Diff line number Diff line change
Expand Up @@ -253,4 +253,75 @@
"token_modifiers": [],
"style": ["type.event", "type"],
},
// C# (Roslyn) extended classification types
{
"token_type": "field",
"token_modifiers": [],
"style": ["property", "variable.member", "variable"],
},
{
"token_type": "constant",
"token_modifiers": [],
"style": ["constant"],
},
{
"token_type": "controlKeyword",
"token_modifiers": [],
"style": ["keyword.control", "keyword"],
},
{
"token_type": "delegate",
"token_modifiers": [],
"style": ["type.delegate", "type"],
},
{
"token_type": "extensionMethod",
"token_modifiers": [],
"style": ["function.method", "function"],
},
{
"token_type": "operatorOverloaded",
"token_modifiers": [],
"style": ["operator"],
},
{
"token_type": "recordClass",
"token_modifiers": [],
"style": ["type.class", "class", "type"],
},
{
"token_type": "recordStruct",
"token_modifiers": [],
"style": ["type.struct", "struct", "type"],
},
{
"token_type": "module",
"token_modifiers": [],
"style": ["namespace", "module"],
},
{
"token_type": "functionPointer",
"token_modifiers": [],
"style": ["function", "type"],
},
{
"token_type": "pointer",
"token_modifiers": [],
"style": ["type"],
},
{
"token_type": "excludedCode",
"token_modifiers": [],
"style": ["comment"],
},
{
"token_type": "stringVerbatim",
"token_modifiers": [],
"style": ["string"],
},
{
"token_type": "stringEscapeCharacter",
"token_modifiers": [],
"style": ["string.escape", "string.special", "string"],
},
]
30 changes: 30 additions & 0 deletions crates/settings/src/settings_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1796,6 +1796,36 @@ mod tests {
);
}

#[test]
fn test_default_semantic_token_rules_cover_roslyn_token_types() {
let rules: SemanticTokenRules =
crate::parse_json_with_comments(&crate::default_semantic_token_rules())
.expect("default_semantic_token_rules.json must parse");

// C# (Roslyn) reports its own extended token-type legend instead of the
// standard LSP types. Each of these needs a rule with a non-empty style,
// otherwise the tokens are dropped and C# falls back to tree-sitter-only
// highlighting.
for token_type in [
"field",
"constant",
"controlKeyword",
"delegate",
"extensionMethod",
"operatorOverloaded",
"recordClass",
"recordStruct",
"module",
] {
assert!(
rules.rules.iter().any(|rule| {
rule.token_type.as_deref() == Some(token_type) && !rule.style.is_empty()
}),
"default semantic token rules must map the C# (Roslyn) token type {token_type:?}"
);
}
}

#[gpui::test]
fn test_default_settings_release_channel_overrides(cx: &mut App) {
// The test deals with overrides and should ignore the other set-ups (Preview and Stable runs)
Expand Down
Loading