Mark same-file definitions in semantic tokens
The server legend gains a declaration modifier, and EditorDiagnostics emits the definition-name token with it when the definition lies in the same document. No type token is emitted because the canonical type has no source span. Registered tests cover modifier encoding and the overlap rule; a real stdio session showed the modifier on both definition names.
This commit is contained in:
1 parent
2cced8363d
commit
816c38da1e
7 files changed
+54
-10
No files matched your search
@@ -49,3 +49,21 @@ VOID_TEST(SemanticTokens, bounds_count_and_length) {
|
||||
const std::vector<Token> long_token{token(0, 0, 64)};
|
||||
expect(normalize(long_token, Limits{.length = 8}).empty());
|
||||
}
|
||||
|
||||
VOID_TEST(SemanticTokens, modifiers_are_preserved_and_encoded) {
|
||||
const std::vector<Token> tokens{{0, 0, 1, function_type, declaration_modifier},
|
||||
{0, 2, 1, function_type, 0}};
|
||||
const auto result = normalize(tokens);
|
||||
require(result.size() == 2);
|
||||
expect(result[0].modifiers == declaration_modifier);
|
||||
expect(result[1].modifiers == 0);
|
||||
expect(encode(result) == std::vector<std::uint32_t>{0, 0, 1, 0, 1, 0, 2, 1, 0, 0});
|
||||
}
|
||||
|
||||
VOID_TEST(SemanticTokens, an_overlapping_token_never_replaces_the_earlier_one) {
|
||||
const std::vector<Token> tokens{{1, 4, 3, function_type, 0},
|
||||
{1, 4, 3, function_type, declaration_modifier}};
|
||||
const auto result = normalize(tokens);
|
||||
require(result.size() == 1);
|
||||
expect(result.front().modifiers == 0);
|
||||
}
|
||||
Reference in new issue
Block a user