Skip to content

Commit 82cf826

Browse files
authored
Merge pull request #1484 from Thom1729/javascript-import-meta
[JavaScript] Implement `import.meta` proposal.
2 parents 7537497 + 9827765 commit 82cf826

File tree

2 files changed

+45
-4
lines changed

2 files changed

+45
-4
lines changed

JavaScript/JavaScript.sublime-syntax

+27-4
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,19 @@ contexts:
104104
scope: punctuation.separator.comma.js
105105

106106
import-export:
107-
- match: import{{identifier_break}}
107+
- match: import{{identifier_break}}(?!\s*\.)
108108
scope: keyword.control.import-export.js
109109
set:
110-
- import-meta
111-
- expect-semicolon
112-
- import-string-or-items
110+
- meta_scope: meta.import.js
111+
- match: (?=\.) # Recovery for import.meta
112+
set:
113+
- expression-statement-end
114+
- import-meta-expression-dot
115+
- match: (?=\S)
116+
set:
117+
- import-meta
118+
- expect-semicolon
119+
- import-string-or-items
113120

114121
- match: export{{identifier_break}}
115122
scope: keyword.control.import-export.js
@@ -748,6 +755,7 @@ contexts:
748755
- include: prefix-operators
749756
- include: yield-expression
750757
- include: await-expression
758+
- include: import-meta-expression
751759

752760
- include: class
753761
- include: constants
@@ -1899,3 +1907,18 @@ contexts:
18991907
scope: invalid.illegal.illegal-identifier.js
19001908
pop: true
19011909
- include: else-pop
1910+
1911+
import-meta-expression:
1912+
- match: import{{identifier_break}}
1913+
scope: variable.language.import.js
1914+
set: import-meta-expression-dot
1915+
1916+
import-meta-expression-dot:
1917+
- match: \.
1918+
scope: punctuation.accessor.js
1919+
set:
1920+
- match: meta{{identifier_break}}
1921+
scope: variable.language.import.js
1922+
pop: true
1923+
- include: object-property
1924+
- include: else-pop

JavaScript/tests/syntax_test_js.js

+18
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,24 @@ export default$
180180
// ^^^^^^^^ - keyword
181181
;
182182

183+
let x = import.meta;
184+
// ^^^^^^^^^^^ - meta.import
185+
// ^^^^^^ variable.language.import
186+
// ^ punctuation.accessor
187+
// ^^^^ variable.language.import
188+
189+
import.meta;
190+
// ^^^^^^^^^^^ - meta.import
191+
// ^^^^^^ variable.language.import
192+
// ^ punctuation.accessor
193+
// ^^^^ variable.language.import
194+
195+
import
196+
.meta;
197+
// ^^^^^ - meta.import
198+
// ^ punctuation.accessor
199+
// ^^^^ variable.language.import
200+
183201
// This object literal is technically broken since foo() does not have a
184202
// method body, but we include it here to ensure that highlighting is not
185203
// broken as the user is typing

0 commit comments

Comments
 (0)