Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 72 additions & 8 deletions grammars/Babel Language.json
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,26 @@
}
]
},
"type-argument-brackets": {
"patterns": [
{
"comment": "Type arguments. This is complicated since we don't want to match things like foo < 123 || bar > baz",
"name": "meta.type-arguments.flowtype",
"begin": "\\s*+(<)(?=((?:(?>[^<>]+)|<\\g<-1>>)*)>)",
"end": "\\s*(>)",
"endCaptures": {
"1": { "name": "punctuation.flowtype" }
},
"beginCaptures": {
"1": { "name": "punctuation.flowtype" }
},
"patterns": [
{ "include": "#flowtype-parse-types" },
{ "include": "#literal-comma" }
]
}
]
},
"square-brackets": {
"patterns": [
{
Expand Down Expand Up @@ -1364,6 +1384,8 @@
{ "include": "#comments" },
{ "include": "#literal-keywords" },
{
"comment": "A new expression with no type params or arguments, like new Foo()",
"name": "meta.new-class.without-arguments.js",
"match": "(?<!\\.)\\s*+(\\bnew\\b)\\s*+((\\#?)((?:[$_\\p{L}\\p{Nl}]|\\\\u\\h{4}|\\\\u{\\h+})(?:[$_\\p{L}\\p{Mn}\\p{Mc}\\p{Nd}\\p{Nl}\\p{Pc}\\x{200C}\\x{200D}]|\\\\u\\h{4}|\\\\u{\\h+})*+)\\s*+(\\?\\.)?(\\()\\s*+(\\)))",
"captures": {
"1": { "name": "keyword.operator.new.js" },
Expand All @@ -1376,7 +1398,27 @@
}
},
{
"begin": "(?<!\\.)\\s*+(\\bnew\\b)\\s*+((\\#?)((?:[$_\\p{L}\\p{Nl}]|\\\\u\\h{4}|\\\\u{\\h+})(?:[$_\\p{L}\\p{Mn}\\p{Mc}\\p{Nd}\\p{Nl}\\p{Pc}\\x{200C}\\x{200D}]|\\\\u\\h{4}|\\\\u{\\h+})*+)\\s*+(\\?\\.)?(?=\\())",
"comment": "A new expression with type params and no arguments, like new Foo<string>()",
"name": "meta.new-class.without-arguments.js",
"begin": "(?<!\\.)\\s*+(\\bnew\\b)\\s*+((\\#?)((?:[$_\\p{L}\\p{Nl}]|\\\\u\\h{4}|\\\\u{\\h+})(?:[$_\\p{L}\\p{Mn}\\p{Mc}\\p{Nd}\\p{Nl}\\p{Pc}\\x{200C}\\x{200D}]|\\\\u\\h{4}|\\\\u{\\h+})*+)\\s*+(\\?\\.)?\\s*+(?=(<(?:(?>[^<>]+)|\\g<-1>)*>)\\s*+(\\()\\s*+(\\))))",
"end": "(?=.)",
"applyEndPatternLast": 1,
"beginCaptures": {
"1": { "name": "keyword.operator.new.js" },
"2": { "name": "meta.function-call.without-arguments.js" },
"3": { "name": "keyword.operator.private.js" },
"4": { "name": "entity.name.type.instance.js" },
"5": { "name": "keyword.operator.existential.js"}
},
"patterns": [
{ "include": "#type-argument-brackets" },
{ "include": "#round-brackets" }
]
},
{
"comment": "A new expression with arguments and maybe type params, like new Foo<string>(123)",
"name": "meta.new-class.with-arguments.js",
"begin": "(?<!\\.)\\s*+(\\bnew\\b)\\s*+((\\#?)((?:[$_\\p{L}\\p{Nl}]|\\\\u\\h{4}|\\\\u{\\h+})(?:[$_\\p{L}\\p{Mn}\\p{Mc}\\p{Nd}\\p{Nl}\\p{Pc}\\x{200C}\\x{200D}]|\\\\u\\h{4}|\\\\u{\\h+})*+)\\s*+(\\?\\.)?\\s*+(?=(<(?:(?>[^<>]+)|\\g<-1>)*>)?\\s*+\\())",
"end": "(?=.)",
"applyEndPatternLast": 1,
"beginCaptures": {
Expand All @@ -1387,11 +1429,13 @@
"5": { "name": "keyword.operator.existential.js"}
},
"patterns": [
{ "include": "#type-argument-brackets" },
{ "include": "#round-brackets" }
]
},
{ "include": "#literal-operators" },
{ "include": "#literal-operators" },
{
"comment": "A call expression with no type params or arguments, like foo()",
"name": "meta.function-call.without-arguments.js",
"match": "(?<!\\.)\\s*+(\\#?)((?:[$_\\p{L}\\p{Nl}]|\\\\u\\h{4}|\\\\u{\\h+})(?:[$_\\p{L}\\p{Mn}\\p{Mc}\\p{Nd}\\p{Nl}\\p{Pc}\\x{200C}\\x{200D}]|\\\\u\\h{4}|\\\\u{\\h+})*+)\\s*+(\\?\\.)?(\\()\\s*+(\\))",
"captures": {
Expand All @@ -1403,9 +1447,25 @@
}
},
{
"comment": "maybe in array form e.g. foo[bar]()",
"comment": "A call expression with type params and no arguments, like foo<string>()",
"name": "meta.function-call.without-arguments.js",
"begin": "(?<!\\.)\\s*+(\\#?)((?:[$_\\p{L}\\p{Nl}]|\\\\u\\h{4}|\\\\u{\\h+})(?:[$_\\p{L}\\p{Mn}\\p{Mc}\\p{Nd}\\p{Nl}\\p{Pc}\\x{200C}\\x{200D}]|\\\\u\\h{4}|\\\\u{\\h+})*+)\\s*+(\\?\\.)?\\s*+(?=(<(?:(?>[^<>]+)|\\g<-1>)*>)\\s*+(\\()\\s*+(\\)))",
"end": "(?=.)",
"applyEndPatternLast": 1,
"beginCaptures": {
"1": { "name": "keyword.operator.private.js" },
"2": { "name": "entity.name.function.js" },
"3": { "name": "keyword.operator.existential.js"}
},
"patterns": [
{ "include": "#type-argument-brackets" },
{ "include": "#round-brackets" }
]
},
{
"comment": "maybe in array form e.g. foo[bar]() or foo[bar]<string>()",
"name": "meta.function-call.without-arguments.js",
"begin": "(?<!\\.)\\s*+((\\bnew\\b)*)\\s*+(\\#?)((?:[$_\\p{L}\\p{Nl}]|\\\\u\\h{4}|\\\\u{\\h+})(?:[$_\\p{L}\\p{Mn}\\p{Mc}\\p{Nd}\\p{Nl}\\p{Pc}\\x{200C}\\x{200D}]|\\\\u\\h{4}|\\\\u{\\h+})*+)(?=\\s*(\\[(?:(?>[^\\[\\]]+)|\\g<-1>)*\\])\\s*+\\(\\s*+\\))",
"begin": "(?<!\\.)\\s*+((\\bnew\\b)*)\\s*+(\\#?)((?:[$_\\p{L}\\p{Nl}]|\\\\u\\h{4}|\\\\u{\\h+})(?:[$_\\p{L}\\p{Mn}\\p{Mc}\\p{Nd}\\p{Nl}\\p{Pc}\\x{200C}\\x{200D}]|\\\\u\\h{4}|\\\\u{\\h+})*+)(?=\\s*(\\[(?:(?>[^\\[\\]]+)|\\g<-1>)*\\])\\s*+(<(?:(?>[^<>]+)|\\g<-1>)*>)?\\s*+\\(\\s*+\\))",
"end": "(?=.)",
"applyEndPatternLast": 1,
"beginCaptures": {
Expand All @@ -1415,12 +1475,14 @@
},
"patterns": [
{ "include": "#square-brackets"},
{ "include": "#type-argument-brackets" },
{ "include": "#round-brackets" }
]
},
{
"comment": "A call expression with arguments and maybe type params, like foo(123) or foo<string>(123)",
"name": "meta.function-call.with-arguments.js",
"begin": "(?<!\\.)\\s*+(\\#?)((?:[$_\\p{L}\\p{Nl}]|\\\\u\\h{4}|\\\\u{\\h+})(?:[$_\\p{L}\\p{Mn}\\p{Mc}\\p{Nd}\\p{Nl}\\p{Pc}\\x{200C}\\x{200D}]|\\\\u\\h{4}|\\\\u{\\h+})*+)\\s*+(\\?\\.)?(?=\\()",
"begin": "(?<!\\.)\\s*+(\\#?)((?:[$_\\p{L}\\p{Nl}]|\\\\u\\h{4}|\\\\u{\\h+})(?:[$_\\p{L}\\p{Mn}\\p{Mc}\\p{Nd}\\p{Nl}\\p{Pc}\\x{200C}\\x{200D}]|\\\\u\\h{4}|\\\\u{\\h+})*+)\\s*+(\\?\\.)?\\s*+(?=(<(?:(?>[^<>]+)|\\g<-1>)*>)?\\s*+\\()",
"end": "(?=.)",
"applyEndPatternLast": 1,
"beginCaptures": {
Expand All @@ -1429,13 +1491,14 @@
"3": { "name": "keyword.operator.existential.js"}
},
"patterns": [
{ "include": "#type-argument-brackets" },
{ "include": "#round-brackets" }
]
},
{
"comment": "maybe in array form e.g. foo[bar]()",
"name": "meta.function-call.without-arguments.js",
"begin": "(?<!\\.)\\s*+((\\bnew\\b)*)\\s*+(\\#?)((?:[$_\\p{L}\\p{Nl}]|\\\\u\\h{4}|\\\\u{\\h+})(?:[$_\\p{L}\\p{Mn}\\p{Mc}\\p{Nd}\\p{Nl}\\p{Pc}\\x{200C}\\x{200D}]|\\\\u\\h{4}|\\\\u{\\h+})*+)\\s*+(?=(\\[(?:(?>[^\\[\\]]+)|\\g<-1>)*\\])\\s*+\\()",
"comment": "maybe in array form e.g. foo[bar](123)",
"name": "meta.function-call.with-arguments.js",
"begin": "(?<!\\.)\\s*+((\\bnew\\b)*)\\s*+(\\#?)((?:[$_\\p{L}\\p{Nl}]|\\\\u\\h{4}|\\\\u{\\h+})(?:[$_\\p{L}\\p{Mn}\\p{Mc}\\p{Nd}\\p{Nl}\\p{Pc}\\x{200C}\\x{200D}]|\\\\u\\h{4}|\\\\u{\\h+})*+)\\s*+(?=(\\[(?:(?>[^\\[\\]]+)|\\g<-1>)*\\])\\s*+(<(?:(?>[^<>]+)|\\g<-1>)*>)?\\s*+\\()",
"end": "(?=.)",
"applyEndPatternLast": 1,
"beginCaptures": {
Expand All @@ -1445,6 +1508,7 @@
},
"patterns": [
{ "include": "#square-brackets"},
{ "include": "#type-argument-brackets" },
{ "include": "#round-brackets" }
]
}
Expand Down
Loading