Skip to content

Commit fd08586

Browse files
authored
Merge pull request #172 from tree-sitter/mj-latest-js
Use latest tree-sitter-javascript (commit 2c5b138)
2 parents 30e1b08 + 83bd251 commit fd08586

File tree

11 files changed

+315
-263
lines changed

11 files changed

+315
-263
lines changed

common/corpus/declarations.txt

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ declare module Foo {
7676
(lexical_declaration
7777
(variable_declarator
7878
name: (identifier)
79-
value: (string))))
79+
value: (string (string_fragment)))))
8080
(ambient_declaration
8181
(function_signature
8282
name: (identifier)
@@ -161,7 +161,7 @@ declare module Foo {
161161
body: (switch_body
162162
(switch_case value: (number) (break_statement))
163163
(switch_default (break_statement))))
164-
(throw_statement (string))
164+
(throw_statement (string (string_fragment)))
165165
(try_statement
166166
body: (statement_block)
167167
handler: (catch_clause
@@ -430,8 +430,8 @@ declare module "example" { }
430430
(identifier)
431431
(type_annotation (generic_type (type_identifier) (type_arguments (type_identifier))))))
432432
(type_annotation (generic_type (type_identifier) (type_arguments (type_identifier))))))))
433-
(ambient_declaration (module (string)))
434-
(ambient_declaration (module (string) (statement_block))))
433+
(ambient_declaration (module (string (string_fragment))))
434+
(ambient_declaration (module (string (string_fragment)) (statement_block))))
435435

436436
=================================
437437
Accessibility modifiers as pair keywords
@@ -667,10 +667,10 @@ class Foo {
667667
(type_identifier)
668668
(class_body
669669
(public_field_definition (number) (type_annotation (predefined_type)))
670-
(public_field_definition (accessibility_modifier) (number) (type_annotation (predefined_type)) (string))
671-
(public_field_definition (accessibility_modifier) (string) (type_annotation (type_identifier)) (string))
672-
(public_field_definition (string) (type_annotation (type_identifier)) (string))
673-
(public_field_definition (string) (type_annotation (type_identifier)) (string)))))
670+
(public_field_definition (accessibility_modifier) (number) (type_annotation (predefined_type)) (string (string_fragment)))
671+
(public_field_definition (accessibility_modifier) (string (string_fragment)) (type_annotation (type_identifier)) (string (string_fragment)))
672+
(public_field_definition (string (string_fragment)) (type_annotation (type_identifier)) (string (string_fragment)))
673+
(public_field_definition (string (string_fragment)) (type_annotation (type_identifier)) (string (string_fragment))))))
674674

675675
=======================================
676676
Classes with decorators
@@ -696,10 +696,10 @@ Classes with decorators
696696
(public_field_definition (number) (type_annotation (predefined_type)))
697697

698698
(decorator (call_expression (member_expression (identifier) (property_identifier)) (arguments (identifier))))
699-
(public_field_definition (accessibility_modifier) (number) (type_annotation (predefined_type)) (string))
699+
(public_field_definition (accessibility_modifier) (number) (type_annotation (predefined_type)) (string (string_fragment)))
700700

701701
(decorator (identifier))
702-
(public_field_definition (string) (type_annotation (type_identifier)) (string))
702+
(public_field_definition (string (string_fragment)) (type_annotation (type_identifier)) (string (string_fragment)))
703703

704704
(decorator (identifier))
705705
(method_definition
@@ -812,7 +812,7 @@ abstract class Foo {
812812
function: (member_expression
813813
object: (identifier)
814814
property: (property_identifier))
815-
arguments: (arguments (string))))))))
815+
arguments: (arguments (string (string_fragment)))))))))
816816
(abstract_class_declaration
817817
decorator: (decorator (identifier))
818818
name: (type_identifier)
@@ -836,7 +836,7 @@ export type Extracted = keyof Pick<Base, "id">
836836
(type_arguments
837837
(type_identifier)
838838
(literal_type
839-
(string))))))))
839+
(string (string_fragment)))))))))
840840

841841
==================================
842842
Definite assignment assertions

common/corpus/expressions.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ typeof module === "object" && typeof module.exports === "object"
5151
(expression_statement
5252
(binary_expression
5353
(unary_expression (class (class_body)))
54-
(string)))
54+
(string (string_fragment))))
5555
(expression_statement
5656
(binary_expression
57-
(binary_expression (unary_expression (identifier)) (string))
58-
(binary_expression (unary_expression (member_expression (identifier) (property_identifier))) (string)))))
57+
(binary_expression (unary_expression (identifier)) (string (string_fragment)))
58+
(binary_expression (unary_expression (member_expression (identifier) (property_identifier))) (string (string_fragment))))))
5959

6060
==================================
6161
Array with empty elements

common/corpus/functions.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function foo<T, U>(this: T[]): U[] {
2626
parameters: (formal_parameters (required_parameter (identifier) (type_annotation (predefined_type))))
2727
body: (statement_block
2828
(return_statement (binary_expression
29-
left: (string)
29+
left: (string (string_fragment))
3030
right: (identifier)))))
3131
(function_declaration
3232
name: (identifier)
@@ -212,7 +212,7 @@ class A extends B {
212212
object: (super)
213213
property: (property_identifier))
214214
arguments: (arguments))
215-
right: (string))
215+
right: (string (string_fragment)))
216216
right: (member_expression
217217
object: (this)
218218
property: (property_identifier)))))))))

common/corpus/types.txt

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ var y: number;
1111
(variable_declaration (variable_declarator
1212
(identifier)
1313
(type_annotation (predefined_type))
14-
(string)))
14+
(string (string_fragment))))
1515
(variable_declaration (variable_declarator
1616
(identifier)
1717
(type_annotation (predefined_type)))))
@@ -183,15 +183,15 @@ f
183183
(formal_parameters)
184184
(type_annotation (predefined_type))
185185
(statement_block
186-
(expression_statement (string))
187-
(expression_statement (string))))
186+
(expression_statement (string (string_fragment)))
187+
(expression_statement (string (string_fragment)))))
188188
(function_declaration
189189
(identifier)
190190
(formal_parameters)
191191
(type_annotation (predefined_type))
192192
(statement_block
193-
(expression_statement (string))
194-
(expression_statement (string)))))
193+
(expression_statement (string (string_fragment)))
194+
(expression_statement (string (string_fragment))))))
195195

196196
=======================================
197197
Array types
@@ -322,16 +322,16 @@ import type UserID, {addUser, removeUser} from './User.js';
322322
(program
323323
(import_statement
324324
(import_clause
325-
(named_imports (import_specifier (identifier)) (import_specifier (identifier)))) (string))
325+
(named_imports (import_specifier (identifier)) (import_specifier (identifier)))) (string (string_fragment)))
326326
(import_statement
327327
(import_clause
328-
(named_imports (import_specifier (identifier)) (import_specifier (identifier)))) (string))
328+
(named_imports (import_specifier (identifier)) (import_specifier (identifier)))) (string (string_fragment)))
329329
(import_statement
330330
(import_clause
331-
(named_imports (import_specifier (identifier) (identifier)))) (string))
331+
(named_imports (import_specifier (identifier) (identifier)))) (string (string_fragment)))
332332
(import_statement
333333
(import_clause (identifier)
334-
(named_imports (import_specifier (identifier)) (import_specifier (identifier)))) (string)))
334+
(named_imports (import_specifier (identifier)) (import_specifier (identifier)))) (string (string_fragment))))
335335

336336
=======================================
337337
Type-only Export
@@ -418,9 +418,9 @@ enum Style {
418418
(program
419419
(enum_declaration (identifier) (enum_body
420420
(property_identifier)
421-
(string)
421+
(string (string_fragment))
422422
(enum_assignment
423-
(string)
423+
(string (string_fragment))
424424
(call_expression
425425
(member_expression (identifier) (property_identifier))
426426
(arguments (binary_expression (call_expression (member_expression (identifier) (property_identifier)) (arguments)) (number)))))
@@ -559,8 +559,8 @@ type Z = | "foo";
559559

560560
(program
561561
(type_alias_declaration (type_identifier) (union_type (predefined_type) (predefined_type)))
562-
(type_alias_declaration (type_identifier) (union_type (union_type (literal_type (string))) (literal_type (string))))
563-
(type_alias_declaration (type_identifier) (union_type (literal_type (string)))))
562+
(type_alias_declaration (type_identifier) (union_type (union_type (literal_type (string (string_fragment)))) (literal_type (string (string_fragment)))))
563+
(type_alias_declaration (type_identifier) (union_type (literal_type (string (string_fragment))))))
564564

565565
=======================================
566566
Flow Intersection types
@@ -610,7 +610,7 @@ let x: false
610610
(lexical_declaration
611611
(variable_declarator (identifier) (type_annotation (union_type (union_type (literal_type (number)) (literal_type (unary_expression (number)))) (literal_type (unary_expression (number)))))))
612612
(lexical_declaration
613-
(variable_declarator (identifier) (type_annotation (literal_type (string))))) (lexical_declaration (variable_declarator (identifier) (type_annotation (literal_type (false))))))
613+
(variable_declarator (identifier) (type_annotation (literal_type (string (string_fragment)))))) (lexical_declaration (variable_declarator (identifier) (type_annotation (literal_type (false))))))
614614

615615
=======================================
616616
Flow type parameter constraint syntax
@@ -737,7 +737,7 @@ type T = keyof U & V;
737737
(type_alias_declaration (type_identifier)
738738
(type_query (generic_type (type_identifier) (type_arguments (type_identifier)))))
739739
(type_alias_declaration (type_identifier)
740-
(type_query (call_expression (import) (arguments (string)))))
740+
(type_query (call_expression (import) (arguments (string (string_fragment))))))
741741
(type_alias_declaration (type_identifier)
742742
(index_type_query (type_query (identifier))))
743743
(type_alias_declaration (type_identifier)
@@ -761,7 +761,7 @@ type A = typeof some_array[number]
761761
(lookup_type (type_identifier) (type_identifier)))
762762
(type_alias_declaration
763763
(type_identifier)
764-
(lookup_type (type_identifier) (union_type (literal_type (string)) (literal_type (string)))))
764+
(lookup_type (type_identifier) (union_type (literal_type (string (string_fragment))) (literal_type (string (string_fragment))))))
765765
(type_alias_declaration
766766
(type_identifier)
767767
(lookup_type (type_query (identifier)) (predefined_type))))

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"main": "./bindings/node",
1616
"devDependencies": {
1717
"tree-sitter-cli": "^0.19.1",
18-
"tree-sitter-javascript": "github:tree-sitter/tree-sitter-javascript#ae9bc67"
18+
"tree-sitter-javascript": "github:tree-sitter/tree-sitter-javascript#2c5b138"
1919
},
2020
"scripts": {
2121
"build": "npm run build-typescript && npm run build-tsx",

tsx/src/grammar.json

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5117,15 +5117,13 @@
51175117
"type": "CHOICE",
51185118
"members": [
51195119
{
5120-
"type": "IMMEDIATE_TOKEN",
5120+
"type": "ALIAS",
51215121
"content": {
5122-
"type": "PREC",
5123-
"value": 1,
5124-
"content": {
5125-
"type": "PATTERN",
5126-
"value": "[^\"\\\\]+"
5127-
}
5128-
}
5122+
"type": "SYMBOL",
5123+
"name": "unescaped_double_string_fragment"
5124+
},
5125+
"named": true,
5126+
"value": "string_fragment"
51295127
},
51305128
{
51315129
"type": "SYMBOL",
@@ -5153,15 +5151,13 @@
51535151
"type": "CHOICE",
51545152
"members": [
51555153
{
5156-
"type": "IMMEDIATE_TOKEN",
5154+
"type": "ALIAS",
51575155
"content": {
5158-
"type": "PREC",
5159-
"value": 1,
5160-
"content": {
5161-
"type": "PATTERN",
5162-
"value": "[^'\\\\]+"
5163-
}
5164-
}
5156+
"type": "SYMBOL",
5157+
"name": "unescaped_single_string_fragment"
5158+
},
5159+
"named": true,
5160+
"value": "string_fragment"
51655161
},
51665162
{
51675163
"type": "SYMBOL",
@@ -5178,6 +5174,28 @@
51785174
}
51795175
]
51805176
},
5177+
"unescaped_double_string_fragment": {
5178+
"type": "IMMEDIATE_TOKEN",
5179+
"content": {
5180+
"type": "PREC",
5181+
"value": 1,
5182+
"content": {
5183+
"type": "PATTERN",
5184+
"value": "[^\"\\\\]+"
5185+
}
5186+
}
5187+
},
5188+
"unescaped_single_string_fragment": {
5189+
"type": "IMMEDIATE_TOKEN",
5190+
"content": {
5191+
"type": "PREC",
5192+
"value": 1,
5193+
"content": {
5194+
"type": "PATTERN",
5195+
"value": "[^'\\\\]+"
5196+
}
5197+
}
5198+
},
51815199
"escape_sequence": {
51825200
"type": "IMMEDIATE_TOKEN",
51835201
"content": {

tsx/src/node-types.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4666,6 +4666,10 @@
46664666
{
46674667
"type": "escape_sequence",
46684668
"named": true
4669+
},
4670+
{
4671+
"type": "string_fragment",
4672+
"named": true
46694673
}
46704674
]
46714675
}
@@ -5972,6 +5976,10 @@
59725976
"type": "string",
59735977
"named": false
59745978
},
5979+
{
5980+
"type": "string_fragment",
5981+
"named": true
5982+
},
59755983
{
59765984
"type": "super",
59775985
"named": true

0 commit comments

Comments
 (0)