Родитель
1cc570c72f
Коммит
7900f29d65
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
changeKind: fix
|
||||
packages:
|
||||
- "@typespec/compiler"
|
||||
---
|
||||
|
||||
Fix semantic highlighting of using of single namespace
|
|
@ -1623,6 +1623,9 @@
|
|||
},
|
||||
{
|
||||
"include": "#identifier-expression"
|
||||
},
|
||||
{
|
||||
"include": "#punctuation-accessor"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
|
@ -219,6 +219,11 @@ export function getSemanticTokens(ast: TypeSpecScriptNode): SemanticToken[] {
|
|||
case SyntaxKind.ScalarConstructor:
|
||||
classify(node.id, SemanticTokenKind.Function);
|
||||
break;
|
||||
case SyntaxKind.UsingStatement:
|
||||
if (node.name.kind === SyntaxKind.Identifier) {
|
||||
classify(node.name, SemanticTokenKind.Namespace);
|
||||
}
|
||||
break;
|
||||
case SyntaxKind.EnumStatement:
|
||||
classify(node.id, SemanticTokenKind.Enum);
|
||||
break;
|
||||
|
|
|
@ -879,7 +879,7 @@ const usingStatement: BeginEndRule = {
|
|||
"1": { scope: "keyword.other.tsp" },
|
||||
},
|
||||
end: universalEnd,
|
||||
patterns: [token, identifierExpression],
|
||||
patterns: [token, identifierExpression, punctuationAccessor],
|
||||
};
|
||||
|
||||
const decoratorDeclarationStatement: BeginEndRule = {
|
||||
|
|
|
@ -53,6 +53,7 @@ const Token = {
|
|||
valueof: createToken("valueof", "keyword.other.tsp"),
|
||||
typeof: createToken("typeof", "keyword.other.tsp"),
|
||||
const: createToken("const", "keyword.other.tsp"),
|
||||
using: createToken("using", "keyword.other.tsp"),
|
||||
other: (text: string) => createToken(text, "keyword.other.tsp"),
|
||||
},
|
||||
|
||||
|
@ -255,6 +256,28 @@ function testColorization(description: string, tokenize: Tokenize) {
|
|||
});
|
||||
});
|
||||
|
||||
describe("using", () => {
|
||||
it("single namespace", async () => {
|
||||
const tokens = await tokenize("using foo;");
|
||||
deepStrictEqual(tokens, [
|
||||
Token.keywords.using,
|
||||
Token.identifiers.type("foo"),
|
||||
Token.punctuation.semicolon,
|
||||
]);
|
||||
});
|
||||
|
||||
it("nested namespace", async () => {
|
||||
const tokens = await tokenize("using foo.bar;");
|
||||
deepStrictEqual(tokens, [
|
||||
Token.keywords.using,
|
||||
Token.identifiers.type("foo"),
|
||||
Token.punctuation.accessor,
|
||||
Token.identifiers.type("bar"),
|
||||
Token.punctuation.semicolon,
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("aliases", () => {
|
||||
it("simple alias", async () => {
|
||||
const tokens = await tokenize("alias Foo = string");
|
||||
|
|
Загрузка…
Ссылка в новой задаче