Patch js/ts grammars to remove special scopes for node
Fixes #94284 Now the we have semantic highlighting, we should use that to identify if a variable is really from node or not
This commit is contained in:
parent
a1d80c4a70
commit
75c625d421
|
@ -3617,30 +3617,6 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "support.class.node.js",
|
||||
"match": "(?x)(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(Buffer|EventEmitter|Server|Pipe|Socket|REPLServer|ReadStream|WriteStream|Stream\n |Inflate|Deflate|InflateRaw|DeflateRaw|GZip|GUnzip|Unzip|Zip)\\b(?!\\$)"
|
||||
},
|
||||
{
|
||||
"match": "(?x)(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(process)(?:(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))(?:\n (arch|argv|config|connected|env|execArgv|execPath|exitCode|mainModule|pid|platform|release|stderr|stdin|stdout|title|version|versions)\n |\n (abort|chdir|cwd|disconnect|exit|[sg]ete?[gu]id|send|[sg]etgroups|initgroups|kill|memoryUsage|nextTick|umask|uptime|hrtime)\n))?\\b(?!\\$)",
|
||||
"captures": {
|
||||
"1": {
|
||||
"name": "support.variable.object.process.js"
|
||||
},
|
||||
"2": {
|
||||
"name": "punctuation.accessor.js"
|
||||
},
|
||||
"3": {
|
||||
"name": "punctuation.accessor.optional.js"
|
||||
},
|
||||
"4": {
|
||||
"name": "support.variable.property.process.js"
|
||||
},
|
||||
"5": {
|
||||
"name": "support.function.process.js"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(exports)|(module)(?:(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))(exports|id|filename|loaded|parent|children))?)\\b(?!\\$)",
|
||||
"captures": {
|
||||
|
@ -3660,10 +3636,6 @@
|
|||
"name": "support.type.object.module.js"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "support.variable.object.node.js",
|
||||
"match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(global|GLOBAL|root|__dirname|__filename)\\b(?!\\$)"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
|
@ -3617,30 +3617,6 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "support.class.node.js.jsx",
|
||||
"match": "(?x)(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(Buffer|EventEmitter|Server|Pipe|Socket|REPLServer|ReadStream|WriteStream|Stream\n |Inflate|Deflate|InflateRaw|DeflateRaw|GZip|GUnzip|Unzip|Zip)\\b(?!\\$)"
|
||||
},
|
||||
{
|
||||
"match": "(?x)(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(process)(?:(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))(?:\n (arch|argv|config|connected|env|execArgv|execPath|exitCode|mainModule|pid|platform|release|stderr|stdin|stdout|title|version|versions)\n |\n (abort|chdir|cwd|disconnect|exit|[sg]ete?[gu]id|send|[sg]etgroups|initgroups|kill|memoryUsage|nextTick|umask|uptime|hrtime)\n))?\\b(?!\\$)",
|
||||
"captures": {
|
||||
"1": {
|
||||
"name": "support.variable.object.process.js.jsx"
|
||||
},
|
||||
"2": {
|
||||
"name": "punctuation.accessor.js.jsx"
|
||||
},
|
||||
"3": {
|
||||
"name": "punctuation.accessor.optional.js.jsx"
|
||||
},
|
||||
"4": {
|
||||
"name": "support.variable.property.process.js.jsx"
|
||||
},
|
||||
"5": {
|
||||
"name": "support.function.process.js.jsx"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(exports)|(module)(?:(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))(exports|id|filename|loaded|parent|children))?)\\b(?!\\$)",
|
||||
"captures": {
|
||||
|
@ -3660,10 +3636,6 @@
|
|||
"name": "support.type.object.module.js.jsx"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "support.variable.object.node.js.jsx",
|
||||
"match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(global|GLOBAL|root|__dirname|__filename)\\b(?!\\$)"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
|
@ -17,6 +17,23 @@ function removeDom(grammar) {
|
|||
return grammar;
|
||||
}
|
||||
|
||||
function removeNodeTypes(grammar) {
|
||||
grammar.repository['support-objects'].patterns = grammar.repository['support-objects'].patterns.filter(pattern => {
|
||||
if (pattern.name) {
|
||||
if (pattern.name.startsWith('support.variable.object.node') || pattern.name.startsWith('support.class.node.')) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (pattern.captures) {
|
||||
if (Object.values(pattern.captures).some(capture => capture.name && capture.name.startsWith('support.variable.object.process'))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
return grammar;
|
||||
}
|
||||
|
||||
function patchJsdoctype(grammar) {
|
||||
grammar.repository['jsdoctype'].patterns = grammar.repository['jsdoctype'].patterns.filter(pattern => {
|
||||
if (pattern.name && pattern.name.indexOf('illegal') >= -1) {
|
||||
|
@ -28,7 +45,7 @@ function patchJsdoctype(grammar) {
|
|||
}
|
||||
|
||||
function patchGrammar(grammar) {
|
||||
return removeDom(patchJsdoctype(grammar));
|
||||
return removeNodeTypes(removeDom(patchJsdoctype(grammar)));
|
||||
}
|
||||
|
||||
function adaptToJavaScript(grammar, replacementScope) {
|
||||
|
|
|
@ -3666,30 +3666,6 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "support.class.node.ts",
|
||||
"match": "(?x)(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(Buffer|EventEmitter|Server|Pipe|Socket|REPLServer|ReadStream|WriteStream|Stream\n |Inflate|Deflate|InflateRaw|DeflateRaw|GZip|GUnzip|Unzip|Zip)\\b(?!\\$)"
|
||||
},
|
||||
{
|
||||
"match": "(?x)(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(process)(?:(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))(?:\n (arch|argv|config|connected|env|execArgv|execPath|exitCode|mainModule|pid|platform|release|stderr|stdin|stdout|title|version|versions)\n |\n (abort|chdir|cwd|disconnect|exit|[sg]ete?[gu]id|send|[sg]etgroups|initgroups|kill|memoryUsage|nextTick|umask|uptime|hrtime)\n))?\\b(?!\\$)",
|
||||
"captures": {
|
||||
"1": {
|
||||
"name": "support.variable.object.process.ts"
|
||||
},
|
||||
"2": {
|
||||
"name": "punctuation.accessor.ts"
|
||||
},
|
||||
"3": {
|
||||
"name": "punctuation.accessor.optional.ts"
|
||||
},
|
||||
"4": {
|
||||
"name": "support.variable.property.process.ts"
|
||||
},
|
||||
"5": {
|
||||
"name": "support.function.process.ts"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(exports)|(module)(?:(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))(exports|id|filename|loaded|parent|children))?)\\b(?!\\$)",
|
||||
"captures": {
|
||||
|
@ -3709,10 +3685,6 @@
|
|||
"name": "support.type.object.module.ts"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "support.variable.object.node.ts",
|
||||
"match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(global|GLOBAL|root|__dirname|__filename)\\b(?!\\$)"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
|
@ -3617,30 +3617,6 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "support.class.node.tsx",
|
||||
"match": "(?x)(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(Buffer|EventEmitter|Server|Pipe|Socket|REPLServer|ReadStream|WriteStream|Stream\n |Inflate|Deflate|InflateRaw|DeflateRaw|GZip|GUnzip|Unzip|Zip)\\b(?!\\$)"
|
||||
},
|
||||
{
|
||||
"match": "(?x)(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(process)(?:(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))(?:\n (arch|argv|config|connected|env|execArgv|execPath|exitCode|mainModule|pid|platform|release|stderr|stdin|stdout|title|version|versions)\n |\n (abort|chdir|cwd|disconnect|exit|[sg]ete?[gu]id|send|[sg]etgroups|initgroups|kill|memoryUsage|nextTick|umask|uptime|hrtime)\n))?\\b(?!\\$)",
|
||||
"captures": {
|
||||
"1": {
|
||||
"name": "support.variable.object.process.tsx"
|
||||
},
|
||||
"2": {
|
||||
"name": "punctuation.accessor.tsx"
|
||||
},
|
||||
"3": {
|
||||
"name": "punctuation.accessor.optional.tsx"
|
||||
},
|
||||
"4": {
|
||||
"name": "support.variable.property.process.tsx"
|
||||
},
|
||||
"5": {
|
||||
"name": "support.function.process.tsx"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?:(exports)|(module)(?:(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))(exports|id|filename|loaded|parent|children))?)\\b(?!\\$)",
|
||||
"captures": {
|
||||
|
@ -3660,10 +3636,6 @@
|
|||
"name": "support.type.object.module.tsx"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "support.variable.object.node.tsx",
|
||||
"match": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(global|GLOBAL|root|__dirname|__filename)\\b(?!\\$)"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue