From a596d627b017a1886916e888d569fe31a8a9d777 Mon Sep 17 00:00:00 2001 From: Alexandre Borela Date: Sun, 28 Jan 2018 23:02:18 -0200 Subject: [PATCH] [FJSX15] Simplify node globals --- syntaxes/fjsx15/node-js.sublime-syntax | 185 ++++++++++++++----------- 1 file changed, 101 insertions(+), 84 deletions(-) diff --git a/syntaxes/fjsx15/node-js.sublime-syntax b/syntaxes/fjsx15/node-js.sublime-syntax index 54190163..5acc34c9 100644 --- a/syntaxes/fjsx15/node-js.sublime-syntax +++ b/syntaxes/fjsx15/node-js.sublime-syntax @@ -17,105 +17,122 @@ hidden: true scope: ... +variables: + processFunctions: | + (?> abort + | chdir + | cpuUsage + | cwd + | disconnect + | emitWarning + | exit + # getegid, geteuid, getgid, getuid, getgroups + | get(?>e[gu]id|[gu]id|groups) + | hrtime + | initgroups + | kill + | memoryUsage + | nextTick + | send + # setegid, seteuid, setgid, setuid, setgroups + | set(?>e[gu]id|[gu]id|groups) + # umask, uptime + | u(?>mask|ptime) + )\b + contexts: main: - - include: module - - include: process - # https://nodejs.org/api/globals.html - - include: functions - - include: constants + - include: global-constant + - include: global-function + # Module property or function. + - match: (module)\s*(\.) + captures: + 1: support.type.object.js.fjsx15 + 2: punctuation.accessor.js.fjsx15 + set: module-property-or-function + # Proccess property or function. + - match: (process)\s*(\.) + captures: + 1: support.type.object.js.fjsx15 + 2: punctuation.accessor.js.fjsx15 + set: process-property-or-function + # Just the global objects. + - match: (?>module|process)\b + scope: support.type.object.js.fjsx15 + pop: true - constants: - - match: | - (?x) - (?> __dirname - | __filename - )\b - scope: support.variable.js.fjsx15 + arguments: + - include: Packages/Naomi/syntaxes/fjsx15/function-call/arguments.sublime-syntax + + else-pop: + - match: (?=\S) pop: true - function-arguments: - - include: Packages/Naomi/syntaxes/fjsx15/expression.sublime-syntax + function-call-meta-scope: + - meta_scope: meta.function-call.js.fjsx15 + - include: pop-now + + global-constant: + - match: __(?>dirname|filename)\b + scope: support.constant.js.fjsx15 + pop: true - functions: + global-function: - match: | (?x) (?> (?>clear|set)Immediate | require )\b scope: support.function.js.fjsx15 - set: function-arguments + set: arguments - module: - - match: | - (?x) - (module)\b - (?: - \s*(\.)\s* - ((?> exports - | parent - ))\b - )? - captures: - 1: support.type.object.module.js.fjsx15 - 2: punctuation.accessor.js.fjsx15 - 3: support.type.object.module.js.fjsx15 + module-property-or-function: + # Properties. + - match: (?>exports|parent)\b + scope: support.variable.js.fjsx15 pop: true + # Bail. + - include: else-pop - process: - # Functions. - - match: | - (?x) - (process)\b - (?: - \s*(\.)\s* - ((?> abort - | chdir - | cpuUsage - | cwd - | disconnect - | emitWarning - | exit - | get(?>e[gu]id|[gu]id|groups) - | hrtime - | initgroups - | kill - | memoryUsage - | nextTick - | send - | set(?>e[gu]id|[gu]id|groups) - | u(?>mask|ptime) - ))\b - ) - captures: - 1: support.type.object.module.js.fjsx15 - 2: punctuation.accessor.js.fjsx15 - 3: support.function.js.fjsx15 - set: function-arguments - # Variables. + pop-now: + - match: "" + pop: true + + process-property-or-function: + # Function call. + - match: (?x){{processFunctions}}(?=\s*\() + scope: support.function.js.fjsx15 + set: [ + function-call-meta-scope, + arguments + ] + # Function reference. + - match: (?x){{processFunctions}} + scope: support.function.js.fjsx15 + pop: true + # Properties. - match: | (?x) - (process)\b - (?: - \s*(\.)\s* - ((?> ar(?>ch|gv0?) - | channel - | config - | connected - | env - | exec(?>Argv|Path) - | exitCode - | mainModule - | pid - | platform - | release - | std(?>err|in|out) - | title - | versions? - ))\b - )? - captures: - 1: support.type.object.module.js.fjsx15 - 2: punctuation.accessor.js.fjsx15 - 3: support.variable.js.fjsx15 + # arch, argv, argv0 + (?> ar(?>ch|gv0?) + | channel + | config + | connected + | env + # execArgv, execPath + | exec(?>Argv|Path) + | exitCode + | mainModule + | pid + | platform + | release + # stderr, stdin, stdout + | std(?>err|in|out) + | title + # version, versions + | versions? + )\b + scope: support.variable.js.fjsx15 pop: true + # Bail. + - include: else-pop