[vscode] Support for >2 type constraints
The previous implementation failed for this case because we attempted to
use repeated capture groups. When a capture group is repeated, like it
was in the now-removed `comma_separated` helper, only the last match is
retained. Thus, the regex template `(?:${capt_1})(?:,\\s*${capt_2})*`
will fail for a case like `:A, B, C`. This is because `A` will always
match `capt_1`, but both `B` and `C` will be caught by the repeated
`capt_2`, with only the last match being retained. The upshot is that
for cases with >2 matches, only the first and last will have the proper
names applied via tmLanguage's "captures" feature, leaving the middle
instance unhighlighted.
This change uses a different strategy: `type-constraints` are now their
own repository definition, always checked as the last possible
constituent pattern on a `type-constructor`. This allows for repeated
highlighting, allowing constraints lists to be of arbitrary length.
Change-Id: I41b16b8cd1414fcce4e02c66f1e2bf08f6451dd5
Reviewed-on: https://fuchsia-review.googlesource.com/c/fidl-misc/+/662244
Reviewed-by: Mitchell Kember <mkember@google.com>
3 files changed