Skip to content

Commit

Permalink
Add missing JavaScript (and Node.js) module directives.
Browse files Browse the repository at this point in the history
  • Loading branch information
zufuliu committed Nov 17, 2018
1 parent 8e9f06c commit 9753a63
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
2 changes: 1 addition & 1 deletion build/VS2017/Notepad2.sln
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28306.52
VisualStudioVersion = 15.0.28307.102
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Notepad2", "Notepad2.vcxproj", "{B69A8C7E-A22D-45DA-9997-2D1403C7AEE8}"
EndProject
Expand Down
10 changes: 7 additions & 3 deletions src/EditLexers/stlJavaScript.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// http://www.ecma-international.org/publications/standards/Ecma-262.htm
static KEYWORDLIST Keywords_JS = {{
// ECMA-262
"async await break case catch class const continue debugger default delete do else export extends finally for function if import in "
"async await break case catch class const continue debugger default delete do else extends finally for function if in "
"instanceof let new return static super switch this throw try typeof var void while with yield "
"null true false undefined NaN Infinity "

Expand All @@ -22,7 +22,10 @@ NULL
, // 3 Directive
NULL
, // 4 Attribute
NULL
// Scripts and Modules
"export import from as "
// Node.js
"module exports require __dirname __filename "

, // 5 Class
// ECMA-262
Expand Down Expand Up @@ -139,7 +142,7 @@ NULL
, NULL, NULL, NULL

, // 15 Code Snippet
"for^() if^() switch^() while^() else^if^() else^{} function() "
"for^() if^() switch^() while^() else^if^() else^{} function() require() "
}};


Expand All @@ -148,6 +151,7 @@ EDITLEXER lexJS = { SCLEX_CPP, NP2LEX_JS, EDITLEXER_HOLE(L"JavaScript"), L"js; j
EDITSTYLE_DEFAULT,
{ SCE_C_WORD, NP2STYLE_Keyword, EDITSTYLE_HOLE(L"Keyword"), L"fore:#0000FF" },
{ SCE_C_WORD2, NP2STYLE_ReservedWord, EDITSTYLE_HOLE(L"Reserved Word"), L"fore:#B000B0" },
{ SCE_C_ATTRIBUTE, NP2STYLE_Directive, EDITSTYLE_HOLE(L"Module Directive"), L"fore:#FF8000" },
{ SCE_C_CLASS, NP2STYLE_Object, EDITSTYLE_HOLE(L"Object"), L"bold; fore:#0080C0" },
{ SCE_C_FUNCTION, NP2STYLE_Function, EDITSTYLE_HOLE(L"Function"), L"fore:#A46000" },
{ SCE_C_CONSTANT, NP2STYLE_Constant, EDITSTYLE_HOLE(L"Constant"), L"fore:#B000B0" },
Expand Down
13 changes: 13 additions & 0 deletions tools/lang/JavaScript.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ Infinity
NaN
undefined

// http://www.ecma-international.org/ecma-262/9.0/index.html#sec-imports
// http://www.ecma-international.org/ecma-262/9.0/index.html#sec-exports
import as from;
export as;
export default;

eval(x)
isFinite(number)
isNaN(number)
Expand Down Expand Up @@ -563,3 +569,10 @@ Storage {
localStorage
sessionStorage
}

// https://nodejs.org/api/globals.html
__dirname
__filename
exports
module
require(path)

0 comments on commit 9753a63

Please sign in to comment.