WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit b4f617a

Browse files
committed
fix: comments on type aliases are now recognized as comments
fix #38
1 parent 256f285 commit b4f617a

13 files changed

+517
-560
lines changed

syntaxes/wit.tmLanguage.json

Lines changed: 40 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -722,6 +722,9 @@
722722
},
723723
{
724724
"include": "#whitespace"
725+
},
726+
{
727+
"include": "#comment"
725728
}
726729
],
727730
"end": "(?<=\\n)",
@@ -976,9 +979,6 @@
976979
{
977980
"include": "#container"
978981
},
979-
{
980-
"include": "#result-base"
981-
},
982982
{
983983
"include": "#identifier"
984984
}
@@ -1035,11 +1035,6 @@
10351035
}
10361036
]
10371037
},
1038-
"result-base": {
1039-
"name": "entity.name.type.result.wit",
1040-
"comment": "Syntax for result types where both the `ok` and `err` types are `_`. This pattern must be placed after the #container pattern to correctly capture `result<...>`.",
1041-
"match": "\\b(result)\\b"
1042-
},
10431038
"tuple": {
10441039
"name": "meta.tuple.ty.wit",
10451040
"comment": "Syntax for WIT types such as tuple",
@@ -1143,7 +1138,7 @@
11431138
"result": {
11441139
"name": "meta.result.ty.wit",
11451140
"comment": "Syntax for WIT types such as result",
1146-
"begin": "\\b(result)\\b(\\<)",
1141+
"begin": "\\b(result)\\b",
11471142
"beginCaptures": {
11481143
"1": {
11491144
"name": "entity.name.type.result.wit"
@@ -1157,28 +1152,47 @@
11571152
"include": "#comment"
11581153
},
11591154
{
1160-
"name": "variable.other.inferred-type.result.wit",
1161-
"match": "(?<!\\w)(\\_)(?!\\w)"
1162-
},
1163-
{
1164-
"name": "meta.types.list.wit",
1165-
"include": "#types"
1166-
},
1167-
{
1168-
"name": "punctuation.comma.wit",
1169-
"match": "(?<!result)\\s*(\\,)"
1155+
"name": "meta.inner.result.wit",
1156+
"begin": "(\\<)",
1157+
"beginCaptures": {
1158+
"1": {
1159+
"name": "punctuation.brackets.angle.begin.wit"
1160+
}
1161+
},
1162+
"patterns": [
1163+
{
1164+
"include": "#comment"
1165+
},
1166+
{
1167+
"name": "variable.other.inferred-type.result.wit",
1168+
"match": "(?<!\\w)(\\_)(?!\\w)"
1169+
},
1170+
{
1171+
"name": "meta.types.result.wit",
1172+
"include": "#types"
1173+
},
1174+
{
1175+
"name": "punctuation.comma.wit",
1176+
"match": "(?<!result)\\s*(\\,)"
1177+
},
1178+
{
1179+
"include": "#whitespace"
1180+
}
1181+
],
1182+
"end": "(\\>)",
1183+
"applyEndPatternLast": 1,
1184+
"endCaptures": {
1185+
"1": {
1186+
"name": "punctuation.brackets.angle.end.wit"
1187+
}
1188+
}
11701189
},
11711190
{
11721191
"include": "#whitespace"
11731192
}
11741193
],
1175-
"end": "(\\>)",
1176-
"applyEndPatternLast": 1,
1177-
"endCaptures": {
1178-
"1": {
1179-
"name": "punctuation.brackets.angle.end.wit"
1180-
}
1181-
}
1194+
"end": "((?<=\\n)|(?=\\,)|(?=\\}))",
1195+
"applyEndPatternLast": 1
11821196
},
11831197
"handle": {
11841198
"name": "meta.handle.ty.wit",

tests/grammar/integration/import-func.wit.snap

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,15 @@
7070
# ^^ source.wit meta.world-item.wit meta.import-item.wit meta.function.wit meta.result-list.wit keyword.operator.arrow.skinny.wit
7171
# ^ source.wit meta.world-item.wit meta.import-item.wit meta.function.wit meta.result-list.wit meta.whitespace.wit
7272
# ^^^^^^ source.wit meta.world-item.wit meta.import-item.wit meta.function.wit meta.result-list.wit meta.result.ty.wit entity.name.type.result.wit
73-
# ^ source.wit meta.world-item.wit meta.import-item.wit meta.function.wit meta.result-list.wit meta.result.ty.wit punctuation.brackets.angle.begin.wit
74-
# ^^^^^^ source.wit meta.world-item.wit meta.import-item.wit meta.function.wit meta.result-list.wit meta.result.ty.wit meta.option.ty.wit entity.name.type.option.wit
75-
# ^ source.wit meta.world-item.wit meta.import-item.wit meta.function.wit meta.result-list.wit meta.result.ty.wit meta.option.ty.wit punctuation.brackets.angle.begin.wit
76-
# ^^^ source.wit meta.world-item.wit meta.import-item.wit meta.function.wit meta.result-list.wit meta.result.ty.wit meta.option.ty.wit entity.name.type.numeric.wit
77-
# ^ source.wit meta.world-item.wit meta.import-item.wit meta.function.wit meta.result-list.wit meta.result.ty.wit meta.option.ty.wit punctuation.brackets.angle.end.wit
78-
# ^ source.wit meta.world-item.wit meta.import-item.wit meta.function.wit meta.result-list.wit meta.result.ty.wit punctuation.comma.wit
79-
# ^ source.wit meta.world-item.wit meta.import-item.wit meta.function.wit meta.result-list.wit meta.result.ty.wit meta.whitespace.wit
80-
# ^^^^^^ source.wit meta.world-item.wit meta.import-item.wit meta.function.wit meta.result-list.wit meta.result.ty.wit entity.name.type.string.wit
81-
# ^ source.wit meta.world-item.wit meta.import-item.wit meta.function.wit meta.result-list.wit meta.result.ty.wit punctuation.brackets.angle.end.wit
73+
# ^ source.wit meta.world-item.wit meta.import-item.wit meta.function.wit meta.result-list.wit meta.result.ty.wit meta.inner.result.wit punctuation.brackets.angle.begin.wit
74+
# ^^^^^^ source.wit meta.world-item.wit meta.import-item.wit meta.function.wit meta.result-list.wit meta.result.ty.wit meta.inner.result.wit meta.option.ty.wit entity.name.type.option.wit
75+
# ^ source.wit meta.world-item.wit meta.import-item.wit meta.function.wit meta.result-list.wit meta.result.ty.wit meta.inner.result.wit meta.option.ty.wit punctuation.brackets.angle.begin.wit
76+
# ^^^ source.wit meta.world-item.wit meta.import-item.wit meta.function.wit meta.result-list.wit meta.result.ty.wit meta.inner.result.wit meta.option.ty.wit entity.name.type.numeric.wit
77+
# ^ source.wit meta.world-item.wit meta.import-item.wit meta.function.wit meta.result-list.wit meta.result.ty.wit meta.inner.result.wit meta.option.ty.wit punctuation.brackets.angle.end.wit
78+
# ^ source.wit meta.world-item.wit meta.import-item.wit meta.function.wit meta.result-list.wit meta.result.ty.wit meta.inner.result.wit punctuation.comma.wit
79+
# ^ source.wit meta.world-item.wit meta.import-item.wit meta.function.wit meta.result-list.wit meta.result.ty.wit meta.inner.result.wit meta.whitespace.wit
80+
# ^^^^^^ source.wit meta.world-item.wit meta.import-item.wit meta.function.wit meta.result-list.wit meta.result.ty.wit meta.inner.result.wit entity.name.type.string.wit
81+
# ^ source.wit meta.world-item.wit meta.import-item.wit meta.function.wit meta.result-list.wit meta.result.ty.wit meta.inner.result.wit punctuation.brackets.angle.end.wit
8282
>}
8383
#^ source.wit meta.world-item.wit punctuation.brackets.curly.end.wit
8484
>

tests/grammar/integration/issue573.wit

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ interface types-interface {
3434
// type aliases are allowed to primitive types and additionally here are some
3535
// examples of other types
3636
type t1 = u32
37-
type t2 = tuple<u32, u64>
37+
type t2 = tuple<u32, u64> // tuple
3838
type t3 = string
39-
type t4 = option<u32>
39+
type t4 = option<u32> // option type
4040
/// no "ok" type
4141
type t5 = result<_, errno> // no "ok" type
4242
type t6 = result<string> // no "err" type

0 commit comments

Comments
 (0)