add in type parameters to map set and list literals

pull/185/head
Tim Whiting 2020-07-11 12:13:05 +07:00
parent 054941eb0a
commit 6f6794748c
5 changed files with 128141 additions and 123051 deletions

@ -230,6 +230,7 @@ module.exports = grammar({
[$._top_level_definition, $.const_object_expression, $._final_const_var_or_type],
[$._final_const_var_or_type, $.const_object_expression],
[$._final_const_var_or_type],
[$.type_parameter, $._type_name],
// [$._expression_without_cascade, $._real_expression]
// [$.constructor_signature, $._formal_parameter_part],
// [$._unannotated_type, $.type_parameter],
@ -588,12 +589,12 @@ module.exports = grammar({
// ),
list_literal: $ => seq(
'[',
optional($.type_arguments), '[',
commaSepTrailingComma($._element),
']'
),
set_or_map_literal: $ => seq(
'{',
optional($.type_arguments), '{',
commaSepTrailingComma(
$._element
),

@ -1821,6 +1821,18 @@
"list_literal": {
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "type_arguments"
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",
"value": "["
@ -1879,6 +1891,18 @@
"set_or_map_literal": {
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "type_arguments"
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",
"value": "{"
@ -9383,6 +9407,10 @@
],
[
"_final_const_var_or_type"
],
[
"type_parameter",
"_type_name"
]
],
"externals": [

@ -6282,6 +6282,10 @@
"type": "throw_expression",
"named": true
},
{
"type": "type_arguments",
"named": true
},
{
"type": "unary_expression",
"named": true
@ -8211,6 +8215,10 @@
"type": "throw_expression",
"named": true
},
{
"type": "type_arguments",
"named": true
},
{
"type": "unary_expression",
"named": true

File diff suppressed because it is too large Load Diff

@ -194,3 +194,17 @@ final set = {"hello", "world"};
(local_variable_declaration (initialized_variable_definition (identifier)
(set_or_map_literal (string_literal) (string_literal)))))
==================================================
collection literal type parameters
==================================================
final dynamic opts = <dynamic, dynamic>{
'transports': ['websocket'],
'forceNew': true,
};
---
(program (local_variable_declaration (initialized_variable_definition (type_identifier) (identifier)
(set_or_map_literal (type_arguments (type_identifier) (type_identifier)) (pair (string_literal)
(list_literal (string_literal))) (pair (string_literal) (true))))))