Родитель
630bdd4041
Коммит
675e6d480d
|
@ -0,0 +1,8 @@
|
|||
---
|
||||
# Change versionKind to one of: internal, fix, dependencies, feature, deprecation, breaking
|
||||
changeKind: fix
|
||||
packages:
|
||||
- "@typespec/compiler"
|
||||
---
|
||||
|
||||
Fix tmlanguage for named type argument in type reference.
|
|
@ -1398,7 +1398,7 @@
|
|||
"name": "keyword.operator.assignment.tsp"
|
||||
}
|
||||
},
|
||||
"end": "=",
|
||||
"end": "(?=>)|(?=,|;|@|\\)|\\}|\\b(?:extern)\\b|\\b(?:namespace|model|op|using|import|enum|alias|union|interface|dec|fn)\\b)",
|
||||
"endCaptures": {
|
||||
"0": {
|
||||
"name": "keyword.operator.assignment.tsp"
|
||||
|
|
|
@ -343,7 +343,7 @@ const typeArgument: BeginEndRule = {
|
|||
"1": { scope: "entity.name.type.tsp" },
|
||||
"2": { scope: "keyword.operator.assignment.tsp" },
|
||||
},
|
||||
end: `=`,
|
||||
end: `(?=>)|${universalEnd}`,
|
||||
endCaptures: {
|
||||
"0": { scope: "keyword.operator.assignment.tsp" },
|
||||
},
|
||||
|
|
|
@ -827,26 +827,58 @@ function testColorization(description: string, tokenize: Tokenize) {
|
|||
});
|
||||
});
|
||||
|
||||
it("named template argument list", async () => {
|
||||
const tokens = await tokenize("alias X = Foo<boolean, T = string, U = int32>;");
|
||||
deepStrictEqual(tokens, [
|
||||
Token.keywords.alias,
|
||||
Token.identifiers.type("X"),
|
||||
Token.operators.assignment,
|
||||
Token.identifiers.type("Foo"),
|
||||
Token.punctuation.typeParameters.begin,
|
||||
Token.identifiers.type("boolean"),
|
||||
Token.punctuation.comma,
|
||||
Token.identifiers.type("T"),
|
||||
Token.operators.assignment,
|
||||
Token.identifiers.type("string"),
|
||||
Token.punctuation.comma,
|
||||
Token.identifiers.type("U"),
|
||||
Token.operators.assignment,
|
||||
Token.identifiers.type("int32"),
|
||||
Token.punctuation.typeParameters.end,
|
||||
Token.punctuation.semicolon,
|
||||
]);
|
||||
describe("template argument", () => {
|
||||
it("multiple named arguments", async () => {
|
||||
const tokens = await tokenize("alias X = Foo<boolean, T = string, U = int32>;");
|
||||
deepStrictEqual(tokens, [
|
||||
Token.keywords.alias,
|
||||
Token.identifiers.type("X"),
|
||||
Token.operators.assignment,
|
||||
Token.identifiers.type("Foo"),
|
||||
Token.punctuation.typeParameters.begin,
|
||||
Token.identifiers.type("boolean"),
|
||||
Token.punctuation.comma,
|
||||
Token.identifiers.type("T"),
|
||||
Token.operators.assignment,
|
||||
Token.identifiers.type("string"),
|
||||
Token.punctuation.comma,
|
||||
Token.identifiers.type("U"),
|
||||
Token.operators.assignment,
|
||||
Token.identifiers.type("int32"),
|
||||
Token.punctuation.typeParameters.end,
|
||||
Token.punctuation.semicolon,
|
||||
]);
|
||||
});
|
||||
|
||||
it("multiple references", async () => {
|
||||
const tokens = await tokenize(`
|
||||
alias A = Foo<Parameters=string>;
|
||||
alias B = Foo<Parameters=string>;
|
||||
`);
|
||||
deepStrictEqual(tokens, [
|
||||
Token.keywords.alias,
|
||||
Token.identifiers.type("A"),
|
||||
Token.operators.assignment,
|
||||
Token.identifiers.type("Foo"),
|
||||
Token.punctuation.typeParameters.begin,
|
||||
Token.identifiers.type("Parameters"),
|
||||
Token.operators.assignment,
|
||||
Token.identifiers.type("string"),
|
||||
Token.punctuation.typeParameters.end,
|
||||
Token.punctuation.semicolon,
|
||||
// --
|
||||
Token.keywords.alias,
|
||||
Token.identifiers.type("B"),
|
||||
Token.operators.assignment,
|
||||
Token.identifiers.type("Foo"),
|
||||
Token.punctuation.typeParameters.begin,
|
||||
Token.identifiers.type("Parameters"),
|
||||
Token.operators.assignment,
|
||||
Token.identifiers.type("string"),
|
||||
Token.punctuation.typeParameters.end,
|
||||
Token.punctuation.semicolon,
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("enums", () => {
|
||||
|
|
Загрузка…
Ссылка в новой задаче