tree-sitter-javascript
Advanced tools
Comparing version 0.4.5 to 0.4.6
@@ -366,2 +366,24 @@ ============================================ | ||
============================================ | ||
Class Decorators | ||
============================================ | ||
@reload | ||
@eval | ||
class Foo { | ||
@foo.bar(baz) static foo() { | ||
} | ||
} | ||
--- | ||
(program | ||
(class | ||
(decorator (identifier)) | ||
(decorator (identifier)) | ||
(identifier) | ||
(class_body | ||
(decorator (call_expression (member_expression (identifier) (property_identifier)) (arguments (identifier)))) | ||
(method_definition (property_identifier) (formal_parameters) (statement_block))))) | ||
============================================ | ||
Arrays | ||
@@ -368,0 +390,0 @@ ============================================ |
@@ -104,2 +104,14 @@ ============================================ | ||
============================================ | ||
Decorators before exports | ||
============================================ | ||
@injectable() | ||
export class Foo { | ||
} | ||
--- | ||
(program (export_statement (decorator (call_expression (identifier) (arguments))) (class (identifier) (class_body)))) | ||
============================================ | ||
If statements | ||
@@ -106,0 +118,0 @@ ============================================ |
@@ -64,4 +64,4 @@ const PREC = { | ||
seq('export', $.export_clause, $._semicolon), | ||
seq('export', $._declaration), | ||
seq('export', 'default', $._expression, $._semicolon) | ||
seq(repeat($.decorator), 'export', $._declaration), | ||
seq(repeat($.decorator), 'export', 'default', $._expression, $._semicolon) | ||
), | ||
@@ -412,3 +412,3 @@ | ||
$.spread_element, | ||
$.method_definition, | ||
seq(repeat($.decorator), $.method_definition), | ||
$.assignment_pattern, | ||
@@ -488,2 +488,3 @@ alias(choice($.identifier, $._reserved_identifier), $.shorthand_property_identifier) | ||
anonymous_class: $ => seq( | ||
repeat($.decorator), | ||
'class', | ||
@@ -495,2 +496,3 @@ optional($.class_heritage), | ||
class: $ => seq( | ||
repeat($.decorator), | ||
'class', | ||
@@ -767,5 +769,31 @@ $.identifier, | ||
decorator: $ => seq( | ||
'@', | ||
choice( | ||
$._identifier_reference, | ||
alias($.decorator_member_expression, $.member_expression), | ||
alias($.decorator_call_expression, $.call_expression)) | ||
), | ||
_identifier_reference: $ => choice( | ||
$.identifier, | ||
alias($._reserved_identifier, $.identifier) | ||
), | ||
decorator_member_expression: $ => prec(PREC.MEMBER, seq( | ||
seq( | ||
choice($._identifier_reference, alias($.decorator_member_expression, $.member_expression)), | ||
'.', | ||
alias($.identifier, $.property_identifier)) | ||
)), | ||
decorator_call_expression: $ => prec(PREC.CALL, seq( | ||
choice($._identifier_reference, alias($.decorator_member_expression, $.member_expression)), | ||
$.arguments | ||
)), | ||
class_body: $ => seq( | ||
'{', | ||
repeat(seq( | ||
repeat($.decorator), | ||
optional('static'), | ||
@@ -772,0 +800,0 @@ choice( |
{ | ||
"name": "tree-sitter-javascript", | ||
"version": "0.4.5", | ||
"version": "0.4.6", | ||
"description": "Javascript grammar for node-tree-sitter", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4116764
12938