Skip to content
Merged
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
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
.vscode
.vscode/*
!.vscode/tasks.json
!.vscode/launch.json
.DS_Store
.vimrc
tags
node_modules
dist
dist
16 changes: 16 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// A launch configuration that launches the extension inside a new window
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
{
"version": "0.2.0",
"configurations": [
{
"name": "Extension",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": ["--extensionDevelopmentPath=${workspaceFolder}"]
}
]
}
109 changes: 97 additions & 12 deletions grammars/Babel-Language.json
Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,30 @@
}
]
},
"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 @@ -2146,6 +2170,8 @@
"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": {
Expand All @@ -2172,7 +2198,24 @@
}
},
{
"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 @@ -2193,6 +2236,9 @@
}
},
"patterns": [
{
"include": "#type-argument-brackets"
},
{
"include": "#round-brackets"
}
Expand All @@ -2202,6 +2248,7 @@
"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 @@ -2223,9 +2270,22 @@
}
},
{
"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*+((\\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*+(\\#?)((?:[$_\\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*+(<(?:(?>[^<>]+)|\\g<-1>)*>)?\\s*+\\(\\s*+\\))",
"end": "(?=.)",
"applyEndPatternLast": 1,
"beginCaptures": {
Expand All @@ -2243,14 +2303,18 @@
{
"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 @@ -2265,15 +2329,18 @@
}
},
"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 @@ -2291,6 +2358,9 @@
{
"include": "#square-brackets"
},
{
"include": "#type-argument-brackets"
},
{
"include": "#round-brackets"
}
Expand Down Expand Up @@ -2704,7 +2774,7 @@
{
"name": "meta.method-call.without-arguments.js",
"comment": "e.g CONSTNAME.method() or CONST.method[p]()",
"begin": "\\s*+(\\#?)((?:[\\p{Lu}])(?:[$_\\p{Lu}\\p{Nd}])*+)\\s*+(?:(\\?\\.)|(\\.))\\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*+(\\#?)((?:[\\p{Lu}])(?:[$_\\p{Lu}\\p{Nd}])*+)\\s*+(?:(\\?\\.)|(\\.))\\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 @@ -2731,6 +2801,9 @@
{
"include": "#square-brackets"
},
{
"include": "#type-argument-brackets"
},
{
"include": "#round-brackets"
}
Expand Down Expand Up @@ -2774,7 +2847,7 @@
{
"name": "meta.method-call.with-arguments.js",
"comment": "e.g CONSTNAME.method()",
"begin": "\\s*+(\\#?)((?:[\\p{Lu}])(?:[$_\\p{Lu}\\p{Nd}])*+)\\s*+(?:(\\?\\.)|(\\.))\\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*+\\()",
"begin": "\\s*+(\\#?)((?:[\\p{Lu}])(?:[$_\\p{Lu}\\p{Nd}])*+)\\s*+(?:(\\?\\.)|(\\.))\\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 @@ -2801,6 +2874,9 @@
{
"include": "#square-brackets"
},
{
"include": "#type-argument-brackets"
},
{
"include": "#round-brackets"
}
Expand All @@ -2809,7 +2885,7 @@
{
"name": "meta.method-call.with-arguments.js",
"comment": "e.g Abc.aaa()",
"begin": "\\s*+(\\#?)((?:[\\p{Lu}])(?:[$_\\p{L}\\p{Mn}\\p{Mc}\\p{Nd}\\p{Nl}\\p{Pc}\\x{200C}\\x{200D}]|\\\\u\\h{4}|\\\\u{\\h+})*+)\\s*+(?:(\\?\\.)|(\\.))\\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*+\\()",
"begin": "\\s*+(\\#?)((?:[\\p{Lu}])(?:[$_\\p{L}\\p{Mn}\\p{Mc}\\p{Nd}\\p{Nl}\\p{Pc}\\x{200C}\\x{200D}]|\\\\u\\h{4}|\\\\u{\\h+})*+)\\s*+(?:(\\?\\.)|(\\.))\\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 @@ -2835,13 +2911,16 @@
"patterns": [
{
"include": "#round-brackets"
},
{
"include": "#type-argument-brackets"
}
]
},
{
"name": "meta.method-call.without-arguments.js",
"comment": "e.g .aaa()",
"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*+(?=(\\[(?:(?>[^\\[\\]]+)|\\\\g<-1>)*\\])?+\\s*+(\\(\\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*+(?=(\\[(?:(?>[^\\[\\]]+)|\\\\g<-1>)*\\])?+\\s*+(<(?:(?>[^<>]+)|\\g<-1>)*>)?\\s*+(\\(\\s*+\\)))",
"end": "(?=.)",
"applyEndPatternLast": 1,
"beginCaptures": {
Expand All @@ -2859,6 +2938,9 @@
{
"include": "#square-brackets"
},
{
"include": "#type-argument-brackets"
},
{
"include": "#round-brackets"
}
Expand All @@ -2867,7 +2949,7 @@
{
"name": "meta.method-call.with-arguments.js",
"comment": "e.g .aaa()",
"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*+(?=(\\[(?:(?>[^\\[\\]]+)|\\\\g<-1>)*\\])?+\\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*+(?=(\\[(?:(?>[^\\[\\]]+)|\\\\g<-1>)*\\])?+\\s*+(<(?:(?>[^<>]+)|\\g<-1>)*>)?\\s*+\\()",
"end": "(?=.)",
"applyEndPatternLast": 1,
"beginCaptures": {
Expand All @@ -2882,6 +2964,9 @@
{
"include": "#square-brackets"
},
{
"include": "#type-argument-brackets"
},
{
"include": "#round-brackets"
}
Expand Down
65 changes: 65 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"postinstall": "node ./node_modules/vscode/bin/install",
"prettier:stdin": "prettier --single-quote --print-width 100 --trailing-comma all --write",
"prettier": "npm run prettier:stdin -- '**/*.ts' '**/*.json'",
"test": "jest"
"test": "vscode-tmgrammar-test -s source.js -g grammars/Babel-Language.json -t 'tests/*.js'"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -174,7 +174,8 @@
"lint-staged": "^8.1.4",
"prettier": "^1.16.4",
"typescript": "^3.3.3",
"vscode": "^1.1.35"
"vscode": "^1.1.35",
"vscode-tmgrammar-test": "0.0.5"
},
"husky": {
"hooks": {
Expand Down
Loading