mirror of
https://github.com/github/codeql.git
synced 2026-05-14 03:09:26 +02:00
unified: make if-condition nodes named, to stop bleed
Before, the `condition` field of an if statement supposedly could contain things like parentheses and commas, due to bleeding from referenced anonymous nodes. Making the node named makes this issue go away.
This commit is contained in:
@@ -1035,12 +1035,12 @@ module.exports = grammar({
|
||||
PRECS["if"],
|
||||
seq(
|
||||
"if",
|
||||
sep1(field("condition", $._if_condition_sequence_item), ","),
|
||||
sep1(field("condition", $.if_condition), ","),
|
||||
$._block,
|
||||
optional(seq($["else"], $._else_options))
|
||||
)
|
||||
),
|
||||
_if_condition_sequence_item: ($) =>
|
||||
if_condition: ($) =>
|
||||
choice($._if_let_binding, $._expression, $.availability_condition),
|
||||
_if_let_binding: ($) =>
|
||||
seq(
|
||||
@@ -1053,7 +1053,7 @@ module.exports = grammar({
|
||||
PRECS["if"],
|
||||
seq(
|
||||
"guard",
|
||||
sep1(field("condition", $._if_condition_sequence_item), ","),
|
||||
sep1(field("condition", $.if_condition), ","),
|
||||
$["else"],
|
||||
$._block
|
||||
)
|
||||
@@ -1237,7 +1237,7 @@ module.exports = grammar({
|
||||
PRECS.loop,
|
||||
seq(
|
||||
"while",
|
||||
sep1(field("condition", $._if_condition_sequence_item), ","),
|
||||
sep1(field("condition", $.if_condition), ","),
|
||||
"{",
|
||||
optional($.statements),
|
||||
"}"
|
||||
@@ -1254,7 +1254,7 @@ module.exports = grammar({
|
||||
// Make sure we make it to the `while` before assuming this is a parameter pack.
|
||||
repeat($._implicit_semi),
|
||||
"while",
|
||||
sep1(field("condition", $._if_condition_sequence_item), ",")
|
||||
sep1(field("condition", $.if_condition), ",")
|
||||
)
|
||||
),
|
||||
control_transfer_statement: ($) =>
|
||||
|
||||
@@ -165,17 +165,17 @@ named:
|
||||
$children*: [mutation_modifier, throws, throws_clause]
|
||||
guard_statement:
|
||||
$children+: [else, statements]
|
||||
bound_identifier*: simple_identifier
|
||||
condition+: ["(", ")", ",", ".", ":", "=", "?", additive_expression, array_literal, array_type, "as", as_expression, assignment, "async", availability_condition, await_expression, bin_literal, bitwise_operation, boolean_literal, call_expression, "case", check_expression, comparison_expression, conjunction_expression, constructor_expression, diagnostic, dictionary_literal, dictionary_type, directive, disjunction_expression, equality_expression, existential_type, fully_open_range, function_type, hex_literal, if_statement, infix_expression, integer_literal, "is", key_path_expression, key_path_string_expression, lambda_literal, line_string_literal, macro_invocation, metatype, multi_line_string_literal, multiplicative_expression, navigation_expression, "nil", nil_coalescing_expression, oct_literal, opaque_type, open_end_range_expression, open_start_range_expression, optional_chain_marker, optional_type, pattern, playground_literal, postfix_expression, prefix_expression, protocol_composition_type, range_expression, raw_string_literal, real_literal, referenceable_operator, regex_literal, selector_expression, self_expression, simple_identifier, special_literal, super_expression, suppressed_constraint, switch_statement, ternary_expression, try_expression, tuple_expression, tuple_type, type_annotation, type_modifiers, type_pack_expansion, type_parameter_pack, user_type, value_binding_pattern, value_pack_expansion, value_parameter_pack, where_clause, wildcard_pattern]
|
||||
name*: [array_type, dictionary_type, existential_type, function_type, metatype, opaque_type, optional_type, protocol_composition_type, suppressed_constraint, tuple_type, type_pack_expansion, type_parameter_pack, user_type]
|
||||
condition+: if_condition
|
||||
hex_literal:
|
||||
identifier:
|
||||
$children+: simple_identifier
|
||||
if_condition:
|
||||
$children*: [additive_expression, array_literal, as_expression, assignment, availability_condition, await_expression, bin_literal, bitwise_operation, boolean_literal, call_expression, check_expression, comparison_expression, conjunction_expression, constructor_expression, diagnostic, dictionary_literal, directive, disjunction_expression, equality_expression, fully_open_range, hex_literal, if_statement, infix_expression, integer_literal, key_path_expression, key_path_string_expression, lambda_literal, line_string_literal, macro_invocation, multi_line_string_literal, multiplicative_expression, navigation_expression, nil_coalescing_expression, oct_literal, open_end_range_expression, open_start_range_expression, optional_chain_marker, pattern, playground_literal, postfix_expression, prefix_expression, range_expression, raw_string_literal, real_literal, referenceable_operator, regex_literal, selector_expression, self_expression, simple_identifier, special_literal, super_expression, switch_statement, ternary_expression, try_expression, tuple_expression, type_annotation, type_modifiers, user_type, value_binding_pattern, value_pack_expansion, value_parameter_pack, where_clause, wildcard_pattern]
|
||||
bound_identifier?: simple_identifier
|
||||
name?: [array_type, dictionary_type, existential_type, function_type, metatype, opaque_type, optional_type, protocol_composition_type, suppressed_constraint, tuple_type, type_pack_expansion, type_parameter_pack, user_type]
|
||||
if_statement:
|
||||
$children*: [else, if_statement, statements]
|
||||
bound_identifier*: simple_identifier
|
||||
condition+: ["(", ")", ",", ".", ":", "=", "?", additive_expression, array_literal, array_type, "as", as_expression, assignment, "async", availability_condition, await_expression, bin_literal, bitwise_operation, boolean_literal, call_expression, "case", check_expression, comparison_expression, conjunction_expression, constructor_expression, diagnostic, dictionary_literal, dictionary_type, directive, disjunction_expression, equality_expression, existential_type, fully_open_range, function_type, hex_literal, if_statement, infix_expression, integer_literal, "is", key_path_expression, key_path_string_expression, lambda_literal, line_string_literal, macro_invocation, metatype, multi_line_string_literal, multiplicative_expression, navigation_expression, "nil", nil_coalescing_expression, oct_literal, opaque_type, open_end_range_expression, open_start_range_expression, optional_chain_marker, optional_type, pattern, playground_literal, postfix_expression, prefix_expression, protocol_composition_type, range_expression, raw_string_literal, real_literal, referenceable_operator, regex_literal, selector_expression, self_expression, simple_identifier, special_literal, super_expression, suppressed_constraint, switch_statement, ternary_expression, try_expression, tuple_expression, tuple_type, type_annotation, type_modifiers, type_pack_expansion, type_parameter_pack, user_type, value_binding_pattern, value_pack_expansion, value_parameter_pack, where_clause, wildcard_pattern]
|
||||
name*: [array_type, dictionary_type, existential_type, function_type, metatype, opaque_type, optional_type, protocol_composition_type, suppressed_constraint, tuple_type, type_pack_expansion, type_parameter_pack, user_type]
|
||||
condition+: if_condition
|
||||
import_declaration:
|
||||
$children+: [identifier, modifiers]
|
||||
infix_expression:
|
||||
@@ -346,9 +346,7 @@ named:
|
||||
regex_literal:
|
||||
repeat_while_statement:
|
||||
$children?: statements
|
||||
bound_identifier*: simple_identifier
|
||||
condition+: ["(", ")", ",", ".", ":", "=", "?", additive_expression, array_literal, array_type, "as", as_expression, assignment, "async", availability_condition, await_expression, bin_literal, bitwise_operation, boolean_literal, call_expression, "case", check_expression, comparison_expression, conjunction_expression, constructor_expression, diagnostic, dictionary_literal, dictionary_type, directive, disjunction_expression, equality_expression, existential_type, fully_open_range, function_type, hex_literal, if_statement, infix_expression, integer_literal, "is", key_path_expression, key_path_string_expression, lambda_literal, line_string_literal, macro_invocation, metatype, multi_line_string_literal, multiplicative_expression, navigation_expression, "nil", nil_coalescing_expression, oct_literal, opaque_type, open_end_range_expression, open_start_range_expression, optional_chain_marker, optional_type, pattern, playground_literal, postfix_expression, prefix_expression, protocol_composition_type, range_expression, raw_string_literal, real_literal, referenceable_operator, regex_literal, selector_expression, self_expression, simple_identifier, special_literal, super_expression, suppressed_constraint, switch_statement, ternary_expression, try_expression, tuple_expression, tuple_type, type_annotation, type_modifiers, type_pack_expansion, type_parameter_pack, user_type, value_binding_pattern, value_pack_expansion, value_parameter_pack, where_clause, wildcard_pattern]
|
||||
name*: [array_type, dictionary_type, existential_type, function_type, metatype, opaque_type, optional_type, protocol_composition_type, suppressed_constraint, tuple_type, type_pack_expansion, type_parameter_pack, user_type]
|
||||
condition+: if_condition
|
||||
selector_expression:
|
||||
$children?: [additive_expression, array_literal, as_expression, assignment, await_expression, bin_literal, bitwise_operation, boolean_literal, call_expression, check_expression, comparison_expression, conjunction_expression, constructor_expression, diagnostic, dictionary_literal, directive, disjunction_expression, equality_expression, fully_open_range, hex_literal, if_statement, infix_expression, integer_literal, key_path_expression, key_path_string_expression, lambda_literal, line_string_literal, macro_invocation, multi_line_string_literal, multiplicative_expression, navigation_expression, nil_coalescing_expression, oct_literal, open_end_range_expression, open_start_range_expression, optional_chain_marker, playground_literal, postfix_expression, prefix_expression, range_expression, raw_string_literal, real_literal, referenceable_operator, regex_literal, selector_expression, self_expression, simple_identifier, special_literal, super_expression, switch_statement, ternary_expression, try_expression, tuple_expression, value_pack_expansion, value_parameter_pack]
|
||||
self_expression:
|
||||
@@ -452,9 +450,7 @@ named:
|
||||
where_keyword:
|
||||
while_statement:
|
||||
$children?: statements
|
||||
bound_identifier*: simple_identifier
|
||||
condition+: ["(", ")", ",", ".", ":", "=", "?", additive_expression, array_literal, array_type, "as", as_expression, assignment, "async", availability_condition, await_expression, bin_literal, bitwise_operation, boolean_literal, call_expression, "case", check_expression, comparison_expression, conjunction_expression, constructor_expression, diagnostic, dictionary_literal, dictionary_type, directive, disjunction_expression, equality_expression, existential_type, fully_open_range, function_type, hex_literal, if_statement, infix_expression, integer_literal, "is", key_path_expression, key_path_string_expression, lambda_literal, line_string_literal, macro_invocation, metatype, multi_line_string_literal, multiplicative_expression, navigation_expression, "nil", nil_coalescing_expression, oct_literal, opaque_type, open_end_range_expression, open_start_range_expression, optional_chain_marker, optional_type, pattern, playground_literal, postfix_expression, prefix_expression, protocol_composition_type, range_expression, raw_string_literal, real_literal, referenceable_operator, regex_literal, selector_expression, self_expression, simple_identifier, special_literal, super_expression, suppressed_constraint, switch_statement, ternary_expression, try_expression, tuple_expression, tuple_type, type_annotation, type_modifiers, type_pack_expansion, type_parameter_pack, user_type, value_binding_pattern, value_pack_expansion, value_parameter_pack, where_clause, wildcard_pattern]
|
||||
name*: [array_type, dictionary_type, existential_type, function_type, metatype, opaque_type, optional_type, protocol_composition_type, suppressed_constraint, tuple_type, type_pack_expansion, type_parameter_pack, user_type]
|
||||
condition+: if_condition
|
||||
wildcard_pattern:
|
||||
willset_clause:
|
||||
$children*: [modifiers, simple_identifier, statements]
|
||||
|
||||
Reference in New Issue
Block a user