diff --git a/unified/extractor/ast_types.yml b/unified/extractor/ast_types.yml index dd17a9d584bf..68a5647e0f05 100644 --- a/unified/extractor/ast_types.yml +++ b/unified/extractor/ast_types.yml @@ -1,6 +1,8 @@ supertypes: expr: - - name_expr + - name_node + - named_pattern + - expr_pattern - int_literal - float_literal - boolean_literal @@ -33,25 +35,16 @@ supertypes: - switch_expr - unresolved_operator_sequence - unsupported_node - - pattern - expr_or_type: - - expr - - type_expr + - or_pattern + - conditional_pattern + - bulk_importing_pattern + - generic_type_expr + - inferred_type_expr # An element of an `unresolved_operator_sequence`: either an operand (`expr`) # or one of the infix operators separating the operands. expr_or_operator: - expr - infix_operator - pattern: - - name_pattern - - tuple_pattern - - constructor_pattern - - or_pattern - - conditional_pattern - - ignore_pattern - - expr_equality_pattern - - bulk_importing_pattern - - unsupported_node # A statement is anything that can appear in a block. # This type contains all of 'expr' and has partial overlap with 'member'. # For example, type_alias_declaration can appear either as a stmt or member. @@ -91,13 +84,6 @@ supertypes: - type_alias_declaration - associated_type_declaration - unsupported_node - type_expr: - - named_type_expr - - generic_type_expr - - tuple_type_expr - - function_type_expr - - inferred_type_expr - - unsupported_node type_constraint: - equality_type_constraint - bound_type_constraint @@ -111,9 +97,16 @@ named: top_level: body: block - # An identifier used in the context of an expression - name_expr: - identifier: identifier + # A name pattern that applies a nested pattern. Used for scoped imports. + named_pattern: + modifier*: modifier + name_node: name_node + sub_pattern: expr + + # A pattern expression with modifiers, such as `let x` or `var x`. + expr_pattern: + modifier*: modifier + expr: expr # An integer literal int_literal: @@ -175,28 +168,23 @@ named: # # Method calls are represented as a call whose `function` is a `member_access_expr`. # - # Constructor calls are marked by a language-specific modifier, and the target may be - # a `type_expr` if the parser can deduce that the target is a type. + # Constructor calls are marked by a language-specific modifier. call_expr: modifier*: modifier - callee: expr_or_type + callee: expr argument*: argument argument: modifier*: modifier - name?: identifier + name_node?: name_node value: expr # Member access, such as `obj.member`. # - # The base may be a type expression when it is a static member access like `Array.method`. - # In ambiguous cases where the parser cannot distinguish static and instance member access, the base - # will be typically be an expression. - # # For `super.x` the base will be an instance of `super_expr`. member_access_expr: - base: expr_or_type - member: identifier + base: expr + member_name_node: name_node # A type expression that refers to a type inferred from the contextual type. # This is used to translate Swift's leading-dot syntax, `.foo`, which means `T.foo` where @@ -211,8 +199,8 @@ named: modifier*: modifier capture_declaration*: variable_declaration parameter*: parameter - return_type?: type_expr - body: block + return_type?: expr + body?: block array_literal: element*: expr @@ -228,26 +216,25 @@ named: key: expr value: expr - # A tuple expression, such as `(a, b, c)`. + # A tuple expression, pattern, or type, such as `(a, b, c)`. tuple_expr: - element*: expr + element*: argument # A parameter. # # `type` is its declared type annotation (if any) # # `pattern` binds the parameter's internal name(s). For a simple parameter this is a - # `name_pattern`, but may be an arbitrary pattern for languages where patterns may appear - # in the parameter list. + # `named_pattern`, but may be an arbitrary expression where languages allow destructuring. # # `external_name` is the name by which to call sites refer to the parameter, if the parameter # can be passed as a named parameter. For example, the Swift function `func greet(person id: String)` - # would have `person` as the external name and a `name_pattern` wrapping `id` is the parameter's pattern. + # would have `person` as the external name and a `named_pattern` wrapping `id` as the parameter's pattern. parameter: modifier*: modifier - external_name?: identifier - type?: type_expr - pattern?: pattern + external_name_node?: name_node + type?: expr + pattern?: expr default?: expr # An expression that does nothing. Used where the grammar permits an @@ -279,8 +266,8 @@ named: # `chained_declaration` modifier so the grouping can be recovered downstream. variable_declaration: modifier*: modifier - pattern: pattern - type?: type_expr + pattern: expr + type?: expr value?: expr # Evaluate 'condition', and if false, execute 'else' which must break from the enclosing block scope (return, break, etc). @@ -292,17 +279,17 @@ named: # `break` (with optional label) break_expr: - label?: identifier + label_name_node?: name_node # `continue` (with optional label) continue_expr: - label?: identifier + label_name_node?: name_node # A labeled statement, such as `outer: for ... { ... }`. The labeled # statement appears as the `stmt` field; `break`/`continue` may target # the label. labeled_stmt: - label: identifier + label_name_node: name_node stmt: stmt # `return value` or bare `return` @@ -322,31 +309,31 @@ named: # import_declaration: modifier*: modifier - imported_expr: expr # Qualified names are encoded as a chain of member_access_expr ending with a name_expr - pattern?: pattern # Binds local names in scope (possibly via bulk_importing_pattern) + imported_expr: expr # Qualified names are encoded as a chain of member_access_expr ending with a name_node + pattern?: expr # Binds local names in scope (possibly via bulk_importing_pattern) # `typealias Name = Type` type_alias_declaration: modifier*: modifier - name: identifier + name_node: name_node type_parameter*: type_parameter type_constraint*: type_constraint - type: type_expr + type: expr # A top-level function declaration. function_declaration: modifier*: modifier - name: identifier + name_node: name_node type_parameter*: type_parameter type_constraint*: type_constraint parameter*: parameter - return_type?: type_expr + return_type?: expr body?: block # `for pattern in iterable [where guard] { body }`. for_each_stmt: modifier*: modifier - pattern: pattern + pattern: expr iterable: expr guard?: expr body?: block @@ -372,7 +359,7 @@ named: catch_clause: modifier*: modifier - pattern?: pattern + pattern?: expr body: block # `switch value { case pattern: body case ...: default: body }` @@ -386,7 +373,7 @@ named: # A `default:` entry has no pattern. switch_case: modifier*: modifier - pattern?: pattern + pattern?: expr body: block # Evaluate 'expr' and match its result against 'pattern', and return true if it matches. @@ -396,7 +383,7 @@ named: # # Java: 'if (x instanceof Foo y && w ...) { ... }' pattern_guard_expr: - pattern: pattern + pattern: expr value: expr # A type cast expression, such as `x as T`, `x as? T`, or `x as! T`. The @@ -404,49 +391,19 @@ named: type_cast_expr: expr: expr operator: infix_operator - type: type_expr + type: expr # A type-test expression, such as `x is T`. Yields a boolean indicating # whether `expr` is an instance of `type`. type_test_expr: expr: expr - operator: infix_operator - type: type_expr - - # An identifier that introduces a variable. - # - # When used as a pattern, the pattern matches anything and binds its incoming value to the variable - name_pattern: - modifier*: modifier - identifier: identifier - sub_pattern?: pattern - - # A pattern matching anything, binding no variables, usually using the syntax "_" - ignore_pattern: - - # A pattern that matches if the incoming value is equal to the value of the given expression. - # Used for literal patterns in switch (e.g. `case 1:`). - expr_equality_pattern: - expr: expr - - # A tuple pattern such as `(a, b)` in `let (a, b) = pair`. - # - # Elements of the tuple pattern can have names, such as Swift's `let (foo: x, bar: y) = tuple`. - tuple_pattern: - modifier*: modifier - element*: pattern_element - - # A pattern such as `Some(x)` where `Some` is the constructor and `x` is an element. - # The element names are interpreted as argument labels and/or field names. - constructor_pattern: - modifier*: modifier - constructor: expr_or_type - element*: pattern_element + operator?: infix_operator + type: expr # A disjunction pattern that matches if any of its sub-patterns match. or_pattern: modifier*: modifier - pattern*: pattern + pattern*: expr # A pattern that matches against a nested pattern, and subsequently checks a condition. # The match is rejected if the condition does not hold. @@ -454,30 +411,15 @@ named: conditional_pattern: modifier*: modifier condition: expr - pattern: pattern - - # A pattern with an optional associated name. - pattern_element: - modifier*: modifier - key?: identifier - pattern: pattern - - # A pattern that checks if the incoming value has the given type, and if so, the - # value is matched against the given nested pattern (and succeeds iff the nested match succeeds). - # - # In Swift: `if let y = x as? Foo` is a pattern_guard_expr containing a type_test_pattern - # In Java: `x instanceof Foo y` is a type_test_pattern wrapping a name_pattern - type_test_pattern: - pattern: pattern - type: type_expr + pattern: expr # A '*' pattern that imports all members of the incoming value into the local scope # Currently this can only appear in import declarations. bulk_importing_pattern: modifier*: modifier - # An simple unqualified identifier token - identifier: + # A simple unqualified name token + name_node: # A node that we don't yet translate unsupported_node: @@ -494,27 +436,27 @@ named: type_parameter: modifier*: modifier - name: identifier - bound?: type_expr + name_node: name_node + bound?: expr # A generic constraint of the form `T == U`, requiring two types to be # equal. Appears in `where` clauses on generic declarations # (e.g. Swift `func foo() where T == U`). equality_type_constraint: - left: type_expr - right: type_expr + left: expr + right: expr # A generic constraint of the form `T: Bound`, requiring a type parameter # to conform to (or inherit from) some other type. Appears in `where` # clauses on generic declarations (e.g. Swift `where T: Equatable`). bound_type_constraint: - type: type_expr - bound: type_expr + type: expr + bound: expr # `infix operator +++` (and the like) — a declaration of a custom operator. operator_syntax_declaration: modifier*: modifier - name: identifier + name_node: name_node # The fixity specifier (`prefix`, `infix`, `postfix`), when applicable. fixity?: fixity # The declared precedence level, when present (e.g. Swift's @@ -529,7 +471,7 @@ named: # no `name`; the extended type appears as a `base_type`. class_like_declaration: modifier*: modifier - name?: identifier + name_node?: name_node type_parameter*: type_parameter type_constraint*: type_constraint base_type*: base_type @@ -541,11 +483,11 @@ named: # kind should be included as a modifier on this node. base_type: modifier*: modifier - type: type_expr + type: expr constructor_declaration: modifier*: modifier - name?: identifier + name_node?: name_node parameter*: parameter body: block @@ -565,10 +507,10 @@ named: # (each observer also tagged with `chained_declaration`). accessor_declaration: modifier*: modifier - name: identifier + name_node: name_node accessor_kind: accessor_kind parameter*: parameter - type?: type_expr + type?: expr body?: block # "get", "set", or a language-specific kind like "didSet" @@ -581,30 +523,12 @@ named: associated_type_declaration: modifier*: modifier - name: identifier - bound?: type_expr - - named_type_expr: - qualifier?: type_expr - name: identifier + name_node: name_node + bound?: expr generic_type_expr: - base: type_expr - type_argument*: type_expr - - # A tuple type such as `(Int, String)` or `(a: A, b: B)`. - tuple_type_expr: - element*: tuple_type_element - - # An element of a `tuple_type_expr`, optionally carrying a label. - tuple_type_element: - name?: identifier - type: type_expr - - # A function type such as `(Int, String) -> Bool` or `(x: Int) -> Bool`. - function_type_expr: - parameter*: parameter - return_type: type_expr + base: expr + type_argument*: expr # A modifier such as 'static', 'public', or 'async'. For now this is just a leaf node with a string value. modifier: diff --git a/unified/extractor/src/languages/swift/swift.rs b/unified/extractor/src/languages/swift/swift.rs index 6396d4addd75..ae51a06d0750 100644 --- a/unified/extractor/src/languages/swift/swift.rs +++ b/unified/extractor/src/languages/swift/swift.rs @@ -8,10 +8,10 @@ use yeast::{ConcreteDesugarer, DesugaringConfig, PhaseKind, Rule, rule, tree}; /// post-hoc mutation. #[derive(Clone, Default)] struct SwiftContext { - /// Identifier node for the property name. Set by the accessor-bearing + /// Name node for the property name. Set by the accessor-bearing /// `variableDecl` rule before translating the accessor block; read by the /// inner `accessorDecl` rules to name each `accessor_declaration`. - property_name: Option, + property_name_node: Option, /// Translated type node for the property type. Set (for computed /// properties) by the accessor-bearing `variableDecl` rule; read by the /// inner `accessorDecl` rules. Left `None` for stored properties with @@ -30,16 +30,13 @@ struct SwiftContext { /// True while translating the parameters of a `functionType`. swift-syntax /// models a function type's parameters with the same `tupleTypeElement` /// kind as a tuple type's elements, so the shared `tupleTypeElement` rule - /// reads this to emit a `parameter` (function-type param) rather than a - /// `tuple_type_element` (tuple-type element). The `tupleType` / - /// `functionType` rules each set it for their direct children, so nested - /// types are translated in the correct context. + /// reads this to emit a `parameter` (function-type parameter) rather than + /// an `argument` (tuple element). The `tupleType` / `functionType` rules + /// each set it for their direct children, so nested types are translated + /// in the correct context. in_function_type: bool, - /// True while translating the argument list of an enum-case - /// `constructor_pattern` (e.g. `case .foo(let x, 3)`). Read by the - /// `labeledExpr` rules so a bare expression argument becomes an - /// `expr_equality_pattern` (wrapped in a `pattern_element`) rather than a - /// call `argument`. + /// True while translating a pattern. Optional chaining in this context is + /// represented as an `Optional.some` call rather than being unwrapped. in_pattern: bool, } @@ -108,7 +105,7 @@ fn make_or_pattern( } /// Translate a multi-part identifier (for example `Foo.Bar.Baz`) into a -/// `member_access_expr` chain rooted at a `name_expr` over the first +/// `member_access_expr` chain rooted at a `name_node` for the first /// part. Panics on an empty input because the grammar's `_+` quantifier /// guarantees at least one part. fn member_chain( @@ -119,10 +116,10 @@ fn member_chain( let first = iter .next() .expect("identifier with `part:` must have at least one part"); - let init = tree!((name_expr identifier: (identifier #{first}))); + let init = tree!((name_node #{first})); iter.fold( init, - |acc, elem| tree!((member_access_expr base: {acc} member: (identifier #{elem}))), + |acc, elem| tree!((member_access_expr base: {acc} member_name_node: (name_node #{elem}))), ) } @@ -159,28 +156,22 @@ fn translation_rules() -> Vec> { // (hex/binary/octal, single- vs multi-line, raw): each is a single // `*LiteralExpr` kind, so one rule per literal type suffices. rule!((integerLiteralExpr) @@node => expr { - let value = tree!((int_literal #{node})); - if ctx.in_pattern { tree!((expr_equality_pattern expr: {value})) } else { value } + tree!((int_literal #{node})) }), rule!((floatLiteralExpr) @@node => expr { - let value = tree!((float_literal #{node})); - if ctx.in_pattern { tree!((expr_equality_pattern expr: {value})) } else { value } + tree!((float_literal #{node})) }), rule!((booleanLiteralExpr) @@node => expr { - let value = tree!((boolean_literal #{node})); - if ctx.in_pattern { tree!((expr_equality_pattern expr: {value})) } else { value } + tree!((boolean_literal #{node})) }), rule!((nilLiteralExpr) @@node => expr { - let value = tree!((builtin_expr #{node})); - if ctx.in_pattern { tree!((expr_equality_pattern expr: {value})) } else { value } + tree!((builtin_expr #{node})) }), rule!((stringLiteralExpr) @@node => expr { - let value = tree!((string_literal #{node})); - if ctx.in_pattern { tree!((expr_equality_pattern expr: {value})) } else { value } + tree!((string_literal #{node})) }), rule!((regexLiteralExpr) @@node => expr { - let value = tree!((regex_literal #{node})); - if ctx.in_pattern { tree!((expr_equality_pattern expr: {value})) } else { value } + tree!((regex_literal #{node})) }), // ---- Names ---- // A function reference spelled with argument labels (`f(x:y:z:)`) is a @@ -195,22 +186,16 @@ fn translation_rules() -> Vec> { (unsupported_node) ), rule!((declReferenceExpr baseName: (identifier) @name) => expr { - let name = tree!((name_expr identifier: (identifier #{name}))); - if ctx.in_pattern { - tree!((expr_equality_pattern expr: {name})) - } else { - name - } + tree!((name_node #{name})) }), // A bare name reference (`x`), and an operator used as a value (`+` in // `reduce(0, +)`), are both `declReferenceExpr`; its `baseName` is the // referenced identifier / operator symbol. - rule!((declReferenceExpr baseName: @name) => (name_expr identifier: (identifier #{name}))), + rule!((declReferenceExpr baseName: @name) => (name_node #{name})), // A discard `_` used as an expression — e.g. the target of a discarding // assignment `_ = x`. swift-syntax models it as a `discardAssignmentExpr`; - // the target AST has no expression-level discard (only `ignore_pattern`, - // which is a pattern), so it becomes a `name_expr` over the `_` token. - rule!((discardAssignmentExpr wildcard: @@w) => (name_expr identifier: (identifier #{w}))), + // the target AST represents it as a `name_node` over the `_` token. + rule!((discardAssignmentExpr wildcard: @@w) => (name_node #{w})), // A generic specialization in expression position (`C`, // `Array`) is represented by swift-syntax as a // `genericSpecializationExpr`. When used as a call target @@ -222,7 +207,7 @@ fn translation_rules() -> Vec> { genericArgumentClause: (genericArgumentClause arguments: (genericArgument argument: @args)*)) => (generic_type_expr - base: (named_type_expr name: (identifier #{name})) + base: (name_node #{name}) type_argument: {args}) ), // ---- Operators ---- @@ -314,7 +299,7 @@ fn translation_rules() -> Vec> { => (accessor_declaration modifier: (modifier #{spec}) - name: (identifier #{name}) + name_node: (name_node #{name}) type: {ty} accessor_kind: (accessor_kind "get") body: (block stmt: {body})) @@ -345,7 +330,7 @@ fn translation_rules() -> Vec> { => member* { ctx.outer_modifiers = vec![tree!((modifier #{spec}))]; - ctx.property_name = Some(tree!((identifier #{name}))); + ctx.property_name_node = Some(tree!((name_node #{name}))); let mut result = Vec::new(); if let Some(val) = val { // Stored property with observers: the initializer is not part @@ -357,7 +342,7 @@ fn translation_rules() -> Vec> { result.push(tree!( (variable_declaration modifier: {ctx.outer_modifiers.clone()} - pattern: (name_pattern identifier: (identifier #{name})) + pattern: (name_node #{name}) type: {ty} value: {val}) )); @@ -392,7 +377,7 @@ fn translation_rules() -> Vec> { }; let chained = chained_modifier(&mut ctx); let name = ctx - .property_name + .property_name_node .ok_or("accessor outside property context")?; let ty = ctx.property_type; let body = match body { @@ -465,7 +450,7 @@ fn translation_rules() -> Vec> { rule!( (enumCaseParameter firstName: _? @@name type: @ty) => - (parameter pattern: (name_pattern identifier: (identifier #{name}))? type: {ty}) + (parameter pattern: (name_node #{name})? type: {ty}) ), // An enum element with associated values (`case circle(radius: Double)`) // becomes a nested `class_like_declaration` whose constructor carries the @@ -481,7 +466,7 @@ fn translation_rules() -> Vec> { modifier: {ctx.outer_modifiers.clone()} modifier: {chained_modifier(&mut ctx)} modifier: (modifier "enum_case") - name: (identifier #{name}) + name_node: (name_node #{name}) member: (constructor_declaration parameter: {params} body: (block))) ), rule!( @@ -491,7 +476,7 @@ fn translation_rules() -> Vec> { modifier: {ctx.outer_modifiers.clone()} modifier: {chained_modifier(&mut ctx)} modifier: (modifier "enum_case") - pattern: (name_pattern identifier: (identifier #{name})) + pattern: (name_node #{name}) value: {val}) ), rule!( @@ -501,7 +486,7 @@ fn translation_rules() -> Vec> { modifier: {ctx.outer_modifiers.clone()} modifier: {chained_modifier(&mut ctx)} modifier: (modifier "enum_case") - pattern: (name_pattern identifier: (identifier #{name}))) + pattern: (name_node #{name})) ), // Enum cases. A single `case` declaration may carry modifiers // (e.g. `indirect`) and list several comma-separated elements; each @@ -527,20 +512,23 @@ fn translation_rules() -> Vec> { rule!( (identifierPattern identifier: @name) => - (name_pattern identifier: (identifier #{name})) + (name_node #{name}) ), // A `let`/`var` value-binding pattern (`let x`) inside a case or `if case` - // introduces a new binding; it unwraps to its inner pattern (a - // `name_pattern`). - rule!((valueBindingPattern pattern: @p) => pattern { p }), + // preserves the binding specifier around its inner pattern. + rule!( + (valueBindingPattern bindingSpecifier: @@spec pattern: @p) + => + (expr_pattern modifier: (modifier #{spec}) expr: {p}) + ), // A tuple destructuring pattern (`let (a, b) = …`). A labelled element - // (`let (x: a) = …`) carries its label through as the `pattern_element` - // key; unlabelled elements have no key. - rule!((tuplePattern elements: _* @els) => (tuple_pattern element: {els})), + // (`let (x: a) = …`) carries its label through as the `argument` name; + // unlabelled elements have no name. + rule!((tuplePattern elements: _* @els) => (tuple_expr element: {els})), rule!( (tuplePatternElement label: _? @@label pattern: @p) => - (pattern_element key: (identifier #{label})? pattern: {p}) + (argument name_node: (name_node #{label})? value: {p}) ), // A type-casting pattern (`case is T`). Not yet supported, so it is // mapped to `unsupported_node` — an explicit reminder that this needs @@ -550,7 +538,7 @@ fn translation_rules() -> Vec> { // A wildcard *binding* pattern (`let _ = x`, `for _ in xs`). swift-syntax // models this as a `wildcardPattern`, distinct from the `_` match form // handled by the context-aware `discardAssignmentExpr` rule. - rule!((wildcardPattern) => (ignore_pattern)), + rule!((wildcardPattern) @@wildcard => (name_node #{wildcard})), // An expression pattern only establishes pattern context; its child // determines the concrete pattern shape. rule!((expressionPattern expression: @@e) => expr { @@ -572,7 +560,7 @@ fn translation_rules() -> Vec> { body: (codeBlock statements: _* @body)) => (function_declaration - name: (identifier #{name}) + name_node: (name_node #{name}) type_parameter: {type_params} parameter: {params} return_type: {ret} @@ -587,7 +575,7 @@ fn translation_rules() -> Vec> { returnClause: (returnClause type: @ret)?)) => (function_declaration - name: (identifier #{name}) + name_node: (name_node #{name}) type_parameter: {type_params} parameter: {params} return_type: {ret} @@ -606,12 +594,12 @@ fn translation_rules() -> Vec> { => parameter { let (external, name) = match second { - Some(second) => (Some(tree!((identifier #{first}))), second), + Some(second) => (Some(tree!((name_node #{first}))), second), None => (None, first), }; tree!((parameter - external_name: {external} - pattern: (name_pattern identifier: (identifier #{name})) + external_name_node: {external} + pattern: (name_node #{name}) type: {ty} default: {val})) } @@ -629,7 +617,7 @@ fn translation_rules() -> Vec> { => (call_expr callee: (generic_type_expr - base: (named_type_expr name: (identifier "Array")) + base: (name_node "Array") type_argument: {element}) argument: {args} argument: (argument value: {tc})) @@ -641,7 +629,7 @@ fn translation_rules() -> Vec> { => (call_expr callee: (generic_type_expr - base: (named_type_expr name: (identifier "Array")) + base: (name_node "Array") type_argument: {element}) argument: {args}) ), @@ -663,20 +651,11 @@ fn translation_rules() -> Vec> { ctx.in_pattern = false; ctx.translate(rawCallee) })?; - if ctx.in_pattern { - tree!((constructor_pattern constructor: {callee} element: {args})) - } else { - tree!((call_expr callee: {callee} argument: {args})) - } + tree!((call_expr callee: {callee} argument: {args})) } ), - // A call argument or an enum-case pattern argument. When translating an - // enum-case `constructor_pattern`'s arguments (`ctx.in_pattern`), a - // `patternExpr` argument (`let x`) becomes a bound `name_pattern`, a - // wildcard (`_`) becomes an `ignore_pattern`, and any other expression - // becomes an `expr_equality_pattern`; each is wrapped in a - // `pattern_element` carrying the optional argument label as its `key`. - // Otherwise the argument keeps its label as the `name` and its value. + // A call or enum-case pattern argument. Both use the shared `argument` + // shape, preserving the optional label as `name` and the child as `value`. // The pattern-only shapes (`patternExpr`, `discardAssignmentExpr`) are // matched first; they never occur as ordinary call arguments. rule!( @@ -687,40 +666,26 @@ fn translation_rules() -> Vec> { arguments: _* @elements)) => argument { - if ctx.in_pattern { - tree!((pattern_element - key: (identifier #{lbl})? - pattern: (constructor_pattern - constructor: {constructor} - element: {elements}))) - } else { - tree!((argument - name: (identifier #{lbl})? - value: (call_expr callee: {constructor} argument: {elements}))) - } + tree!((argument + name_node: (name_node #{lbl})? + value: (call_expr callee: {constructor} argument: {elements}))) } ), rule!( (labeledExpr label: _? @@lbl expression: (patternExpr pattern: @p)) => - (pattern_element key: (identifier #{lbl})? pattern: {p}) + (argument name_node: (name_node #{lbl})? value: {p}) ), rule!( (labeledExpr label: _? @@lbl expression: (discardAssignmentExpr) @@wildcard) => - (pattern_element key: (identifier #{lbl})? pattern: (ignore_pattern #{wildcard})) + (argument name_node: (name_node #{lbl})? value: (name_node #{wildcard})) ), rule!( (labeledExpr label: _? @@lbl expression: @val) => argument { - if ctx.in_pattern { - tree!((pattern_element - key: (identifier #{lbl})? - pattern: {val})) - } else { - tree!((argument name: (identifier #{lbl})? value: {val})) - } + tree!((argument name_node: (name_node #{lbl})? value: {val})) } ), // Member access (`list.append`). The `declName` is itself a @@ -737,26 +702,26 @@ fn translation_rules() -> Vec> { => (member_access_expr base: (generic_type_expr - base: (named_type_expr name: (identifier "Array")) + base: (name_node "Array") type_argument: {element}) - member: (identifier #{member})) + member_name_node: (name_node #{member})) ), rule!( (memberAccessExpr base: @base declName: (declReferenceExpr baseName: @member)) => - (member_access_expr base: {base} member: (identifier #{member})) + (member_access_expr base: {base} member_name_node: (name_node #{member})) ), rule!( (memberAccessExpr period: @dot declName: (declReferenceExpr baseName: @member)) => - (member_access_expr base: (inferred_type_expr #{dot}) member: (identifier #{member})) + (member_access_expr base: (inferred_type_expr #{dot}) member_name_node: (name_node #{member})) ), // Control transfer, one rule per keyword. `return` carries an optional // value; `break` / `continue` an optional target label; `throw` its // thrown expression. rule!((returnStmt expression: _? @val) => (return_expr value: {val})), - rule!((breakStmt label: _? @@lbl) => (break_expr label: (identifier #{lbl})?)), - rule!((continueStmt label: _? @@lbl) => (continue_expr label: (identifier #{lbl})?)), + rule!((breakStmt label: _? @@lbl) => (break_expr label_name_node: (name_node #{lbl})?)), + rule!((continueStmt label: _? @@lbl) => (continue_expr label_name_node: (name_node #{lbl})?)), rule!((throwStmt expression: @val) => (throw_expr value: {val})), // ---- Closures ---- // A closure (`{ (x: Int) -> Int in … }`) becomes a `function_expr`. The @@ -783,7 +748,7 @@ fn translation_rules() -> Vec> { ), // A closure capture (`[weak self]`, `[x]`, `[y = expr]`). The optional // ownership specifier (`weak`/`unowned`) becomes a modifier; the - // captured name becomes the bound `name_pattern`; an explicit capture + // captured name becomes the bound `name_node`; an explicit capture // initializer (`[y = expr]`) becomes the bound value. rule!( (closureCapture @@ -793,7 +758,7 @@ fn translation_rules() -> Vec> { => (variable_declaration modifier: (modifier #{spec})? - pattern: (name_pattern identifier: (identifier #{name})) + pattern: (name_node #{name}) value: {val}) ), // A closure parameter clause (`(x: Int, y)`) unwraps to its parameters. @@ -803,14 +768,14 @@ fn translation_rules() -> Vec> { rule!( (closureParameter firstName: @name type: _? @ty) => - (parameter pattern: (name_pattern identifier: (identifier #{name})) type: {ty}) + (parameter pattern: (name_node #{name}) type: {ty}) ), // A shorthand closure parameter (`x` in `{ x, y in … }`): a bare name // with no parentheses and no type. rule!( (closureShorthandParameter name: @name) => - (parameter pattern: (name_pattern identifier: (identifier #{name}))) + (parameter pattern: (name_node #{name})) ), // ---- Control flow ---- // An `if`/`else` expression. Conditions are joined via `and_chain`; the @@ -881,18 +846,22 @@ fn translation_rules() -> Vec> { => (pattern_guard_expr value: {val} - pattern: (constructor_pattern - constructor: (member_access_expr base: (named_type_expr name: (identifier "Optional")) member: (identifier "some")) - element: (pattern_element pattern: (name_pattern identifier: (identifier #{name}))))) + pattern: (call_expr + callee: (member_access_expr base: (name_node "Optional") member_name_node: (name_node "some")) + argument: (argument value: (expr_pattern + modifier: (modifier "let") + expr: (name_node #{name}))))) ), rule!( (optionalBindingCondition pattern: (identifierPattern identifier: @name)) => (pattern_guard_expr - value: (name_expr identifier: (identifier #{name})) - pattern: (constructor_pattern - constructor: (member_access_expr base: (named_type_expr name: (identifier "Optional")) member: (identifier "some")) - element: (pattern_element pattern: (name_pattern identifier: (identifier #{name}))))) + value: (name_node #{name}) + pattern: (call_expr + callee: (member_access_expr base: (name_node "Optional") member_name_node: (name_node "some")) + argument: (argument value: (expr_pattern + modifier: (modifier "let") + expr: (name_node #{name}))))) ), // A single condition in an `if`/`while`/`guard` condition list unwraps to // its inner expression; `and_chain` joins multiple with `&&`. @@ -936,7 +905,7 @@ fn translation_rules() -> Vec> { rule!( (labeledStmt label: @@lbl statement: @stmt) => - (labeled_stmt label: (identifier #{lbl}) stmt: {stmt}) + (labeled_stmt label_name_node: (name_node #{lbl}) stmt: {stmt}) ), // ---- Collections ---- // An array literal (`[1, 2, 3]`). Each `arrayElement` unwraps to its @@ -964,11 +933,11 @@ fn translation_rules() -> Vec> { rule!((optionalChainingExpr expression: @@inner) => expr { let inner = ctx.translate(inner)?.into_iter().next().ok_or("optional chaining expression has no child")?; if ctx.in_pattern { - tree!((constructor_pattern - constructor: (member_access_expr - base: (named_type_expr name: (identifier "Optional")) - member: (identifier "some")) - element: (pattern_element pattern: {inner}))) + tree!((call_expr + callee: (member_access_expr + base: (name_node "Optional") + member_name_node: (name_node "some")) + argument: (argument value: {inner}))) } else { inner } @@ -1026,10 +995,10 @@ fn translation_rules() -> Vec> { rule!((forceUnwrapExpr expression: @e) => (unary_expr operator: (postfix_operator "!") operand: {e})), // ---- Imports ---- // An import declaration. The dotted path (a list of - // `importPathComponent`s) becomes a `name_expr`/`member_access_expr` + // `importPathComponent`s) becomes a `name_node`/`member_access_expr` // chain (via `member_chain`). A scoped import (`import struct Foo.Bar`) // has an `importKindSpecifier` and binds the last path component as a - // `name_pattern`; a plain import (`import Foundation`) has none and uses + // raw name node; a plain import (`import Foundation`) has none and uses // a `bulk_importing_pattern` spanning the whole declaration. Any leading // attributes (`@_exported`) and access modifiers (`public`) become // `modifier`s. @@ -1041,12 +1010,13 @@ fn translation_rules() -> Vec> { path: (importPathComponent name: @@parts)*) => import_declaration { - let bulk_import = match kind { - None => Some(tree!((bulk_importing_pattern))), - Some(_) => None, // scoped import, no bulk import - }; let last = *parts.last().ok_or("import has no path")?; - let pattern = tree!((name_pattern identifier: (identifier #{last}) sub_pattern: {bulk_import})); + let pattern = match kind { + None => tree!((named_pattern + name_node: (name_node #{last}) + sub_pattern: (bulk_importing_pattern))), + Some(_) => tree!((name_node #{last})), + }; tree!((import_declaration modifier: (modifier #{kind})? modifier: {attrs} @@ -1075,75 +1045,75 @@ fn translation_rules() -> Vec> { genericArgumentClause: (genericArgumentClause arguments: (genericArgument argument: @args)*)) => (generic_type_expr - base: (named_type_expr name: (identifier #{name})) + base: (name_node #{name}) type_argument: {args}) ), // A named type (`Int`). `identifierType.name` is the type-name token. - rule!((identifierType name: @@n) => (named_type_expr name: (identifier #{n}))), + rule!((identifierType name: @@n) => (name_node #{n})), // A qualified type (`Outer.Inner`, `NSString.CompareOptions`). swift-syntax - // nests these as `memberType` nodes; preserve the nesting in the - // named_type_expr qualifier field. + // nests these as `memberType` nodes; preserve the nesting as ordinary + // member access. rule!( (memberType baseType: @base name: @@name) => - (named_type_expr qualifier: {base} name: (identifier #{name})) + (member_access_expr base: {base} member_name_node: (name_node #{name})) ), // Sugared types desugar to `generic_type_expr`: `T?` -> Optional, // `[T]` -> Array, `[K: V]` -> Dictionary. rule!( (optionalType wrappedType: @w) => - (generic_type_expr base: (named_type_expr name: (identifier "Optional")) type_argument: {w}) + (generic_type_expr base: (name_node "Optional") type_argument: {w}) ), rule!( (arrayType element: @e) => - (generic_type_expr base: (named_type_expr name: (identifier "Array")) type_argument: {e}) + (generic_type_expr base: (name_node "Array") type_argument: {e}) ), rule!( (dictionaryType key: @k value: @v) => - (generic_type_expr base: (named_type_expr name: (identifier "Dictionary")) type_argument: {k} type_argument: {v}) + (generic_type_expr base: (name_node "Dictionary") type_argument: {k} type_argument: {v}) ), // A tuple type (`(Int, String)`) or function type (`(Int) -> Bool`). // Both hold their contents as `tupleTypeElement`s, but a tuple element - // maps to `tuple_type_element` while a function parameter maps to - // `parameter`. Each container sets `ctx.in_function_type` for its direct + // maps to `argument` while a function parameter maps to `parameter`. + // Each container sets `ctx.in_function_type` for its direct // children (and translates them explicitly, so a nested type is // translated in the right context) and the shared `tupleTypeElement` // rule below reads it. An element's label (`firstName`) is optional. rule!( (tupleType elements: _* @@elems) => - tuple_type_expr { + tuple_expr { ctx.in_function_type = false; let mut out = Vec::new(); for e in elems { out.extend(ctx.translate(e)?); } - tree!((tuple_type_expr element: {out})) + tree!((tuple_expr element: {out})) } ), rule!( (functionType parameters: _* @@params returnClause: (returnClause type: @ret)) => - function_type_expr { + function_expr { ctx.in_function_type = true; let mut out = Vec::new(); for p in params { out.extend(ctx.translate(p)?); } - tree!((function_type_expr parameter: {out} return_type: {ret})) + tree!((function_expr parameter: {out} return_type: {ret})) } ), rule!( (tupleTypeElement firstName: _? @@name type: @ty) => - tuple_type_element { + argument { if ctx.in_function_type { - tree!((parameter external_name: (identifier #{name})? type: {ty})) + tree!((parameter external_name_node: (name_node #{name})? type: {ty})) } else { - tree!((tuple_type_element name: (identifier #{name})? type: {ty})) + tree!((argument name_node: (name_node #{name})? value: {ty})) } } ), @@ -1164,7 +1134,7 @@ fn translation_rules() -> Vec> { (type_parameter modifier: {attrs} modifier: (modifier #{spec})? - name: (identifier #{name}) + name_node: (name_node #{name}) bound: {bound}) ), rule!( @@ -1195,7 +1165,7 @@ fn translation_rules() -> Vec> { (class_like_declaration modifier: (modifier #{kind}) modifier: {mods} - name: (identifier #{name}) + name_node: (name_node #{name}) type_parameter: {params} type_constraint: {parameter_constraints} type_constraint: {declaration_constraints} @@ -1218,7 +1188,7 @@ fn translation_rules() -> Vec> { (class_like_declaration modifier: (modifier #{kind}) modifier: {mods} - name: (identifier #{name}) + name_node: (name_node #{name}) type_parameter: {params} type_constraint: {parameter_constraints} type_constraint: {declaration_constraints} @@ -1241,7 +1211,7 @@ fn translation_rules() -> Vec> { (class_like_declaration modifier: (modifier #{kind}) modifier: {mods} - name: (identifier #{name}) + name_node: (name_node #{name}) type_parameter: {params} type_constraint: {parameter_constraints} type_constraint: {declaration_constraints} @@ -1262,7 +1232,7 @@ fn translation_rules() -> Vec> { (class_like_declaration modifier: (modifier #{kind}) modifier: {mods} - name: (identifier #{name}) + name_node: (name_node #{name}) type_parameter: {params} type_constraint: {declaration_constraints} base_type: {bases.into_iter().map(|ty| tree!((base_type type: {ty})))} @@ -1283,7 +1253,7 @@ fn translation_rules() -> Vec> { (class_like_declaration modifier: (modifier #{kind}) modifier: {mods} - name: (identifier #{name}) + name_node: (name_node #{name}) base_type: {bases.into_iter().map(|ty| tree!((base_type type: {ty})))} member: {members}) ), @@ -1324,7 +1294,7 @@ fn translation_rules() -> Vec> { => (type_alias_declaration modifier: {mods} - name: (identifier #{name}) + name_node: (name_node #{name}) type_parameter: {type_params} r#type: {val}) ), @@ -1337,7 +1307,7 @@ fn translation_rules() -> Vec> { => (associated_type_declaration modifier: {mods} - name: (identifier #{name}) + name_node: (name_node #{name}) bound: {bound}) ), // ---- Fallbacks ---- diff --git a/unified/extractor/tests/corpus/swift/closures/closure-with-capture-list.output b/unified/extractor/tests/corpus/swift/closures/closure-with-capture-list.output index 6833344de16d..3571f2aa0897 100644 --- a/unified/extractor/tests/corpus/swift/closures/closure-with-capture-list.output +++ b/unified/extractor/tests/corpus/swift/closures/closure-with-capture-list.output @@ -66,24 +66,18 @@ top_level stmt: variable_declaration modifier: modifier "let" - pattern: - name_pattern - identifier: identifier "f" + pattern: name_node "f" value: function_expr capture_declaration: variable_declaration modifier: modifier "weak" - pattern: - name_pattern - identifier: identifier "self" + pattern: name_node "self" body: block stmt: call_expr callee: member_access_expr - base: - name_expr - identifier: identifier "self" - member: identifier "doThing" + base: name_node "self" + member_name_node: name_node "doThing" diff --git a/unified/extractor/tests/corpus/swift/closures/closure-with-explicit-parameters.output b/unified/extractor/tests/corpus/swift/closures/closure-with-explicit-parameters.output index c20da77c72cb..f47f3d88eece 100644 --- a/unified/extractor/tests/corpus/swift/closures/closure-with-explicit-parameters.output +++ b/unified/extractor/tests/corpus/swift/closures/closure-with-explicit-parameters.output @@ -68,28 +68,18 @@ top_level stmt: variable_declaration modifier: modifier "let" - pattern: - name_pattern - identifier: identifier "f" + pattern: name_node "f" value: function_expr parameter: parameter - type: - named_type_expr - name: identifier "Int" - pattern: - name_pattern - identifier: identifier "x" - return_type: - named_type_expr - name: identifier "Int" + type: name_node "Int" + pattern: name_node "x" + return_type: name_node "Int" body: block stmt: binary_expr - left: - name_expr - identifier: identifier "x" + left: name_node "x" operator: infix_operator "*" right: int_literal "2" diff --git a/unified/extractor/tests/corpus/swift/closures/closure-with-shorthand-parameters.output b/unified/extractor/tests/corpus/swift/closures/closure-with-shorthand-parameters.output index 1b07604e02c5..6889936d2344 100644 --- a/unified/extractor/tests/corpus/swift/closures/closure-with-shorthand-parameters.output +++ b/unified/extractor/tests/corpus/swift/closures/closure-with-shorthand-parameters.output @@ -45,19 +45,13 @@ top_level stmt: variable_declaration modifier: modifier "let" - pattern: - name_pattern - identifier: identifier "f" + pattern: name_node "f" value: function_expr body: block stmt: binary_expr - left: - name_expr - identifier: identifier "$0" + left: name_node "$0" operator: infix_operator "+" - right: - name_expr - identifier: identifier "$1" + right: name_node "$1" diff --git a/unified/extractor/tests/corpus/swift/closures/multi-statement-closure.output b/unified/extractor/tests/corpus/swift/closures/multi-statement-closure.output index 4fbc1c8f71f0..9b913211967c 100644 --- a/unified/extractor/tests/corpus/swift/closures/multi-statement-closure.output +++ b/unified/extractor/tests/corpus/swift/closures/multi-statement-closure.output @@ -99,42 +99,28 @@ top_level stmt: variable_declaration modifier: modifier "let" - pattern: - name_pattern - identifier: identifier "f" + pattern: name_node "f" value: function_expr parameter: parameter - type: - named_type_expr - name: identifier "Int" - pattern: - name_pattern - identifier: identifier "x" - return_type: - named_type_expr - name: identifier "Int" + type: name_node "Int" + pattern: name_node "x" + return_type: name_node "Int" body: block stmt: variable_declaration modifier: modifier "let" - pattern: - name_pattern - identifier: identifier "y" + pattern: name_node "y" value: binary_expr - left: - name_expr - identifier: identifier "x" + left: name_node "x" operator: infix_operator "+" right: int_literal "1" return_expr value: binary_expr - left: - name_expr - identifier: identifier "y" + left: name_node "y" operator: infix_operator "*" right: int_literal "2" diff --git a/unified/extractor/tests/corpus/swift/closures/trailing-closure.output b/unified/extractor/tests/corpus/swift/closures/trailing-closure.output index 3e26ff27eb58..99197a178a94 100644 --- a/unified/extractor/tests/corpus/swift/closures/trailing-closure.output +++ b/unified/extractor/tests/corpus/swift/closures/trailing-closure.output @@ -46,10 +46,8 @@ top_level call_expr callee: member_access_expr - base: - name_expr - identifier: identifier "xs" - member: identifier "map" + base: name_node "xs" + member_name_node: name_node "map" argument: argument value: @@ -58,8 +56,6 @@ top_level block stmt: binary_expr - left: - name_expr - identifier: identifier "$0" + left: name_node "$0" operator: infix_operator "*" right: int_literal "2" diff --git a/unified/extractor/tests/corpus/swift/collections/array-literal.output b/unified/extractor/tests/corpus/swift/collections/array-literal.output index c6ea2c2094fa..799fd395744b 100644 --- a/unified/extractor/tests/corpus/swift/collections/array-literal.output +++ b/unified/extractor/tests/corpus/swift/collections/array-literal.output @@ -47,9 +47,7 @@ top_level stmt: variable_declaration modifier: modifier "let" - pattern: - name_pattern - identifier: identifier "xs" + pattern: name_node "xs" value: array_literal element: diff --git a/unified/extractor/tests/corpus/swift/collections/dictionary-literal.output b/unified/extractor/tests/corpus/swift/collections/dictionary-literal.output index edd306a69cbd..3c2d3841a3c9 100644 --- a/unified/extractor/tests/corpus/swift/collections/dictionary-literal.output +++ b/unified/extractor/tests/corpus/swift/collections/dictionary-literal.output @@ -58,7 +58,5 @@ top_level stmt: variable_declaration modifier: modifier "let" - pattern: - name_pattern - identifier: identifier "d" + pattern: name_node "d" value: map_literal "[\"a\": 1, \"b\": 2]" diff --git a/unified/extractor/tests/corpus/swift/collections/dictionary-subscript.output b/unified/extractor/tests/corpus/swift/collections/dictionary-subscript.output index e2f939e0683c..f9e71d82e406 100644 --- a/unified/extractor/tests/corpus/swift/collections/dictionary-subscript.output +++ b/unified/extractor/tests/corpus/swift/collections/dictionary-subscript.output @@ -47,14 +47,10 @@ top_level stmt: variable_declaration modifier: modifier "let" - pattern: - name_pattern - identifier: identifier "v" + pattern: name_node "v" value: call_expr - callee: - name_expr - identifier: identifier "d" + callee: name_node "d" argument: argument value: string_literal "\"key\"" diff --git a/unified/extractor/tests/corpus/swift/collections/empty-array-literal-with-type.output b/unified/extractor/tests/corpus/swift/collections/empty-array-literal-with-type.output index e9a70a43bb42..40f699240752 100644 --- a/unified/extractor/tests/corpus/swift/collections/empty-array-literal-with-type.output +++ b/unified/extractor/tests/corpus/swift/collections/empty-array-literal-with-type.output @@ -43,15 +43,9 @@ top_level stmt: variable_declaration modifier: modifier "let" - pattern: - name_pattern - identifier: identifier "xs" + pattern: name_node "xs" type: generic_type_expr - base: - named_type_expr - name: identifier "Array" - type_argument: - named_type_expr - name: identifier "Int" + base: name_node "Array" + type_argument: name_node "Int" value: array_literal "[]" diff --git a/unified/extractor/tests/corpus/swift/collections/set-literal.output b/unified/extractor/tests/corpus/swift/collections/set-literal.output index a06670231ebb..3fb68904479a 100644 --- a/unified/extractor/tests/corpus/swift/collections/set-literal.output +++ b/unified/extractor/tests/corpus/swift/collections/set-literal.output @@ -62,17 +62,11 @@ top_level stmt: variable_declaration modifier: modifier "let" - pattern: - name_pattern - identifier: identifier "s" + pattern: name_node "s" type: generic_type_expr - base: - named_type_expr - name: identifier "Set" - type_argument: - named_type_expr - name: identifier "Int" + base: name_node "Set" + type_argument: name_node "Int" value: array_literal element: diff --git a/unified/extractor/tests/corpus/swift/collections/subscript-access.output b/unified/extractor/tests/corpus/swift/collections/subscript-access.output index ec24f0c1f1df..cd7d58818231 100644 --- a/unified/extractor/tests/corpus/swift/collections/subscript-access.output +++ b/unified/extractor/tests/corpus/swift/collections/subscript-access.output @@ -44,14 +44,10 @@ top_level stmt: variable_declaration modifier: modifier "let" - pattern: - name_pattern - identifier: identifier "first" + pattern: name_node "first" value: call_expr - callee: - name_expr - identifier: identifier "xs" + callee: name_node "xs" argument: argument value: int_literal "0" diff --git a/unified/extractor/tests/corpus/swift/collections/tuple-literal.output b/unified/extractor/tests/corpus/swift/collections/tuple-literal.output index facbc2fcbb45..a977ae4b24cb 100644 --- a/unified/extractor/tests/corpus/swift/collections/tuple-literal.output +++ b/unified/extractor/tests/corpus/swift/collections/tuple-literal.output @@ -51,7 +51,5 @@ top_level stmt: variable_declaration modifier: modifier "let" - pattern: - name_pattern - identifier: identifier "t" + pattern: name_node "t" value: tuple_expr "(1, \"two\", 3.0)" diff --git a/unified/extractor/tests/corpus/swift/collections/tuple-member-access.output b/unified/extractor/tests/corpus/swift/collections/tuple-member-access.output index 6ecbd22eebe0..3c058183cf3a 100644 --- a/unified/extractor/tests/corpus/swift/collections/tuple-member-access.output +++ b/unified/extractor/tests/corpus/swift/collections/tuple-member-access.output @@ -37,12 +37,8 @@ top_level stmt: variable_declaration modifier: modifier "let" - pattern: - name_pattern - identifier: identifier "n" + pattern: name_node "n" value: member_access_expr - base: - name_expr - identifier: identifier "t" - member: identifier "0" + base: name_node "t" + member_name_node: name_node "0" diff --git a/unified/extractor/tests/corpus/swift/control-flow/binding-modifier-does-not-leak-to-sibling.output b/unified/extractor/tests/corpus/swift/control-flow/binding-modifier-does-not-leak-to-sibling.output index 800647eb7474..347b00c23eef 100644 --- a/unified/extractor/tests/corpus/swift/control-flow/binding-modifier-does-not-leak-to-sibling.output +++ b/unified/extractor/tests/corpus/swift/control-flow/binding-modifier-does-not-leak-to-sibling.output @@ -90,28 +90,18 @@ top_level stmt: variable_declaration modifier: modifier "let" - pattern: - name_pattern - identifier: identifier "x" + pattern: name_node "x" value: int_literal "1" switch_expr - value: - name_expr - identifier: identifier "y" + value: name_node "y" case: switch_case - pattern: - expr_equality_pattern - expr: - name_expr - identifier: identifier "someConstant" + pattern: name_node "someConstant" body: block stmt: call_expr - callee: - name_expr - identifier: identifier "print" + callee: name_node "print" argument: argument value: string_literal "\"matched\"" diff --git a/unified/extractor/tests/corpus/swift/control-flow/defer-statement.output b/unified/extractor/tests/corpus/swift/control-flow/defer-statement.output index 6e8ec9ae3b9a..fab8dfbd8630 100644 --- a/unified/extractor/tests/corpus/swift/control-flow/defer-statement.output +++ b/unified/extractor/tests/corpus/swift/control-flow/defer-statement.output @@ -80,15 +80,13 @@ top_level block stmt: function_declaration - name: identifier "withCleanup" + name_node: name_node "withCleanup" body: block stmt: unsupported_node "defer { print(\"cleanup\") }" call_expr - callee: - name_expr - identifier: identifier "print" + callee: name_node "print" argument: argument value: string_literal "\"work\"" diff --git a/unified/extractor/tests/corpus/swift/control-flow/discard-statement.output b/unified/extractor/tests/corpus/swift/control-flow/discard-statement.output index 7e0eac29c0fc..cfaab7d0026a 100644 --- a/unified/extractor/tests/corpus/swift/control-flow/discard-statement.output +++ b/unified/extractor/tests/corpus/swift/control-flow/discard-statement.output @@ -69,13 +69,13 @@ top_level stmt: class_like_declaration modifier: modifier "struct" - name: identifier "Resource" + name_node: name_node "Resource" base_type: base_type type: unsupported_node "~Copyable" member: function_declaration - name: identifier "close" + name_node: name_node "close" body: block stmt: unsupported_node "discard self" diff --git a/unified/extractor/tests/corpus/swift/control-flow/fallthrough.output b/unified/extractor/tests/corpus/swift/control-flow/fallthrough.output index 9cfe81048402..f3c2463372af 100644 --- a/unified/extractor/tests/corpus/swift/control-flow/fallthrough.output +++ b/unified/extractor/tests/corpus/swift/control-flow/fallthrough.output @@ -87,28 +87,20 @@ top_level block stmt: function_declaration - name: identifier "classify" + name_node: name_node "classify" parameter: parameter - external_name: identifier "_" - type: - named_type_expr - name: identifier "Int" - pattern: - name_pattern - identifier: identifier "x" + external_name_node: name_node "_" + type: name_node "Int" + pattern: name_node "x" body: block stmt: switch_expr - value: - name_expr - identifier: identifier "x" + value: name_node "x" case: switch_case - pattern: - expr_equality_pattern - expr: int_literal "1" + pattern: int_literal "1" body: block stmt: unsupported_node "fallthrough" diff --git a/unified/extractor/tests/corpus/swift/control-flow/guard-let.output b/unified/extractor/tests/corpus/swift/control-flow/guard-let.output index d739eca564b5..baf6b0232ca6 100644 --- a/unified/extractor/tests/corpus/swift/control-flow/guard-let.output +++ b/unified/extractor/tests/corpus/swift/control-flow/guard-let.output @@ -44,21 +44,18 @@ top_level condition: pattern_guard_expr pattern: - constructor_pattern - constructor: + call_expr + callee: member_access_expr - base: - named_type_expr - name: identifier "Optional" - member: identifier "some" - element: - pattern_element - pattern: - name_pattern - identifier: identifier "value" - value: - name_expr - identifier: identifier "optional" + base: name_node "Optional" + member_name_node: name_node "some" + argument: + argument + value: + expr_pattern + modifier: modifier "let" + expr: name_node "value" + value: name_node "optional" else: block stmt: return_expr "return" diff --git a/unified/extractor/tests/corpus/swift/control-flow/if-case-let-with-shadowing-in-condition-value.output b/unified/extractor/tests/corpus/swift/control-flow/if-case-let-with-shadowing-in-condition-value.output index 2a0676513f23..ddacbba74def 100644 --- a/unified/extractor/tests/corpus/swift/control-flow/if-case-let-with-shadowing-in-condition-value.output +++ b/unified/extractor/tests/corpus/swift/control-flow/if-case-let-with-shadowing-in-condition-value.output @@ -2,6 +2,10 @@ if case let x = x + 10 { print(x) } +if case var y = y + 10 { + y += 1 +} + --- sourceFile @@ -57,6 +61,54 @@ sourceFile bindingSpecifier: let caseKeyword: case ifKeyword: if + codeBlockItem + item: + expressionStmt + expression: + ifExpr + body: + codeBlock + leftBrace: { + rightBrace: } + statements: + codeBlockItem + item: + infixOperatorExpr + operator: + binaryOperatorExpr + operator: binaryOperator "+=" + leftOperand: + declReferenceExpr + baseName: identifier "y" + rightOperand: + integerLiteralExpr + literal: integerLiteral "1" + conditions: + conditionElement + condition: + matchingPatternCondition + initializer: + initializerClause + equal: = + value: + infixOperatorExpr + operator: + binaryOperatorExpr + operator: binaryOperator "+" + leftOperand: + declReferenceExpr + baseName: identifier "y" + rightOperand: + integerLiteralExpr + literal: integerLiteral "10" + pattern: + valueBindingPattern + pattern: + identifierPattern + identifier: identifier "y" + bindingSpecifier: var + caseKeyword: case + ifKeyword: if --- @@ -68,24 +120,38 @@ top_level condition: pattern_guard_expr pattern: - name_pattern - identifier: identifier "x" + expr_pattern + modifier: modifier "let" + expr: name_node "x" value: binary_expr - left: - name_expr - identifier: identifier "x" + left: name_node "x" operator: infix_operator "+" right: int_literal "10" then: block stmt: call_expr - callee: - name_expr - identifier: identifier "print" + callee: name_node "print" argument: argument - value: - name_expr - identifier: identifier "x" + value: name_node "x" + if_expr + condition: + pattern_guard_expr + pattern: + expr_pattern + modifier: modifier "var" + expr: name_node "y" + value: + binary_expr + left: name_node "y" + operator: infix_operator "+" + right: int_literal "10" + then: + block + stmt: + compound_assign_expr + target: name_node "y" + operator: infix_operator "+=" + value: int_literal "1" diff --git a/unified/extractor/tests/corpus/swift/control-flow/if-case-let-with-shadowing-in-condition-value.swift b/unified/extractor/tests/corpus/swift/control-flow/if-case-let-with-shadowing-in-condition-value.swift index c57c8ae5b67c..0939555e91ad 100644 --- a/unified/extractor/tests/corpus/swift/control-flow/if-case-let-with-shadowing-in-condition-value.swift +++ b/unified/extractor/tests/corpus/swift/control-flow/if-case-let-with-shadowing-in-condition-value.swift @@ -1,3 +1,7 @@ if case let x = x + 10 { print(x) } + +if case var y = y + 10 { + y += 1 +} diff --git a/unified/extractor/tests/corpus/swift/control-flow/if-else-if-chain.output b/unified/extractor/tests/corpus/swift/control-flow/if-else-if-chain.output index 35f1c2c46d2c..de2ccc30fca5 100644 --- a/unified/extractor/tests/corpus/swift/control-flow/if-else-if-chain.output +++ b/unified/extractor/tests/corpus/swift/control-flow/if-else-if-chain.output @@ -115,18 +115,14 @@ top_level if_expr condition: binary_expr - left: - name_expr - identifier: identifier "x" + left: name_node "x" operator: infix_operator ">" right: int_literal "0" then: block stmt: call_expr - callee: - name_expr - identifier: identifier "print" + callee: name_node "print" argument: argument value: int_literal "1" @@ -134,18 +130,14 @@ top_level if_expr condition: binary_expr - left: - name_expr - identifier: identifier "x" + left: name_node "x" operator: infix_operator "<" right: int_literal "0" then: block stmt: call_expr - callee: - name_expr - identifier: identifier "print" + callee: name_node "print" argument: argument value: int_literal "2" @@ -153,9 +145,7 @@ top_level block stmt: call_expr - callee: - name_expr - identifier: identifier "print" + callee: name_node "print" argument: argument value: int_literal "3" diff --git a/unified/extractor/tests/corpus/swift/control-flow/if-else.output b/unified/extractor/tests/corpus/swift/control-flow/if-else.output index 744b5c51ab24..ec39c10dc216 100644 --- a/unified/extractor/tests/corpus/swift/control-flow/if-else.output +++ b/unified/extractor/tests/corpus/swift/control-flow/if-else.output @@ -80,35 +80,25 @@ top_level if_expr condition: binary_expr - left: - name_expr - identifier: identifier "x" + left: name_node "x" operator: infix_operator ">" right: int_literal "0" then: block stmt: call_expr - callee: - name_expr - identifier: identifier "print" + callee: name_node "print" argument: argument - value: - name_expr - identifier: identifier "x" + value: name_node "x" else: block stmt: call_expr - callee: - name_expr - identifier: identifier "print" + callee: name_node "print" argument: argument value: unary_expr - operand: - name_expr - identifier: identifier "x" + operand: name_node "x" operator: prefix_operator "-" diff --git a/unified/extractor/tests/corpus/swift/control-flow/if-let-optional-binding.output b/unified/extractor/tests/corpus/swift/control-flow/if-let-optional-binding.output index d1bcf82b0faa..fe5a32c9a187 100644 --- a/unified/extractor/tests/corpus/swift/control-flow/if-let-optional-binding.output +++ b/unified/extractor/tests/corpus/swift/control-flow/if-let-optional-binding.output @@ -57,30 +57,23 @@ top_level condition: pattern_guard_expr pattern: - constructor_pattern - constructor: + call_expr + callee: member_access_expr - base: - named_type_expr - name: identifier "Optional" - member: identifier "some" - element: - pattern_element - pattern: - name_pattern - identifier: identifier "value" - value: - name_expr - identifier: identifier "optional" + base: name_node "Optional" + member_name_node: name_node "some" + argument: + argument + value: + expr_pattern + modifier: modifier "let" + expr: name_node "value" + value: name_node "optional" then: block stmt: call_expr - callee: - name_expr - identifier: identifier "print" + callee: name_node "print" argument: argument - value: - name_expr - identifier: identifier "value" + value: name_node "value" diff --git a/unified/extractor/tests/corpus/swift/control-flow/if-statement.output b/unified/extractor/tests/corpus/swift/control-flow/if-statement.output index 77bba019ffb9..457960370326 100644 --- a/unified/extractor/tests/corpus/swift/control-flow/if-statement.output +++ b/unified/extractor/tests/corpus/swift/control-flow/if-statement.output @@ -55,20 +55,14 @@ top_level if_expr condition: binary_expr - left: - name_expr - identifier: identifier "x" + left: name_node "x" operator: infix_operator ">" right: int_literal "0" then: block stmt: call_expr - callee: - name_expr - identifier: identifier "print" + callee: name_node "print" argument: argument - value: - name_expr - identifier: identifier "x" + value: name_node "x" diff --git a/unified/extractor/tests/corpus/swift/control-flow/nested-enum-case-pattern.output b/unified/extractor/tests/corpus/swift/control-flow/nested-enum-case-pattern.output index 66a6f32dab4d..9bbcacf3ad22 100644 --- a/unified/extractor/tests/corpus/swift/control-flow/nested-enum-case-pattern.output +++ b/unified/extractor/tests/corpus/swift/control-flow/nested-enum-case-pattern.output @@ -160,76 +160,62 @@ top_level block stmt: switch_expr - value: - name_expr - identifier: identifier "event" + value: name_node "event" case: switch_case pattern: - constructor_pattern - constructor: - member_access_expr - base: inferred_type_expr "." - member: identifier "received" - element: - pattern_element - pattern: - constructor_pattern - constructor: - member_access_expr - base: inferred_type_expr "." - member: identifier "some" - element: - pattern_element - pattern: - name_pattern - identifier: identifier "value" - pattern_element - pattern: - name_pattern - identifier: identifier "timestamp" + expr_pattern + modifier: modifier "let" + expr: + call_expr + callee: + member_access_expr + base: inferred_type_expr "." + member_name_node: name_node "received" + argument: + argument + value: + call_expr + callee: + member_access_expr + base: inferred_type_expr "." + member_name_node: name_node "some" + argument: + argument + value: name_node "value" + argument + value: name_node "timestamp" body: block stmt: call_expr - callee: - name_expr - identifier: identifier "print" + callee: name_node "print" argument: argument - value: - name_expr - identifier: identifier "value" + value: name_node "value" argument - value: - name_expr - identifier: identifier "timestamp" + value: name_node "timestamp" switch_case pattern: - constructor_pattern - constructor: + call_expr + callee: member_access_expr - base: - name_expr - identifier: identifier "Type" - member: identifier "some" - element: - pattern_element - pattern: - name_pattern - identifier: identifier "value" + base: name_node "Type" + member_name_node: name_node "some" + argument: + argument + value: + expr_pattern + modifier: modifier "let" + expr: name_node "value" body: block stmt: call_expr - callee: - name_expr - identifier: identifier "print" + callee: name_node "print" argument: argument - value: - name_expr - identifier: identifier "value" + value: name_node "value" switch_case body: block diff --git a/unified/extractor/tests/corpus/swift/control-flow/switch-case-item-where-clauses.output b/unified/extractor/tests/corpus/swift/control-flow/switch-case-item-where-clauses.output index 9d2041aa2ad1..f58f3e0ba4b7 100644 --- a/unified/extractor/tests/corpus/swift/control-flow/switch-case-item-where-clauses.output +++ b/unified/extractor/tests/corpus/swift/control-flow/switch-case-item-where-clauses.output @@ -155,30 +155,25 @@ top_level block stmt: switch_expr - value: - name_expr - identifier: identifier "n" + value: name_node "n" case: switch_case pattern: conditional_pattern condition: binary_expr - left: - name_expr - identifier: identifier "x" + left: name_node "x" operator: infix_operator ">" right: int_literal "0" pattern: - name_pattern - identifier: identifier "x" + expr_pattern + modifier: modifier "let" + expr: name_node "x" body: block stmt: call_expr - callee: - name_expr - identifier: identifier "print" + callee: name_node "print" argument: argument value: string_literal "\"positive\"" @@ -189,23 +184,19 @@ top_level conditional_pattern condition: binary_expr - left: - name_expr - identifier: identifier "y" + left: name_node "y" operator: infix_operator "<" right: int_literal "0" pattern: - name_pattern - identifier: identifier "y" - expr_equality_pattern - expr: int_literal "0" + expr_pattern + modifier: modifier "let" + expr: name_node "y" + int_literal "0" body: block stmt: call_expr - callee: - name_expr - identifier: identifier "print" + callee: name_node "print" argument: argument value: string_literal "\"non-positive\"" @@ -214,9 +205,7 @@ top_level block stmt: call_expr - callee: - name_expr - identifier: identifier "print" + callee: name_node "print" argument: argument value: string_literal "\"other\"" diff --git a/unified/extractor/tests/corpus/swift/control-flow/switch-statement.output b/unified/extractor/tests/corpus/swift/control-flow/switch-statement.output index a88579852947..c1332afdd631 100644 --- a/unified/extractor/tests/corpus/swift/control-flow/switch-statement.output +++ b/unified/extractor/tests/corpus/swift/control-flow/switch-statement.output @@ -125,21 +125,15 @@ top_level block stmt: switch_expr - value: - name_expr - identifier: identifier "x" + value: name_node "x" case: switch_case - pattern: - expr_equality_pattern - expr: int_literal "1" + pattern: int_literal "1" body: block stmt: call_expr - callee: - name_expr - identifier: identifier "print" + callee: name_node "print" argument: argument value: string_literal "\"one\"" @@ -147,17 +141,13 @@ top_level pattern: or_pattern pattern: - expr_equality_pattern - expr: int_literal "2" - expr_equality_pattern - expr: int_literal "3" + int_literal "2" + int_literal "3" body: block stmt: call_expr - callee: - name_expr - identifier: identifier "print" + callee: name_node "print" argument: argument value: string_literal "\"two or three\"" @@ -166,9 +156,7 @@ top_level block stmt: call_expr - callee: - name_expr - identifier: identifier "print" + callee: name_node "print" argument: argument value: string_literal "\"other\"" diff --git a/unified/extractor/tests/corpus/swift/control-flow/switch-with-binding-pattern.output b/unified/extractor/tests/corpus/swift/control-flow/switch-with-binding-pattern.output index 90bb6b44e6e5..a623d8c1428f 100644 --- a/unified/extractor/tests/corpus/swift/control-flow/switch-with-binding-pattern.output +++ b/unified/extractor/tests/corpus/swift/control-flow/switch-with-binding-pattern.output @@ -120,55 +120,47 @@ top_level block stmt: switch_expr - value: - name_expr - identifier: identifier "shape" + value: name_node "shape" case: switch_case pattern: - constructor_pattern - constructor: + call_expr + callee: member_access_expr base: inferred_type_expr "." - member: identifier "circle" - element: - pattern_element - pattern: - name_pattern - identifier: identifier "r" + member_name_node: name_node "circle" + argument: + argument + value: + expr_pattern + modifier: modifier "let" + expr: name_node "r" body: block stmt: call_expr - callee: - name_expr - identifier: identifier "print" + callee: name_node "print" argument: argument - value: - name_expr - identifier: identifier "r" + value: name_node "r" switch_case pattern: - constructor_pattern - constructor: + call_expr + callee: member_access_expr base: inferred_type_expr "." - member: identifier "square" - element: - pattern_element - pattern: - name_pattern - identifier: identifier "s" + member_name_node: name_node "square" + argument: + argument + value: + expr_pattern + modifier: modifier "let" + expr: name_node "s" body: block stmt: call_expr - callee: - name_expr - identifier: identifier "print" + callee: name_node "print" argument: argument - value: - name_expr - identifier: identifier "s" + value: name_node "s" diff --git a/unified/extractor/tests/corpus/swift/control-flow/switch-with-labeled-case-pattern-arguments.output b/unified/extractor/tests/corpus/swift/control-flow/switch-with-labeled-case-pattern-arguments.output index 20b17d160e44..a052d356018a 100644 --- a/unified/extractor/tests/corpus/swift/control-flow/switch-with-labeled-case-pattern-arguments.output +++ b/unified/extractor/tests/corpus/swift/control-flow/switch-with-labeled-case-pattern-arguments.output @@ -128,57 +128,48 @@ top_level block stmt: switch_expr - value: - name_expr - identifier: identifier "x" + value: name_node "x" case: switch_case pattern: - constructor_pattern - constructor: + call_expr + callee: member_access_expr base: inferred_type_expr "." - member: identifier "implicit" - element: - pattern_element - key: identifier "isAcknowledged" - pattern: - expr_equality_pattern - expr: boolean_literal "false" + member_name_node: name_node "implicit" + argument: + argument + name_node: name_node "isAcknowledged" + value: boolean_literal "false" body: block stmt: call_expr - callee: - name_expr - identifier: identifier "print" + callee: name_node "print" argument: argument value: string_literal "\"yes\"" switch_case pattern: - constructor_pattern - constructor: + call_expr + callee: member_access_expr base: inferred_type_expr "." - member: identifier "thread" - element: - pattern_element - key: identifier "threadRowId" - pattern: ignore_pattern "_" - pattern_element - pattern: - name_pattern - identifier: identifier "rowId" + member_name_node: name_node "thread" + argument: + argument + name_node: name_node "threadRowId" + value: name_node "_" + argument + value: + expr_pattern + modifier: modifier "let" + expr: name_node "rowId" body: block stmt: call_expr - callee: - name_expr - identifier: identifier "print" + callee: name_node "print" argument: argument - value: - name_expr - identifier: identifier "rowId" + value: name_node "rowId" diff --git a/unified/extractor/tests/corpus/swift/control-flow/ternary-expression.output b/unified/extractor/tests/corpus/swift/control-flow/ternary-expression.output index 88c7bc1b886c..55845908e557 100644 --- a/unified/extractor/tests/corpus/swift/control-flow/ternary-expression.output +++ b/unified/extractor/tests/corpus/swift/control-flow/ternary-expression.output @@ -52,16 +52,12 @@ top_level stmt: variable_declaration modifier: modifier "let" - pattern: - name_pattern - identifier: identifier "y" + pattern: name_node "y" value: if_expr condition: binary_expr - left: - name_expr - identifier: identifier "x" + left: name_node "x" operator: infix_operator ">" right: int_literal "0" then: int_literal "1" diff --git a/unified/extractor/tests/corpus/swift/desugar/another-additive-expression-is-desugared.output b/unified/extractor/tests/corpus/swift/desugar/another-additive-expression-is-desugared.output index 982309ffa5af..4e7ea6449609 100644 --- a/unified/extractor/tests/corpus/swift/desugar/another-additive-expression-is-desugared.output +++ b/unified/extractor/tests/corpus/swift/desugar/another-additive-expression-is-desugared.output @@ -25,10 +25,6 @@ top_level block stmt: binary_expr - left: - name_expr - identifier: identifier "foo" + left: name_node "foo" operator: infix_operator "+" - right: - name_expr - identifier: identifier "bar" + right: name_node "bar" diff --git a/unified/extractor/tests/corpus/swift/desugar/import-with-deeply-nested-path-three-parts.output b/unified/extractor/tests/corpus/swift/desugar/import-with-deeply-nested-path-three-parts.output index ed16e68e219d..a9e047648d98 100644 --- a/unified/extractor/tests/corpus/swift/desugar/import-with-deeply-nested-path-three-parts.output +++ b/unified/extractor/tests/corpus/swift/desugar/import-with-deeply-nested-path-three-parts.output @@ -32,12 +32,10 @@ top_level member_access_expr base: member_access_expr - base: - name_expr - identifier: identifier "Foundation" - member: identifier "Networking" - member: identifier "URLSession" + base: name_node "Foundation" + member_name_node: name_node "Networking" + member_name_node: name_node "URLSession" pattern: - name_pattern - identifier: identifier "URLSession" + named_pattern + name_node: name_node "URLSession" sub_pattern: bulk_importing_pattern "import Foundation.Networking.URLSession" diff --git a/unified/extractor/tests/corpus/swift/desugar/import-with-dotted-path-two-parts.output b/unified/extractor/tests/corpus/swift/desugar/import-with-dotted-path-two-parts.output index 88f08baa19ce..304c367685e0 100644 --- a/unified/extractor/tests/corpus/swift/desugar/import-with-dotted-path-two-parts.output +++ b/unified/extractor/tests/corpus/swift/desugar/import-with-dotted-path-two-parts.output @@ -27,11 +27,9 @@ top_level import_declaration imported_expr: member_access_expr - base: - name_expr - identifier: identifier "Foundation" - member: identifier "Networking" + base: name_node "Foundation" + member_name_node: name_node "Networking" pattern: - name_pattern - identifier: identifier "Networking" + named_pattern + name_node: name_node "Networking" sub_pattern: bulk_importing_pattern "import Foundation.Networking" diff --git a/unified/extractor/tests/corpus/swift/desugar/scoped-import-uses-name-pattern.output b/unified/extractor/tests/corpus/swift/desugar/scoped-import-uses-name-pattern.output index 93319c522981..69dfbacd5149 100644 --- a/unified/extractor/tests/corpus/swift/desugar/scoped-import-uses-name-pattern.output +++ b/unified/extractor/tests/corpus/swift/desugar/scoped-import-uses-name-pattern.output @@ -29,10 +29,6 @@ top_level modifier: modifier "struct" imported_expr: member_access_expr - base: - name_expr - identifier: identifier "Foundation" - member: identifier "Date" - pattern: - name_pattern - identifier: identifier "Date" + base: name_node "Foundation" + member_name_node: name_node "Date" + pattern: name_node "Date" diff --git a/unified/extractor/tests/corpus/swift/desugar/simple-import-with-single-name.output b/unified/extractor/tests/corpus/swift/desugar/simple-import-with-single-name.output index 31261cd952c3..b22d05d57bd4 100644 --- a/unified/extractor/tests/corpus/swift/desugar/simple-import-with-single-name.output +++ b/unified/extractor/tests/corpus/swift/desugar/simple-import-with-single-name.output @@ -22,10 +22,8 @@ top_level block stmt: import_declaration - imported_expr: - name_expr - identifier: identifier "Foundation" + imported_expr: name_node "Foundation" pattern: - name_pattern - identifier: identifier "Foundation" + named_pattern + name_node: name_node "Foundation" sub_pattern: bulk_importing_pattern "import Foundation" diff --git a/unified/extractor/tests/corpus/swift/expressions/array-type-constructor.output b/unified/extractor/tests/corpus/swift/expressions/array-type-constructor.output index 43f1c8a553da..e2fd427aa64b 100644 --- a/unified/extractor/tests/corpus/swift/expressions/array-type-constructor.output +++ b/unified/extractor/tests/corpus/swift/expressions/array-type-constructor.output @@ -130,65 +130,43 @@ top_level stmt: variable_declaration modifier: modifier "let" - pattern: - name_pattern - identifier: identifier "values" + pattern: name_node "values" value: call_expr callee: generic_type_expr - base: - named_type_expr - name: identifier "Array" + base: name_node "Array" type_argument: generic_type_expr - base: - named_type_expr - name: identifier "Result" - type_argument: - named_type_expr - name: identifier "Void" + base: name_node "Result" + type_argument: name_node "Void" variable_declaration modifier: modifier "let" - pattern: - name_pattern - identifier: identifier "initialized" + pattern: name_node "initialized" value: call_expr callee: generic_type_expr - base: - named_type_expr - name: identifier "Array" + base: name_node "Array" type_argument: generic_type_expr - base: - named_type_expr - name: identifier "Result" - type_argument: - named_type_expr - name: identifier "Void" + base: name_node "Result" + type_argument: name_node "Void" argument: argument - name: identifier "unsafeUninitializedCapacity" + name_node: name_node "unsafeUninitializedCapacity" value: int_literal "1" argument value: function_expr parameter: parameter - pattern: - name_pattern - identifier: identifier "_" + pattern: name_node "_" parameter - pattern: - name_pattern - identifier: identifier "count" + pattern: name_node "count" body: block stmt: assign_expr - target: - name_expr - identifier: identifier "count" + target: name_node "count" value: int_literal "0" diff --git a/unified/extractor/tests/corpus/swift/expressions/array-type-metatype.output b/unified/extractor/tests/corpus/swift/expressions/array-type-metatype.output index f06917190b3a..e1c4f646c007 100644 --- a/unified/extractor/tests/corpus/swift/expressions/array-type-metatype.output +++ b/unified/extractor/tests/corpus/swift/expressions/array-type-metatype.output @@ -54,22 +54,14 @@ top_level stmt: variable_declaration modifier: modifier "let" - pattern: - name_pattern - identifier: identifier "type" + pattern: name_node "type" value: member_access_expr base: generic_type_expr - base: - named_type_expr - name: identifier "Array" + base: name_node "Array" type_argument: generic_type_expr - base: - named_type_expr - name: identifier "Result" - type_argument: - named_type_expr - name: identifier "Void" - member: identifier "self" + base: name_node "Result" + type_argument: name_node "Void" + member_name_node: name_node "self" diff --git a/unified/extractor/tests/corpus/swift/expressions/consume-expression.output b/unified/extractor/tests/corpus/swift/expressions/consume-expression.output index f20f89b72558..7493325eaf92 100644 --- a/unified/extractor/tests/corpus/swift/expressions/consume-expression.output +++ b/unified/extractor/tests/corpus/swift/expressions/consume-expression.output @@ -68,9 +68,7 @@ top_level stmt: variable_declaration modifier: modifier "let" - pattern: - name_pattern - identifier: identifier "original" + pattern: name_node "original" value: array_literal element: @@ -79,7 +77,5 @@ top_level int_literal "3" variable_declaration modifier: modifier "let" - pattern: - name_pattern - identifier: identifier "consumed" + pattern: name_node "consumed" value: unsupported_node "consume original" diff --git a/unified/extractor/tests/corpus/swift/expressions/copy-expression.output b/unified/extractor/tests/corpus/swift/expressions/copy-expression.output index 9f065b046a90..f9297472b658 100644 --- a/unified/extractor/tests/corpus/swift/expressions/copy-expression.output +++ b/unified/extractor/tests/corpus/swift/expressions/copy-expression.output @@ -68,9 +68,7 @@ top_level stmt: variable_declaration modifier: modifier "let" - pattern: - name_pattern - identifier: identifier "original" + pattern: name_node "original" value: array_literal element: @@ -79,7 +77,5 @@ top_level int_literal "3" variable_declaration modifier: modifier "let" - pattern: - name_pattern - identifier: identifier "copied" + pattern: name_node "copied" value: unsupported_node "copy original" diff --git a/unified/extractor/tests/corpus/swift/expressions/generic-specialization-expression.output b/unified/extractor/tests/corpus/swift/expressions/generic-specialization-expression.output index 94cdf978b9d2..c8dccc087d05 100644 --- a/unified/extractor/tests/corpus/swift/expressions/generic-specialization-expression.output +++ b/unified/extractor/tests/corpus/swift/expressions/generic-specialization-expression.output @@ -48,16 +48,10 @@ top_level stmt: variable_declaration modifier: modifier "let" - pattern: - name_pattern - identifier: identifier "numbers" + pattern: name_node "numbers" value: call_expr callee: generic_type_expr - base: - named_type_expr - name: identifier "Array" - type_argument: - named_type_expr - name: identifier "Int" + base: name_node "Array" + type_argument: name_node "Int" diff --git a/unified/extractor/tests/corpus/swift/expressions/key-path-expression.output b/unified/extractor/tests/corpus/swift/expressions/key-path-expression.output index a803e9e594fd..f01e2d158eb0 100644 --- a/unified/extractor/tests/corpus/swift/expressions/key-path-expression.output +++ b/unified/extractor/tests/corpus/swift/expressions/key-path-expression.output @@ -42,7 +42,5 @@ top_level stmt: variable_declaration modifier: modifier "let" - pattern: - name_pattern - identifier: identifier "keyPath" + pattern: name_node "keyPath" value: unsupported_node "\\String.count" diff --git a/unified/extractor/tests/corpus/swift/expressions/unsafe-expression.output b/unified/extractor/tests/corpus/swift/expressions/unsafe-expression.output index 2bdc964ddeaa..3965fa5f868b 100644 --- a/unified/extractor/tests/corpus/swift/expressions/unsafe-expression.output +++ b/unified/extractor/tests/corpus/swift/expressions/unsafe-expression.output @@ -46,6 +46,6 @@ top_level block stmt: function_declaration - name: identifier "doWork" + name_node: name_node "doWork" body: block "func doWork() {}" unsupported_node "unsafe doWork()" diff --git a/unified/extractor/tests/corpus/swift/functions/call-with-inout-argument.output b/unified/extractor/tests/corpus/swift/functions/call-with-inout-argument.output index 3dae9884c81e..0f517d5da797 100644 --- a/unified/extractor/tests/corpus/swift/functions/call-with-inout-argument.output +++ b/unified/extractor/tests/corpus/swift/functions/call-with-inout-argument.output @@ -75,20 +75,14 @@ top_level stmt: variable_declaration modifier: modifier "var" - pattern: - name_pattern - identifier: identifier "a" + pattern: name_node "a" value: int_literal "1" variable_declaration modifier: modifier "var" - pattern: - name_pattern - identifier: identifier "b" + pattern: name_node "b" value: int_literal "2" call_expr - callee: - name_expr - identifier: identifier "swap" + callee: name_node "swap" argument: argument value: unsupported_node "&a" diff --git a/unified/extractor/tests/corpus/swift/functions/constructor-call-with-type-arguments.output b/unified/extractor/tests/corpus/swift/functions/constructor-call-with-type-arguments.output index 37afdfa0d639..1dd021d25078 100644 --- a/unified/extractor/tests/corpus/swift/functions/constructor-call-with-type-arguments.output +++ b/unified/extractor/tests/corpus/swift/functions/constructor-call-with-type-arguments.output @@ -82,25 +82,19 @@ top_level stmt: class_like_declaration modifier: modifier "class" - name: identifier "Foo" + name_node: name_node "Foo" class_like_declaration modifier: modifier "class" - name: identifier "C" + name_node: name_node "C" type_parameter: type_parameter - name: identifier "T" + name_node: name_node "T" variable_declaration modifier: modifier "let" - pattern: - name_pattern - identifier: identifier "x" + pattern: name_node "x" value: call_expr callee: generic_type_expr - base: - named_type_expr - name: identifier "C" - type_argument: - named_type_expr - name: identifier "Foo" + base: name_node "C" + type_argument: name_node "Foo" diff --git a/unified/extractor/tests/corpus/swift/functions/function-call-with-labelled-arguments.output b/unified/extractor/tests/corpus/swift/functions/function-call-with-labelled-arguments.output index f885d5762f2d..c4d9f6036af4 100644 --- a/unified/extractor/tests/corpus/swift/functions/function-call-with-labelled-arguments.output +++ b/unified/extractor/tests/corpus/swift/functions/function-call-with-labelled-arguments.output @@ -33,10 +33,8 @@ top_level block stmt: call_expr - callee: - name_expr - identifier: identifier "greet" + callee: name_node "greet" argument: argument - name: identifier "person" + name_node: name_node "person" value: string_literal "\"Bob\"" diff --git a/unified/extractor/tests/corpus/swift/functions/function-call.output b/unified/extractor/tests/corpus/swift/functions/function-call.output index a1e2859ccd6a..e5860f5037d0 100644 --- a/unified/extractor/tests/corpus/swift/functions/function-call.output +++ b/unified/extractor/tests/corpus/swift/functions/function-call.output @@ -32,9 +32,7 @@ top_level block stmt: call_expr - callee: - name_expr - identifier: identifier "foo" + callee: name_node "foo" argument: argument value: int_literal "1" diff --git a/unified/extractor/tests/corpus/swift/functions/function-with-default-parameter-value.output b/unified/extractor/tests/corpus/swift/functions/function-with-default-parameter-value.output index 3495a13106fb..095503b1802c 100644 --- a/unified/extractor/tests/corpus/swift/functions/function-with-default-parameter-value.output +++ b/unified/extractor/tests/corpus/swift/functions/function-with-default-parameter-value.output @@ -66,25 +66,17 @@ top_level block stmt: function_declaration - name: identifier "greet" + name_node: name_node "greet" parameter: parameter - type: - named_type_expr - name: identifier "String" - pattern: - name_pattern - identifier: identifier "name" + type: name_node "String" + pattern: name_node "name" default: string_literal "\"world\"" body: block stmt: call_expr - callee: - name_expr - identifier: identifier "print" + callee: name_node "print" argument: argument - value: - name_expr - identifier: identifier "name" + value: name_node "name" diff --git a/unified/extractor/tests/corpus/swift/functions/function-with-inout-parameter.output b/unified/extractor/tests/corpus/swift/functions/function-with-inout-parameter.output index 232fb6dc2dbc..7647905c9f56 100644 --- a/unified/extractor/tests/corpus/swift/functions/function-with-inout-parameter.output +++ b/unified/extractor/tests/corpus/swift/functions/function-with-inout-parameter.output @@ -62,20 +62,16 @@ top_level block stmt: function_declaration - name: identifier "increment" + name_node: name_node "increment" parameter: parameter - external_name: identifier "_" + external_name_node: name_node "_" type: unsupported_node "inout Int" - pattern: - name_pattern - identifier: identifier "x" + pattern: name_node "x" body: block stmt: compound_assign_expr - target: - name_expr - identifier: identifier "x" + target: name_node "x" operator: infix_operator "+=" value: int_literal "1" diff --git a/unified/extractor/tests/corpus/swift/functions/function-with-named-parameters.output b/unified/extractor/tests/corpus/swift/functions/function-with-named-parameters.output index 7488edbcb231..90053743d846 100644 --- a/unified/extractor/tests/corpus/swift/functions/function-with-named-parameters.output +++ b/unified/extractor/tests/corpus/swift/functions/function-with-named-parameters.output @@ -57,25 +57,17 @@ top_level block stmt: function_declaration - name: identifier "greet" + name_node: name_node "greet" parameter: parameter - external_name: identifier "person" - type: - named_type_expr - name: identifier "String" - pattern: - name_pattern - identifier: identifier "name" + external_name_node: name_node "person" + type: name_node "String" + pattern: name_node "name" body: block stmt: call_expr - callee: - name_expr - identifier: identifier "print" + callee: name_node "print" argument: argument - value: - name_expr - identifier: identifier "name" + value: name_node "name" diff --git a/unified/extractor/tests/corpus/swift/functions/function-with-no-parameters.output b/unified/extractor/tests/corpus/swift/functions/function-with-no-parameters.output index 4ddc26ae94d6..b9d12c262423 100644 --- a/unified/extractor/tests/corpus/swift/functions/function-with-no-parameters.output +++ b/unified/extractor/tests/corpus/swift/functions/function-with-no-parameters.output @@ -52,14 +52,12 @@ top_level block stmt: function_declaration - name: identifier "greet" + name_node: name_node "greet" body: block stmt: call_expr - callee: - name_expr - identifier: identifier "print" + callee: name_node "print" argument: argument value: string_literal "\"hello\"" diff --git a/unified/extractor/tests/corpus/swift/functions/function-with-parameters-and-return-type.output b/unified/extractor/tests/corpus/swift/functions/function-with-parameters-and-return-type.output index e69b19307674..ec55c630e588 100644 --- a/unified/extractor/tests/corpus/swift/functions/function-with-parameters-and-return-type.output +++ b/unified/extractor/tests/corpus/swift/functions/function-with-parameters-and-return-type.output @@ -74,37 +74,23 @@ top_level block stmt: function_declaration - name: identifier "add" + name_node: name_node "add" parameter: parameter - external_name: identifier "_" - type: - named_type_expr - name: identifier "Int" - pattern: - name_pattern - identifier: identifier "a" + external_name_node: name_node "_" + type: name_node "Int" + pattern: name_node "a" parameter - external_name: identifier "_" - type: - named_type_expr - name: identifier "Int" - pattern: - name_pattern - identifier: identifier "b" - return_type: - named_type_expr - name: identifier "Int" + external_name_node: name_node "_" + type: name_node "Int" + pattern: name_node "b" + return_type: name_node "Int" body: block stmt: return_expr value: binary_expr - left: - name_expr - identifier: identifier "a" + left: name_node "a" operator: infix_operator "+" - right: - name_expr - identifier: identifier "b" + right: name_node "b" diff --git a/unified/extractor/tests/corpus/swift/functions/generic-function.output b/unified/extractor/tests/corpus/swift/functions/generic-function.output index dc7831410e23..c8b7d652ac04 100644 --- a/unified/extractor/tests/corpus/swift/functions/generic-function.output +++ b/unified/extractor/tests/corpus/swift/functions/generic-function.output @@ -64,26 +64,18 @@ top_level block stmt: function_declaration - name: identifier "identity" + name_node: name_node "identity" type_parameter: type_parameter - name: identifier "T" + name_node: name_node "T" parameter: parameter - external_name: identifier "_" - type: - named_type_expr - name: identifier "T" - pattern: - name_pattern - identifier: identifier "x" - return_type: - named_type_expr - name: identifier "T" + external_name_node: name_node "_" + type: name_node "T" + pattern: name_node "x" + return_type: name_node "T" body: block stmt: return_expr - value: - name_expr - identifier: identifier "x" + value: name_node "x" diff --git a/unified/extractor/tests/corpus/swift/functions/generic-type-alias.output b/unified/extractor/tests/corpus/swift/functions/generic-type-alias.output index 36737bd95bda..311f397ef118 100644 --- a/unified/extractor/tests/corpus/swift/functions/generic-type-alias.output +++ b/unified/extractor/tests/corpus/swift/functions/generic-type-alias.output @@ -56,22 +56,16 @@ top_level block stmt: type_alias_declaration - name: identifier "Box" + name_node: name_node "Box" type_parameter: type_parameter - name: identifier "T" - bound: - named_type_expr - name: identifier "Equatable" + name_node: name_node "T" + bound: name_node "Equatable" type_parameter - name: identifier "U" + name_node: name_node "U" type: generic_type_expr - base: - named_type_expr - name: identifier "Dictionary" + base: name_node "Dictionary" type_argument: - named_type_expr - name: identifier "T" - named_type_expr - name: identifier "U" + name_node "T" + name_node "U" diff --git a/unified/extractor/tests/corpus/swift/functions/leading-dot-expression-call.output b/unified/extractor/tests/corpus/swift/functions/leading-dot-expression-call.output index a5b38e1e2bea..43990d114450 100644 --- a/unified/extractor/tests/corpus/swift/functions/leading-dot-expression-call.output +++ b/unified/extractor/tests/corpus/swift/functions/leading-dot-expression-call.output @@ -44,15 +44,13 @@ top_level stmt: variable_declaration modifier: modifier "let" - pattern: - name_pattern - identifier: identifier "y" + pattern: name_node "y" value: call_expr callee: member_access_expr base: inferred_type_expr "." - member: identifier "some" + member_name_node: name_node "some" argument: argument value: int_literal "1" diff --git a/unified/extractor/tests/corpus/swift/functions/leading-dot-expression-value.output b/unified/extractor/tests/corpus/swift/functions/leading-dot-expression-value.output index 41128b61818e..f2ffad2f409c 100644 --- a/unified/extractor/tests/corpus/swift/functions/leading-dot-expression-value.output +++ b/unified/extractor/tests/corpus/swift/functions/leading-dot-expression-value.output @@ -34,10 +34,8 @@ top_level stmt: variable_declaration modifier: modifier "let" - pattern: - name_pattern - identifier: identifier "x" + pattern: name_node "x" value: member_access_expr base: inferred_type_expr "." - member: identifier "foo" + member_name_node: name_node "foo" diff --git a/unified/extractor/tests/corpus/swift/functions/method-call.output b/unified/extractor/tests/corpus/swift/functions/method-call.output index 3c0b150b8235..2b1fcb97e395 100644 --- a/unified/extractor/tests/corpus/swift/functions/method-call.output +++ b/unified/extractor/tests/corpus/swift/functions/method-call.output @@ -35,10 +35,8 @@ top_level call_expr callee: member_access_expr - base: - name_expr - identifier: identifier "list" - member: identifier "append" + base: name_node "list" + member_name_node: name_node "append" argument: argument value: int_literal "1" diff --git a/unified/extractor/tests/corpus/swift/functions/nested-function-type.output b/unified/extractor/tests/corpus/swift/functions/nested-function-type.output index d9ce0cd7a976..90ff59730ad5 100644 --- a/unified/extractor/tests/corpus/swift/functions/nested-function-type.output +++ b/unified/extractor/tests/corpus/swift/functions/nested-function-type.output @@ -105,52 +105,36 @@ top_level block stmt: type_alias_declaration - name: identifier "NestedFunction" + name_node: name_node "NestedFunction" type: - function_type_expr + function_expr parameter: parameter type: - function_type_expr + function_expr parameter: parameter - type: - named_type_expr - name: identifier "Int" - return_type: - named_type_expr - name: identifier "Bool" - return_type: - named_type_expr - name: identifier "Bool" + type: name_node "Int" + return_type: name_node "Bool" + return_type: name_node "Bool" type_alias_declaration - name: identifier "MixedParametersAndTuples" + name_node: name_node "MixedParametersAndTuples" type: - function_type_expr + function_expr parameter: parameter type: - function_type_expr + function_expr parameter: parameter - type: - named_type_expr - name: identifier "Int" - return_type: - named_type_expr - name: identifier "Bool" + type: name_node "Int" + return_type: name_node "Bool" parameter - type: - named_type_expr - name: identifier "String" + type: name_node "String" return_type: - tuple_type_expr + tuple_expr element: - tuple_type_element - type: - named_type_expr - name: identifier "Bool" - tuple_type_element - type: - named_type_expr - name: identifier "Int" + argument + value: name_node "Bool" + argument + value: name_node "Int" diff --git a/unified/extractor/tests/corpus/swift/functions/variadic-function.output b/unified/extractor/tests/corpus/swift/functions/variadic-function.output index 78c20ffc01e9..0bf0c4b88334 100644 --- a/unified/extractor/tests/corpus/swift/functions/variadic-function.output +++ b/unified/extractor/tests/corpus/swift/functions/variadic-function.output @@ -78,19 +78,13 @@ top_level block stmt: function_declaration - name: identifier "sum" + name_node: name_node "sum" parameter: parameter - external_name: identifier "_" - type: - named_type_expr - name: identifier "Int" - pattern: - name_pattern - identifier: identifier "values" - return_type: - named_type_expr - name: identifier "Int" + external_name_node: name_node "_" + type: name_node "Int" + pattern: name_node "values" + return_type: name_node "Int" body: block stmt: @@ -99,14 +93,10 @@ top_level call_expr callee: member_access_expr - base: - name_expr - identifier: identifier "values" - member: identifier "reduce" + base: name_node "values" + member_name_node: name_node "reduce" argument: argument value: int_literal "0" argument - value: - name_expr - identifier: identifier "+" + value: name_node "+" diff --git a/unified/extractor/tests/corpus/swift/literals/line-magic-literal.output b/unified/extractor/tests/corpus/swift/literals/line-magic-literal.output index 1616055fc16c..404b81d5b162 100644 --- a/unified/extractor/tests/corpus/swift/literals/line-magic-literal.output +++ b/unified/extractor/tests/corpus/swift/literals/line-magic-literal.output @@ -34,7 +34,5 @@ top_level stmt: variable_declaration modifier: modifier "let" - pattern: - name_pattern - identifier: identifier "currentLine" + pattern: name_node "currentLine" value: unsupported_node "#line" diff --git a/unified/extractor/tests/corpus/swift/loops/break-and-continue.output b/unified/extractor/tests/corpus/swift/loops/break-and-continue.output index 7ce869998272..35d31c4a3404 100644 --- a/unified/extractor/tests/corpus/swift/loops/break-and-continue.output +++ b/unified/extractor/tests/corpus/swift/loops/break-and-continue.output @@ -103,21 +103,15 @@ top_level block stmt: for_each_stmt - pattern: - name_pattern - identifier: identifier "x" - iterable: - name_expr - identifier: identifier "xs" + pattern: name_node "x" + iterable: name_node "xs" body: block stmt: if_expr condition: binary_expr - left: - name_expr - identifier: identifier "x" + left: name_node "x" operator: infix_operator "<" right: int_literal "0" then: @@ -126,20 +120,14 @@ top_level if_expr condition: binary_expr - left: - name_expr - identifier: identifier "x" + left: name_node "x" operator: infix_operator ">" right: int_literal "100" then: block stmt: break_expr "break" call_expr - callee: - name_expr - identifier: identifier "print" + callee: name_node "print" argument: argument - value: - name_expr - identifier: identifier "x" + value: name_node "x" diff --git a/unified/extractor/tests/corpus/swift/loops/for-in-over-array-literal.output b/unified/extractor/tests/corpus/swift/loops/for-in-over-array-literal.output index 2d8db27bfe85..1d94fa1bd500 100644 --- a/unified/extractor/tests/corpus/swift/loops/for-in-over-array-literal.output +++ b/unified/extractor/tests/corpus/swift/loops/for-in-over-array-literal.output @@ -61,9 +61,7 @@ top_level block stmt: for_each_stmt - pattern: - name_pattern - identifier: identifier "x" + pattern: name_node "x" iterable: array_literal element: @@ -74,11 +72,7 @@ top_level block stmt: call_expr - callee: - name_expr - identifier: identifier "print" + callee: name_node "print" argument: argument - value: - name_expr - identifier: identifier "x" + value: name_node "x" diff --git a/unified/extractor/tests/corpus/swift/loops/for-in-over-range.output b/unified/extractor/tests/corpus/swift/loops/for-in-over-range.output index cb8b4e67b68d..74ff30cd7f2c 100644 --- a/unified/extractor/tests/corpus/swift/loops/for-in-over-range.output +++ b/unified/extractor/tests/corpus/swift/loops/for-in-over-range.output @@ -53,9 +53,7 @@ top_level block stmt: for_each_stmt - pattern: - name_pattern - identifier: identifier "i" + pattern: name_node "i" iterable: binary_expr left: int_literal "0" @@ -65,11 +63,7 @@ top_level block stmt: call_expr - callee: - name_expr - identifier: identifier "print" + callee: name_node "print" argument: argument - value: - name_expr - identifier: identifier "i" + value: name_node "i" diff --git a/unified/extractor/tests/corpus/swift/loops/for-in-with-where-clause.output b/unified/extractor/tests/corpus/swift/loops/for-in-with-where-clause.output index 6659039029f3..5d7a0ee29ecd 100644 --- a/unified/extractor/tests/corpus/swift/loops/for-in-with-where-clause.output +++ b/unified/extractor/tests/corpus/swift/loops/for-in-with-where-clause.output @@ -59,28 +59,18 @@ top_level block stmt: for_each_stmt - pattern: - name_pattern - identifier: identifier "x" - iterable: - name_expr - identifier: identifier "xs" + pattern: name_node "x" + iterable: name_node "xs" guard: binary_expr - left: - name_expr - identifier: identifier "x" + left: name_node "x" operator: infix_operator ">" right: int_literal "0" body: block stmt: call_expr - callee: - name_expr - identifier: identifier "print" + callee: name_node "print" argument: argument - value: - name_expr - identifier: identifier "x" + value: name_node "x" diff --git a/unified/extractor/tests/corpus/swift/loops/repeat-while-loop.output b/unified/extractor/tests/corpus/swift/loops/repeat-while-loop.output index 71c49fd2cd10..014320ea51f5 100644 --- a/unified/extractor/tests/corpus/swift/loops/repeat-while-loop.output +++ b/unified/extractor/tests/corpus/swift/loops/repeat-while-loop.output @@ -52,15 +52,11 @@ top_level block stmt: compound_assign_expr - target: - name_expr - identifier: identifier "x" + target: name_node "x" operator: infix_operator "-=" value: int_literal "1" condition: binary_expr - left: - name_expr - identifier: identifier "x" + left: name_node "x" operator: infix_operator ">" right: int_literal "0" diff --git a/unified/extractor/tests/corpus/swift/loops/while-loop.output b/unified/extractor/tests/corpus/swift/loops/while-loop.output index 1132c6f9f819..eb7e0d19ea07 100644 --- a/unified/extractor/tests/corpus/swift/loops/while-loop.output +++ b/unified/extractor/tests/corpus/swift/loops/while-loop.output @@ -51,17 +51,13 @@ top_level while_stmt condition: binary_expr - left: - name_expr - identifier: identifier "x" + left: name_node "x" operator: infix_operator ">" right: int_literal "0" body: block stmt: compound_assign_expr - target: - name_expr - identifier: identifier "x" + target: name_node "x" operator: infix_operator "-=" value: int_literal "1" diff --git a/unified/extractor/tests/corpus/swift/operators/addition.output b/unified/extractor/tests/corpus/swift/operators/addition.output index 9ba0f4de4770..1f46d52a9615 100644 --- a/unified/extractor/tests/corpus/swift/operators/addition.output +++ b/unified/extractor/tests/corpus/swift/operators/addition.output @@ -25,10 +25,6 @@ top_level block stmt: binary_expr - left: - name_expr - identifier: identifier "a" + left: name_node "a" operator: infix_operator "+" - right: - name_expr - identifier: identifier "b" + right: name_node "b" diff --git a/unified/extractor/tests/corpus/swift/operators/comparison.output b/unified/extractor/tests/corpus/swift/operators/comparison.output index 49bb8c996f2c..0279f2131d52 100644 --- a/unified/extractor/tests/corpus/swift/operators/comparison.output +++ b/unified/extractor/tests/corpus/swift/operators/comparison.output @@ -25,10 +25,6 @@ top_level block stmt: binary_expr - left: - name_expr - identifier: identifier "a" + left: name_node "a" operator: infix_operator "<" - right: - name_expr - identifier: identifier "b" + right: name_node "b" diff --git a/unified/extractor/tests/corpus/swift/operators/custom-postfix-operator.output b/unified/extractor/tests/corpus/swift/operators/custom-postfix-operator.output index 5067671aa997..51425d5f7261 100644 --- a/unified/extractor/tests/corpus/swift/operators/custom-postfix-operator.output +++ b/unified/extractor/tests/corpus/swift/operators/custom-postfix-operator.output @@ -42,7 +42,5 @@ top_level unsupported_node "postfix operator ^^" variable_declaration modifier: modifier "let" - pattern: - name_pattern - identifier: identifier "squared" + pattern: name_node "squared" value: unsupported_node "3^^" diff --git a/unified/extractor/tests/corpus/swift/operators/division.output b/unified/extractor/tests/corpus/swift/operators/division.output index f15dce8e8ea5..16c06e60c005 100644 --- a/unified/extractor/tests/corpus/swift/operators/division.output +++ b/unified/extractor/tests/corpus/swift/operators/division.output @@ -25,10 +25,6 @@ top_level block stmt: binary_expr - left: - name_expr - identifier: identifier "a" + left: name_node "a" operator: infix_operator "/" - right: - name_expr - identifier: identifier "b" + right: name_node "b" diff --git a/unified/extractor/tests/corpus/swift/operators/equality.output b/unified/extractor/tests/corpus/swift/operators/equality.output index 7cf139ffa18d..60fdefd918ba 100644 --- a/unified/extractor/tests/corpus/swift/operators/equality.output +++ b/unified/extractor/tests/corpus/swift/operators/equality.output @@ -25,10 +25,6 @@ top_level block stmt: binary_expr - left: - name_expr - identifier: identifier "a" + left: name_node "a" operator: infix_operator "==" - right: - name_expr - identifier: identifier "b" + right: name_node "b" diff --git a/unified/extractor/tests/corpus/swift/operators/logical-and.output b/unified/extractor/tests/corpus/swift/operators/logical-and.output index 32a71ed1088c..218bc68eb9c8 100644 --- a/unified/extractor/tests/corpus/swift/operators/logical-and.output +++ b/unified/extractor/tests/corpus/swift/operators/logical-and.output @@ -25,10 +25,6 @@ top_level block stmt: binary_expr - left: - name_expr - identifier: identifier "a" + left: name_node "a" operator: infix_operator "&&" - right: - name_expr - identifier: identifier "b" + right: name_node "b" diff --git a/unified/extractor/tests/corpus/swift/operators/logical-not.output b/unified/extractor/tests/corpus/swift/operators/logical-not.output index 1e80aa2ca71e..935c8845c8db 100644 --- a/unified/extractor/tests/corpus/swift/operators/logical-not.output +++ b/unified/extractor/tests/corpus/swift/operators/logical-not.output @@ -20,7 +20,5 @@ top_level block stmt: unary_expr - operand: - name_expr - identifier: identifier "a" + operand: name_node "a" operator: prefix_operator "!" diff --git a/unified/extractor/tests/corpus/swift/operators/logical-or.output b/unified/extractor/tests/corpus/swift/operators/logical-or.output index b75d018dea71..2fe039ff7924 100644 --- a/unified/extractor/tests/corpus/swift/operators/logical-or.output +++ b/unified/extractor/tests/corpus/swift/operators/logical-or.output @@ -25,10 +25,6 @@ top_level block stmt: binary_expr - left: - name_expr - identifier: identifier "a" + left: name_node "a" operator: infix_operator "||" - right: - name_expr - identifier: identifier "b" + right: name_node "b" diff --git a/unified/extractor/tests/corpus/swift/operators/multiplication.output b/unified/extractor/tests/corpus/swift/operators/multiplication.output index 387c16439c48..c50138fede49 100644 --- a/unified/extractor/tests/corpus/swift/operators/multiplication.output +++ b/unified/extractor/tests/corpus/swift/operators/multiplication.output @@ -25,10 +25,6 @@ top_level block stmt: binary_expr - left: - name_expr - identifier: identifier "a" + left: name_node "a" operator: infix_operator "*" - right: - name_expr - identifier: identifier "b" + right: name_node "b" diff --git a/unified/extractor/tests/corpus/swift/operators/operator-precedence-addition-and-multiplication.output b/unified/extractor/tests/corpus/swift/operators/operator-precedence-addition-and-multiplication.output index f458c3ef847c..a7baf032b9d6 100644 --- a/unified/extractor/tests/corpus/swift/operators/operator-precedence-addition-and-multiplication.output +++ b/unified/extractor/tests/corpus/swift/operators/operator-precedence-addition-and-multiplication.output @@ -33,16 +33,10 @@ top_level block stmt: binary_expr - left: - name_expr - identifier: identifier "a" + left: name_node "a" operator: infix_operator "+" right: binary_expr - left: - name_expr - identifier: identifier "b" + left: name_node "b" operator: infix_operator "*" - right: - name_expr - identifier: identifier "c" + right: name_node "c" diff --git a/unified/extractor/tests/corpus/swift/operators/parenthesised-expression.output b/unified/extractor/tests/corpus/swift/operators/parenthesised-expression.output index 0324476ce994..24ffa1e76923 100644 --- a/unified/extractor/tests/corpus/swift/operators/parenthesised-expression.output +++ b/unified/extractor/tests/corpus/swift/operators/parenthesised-expression.output @@ -41,6 +41,4 @@ top_level binary_expr left: tuple_expr "(a + b)" operator: infix_operator "*" - right: - name_expr - identifier: identifier "c" + right: name_node "c" diff --git a/unified/extractor/tests/corpus/swift/operators/partial-range-from.output b/unified/extractor/tests/corpus/swift/operators/partial-range-from.output index 1b9208cedf8b..9d8977c2ec8e 100644 --- a/unified/extractor/tests/corpus/swift/operators/partial-range-from.output +++ b/unified/extractor/tests/corpus/swift/operators/partial-range-from.output @@ -34,7 +34,5 @@ top_level stmt: variable_declaration modifier: modifier "let" - pattern: - name_pattern - identifier: identifier "range" + pattern: name_node "range" value: unsupported_node "3..." diff --git a/unified/extractor/tests/corpus/swift/operators/subtraction.output b/unified/extractor/tests/corpus/swift/operators/subtraction.output index 5c6fd51a2d38..1e21bc3c8baf 100644 --- a/unified/extractor/tests/corpus/swift/operators/subtraction.output +++ b/unified/extractor/tests/corpus/swift/operators/subtraction.output @@ -25,10 +25,6 @@ top_level block stmt: binary_expr - left: - name_expr - identifier: identifier "a" + left: name_node "a" operator: infix_operator "-" - right: - name_expr - identifier: identifier "b" + right: name_node "b" diff --git a/unified/extractor/tests/corpus/swift/operators/unresolved-operator-sequence-with-casts.output b/unified/extractor/tests/corpus/swift/operators/unresolved-operator-sequence-with-casts.output index a0563c7bc88b..f45efa5e9406 100644 --- a/unified/extractor/tests/corpus/swift/operators/unresolved-operator-sequence-with-casts.output +++ b/unified/extractor/tests/corpus/swift/operators/unresolved-operator-sequence-with-casts.output @@ -94,48 +94,34 @@ top_level block stmt: function_declaration - name: identifier "casts" + name_node: name_node "casts" parameter: parameter - external_name: identifier "_" - type: - named_type_expr - name: identifier "Any" - pattern: - name_pattern - identifier: identifier "a" + external_name_node: name_node "_" + type: name_node "Any" + pattern: name_node "a" parameter - external_name: identifier "_" - type: - named_type_expr - name: identifier "Int" - pattern: - name_pattern - identifier: identifier "b" + external_name_node: name_node "_" + type: name_node "Int" + pattern: name_node "b" body: block stmt: unresolved_operator_sequence element: - name_expr - identifier: identifier "_" + name_node "_" infix_operator "=" - name_expr - identifier: identifier "a" + name_node "a" infix_operator "as" unsupported_node "Int" infix_operator ".&" - name_expr - identifier: identifier "b" + name_node "b" unresolved_operator_sequence element: - name_expr - identifier: identifier "_" + name_node "_" infix_operator "=" - name_expr - identifier: identifier "a" + name_node "a" infix_operator "is" unsupported_node "Int" infix_operator ".&" - name_expr - identifier: identifier "b" + name_node "b" diff --git a/unified/extractor/tests/corpus/swift/operators/unresolved-operator-sequence-with-ternary.output b/unified/extractor/tests/corpus/swift/operators/unresolved-operator-sequence-with-ternary.output index 57274c32a9c2..c8f5b29f4b46 100644 --- a/unified/extractor/tests/corpus/swift/operators/unresolved-operator-sequence-with-ternary.output +++ b/unified/extractor/tests/corpus/swift/operators/unresolved-operator-sequence-with-ternary.output @@ -100,43 +100,25 @@ top_level block stmt: function_declaration - name: identifier "choose" + name_node: name_node "choose" parameter: parameter - external_name: identifier "_" - type: - named_type_expr - name: identifier "Bool" - pattern: - name_pattern - identifier: identifier "c" + external_name_node: name_node "_" + type: name_node "Bool" + pattern: name_node "c" parameter - external_name: identifier "_" - type: - named_type_expr - name: identifier "Int" - pattern: - name_pattern - identifier: identifier "a" + external_name_node: name_node "_" + type: name_node "Int" + pattern: name_node "a" parameter - external_name: identifier "_" - type: - named_type_expr - name: identifier "Int" - pattern: - name_pattern - identifier: identifier "b" + external_name_node: name_node "_" + type: name_node "Int" + pattern: name_node "b" parameter - external_name: identifier "_" - type: - named_type_expr - name: identifier "Int" - pattern: - name_pattern - identifier: identifier "d" - return_type: - named_type_expr - name: identifier "Int" + external_name_node: name_node "_" + type: name_node "Int" + pattern: name_node "d" + return_type: name_node "Int" body: block stmt: @@ -144,14 +126,10 @@ top_level value: unresolved_operator_sequence element: - name_expr - identifier: identifier "c" + name_node "c" infix_operator "?" - name_expr - identifier: identifier "a" + name_node "a" infix_operator ":" - name_expr - identifier: identifier "b" + name_node "b" infix_operator ".&" - name_expr - identifier: identifier "d" + name_node "d" diff --git a/unified/extractor/tests/corpus/swift/operators/unresolved-operator-sequence.output b/unified/extractor/tests/corpus/swift/operators/unresolved-operator-sequence.output index 46dc8ca6ae89..bc287a5ed376 100644 --- a/unified/extractor/tests/corpus/swift/operators/unresolved-operator-sequence.output +++ b/unified/extractor/tests/corpus/swift/operators/unresolved-operator-sequence.output @@ -67,34 +67,23 @@ top_level block stmt: function_declaration - name: identifier "combine" + name_node: name_node "combine" parameter: parameter - external_name: identifier "_" - type: - named_type_expr - name: identifier "Int" - pattern: - name_pattern - identifier: identifier "a" + external_name_node: name_node "_" + type: name_node "Int" + pattern: name_node "a" parameter - external_name: identifier "_" - type: - named_type_expr - name: identifier "Int" - pattern: - name_pattern - identifier: identifier "b" + external_name_node: name_node "_" + type: name_node "Int" + pattern: name_node "b" body: block stmt: unresolved_operator_sequence element: - name_expr - identifier: identifier "_" + name_node "_" infix_operator "=" - name_expr - identifier: identifier "a" + name_node "a" infix_operator ".&" - name_expr - identifier: identifier "b" + name_node "b" diff --git a/unified/extractor/tests/corpus/swift/optionals-and-errors/catch-where-clauses.output b/unified/extractor/tests/corpus/swift/optionals-and-errors/catch-where-clauses.output index 79b7879d35fa..65976951ff61 100644 --- a/unified/extractor/tests/corpus/swift/optionals-and-errors/catch-where-clauses.output +++ b/unified/extractor/tests/corpus/swift/optionals-and-errors/catch-where-clauses.output @@ -147,9 +147,7 @@ top_level unary_expr operand: call_expr - callee: - name_expr - identifier: identifier "foo" + callee: name_node "foo" operator: prefix_operator "try" catch_clause: catch_clause @@ -159,38 +157,30 @@ top_level conditional_pattern condition: call_expr - callee: - name_expr - identifier: identifier "isNetworkError" + callee: name_node "isNetworkError" argument: argument - value: - name_expr - identifier: identifier "e" + value: name_node "e" pattern: - name_pattern - identifier: identifier "e" + expr_pattern + modifier: modifier "let" + expr: name_node "e" conditional_pattern condition: call_expr - callee: - name_expr - identifier: identifier "isTimeout" + callee: name_node "isTimeout" argument: argument - value: - name_expr - identifier: identifier "f" + value: name_node "f" pattern: - name_pattern - identifier: identifier "f" + expr_pattern + modifier: modifier "let" + expr: name_node "f" body: block stmt: call_expr - callee: - name_expr - identifier: identifier "print" + callee: name_node "print" argument: argument value: string_literal "\"retry\"" @@ -199,9 +189,7 @@ top_level block stmt: call_expr - callee: - name_expr - identifier: identifier "print" + callee: name_node "print" argument: argument value: string_literal "\"fallback\"" diff --git a/unified/extractor/tests/corpus/swift/optionals-and-errors/do-catch.output b/unified/extractor/tests/corpus/swift/optionals-and-errors/do-catch.output index 81491b295fc1..0cecd9c4a5aa 100644 --- a/unified/extractor/tests/corpus/swift/optionals-and-errors/do-catch.output +++ b/unified/extractor/tests/corpus/swift/optionals-and-errors/do-catch.output @@ -68,9 +68,7 @@ top_level unary_expr operand: call_expr - callee: - name_expr - identifier: identifier "foo" + callee: name_node "foo" operator: prefix_operator "try" catch_clause: catch_clause @@ -78,11 +76,7 @@ top_level block stmt: call_expr - callee: - name_expr - identifier: identifier "print" + callee: name_node "print" argument: argument - value: - name_expr - identifier: identifier "error" + value: name_node "error" diff --git a/unified/extractor/tests/corpus/swift/optionals-and-errors/force-unwrap.output b/unified/extractor/tests/corpus/swift/optionals-and-errors/force-unwrap.output index 2c6fd1a6f763..97659e0bf692 100644 --- a/unified/extractor/tests/corpus/swift/optionals-and-errors/force-unwrap.output +++ b/unified/extractor/tests/corpus/swift/optionals-and-errors/force-unwrap.output @@ -34,12 +34,8 @@ top_level stmt: variable_declaration modifier: modifier "let" - pattern: - name_pattern - identifier: identifier "n" + pattern: name_node "n" value: unary_expr - operand: - name_expr - identifier: identifier "opt" + operand: name_node "opt" operator: postfix_operator "!" diff --git a/unified/extractor/tests/corpus/swift/optionals-and-errors/nil-coalescing.output b/unified/extractor/tests/corpus/swift/optionals-and-errors/nil-coalescing.output index 31a039ad0065..34d29986d03e 100644 --- a/unified/extractor/tests/corpus/swift/optionals-and-errors/nil-coalescing.output +++ b/unified/extractor/tests/corpus/swift/optionals-and-errors/nil-coalescing.output @@ -39,13 +39,9 @@ top_level stmt: variable_declaration modifier: modifier "let" - pattern: - name_pattern - identifier: identifier "n" + pattern: name_node "n" value: binary_expr - left: - name_expr - identifier: identifier "opt" + left: name_node "opt" operator: infix_operator "??" right: int_literal "0" diff --git a/unified/extractor/tests/corpus/swift/optionals-and-errors/optional-chaining.output b/unified/extractor/tests/corpus/swift/optionals-and-errors/optional-chaining.output index b69b0ae47d50..6d3e7832f5ce 100644 --- a/unified/extractor/tests/corpus/swift/optionals-and-errors/optional-chaining.output +++ b/unified/extractor/tests/corpus/swift/optionals-and-errors/optional-chaining.output @@ -49,15 +49,11 @@ top_level stmt: variable_declaration modifier: modifier "let" - pattern: - name_pattern - identifier: identifier "n" + pattern: name_node "n" value: member_access_expr base: member_access_expr - base: - name_expr - identifier: identifier "obj" - member: identifier "foo" - member: identifier "bar" + base: name_node "obj" + member_name_node: name_node "foo" + member_name_node: name_node "bar" diff --git a/unified/extractor/tests/corpus/swift/optionals-and-errors/optional-enum-case-binding.output b/unified/extractor/tests/corpus/swift/optionals-and-errors/optional-enum-case-binding.output index 7b1eb1eea3b4..bbeb95a90c41 100644 --- a/unified/extractor/tests/corpus/swift/optionals-and-errors/optional-enum-case-binding.output +++ b/unified/extractor/tests/corpus/swift/optionals-and-errors/optional-enum-case-binding.output @@ -80,38 +80,31 @@ top_level condition: pattern_guard_expr pattern: - constructor_pattern - constructor: + call_expr + callee: member_access_expr - base: - named_type_expr - name: identifier "Optional" - member: identifier "some" - element: - pattern_element - pattern: - constructor_pattern - constructor: + base: name_node "Optional" + member_name_node: name_node "some" + argument: + argument + value: + call_expr + callee: member_access_expr base: inferred_type_expr "." - member: identifier "some" - element: - pattern_element - pattern: - name_pattern - identifier: identifier "value" - value: - name_expr - identifier: identifier "input" + member_name_node: name_node "some" + argument: + argument + value: + expr_pattern + modifier: modifier "let" + expr: name_node "value" + value: name_node "input" then: block stmt: call_expr - callee: - name_expr - identifier: identifier "print" + callee: name_node "print" argument: argument - value: - name_expr - identifier: identifier "value" + value: name_node "value" diff --git a/unified/extractor/tests/corpus/swift/optionals-and-errors/optional-type-annotation.output b/unified/extractor/tests/corpus/swift/optionals-and-errors/optional-type-annotation.output index 1927b494ef9a..492f910e9874 100644 --- a/unified/extractor/tests/corpus/swift/optionals-and-errors/optional-type-annotation.output +++ b/unified/extractor/tests/corpus/swift/optionals-and-errors/optional-type-annotation.output @@ -40,15 +40,9 @@ top_level stmt: variable_declaration modifier: modifier "let" - pattern: - name_pattern - identifier: identifier "x" + pattern: name_node "x" type: generic_type_expr - base: - named_type_expr - name: identifier "Optional" - type_argument: - named_type_expr - name: identifier "Int" + base: name_node "Optional" + type_argument: name_node "Int" value: builtin_expr "nil" diff --git a/unified/extractor/tests/corpus/swift/optionals-and-errors/throwing-function.output b/unified/extractor/tests/corpus/swift/optionals-and-errors/throwing-function.output index e68b4c3c57ac..13cd6fc71d1b 100644 --- a/unified/extractor/tests/corpus/swift/optionals-and-errors/throwing-function.output +++ b/unified/extractor/tests/corpus/swift/optionals-and-errors/throwing-function.output @@ -56,10 +56,8 @@ top_level block stmt: function_declaration - name: identifier "read" - return_type: - named_type_expr - name: identifier "String" + name_node: name_node "read" + return_type: name_node "String" body: block stmt: diff --git a/unified/extractor/tests/corpus/swift/optionals-and-errors/try-expression-2.output b/unified/extractor/tests/corpus/swift/optionals-and-errors/try-expression-2.output index aafc0c67c217..94143a875f54 100644 --- a/unified/extractor/tests/corpus/swift/optionals-and-errors/try-expression-2.output +++ b/unified/extractor/tests/corpus/swift/optionals-and-errors/try-expression-2.output @@ -41,14 +41,10 @@ top_level stmt: variable_declaration modifier: modifier "let" - pattern: - name_pattern - identifier: identifier "result" + pattern: name_node "result" value: unary_expr operand: call_expr - callee: - name_expr - identifier: identifier "foo" + callee: name_node "foo" operator: prefix_operator "try!" diff --git a/unified/extractor/tests/corpus/swift/optionals-and-errors/try-expression.output b/unified/extractor/tests/corpus/swift/optionals-and-errors/try-expression.output index 5b1b0b24d0fa..11701828d759 100644 --- a/unified/extractor/tests/corpus/swift/optionals-and-errors/try-expression.output +++ b/unified/extractor/tests/corpus/swift/optionals-and-errors/try-expression.output @@ -41,14 +41,10 @@ top_level stmt: variable_declaration modifier: modifier "let" - pattern: - name_pattern - identifier: identifier "result" + pattern: name_node "result" value: unary_expr operand: call_expr - callee: - name_expr - identifier: identifier "foo" + callee: name_node "foo" operator: prefix_operator "try?" diff --git a/unified/extractor/tests/corpus/swift/types/binding-modifier-does-not-leak-into-accessor-body.output b/unified/extractor/tests/corpus/swift/types/binding-modifier-does-not-leak-into-accessor-body.output index c05bc7794437..50e8feb3bf8b 100644 --- a/unified/extractor/tests/corpus/swift/types/binding-modifier-does-not-leak-into-accessor-body.output +++ b/unified/extractor/tests/corpus/swift/types/binding-modifier-does-not-leak-into-accessor-body.output @@ -98,25 +98,16 @@ top_level stmt: accessor_declaration modifier: modifier "var" - name: identifier "p" accessor_kind: accessor_kind "get" - type: - named_type_expr - name: identifier "Int" + type: name_node "Int" body: block stmt: switch_expr - value: - name_expr - identifier: identifier "y" + value: name_node "y" case: switch_case - pattern: - expr_equality_pattern - expr: - name_expr - identifier: identifier "someConstant" + pattern: name_node "someConstant" body: block stmt: @@ -128,3 +119,5 @@ top_level stmt: return_expr value: int_literal "2" + name: name_node "p" <-- ERROR: the node 'accessor_declaration' has no field 'name' + <-- ERROR: missing required field 'name_node' diff --git a/unified/extractor/tests/corpus/swift/types/class-inheritance.output b/unified/extractor/tests/corpus/swift/types/class-inheritance.output index 12328f4acb0d..f017998a1249 100644 --- a/unified/extractor/tests/corpus/swift/types/class-inheritance.output +++ b/unified/extractor/tests/corpus/swift/types/class-inheritance.output @@ -34,9 +34,7 @@ top_level stmt: class_like_declaration modifier: modifier "class" - name: identifier "Dog" + name_node: name_node "Dog" base_type: base_type - type: - named_type_expr - name: identifier "Animal" + type: name_node "Animal" diff --git a/unified/extractor/tests/corpus/swift/types/class-with-initializer.output b/unified/extractor/tests/corpus/swift/types/class-with-initializer.output index 83945d89e3a0..518cfc99e2a6 100644 --- a/unified/extractor/tests/corpus/swift/types/class-with-initializer.output +++ b/unified/extractor/tests/corpus/swift/types/class-with-initializer.output @@ -92,35 +92,23 @@ top_level stmt: class_like_declaration modifier: modifier "class" - name: identifier "Point" + name_node: name_node "Point" member: variable_declaration modifier: modifier "var" - pattern: - name_pattern - identifier: identifier "x" - type: - named_type_expr - name: identifier "Int" + pattern: name_node "x" + type: name_node "Int" constructor_declaration parameter: parameter - type: - named_type_expr - name: identifier "Int" - pattern: - name_pattern - identifier: identifier "x" + type: name_node "Int" + pattern: name_node "x" body: block stmt: assign_expr target: member_access_expr - base: - name_expr - identifier: identifier "self" - member: identifier "x" - value: - name_expr - identifier: identifier "x" + base: name_node "self" + member_name_node: name_node "x" + value: name_node "x" diff --git a/unified/extractor/tests/corpus/swift/types/class-with-method.output b/unified/extractor/tests/corpus/swift/types/class-with-method.output index f45cb31e53ad..96124be90c10 100644 --- a/unified/extractor/tests/corpus/swift/types/class-with-method.output +++ b/unified/extractor/tests/corpus/swift/types/class-with-method.output @@ -79,22 +79,18 @@ top_level stmt: class_like_declaration modifier: modifier "class" - name: identifier "Counter" + name_node: name_node "Counter" member: variable_declaration modifier: modifier "var" - pattern: - name_pattern - identifier: identifier "n" + pattern: name_node "n" value: int_literal "0" function_declaration - name: identifier "bump" + name_node: name_node "bump" body: block stmt: compound_assign_expr - target: - name_expr - identifier: identifier "n" + target: name_node "n" operator: infix_operator "+=" value: int_literal "1" diff --git a/unified/extractor/tests/corpus/swift/types/class-with-multiple-base-types.output b/unified/extractor/tests/corpus/swift/types/class-with-multiple-base-types.output index e66b88e9be3d..071cc9e96aee 100644 --- a/unified/extractor/tests/corpus/swift/types/class-with-multiple-base-types.output +++ b/unified/extractor/tests/corpus/swift/types/class-with-multiple-base-types.output @@ -39,13 +39,9 @@ top_level stmt: class_like_declaration modifier: modifier "class" - name: identifier "Button" + name_node: name_node "Button" base_type: base_type - type: - named_type_expr - name: identifier "Control" + type: name_node "Control" base_type - type: - named_type_expr - name: identifier "Drawable" + type: name_node "Drawable" diff --git a/unified/extractor/tests/corpus/swift/types/class-with-stored-properties.output b/unified/extractor/tests/corpus/swift/types/class-with-stored-properties.output index e184426eb755..622f298fb06c 100644 --- a/unified/extractor/tests/corpus/swift/types/class-with-stored-properties.output +++ b/unified/extractor/tests/corpus/swift/types/class-with-stored-properties.output @@ -63,21 +63,13 @@ top_level stmt: class_like_declaration modifier: modifier "class" - name: identifier "Point" + name_node: name_node "Point" member: variable_declaration modifier: modifier "var" - pattern: - name_pattern - identifier: identifier "x" - type: - named_type_expr - name: identifier "Int" + pattern: name_node "x" + type: name_node "Int" variable_declaration modifier: modifier "var" - pattern: - name_pattern - identifier: identifier "y" - type: - named_type_expr - name: identifier "Int" + pattern: name_node "y" + type: name_node "Int" diff --git a/unified/extractor/tests/corpus/swift/types/computed-property.output b/unified/extractor/tests/corpus/swift/types/computed-property.output index 24e816be0091..ad4742550600 100644 --- a/unified/extractor/tests/corpus/swift/types/computed-property.output +++ b/unified/extractor/tests/corpus/swift/types/computed-property.output @@ -103,41 +103,27 @@ top_level stmt: class_like_declaration modifier: modifier "class" - name: identifier "Rect" + name_node: name_node "Rect" member: variable_declaration modifier: modifier "var" - pattern: - name_pattern - identifier: identifier "w" - type: - named_type_expr - name: identifier "Double" + pattern: name_node "w" + type: name_node "Double" variable_declaration modifier: modifier "var" - pattern: - name_pattern - identifier: identifier "h" - type: - named_type_expr - name: identifier "Double" + pattern: name_node "h" + type: name_node "Double" accessor_declaration modifier: modifier "var" - name: identifier "area" + name_node: name_node "area" accessor_kind: accessor_kind "get" - type: - named_type_expr - name: identifier "Double" + type: name_node "Double" body: block stmt: return_expr value: binary_expr - left: - name_expr - identifier: identifier "w" + left: name_node "w" operator: infix_operator "*" - right: - name_expr - identifier: identifier "h" + right: name_node "h" diff --git a/unified/extractor/tests/corpus/swift/types/conditional-compilation-in-class-body.output b/unified/extractor/tests/corpus/swift/types/conditional-compilation-in-class-body.output index 2c530111b9ca..f0d0d04c5a06 100644 --- a/unified/extractor/tests/corpus/swift/types/conditional-compilation-in-class-body.output +++ b/unified/extractor/tests/corpus/swift/types/conditional-compilation-in-class-body.output @@ -83,5 +83,5 @@ top_level stmt: class_like_declaration modifier: modifier "class" - name: identifier "C" + name_node: name_node "C" member: unsupported_node "#if DEBUG\n init(x: Int) {}\n deinit {}\n#endif" diff --git a/unified/extractor/tests/corpus/swift/types/constructor-with-parameters.output b/unified/extractor/tests/corpus/swift/types/constructor-with-parameters.output index c9be21dd156a..cbada85ed06c 100644 --- a/unified/extractor/tests/corpus/swift/types/constructor-with-parameters.output +++ b/unified/extractor/tests/corpus/swift/types/constructor-with-parameters.output @@ -65,24 +65,16 @@ top_level stmt: class_like_declaration modifier: modifier "struct" - name: identifier "Size" + name_node: name_node "Size" member: constructor_declaration parameter: parameter - external_name: identifier "width" - type: - named_type_expr - name: identifier "Int" - pattern: - name_pattern - identifier: identifier "w" + external_name_node: name_node "width" + type: name_node "Int" + pattern: name_node "w" parameter - external_name: identifier "height" - type: - named_type_expr - name: identifier "Int" - pattern: - name_pattern - identifier: identifier "h" + external_name_node: name_node "height" + type: name_node "Int" + pattern: name_node "h" body: block "init(width w: Int, height h: Int) {}" diff --git a/unified/extractor/tests/corpus/swift/types/empty-class.output b/unified/extractor/tests/corpus/swift/types/empty-class.output index 6693744c9b43..0be44432243f 100644 --- a/unified/extractor/tests/corpus/swift/types/empty-class.output +++ b/unified/extractor/tests/corpus/swift/types/empty-class.output @@ -26,4 +26,4 @@ top_level stmt: class_like_declaration modifier: modifier "class" - name: identifier "Foo" + name_node: name_node "Foo" diff --git a/unified/extractor/tests/corpus/swift/types/enum-with-associated-values.output b/unified/extractor/tests/corpus/swift/types/enum-with-associated-values.output index 399239bbea30..d2617883ff67 100644 --- a/unified/extractor/tests/corpus/swift/types/enum-with-associated-values.output +++ b/unified/extractor/tests/corpus/swift/types/enum-with-associated-values.output @@ -71,33 +71,25 @@ top_level stmt: class_like_declaration modifier: modifier "enum" - name: identifier "Shape" + name_node: name_node "Shape" member: class_like_declaration modifier: modifier "enum_case" - name: identifier "circle" + name_node: name_node "circle" member: constructor_declaration parameter: parameter - type: - named_type_expr - name: identifier "Double" - pattern: - name_pattern - identifier: identifier "radius" + type: name_node "Double" + pattern: name_node "radius" body: block "circle(radius: Double)" class_like_declaration modifier: modifier "enum_case" - name: identifier "square" + name_node: name_node "square" member: constructor_declaration parameter: parameter - type: - named_type_expr - name: identifier "Double" - pattern: - name_pattern - identifier: identifier "side" + type: name_node "Double" + pattern: name_node "side" body: block "square(side: Double)" diff --git a/unified/extractor/tests/corpus/swift/types/enum-with-cases.output b/unified/extractor/tests/corpus/swift/types/enum-with-cases.output index f081c2a82046..5de37275931c 100644 --- a/unified/extractor/tests/corpus/swift/types/enum-with-cases.output +++ b/unified/extractor/tests/corpus/swift/types/enum-with-cases.output @@ -67,25 +67,17 @@ top_level stmt: class_like_declaration modifier: modifier "enum" - name: identifier "Direction" + name_node: name_node "Direction" member: variable_declaration modifier: modifier "enum_case" - pattern: - name_pattern - identifier: identifier "north" + pattern: name_node "north" variable_declaration modifier: modifier "enum_case" - pattern: - name_pattern - identifier: identifier "south" + pattern: name_node "south" variable_declaration modifier: modifier "enum_case" - pattern: - name_pattern - identifier: identifier "east" + pattern: name_node "east" variable_declaration modifier: modifier "enum_case" - pattern: - name_pattern - identifier: identifier "west" + pattern: name_node "west" diff --git a/unified/extractor/tests/corpus/swift/types/enum-with-comma-separated-cases-chained-declaration.output b/unified/extractor/tests/corpus/swift/types/enum-with-comma-separated-cases-chained-declaration.output index 6a4ea95e9a62..10dc40a0e71d 100644 --- a/unified/extractor/tests/corpus/swift/types/enum-with-comma-separated-cases-chained-declaration.output +++ b/unified/extractor/tests/corpus/swift/types/enum-with-comma-separated-cases-chained-declaration.output @@ -46,31 +46,23 @@ top_level stmt: class_like_declaration modifier: modifier "enum" - name: identifier "Suit" + name_node: name_node "Suit" member: variable_declaration modifier: modifier "enum_case" - pattern: - name_pattern - identifier: identifier "clubs" + pattern: name_node "clubs" variable_declaration modifier: modifier "chained_declaration" modifier "enum_case" - pattern: - name_pattern - identifier: identifier "diamonds" + pattern: name_node "diamonds" variable_declaration modifier: modifier "chained_declaration" modifier "enum_case" - pattern: - name_pattern - identifier: identifier "hearts" + pattern: name_node "hearts" variable_declaration modifier: modifier "chained_declaration" modifier "enum_case" - pattern: - name_pattern - identifier: identifier "spades" + pattern: name_node "spades" diff --git a/unified/extractor/tests/corpus/swift/types/extension.output b/unified/extractor/tests/corpus/swift/types/extension.output index 1b1d02ebddad..1791ec4c44ef 100644 --- a/unified/extractor/tests/corpus/swift/types/extension.output +++ b/unified/extractor/tests/corpus/swift/types/extension.output @@ -70,23 +70,17 @@ top_level stmt: class_like_declaration modifier: modifier "extension" - name: identifier "Int" + name_node: name_node "Int" member: function_declaration - name: identifier "squared" - return_type: - named_type_expr - name: identifier "Int" + name_node: name_node "squared" + return_type: name_node "Int" body: block stmt: return_expr value: binary_expr - left: - name_expr - identifier: identifier "self" + left: name_node "self" operator: infix_operator "*" - right: - name_expr - identifier: identifier "self" + right: name_node "self" diff --git a/unified/extractor/tests/corpus/swift/types/function-type-with-convention-attribute.output b/unified/extractor/tests/corpus/swift/types/function-type-with-convention-attribute.output index 3d484d6f65d8..9ff8629e49d5 100644 --- a/unified/extractor/tests/corpus/swift/types/function-type-with-convention-attribute.output +++ b/unified/extractor/tests/corpus/swift/types/function-type-with-convention-attribute.output @@ -64,9 +64,7 @@ top_level stmt: variable_declaration modifier: modifier "let" - pattern: - name_pattern - identifier: identifier "callback" + pattern: name_node "callback" type: unsupported_node "@convention(c) () -> Void" value: function_expr diff --git a/unified/extractor/tests/corpus/swift/types/function-type-with-sendable-attribute.output b/unified/extractor/tests/corpus/swift/types/function-type-with-sendable-attribute.output index ef9f838dadbe..ffd73f69d74a 100644 --- a/unified/extractor/tests/corpus/swift/types/function-type-with-sendable-attribute.output +++ b/unified/extractor/tests/corpus/swift/types/function-type-with-sendable-attribute.output @@ -57,9 +57,7 @@ top_level stmt: variable_declaration modifier: modifier "let" - pattern: - name_pattern - identifier: identifier "handler" + pattern: name_node "handler" type: unsupported_node "@Sendable () -> Void" value: function_expr diff --git a/unified/extractor/tests/corpus/swift/types/generic-class-parameters-and-constraints.output b/unified/extractor/tests/corpus/swift/types/generic-class-parameters-and-constraints.output index 26b17599ae00..c64dbaa9d36b 100644 --- a/unified/extractor/tests/corpus/swift/types/generic-class-parameters-and-constraints.output +++ b/unified/extractor/tests/corpus/swift/types/generic-class-parameters-and-constraints.output @@ -68,27 +68,17 @@ top_level stmt: class_like_declaration modifier: modifier "class" - name: identifier "Box" + name_node: name_node "Box" type_parameter: type_parameter - name: identifier "T" - bound: - named_type_expr - name: identifier "Equatable" + name_node: name_node "T" + bound: name_node "Equatable" type_parameter - name: identifier "U" + name_node: name_node "U" type_constraint: bound_type_constraint - type: - named_type_expr - name: identifier "U" - bound: - named_type_expr - name: identifier "Equatable" + type: name_node "U" + bound: name_node "Equatable" equality_type_constraint - left: - named_type_expr - name: identifier "U" - right: - named_type_expr - name: identifier "T" + left: name_node "U" + right: name_node "T" diff --git a/unified/extractor/tests/corpus/swift/types/generic-type-arguments.output b/unified/extractor/tests/corpus/swift/types/generic-type-arguments.output index ce12c853d9d5..8bbc439f8cde 100644 --- a/unified/extractor/tests/corpus/swift/types/generic-type-arguments.output +++ b/unified/extractor/tests/corpus/swift/types/generic-type-arguments.output @@ -62,22 +62,13 @@ top_level stmt: variable_declaration modifier: modifier "let" - pattern: - name_pattern - identifier: identifier "cache" + pattern: name_node "cache" type: generic_type_expr - base: - named_type_expr - name: identifier "Dictionary" + base: name_node "Dictionary" type_argument: - named_type_expr - name: identifier "String" + name_node "String" generic_type_expr - base: - named_type_expr - name: identifier "Array" - type_argument: - named_type_expr - name: identifier "Int" + base: name_node "Array" + type_argument: name_node "Int" value: map_literal "[:]" diff --git a/unified/extractor/tests/corpus/swift/types/inline-array-type.output b/unified/extractor/tests/corpus/swift/types/inline-array-type.output index 5f70d9d55168..3a1aab5cb81b 100644 --- a/unified/extractor/tests/corpus/swift/types/inline-array-type.output +++ b/unified/extractor/tests/corpus/swift/types/inline-array-type.output @@ -65,9 +65,7 @@ top_level stmt: variable_declaration modifier: modifier "let" - pattern: - name_pattern - identifier: identifier "triple" + pattern: name_node "triple" type: unsupported_node "[3 of Int]" value: array_literal diff --git a/unified/extractor/tests/corpus/swift/types/noncopyable-type.output b/unified/extractor/tests/corpus/swift/types/noncopyable-type.output index 4fb13ca13ece..1eaefbe4b87b 100644 --- a/unified/extractor/tests/corpus/swift/types/noncopyable-type.output +++ b/unified/extractor/tests/corpus/swift/types/noncopyable-type.output @@ -56,16 +56,12 @@ top_level stmt: class_like_declaration modifier: modifier "struct" - name: identifier "FileHandle" + name_node: name_node "FileHandle" base_type: base_type type: unsupported_node "~Copyable" member: variable_declaration modifier: modifier "let" - pattern: - name_pattern - identifier: identifier "descriptor" - type: - named_type_expr - name: identifier "Int" + pattern: name_node "descriptor" + type: name_node "Int" diff --git a/unified/extractor/tests/corpus/swift/types/property-with-getter-and-setter.output b/unified/extractor/tests/corpus/swift/types/property-with-getter-and-setter.output index 951768cd8444..74c5db3bda56 100644 --- a/unified/extractor/tests/corpus/swift/types/property-with-getter-and-setter.output +++ b/unified/extractor/tests/corpus/swift/types/property-with-getter-and-setter.output @@ -108,46 +108,36 @@ top_level stmt: class_like_declaration modifier: modifier "class" - name: identifier "Box" + name_node: name_node "Box" member: variable_declaration modifier: modifier "var" modifier "private" - pattern: - name_pattern - identifier: identifier "_v" + pattern: name_node "_v" value: int_literal "0" accessor_declaration modifier: modifier "var" - name: identifier "v" accessor_kind: accessor_kind "get" - type: - named_type_expr - name: identifier "Int" + type: name_node "Int" body: block stmt: return_expr - value: - name_expr - identifier: identifier "_v" + value: name_node "_v" + name: name_node "v" <-- ERROR: the node 'accessor_declaration' has no field 'name' + <-- ERROR: missing required field 'name_node' accessor_declaration modifier: modifier "var" modifier "chained_declaration" - name: identifier "v" accessor_kind: accessor_kind "set" - type: - named_type_expr - name: identifier "Int" + type: name_node "Int" body: block stmt: assign_expr - target: - name_expr - identifier: identifier "_v" - value: - name_expr - identifier: identifier "newValue" + target: name_node "_v" + value: name_node "newValue" + name: name_node "v" <-- ERROR: the node 'accessor_declaration' has no field 'name' + <-- ERROR: missing required field 'name_node' diff --git a/unified/extractor/tests/corpus/swift/types/protocol-declaration.output b/unified/extractor/tests/corpus/swift/types/protocol-declaration.output index e848fb23eb3f..9cdf80a7aee3 100644 --- a/unified/extractor/tests/corpus/swift/types/protocol-declaration.output +++ b/unified/extractor/tests/corpus/swift/types/protocol-declaration.output @@ -42,8 +42,8 @@ top_level stmt: class_like_declaration modifier: modifier "protocol" - name: identifier "Drawable" + name_node: name_node "Drawable" member: function_declaration - name: identifier "draw" + name_node: name_node "draw" body: block "func draw()" diff --git a/unified/extractor/tests/corpus/swift/types/protocol-with-read-only-and-read-write-property-requirements.output b/unified/extractor/tests/corpus/swift/types/protocol-with-read-only-and-read-write-property-requirements.output index 83362740bb1e..7b51f06a2f14 100644 --- a/unified/extractor/tests/corpus/swift/types/protocol-with-read-only-and-read-write-property-requirements.output +++ b/unified/extractor/tests/corpus/swift/types/protocol-with-read-only-and-read-write-property-requirements.output @@ -82,24 +82,21 @@ top_level stmt: class_like_declaration modifier: modifier "protocol" - name: identifier "P" + name_node: name_node "P" member: accessor_declaration - name: identifier "foo" accessor_kind: accessor_kind "get" - type: - named_type_expr - name: identifier "Int" + type: name_node "Int" + name: name_node "foo" <-- ERROR: the node 'accessor_declaration' has no field 'name' + <-- ERROR: missing required field 'name_node' accessor_declaration - name: identifier "bar" accessor_kind: accessor_kind "get" - type: - named_type_expr - name: identifier "String" + type: name_node "String" + name: name_node "bar" <-- ERROR: the node 'accessor_declaration' has no field 'name' + <-- ERROR: missing required field 'name_node' accessor_declaration modifier: modifier "chained_declaration" - name: identifier "bar" accessor_kind: accessor_kind "set" - type: - named_type_expr - name: identifier "String" + type: name_node "String" + name: name_node "bar" <-- ERROR: the node 'accessor_declaration' has no field 'name' + <-- ERROR: missing required field 'name_node' diff --git a/unified/extractor/tests/corpus/swift/types/qualified-type.output b/unified/extractor/tests/corpus/swift/types/qualified-type.output index f561dc6ab2dc..db47c6ceae48 100644 --- a/unified/extractor/tests/corpus/swift/types/qualified-type.output +++ b/unified/extractor/tests/corpus/swift/types/qualified-type.output @@ -103,37 +103,29 @@ top_level stmt: class_like_declaration modifier: modifier "struct" - name: identifier "Outer" + name_node: name_node "Outer" member: class_like_declaration modifier: modifier "struct" - name: identifier "Inner" + name_node: name_node "Inner" member: class_like_declaration modifier: modifier "struct" - name: identifier "Deep" + name_node: name_node "Deep" variable_declaration modifier: modifier "let" - pattern: - name_pattern - identifier: identifier "value" + pattern: name_node "value" type: - named_type_expr - qualifier: - named_type_expr - name: identifier "Outer" - name: identifier "Inner" + member_access_expr + base: name_node "Outer" + member_name_node: name_node "Inner" variable_declaration modifier: modifier "let" - pattern: - name_pattern - identifier: identifier "nested" + pattern: name_node "nested" type: - named_type_expr - qualifier: - named_type_expr - qualifier: - named_type_expr - name: identifier "Outer" - name: identifier "Inner" - name: identifier "Deep" + member_access_expr + base: + member_access_expr + base: name_node "Outer" + member_name_node: name_node "Inner" + member_name_node: name_node "Deep" diff --git a/unified/extractor/tests/corpus/swift/types/struct.output b/unified/extractor/tests/corpus/swift/types/struct.output index 57fb25c9e193..115aeaf8da74 100644 --- a/unified/extractor/tests/corpus/swift/types/struct.output +++ b/unified/extractor/tests/corpus/swift/types/struct.output @@ -63,21 +63,13 @@ top_level stmt: class_like_declaration modifier: modifier "struct" - name: identifier "Point" + name_node: name_node "Point" member: variable_declaration modifier: modifier "let" - pattern: - name_pattern - identifier: identifier "x" - type: - named_type_expr - name: identifier "Int" + pattern: name_node "x" + type: name_node "Int" variable_declaration modifier: modifier "let" - pattern: - name_pattern - identifier: identifier "y" - type: - named_type_expr - name: identifier "Int" + pattern: name_node "y" + type: name_node "Int" diff --git a/unified/extractor/tests/corpus/swift/variables/assignment.output b/unified/extractor/tests/corpus/swift/variables/assignment.output index a011eb76cafc..536d78cd9765 100644 --- a/unified/extractor/tests/corpus/swift/variables/assignment.output +++ b/unified/extractor/tests/corpus/swift/variables/assignment.output @@ -25,7 +25,5 @@ top_level block stmt: assign_expr - target: - name_expr - identifier: identifier "x" + target: name_node "x" value: int_literal "1" diff --git a/unified/extractor/tests/corpus/swift/variables/binding-modifier-does-not-leak-into-initializer.output b/unified/extractor/tests/corpus/swift/variables/binding-modifier-does-not-leak-into-initializer.output index d159cd6b37cb..50451fe12e62 100644 --- a/unified/extractor/tests/corpus/swift/variables/binding-modifier-does-not-leak-into-initializer.output +++ b/unified/extractor/tests/corpus/swift/variables/binding-modifier-does-not-leak-into-initializer.output @@ -67,21 +67,13 @@ top_level stmt: variable_declaration modifier: modifier "let" - pattern: - name_pattern - identifier: identifier "x" + pattern: name_node "x" value: switch_expr - value: - name_expr - identifier: identifier "y" + value: name_node "y" case: switch_case - pattern: - expr_equality_pattern - expr: - name_expr - identifier: identifier "someConstant" + pattern: name_node "someConstant" body: block stmt: int_literal "1" diff --git a/unified/extractor/tests/corpus/swift/variables/compound-assignment.output b/unified/extractor/tests/corpus/swift/variables/compound-assignment.output index 485b5044ad69..871455c8c629 100644 --- a/unified/extractor/tests/corpus/swift/variables/compound-assignment.output +++ b/unified/extractor/tests/corpus/swift/variables/compound-assignment.output @@ -25,8 +25,6 @@ top_level block stmt: compound_assign_expr - target: - name_expr - identifier: identifier "x" + target: name_node "x" operator: infix_operator "+=" value: int_literal "1" diff --git a/unified/extractor/tests/corpus/swift/variables/let-binding.output b/unified/extractor/tests/corpus/swift/variables/let-binding.output index 4774eb3eeca8..79cef2b67621 100644 --- a/unified/extractor/tests/corpus/swift/variables/let-binding.output +++ b/unified/extractor/tests/corpus/swift/variables/let-binding.output @@ -31,7 +31,5 @@ top_level stmt: variable_declaration modifier: modifier "let" - pattern: - name_pattern - identifier: identifier "x" + pattern: name_node "x" value: int_literal "1" diff --git a/unified/extractor/tests/corpus/swift/variables/let-with-type-annotation.output b/unified/extractor/tests/corpus/swift/variables/let-with-type-annotation.output index a56feb445ace..f65a9bbfbb31 100644 --- a/unified/extractor/tests/corpus/swift/variables/let-with-type-annotation.output +++ b/unified/extractor/tests/corpus/swift/variables/let-with-type-annotation.output @@ -37,10 +37,6 @@ top_level stmt: variable_declaration modifier: modifier "let" - pattern: - name_pattern - identifier: identifier "x" - type: - named_type_expr - name: identifier "Int" + pattern: name_node "x" + type: name_node "Int" value: int_literal "1" diff --git a/unified/extractor/tests/corpus/swift/variables/multiple-bindings-on-one-line.output b/unified/extractor/tests/corpus/swift/variables/multiple-bindings-on-one-line.output index 9470a578ad62..c4a005a5d3a6 100644 --- a/unified/extractor/tests/corpus/swift/variables/multiple-bindings-on-one-line.output +++ b/unified/extractor/tests/corpus/swift/variables/multiple-bindings-on-one-line.output @@ -42,15 +42,11 @@ top_level stmt: variable_declaration modifier: modifier "let" - pattern: - name_pattern - identifier: identifier "x" + pattern: name_node "x" value: int_literal "1" variable_declaration modifier: modifier "let" modifier "chained_declaration" - pattern: - name_pattern - identifier: identifier "y" + pattern: name_node "y" value: int_literal "2" diff --git a/unified/extractor/tests/corpus/swift/variables/property-with-willset-and-didset-observers.output b/unified/extractor/tests/corpus/swift/variables/property-with-willset-and-didset-observers.output index 8071d5d52900..0dc3370efac3 100644 --- a/unified/extractor/tests/corpus/swift/variables/property-with-willset-and-didset-observers.output +++ b/unified/extractor/tests/corpus/swift/variables/property-with-willset-and-didset-observers.output @@ -103,50 +103,40 @@ top_level stmt: class_like_declaration modifier: modifier "class" - name: identifier "C" + name_node: name_node "C" member: variable_declaration modifier: modifier "var" - pattern: - name_pattern - identifier: identifier "x" - type: - named_type_expr - name: identifier "Int" + pattern: name_node "x" + type: name_node "Int" value: int_literal "0" accessor_declaration modifier: modifier "var" modifier "chained_declaration" - name: identifier "x" accessor_kind: accessor_kind "willSet" body: block stmt: call_expr - callee: - name_expr - identifier: identifier "print" + callee: name_node "print" argument: argument - value: - name_expr - identifier: identifier "newValue" + value: name_node "newValue" + name: name_node "x" <-- ERROR: the node 'accessor_declaration' has no field 'name' + <-- ERROR: missing required field 'name_node' accessor_declaration modifier: modifier "var" modifier "chained_declaration" - name: identifier "x" accessor_kind: accessor_kind "didSet" body: block stmt: call_expr - callee: - name_expr - identifier: identifier "print" + callee: name_node "print" argument: argument - value: - name_expr - identifier: identifier "oldValue" + value: name_node "oldValue" + name: name_node "x" <-- ERROR: the node 'accessor_declaration' has no field 'name' + <-- ERROR: missing required field 'name_node' diff --git a/unified/extractor/tests/corpus/swift/variables/tuple-destructuring-binding.output b/unified/extractor/tests/corpus/swift/variables/tuple-destructuring-binding.output index 6b6bd81115ed..25f877fb1796 100644 --- a/unified/extractor/tests/corpus/swift/variables/tuple-destructuring-binding.output +++ b/unified/extractor/tests/corpus/swift/variables/tuple-destructuring-binding.output @@ -43,16 +43,10 @@ top_level variable_declaration modifier: modifier "let" pattern: - tuple_pattern + tuple_expr element: - pattern_element - pattern: - name_pattern - identifier: identifier "a" - pattern_element - pattern: - name_pattern - identifier: identifier "b" - value: - name_expr - identifier: identifier "pair" + argument + value: name_node "a" + argument + value: name_node "b" + value: name_node "pair" diff --git a/unified/extractor/tests/corpus/swift/variables/var-binding.output b/unified/extractor/tests/corpus/swift/variables/var-binding.output index 63498105dc75..ab70bd830c61 100644 --- a/unified/extractor/tests/corpus/swift/variables/var-binding.output +++ b/unified/extractor/tests/corpus/swift/variables/var-binding.output @@ -31,7 +31,5 @@ top_level stmt: variable_declaration modifier: modifier "var" - pattern: - name_pattern - identifier: identifier "x" + pattern: name_node "x" value: int_literal "1" diff --git a/unified/extractor/tests/corpus/swift/variables/var-without-initialiser.output b/unified/extractor/tests/corpus/swift/variables/var-without-initialiser.output index d841ce2bb583..3e746fe2cf17 100644 --- a/unified/extractor/tests/corpus/swift/variables/var-without-initialiser.output +++ b/unified/extractor/tests/corpus/swift/variables/var-without-initialiser.output @@ -31,9 +31,5 @@ top_level stmt: variable_declaration modifier: modifier "var" - pattern: - name_pattern - identifier: identifier "x" - type: - named_type_expr - name: identifier "Int" + pattern: name_node "x" + type: name_node "Int" diff --git a/unified/ql/lib/codeql/Definitions.qll b/unified/ql/lib/codeql/Definitions.qll index 3eb6ddcef102..032e6b72bc9d 100644 --- a/unified/ql/lib/codeql/Definitions.qll +++ b/unified/ql/lib/codeql/Definitions.qll @@ -9,7 +9,7 @@ private import codeql.unified.internal.StaticNameBinding * Holds if `reference` refers to `definition`. */ cached -predicate definitionOf(Identifier reference, NameDeclaration definition, string kind) { +predicate definitionOf(NameNode reference, NameDeclaration definition, string kind) { definition = getStaticBindingTarget(reference) and not reference instanceof NameDeclaration and kind = "name" diff --git a/unified/ql/lib/codeql/unified/internal/AnalysisQuality.qll b/unified/ql/lib/codeql/unified/internal/AnalysisQuality.qll index 6f899bba4283..45bd6481a3c5 100644 --- a/unified/ql/lib/codeql/unified/internal/AnalysisQuality.qll +++ b/unified/ql/lib/codeql/unified/internal/AnalysisQuality.qll @@ -4,13 +4,13 @@ private import codeql.unified.internal.StaticNameBinding private import codeql.unified.internal.LocalNameBinding private import codeql.unified.internal.NameBindingPlugin -/** Stats about identifiers that static name binding could resolve. */ +/** Stats about name nodes that static name binding could resolve. */ module StaticNameResolutionStats implements EntityStatsSig { /** * Holds if `name` has been positively identified as referring to a value, so static name binding * is not expected to resolve its members. */ - private predicate resolvesToValue(Identifier name) { + private predicate resolvesToValue(NameNode name) { exists(AstNode decl | decl = getStaticBindingTarget(name).getDeclaration() and not decl instanceof ClassLikeDeclaration and @@ -28,20 +28,20 @@ module StaticNameResolutionStats implements EntityStatsSig { private predicate memberAccessDependsOnTypeInference(MemberAccessExpr expr) { exists(Expr base | base = expr.getBase() | // Base expression resolves to a value, e.g. a field, variable, or function (for languages where functions are values). - resolvesToValue(getIdentifierFromRef(base)) + resolvesToValue(getNameNodeFromRef(base)) or // Base expression is of a kind that is not subject to static name resolution, e.g. `foo().x` - not exists(getIdentifierFromRef(base)) + not exists(getNameNodeFromRef(base)) or // Base expression is a confirmed to depend on type inference memberAccessDependsOnTypeInference(base) ) } - class Candidate extends Identifier { + class Candidate extends NameNode { Candidate() { exists(AstNode ref | - this = getIdentifierFromRef(ref) and + this = getNameNodeFromRef(ref) and not memberAccessDependsOnTypeInference(ref) ) and not this instanceof NameDeclaration @@ -49,10 +49,10 @@ module StaticNameResolutionStats implements EntityStatsSig { NameBindingNode getTarget() { ( - result.asIdentifier() = getStaticBindingTarget(this) + result.asNameNode() = getStaticBindingTarget(this) or result.isModuleScopeNode(_) and - result.(NamespaceNode).ref().isIdentifier(this) + result.(NamespaceNode).ref().isNameNode(this) ) } diff --git a/unified/ql/lib/codeql/unified/internal/Ast.qll b/unified/ql/lib/codeql/unified/internal/Ast.qll index cf927e257a9c..c2965400df09 100644 --- a/unified/ql/lib/codeql/unified/internal/Ast.qll +++ b/unified/ql/lib/codeql/unified/internal/Ast.qll @@ -112,8 +112,8 @@ module Unified { /** Gets the node corresponding to the field `modifier`. */ final F::Modifier getAModifier() { result = this.getModifier(_) } - /** Gets the node corresponding to the field `name`. */ - final F::Identifier getName() { unified_accessor_declaration_def(this, _, result) } + /** Gets the node corresponding to the field `name_node`. */ + final F::NameNode getNameNode() { unified_accessor_declaration_def(this, _, result) } /** Gets the node corresponding to the field `parameter`. */ final F::Parameter getParameter(int i) { @@ -124,7 +124,7 @@ module Unified { final F::Parameter getAParameter() { result = this.getParameter(_) } /** Gets the node corresponding to the field `type`. */ - final F::TypeExpr getType() { unified_accessor_declaration_type(this, result) } + final F::Expr getType() { unified_accessor_declaration_type(this, result) } /** Gets a field or child node of this node. */ final override F::AstNode getAFieldOrChild() { @@ -154,8 +154,8 @@ module Unified { /** Gets the node corresponding to the field `modifier`. */ final F::Modifier getAModifier() { result = this.getModifier(_) } - /** Gets the node corresponding to the field `name`. */ - final F::Identifier getName() { unified_argument_name(this, result) } + /** Gets the node corresponding to the field `name_node`. */ + final F::NameNode getNameNode() { unified_argument_name_node(this, result) } /** Gets the node corresponding to the field `value`. */ final F::Expr getValue() { unified_argument_def(this, result) } @@ -163,7 +163,7 @@ module Unified { /** Gets a field or child node of this node. */ final override F::AstNode getAFieldOrChild() { unified_argument_modifier(this, _, result) or - unified_argument_name(this, result) or + unified_argument_name_node(this, result) or unified_argument_def(this, result) } } @@ -206,7 +206,7 @@ module Unified { final override string getAPrimaryQlClass() { result = "AssociatedTypeDeclaration" } /** Gets the node corresponding to the field `bound`. */ - final F::TypeExpr getBound() { unified_associated_type_declaration_bound(this, result) } + final F::Expr getBound() { unified_associated_type_declaration_bound(this, result) } /** Gets the node corresponding to the field `modifier`. */ final F::Modifier getModifier(int i) { @@ -216,8 +216,8 @@ module Unified { /** Gets the node corresponding to the field `modifier`. */ final F::Modifier getAModifier() { result = this.getModifier(_) } - /** Gets the node corresponding to the field `name`. */ - final F::Identifier getName() { unified_associated_type_declaration_def(this, result) } + /** Gets the node corresponding to the field `name_node`. */ + final F::NameNode getNameNode() { unified_associated_type_declaration_def(this, result) } /** Gets a field or child node of this node. */ final override F::AstNode getAFieldOrChild() { @@ -239,7 +239,7 @@ module Unified { final F::Modifier getAModifier() { result = this.getModifier(_) } /** Gets the node corresponding to the field `type`. */ - final F::TypeExpr getType() { unified_base_type_def(this, result) } + final F::Expr getType() { unified_base_type_def(this, result) } /** Gets a field or child node of this node. */ final override F::AstNode getAFieldOrChild() { @@ -296,10 +296,10 @@ module Unified { final override string getAPrimaryQlClass() { result = "BoundTypeConstraint" } /** Gets the node corresponding to the field `bound`. */ - final F::TypeExpr getBound() { unified_bound_type_constraint_def(this, result, _) } + final F::Expr getBound() { unified_bound_type_constraint_def(this, result, _) } /** Gets the node corresponding to the field `type`. */ - final F::TypeExpr getType() { unified_bound_type_constraint_def(this, _, result) } + final F::Expr getType() { unified_bound_type_constraint_def(this, _, result) } /** Gets a field or child node of this node. */ final override F::AstNode getAFieldOrChild() { @@ -313,11 +313,13 @@ module Unified { /** Gets the name of the primary QL class for this element. */ final override string getAPrimaryQlClass() { result = "BreakExpr" } - /** Gets the node corresponding to the field `label`. */ - final F::Identifier getLabel() { unified_break_expr_label(this, result) } + /** Gets the node corresponding to the field `label_name_node`. */ + final F::NameNode getLabelNameNode() { unified_break_expr_label_name_node(this, result) } /** Gets a field or child node of this node. */ - final override F::AstNode getAFieldOrChild() { unified_break_expr_label(this, result) } + final override F::AstNode getAFieldOrChild() { + unified_break_expr_label_name_node(this, result) + } } /** A class representing `builtin_expr` tokens. */ @@ -327,7 +329,7 @@ module Unified { } /** A class representing `bulk_importing_pattern` nodes. */ - class BulkImportingPattern extends @unified_bulk_importing_pattern, F::Pattern { + class BulkImportingPattern extends @unified_bulk_importing_pattern, F::Expr { /** Gets the name of the primary QL class for this element. */ final override string getAPrimaryQlClass() { result = "BulkImportingPattern" } @@ -357,7 +359,7 @@ module Unified { final F::Argument getAnArgument() { result = this.getArgument(_) } /** Gets the node corresponding to the field `callee`. */ - final F::ExprOrType getCallee() { unified_call_expr_def(this, result) } + final F::Expr getCallee() { unified_call_expr_def(this, result) } /** Gets the node corresponding to the field `modifier`. */ final F::Modifier getModifier(int i) { unified_call_expr_modifier(this, i, result) } @@ -390,7 +392,7 @@ module Unified { final F::Modifier getAModifier() { result = this.getModifier(_) } /** Gets the node corresponding to the field `pattern`. */ - final F::Pattern getPattern() { unified_catch_clause_pattern(this, result) } + final F::Expr getPattern() { unified_catch_clause_pattern(this, result) } /** Gets a field or child node of this node. */ final override F::AstNode getAFieldOrChild() { @@ -427,8 +429,8 @@ module Unified { /** Gets the node corresponding to the field `modifier`. */ final F::Modifier getAModifier() { result = this.getModifier(_) } - /** Gets the node corresponding to the field `name`. */ - final F::Identifier getName() { unified_class_like_declaration_name(this, result) } + /** Gets the node corresponding to the field `name_node`. */ + final F::NameNode getNameNode() { unified_class_like_declaration_name_node(this, result) } /** Gets the node corresponding to the field `type_constraint`. */ final F::TypeConstraint getTypeConstraint(int i) { @@ -451,7 +453,7 @@ module Unified { unified_class_like_declaration_base_type(this, _, result) or unified_class_like_declaration_member(this, _, result) or unified_class_like_declaration_modifier(this, _, result) or - unified_class_like_declaration_name(this, result) or + unified_class_like_declaration_name_node(this, result) or unified_class_like_declaration_type_constraint(this, _, result) or unified_class_like_declaration_type_parameter(this, _, result) } @@ -480,7 +482,7 @@ module Unified { } /** A class representing `conditional_pattern` nodes. */ - class ConditionalPattern extends @unified_conditional_pattern, F::Pattern { + class ConditionalPattern extends @unified_conditional_pattern, F::Expr { /** Gets the name of the primary QL class for this element. */ final override string getAPrimaryQlClass() { result = "ConditionalPattern" } @@ -494,7 +496,7 @@ module Unified { final F::Modifier getAModifier() { result = this.getModifier(_) } /** Gets the node corresponding to the field `pattern`. */ - final F::Pattern getPattern() { unified_conditional_pattern_def(this, _, result) } + final F::Expr getPattern() { unified_conditional_pattern_def(this, _, result) } /** Gets a field or child node of this node. */ final override F::AstNode getAFieldOrChild() { @@ -522,8 +524,8 @@ module Unified { /** Gets the node corresponding to the field `modifier`. */ final F::Modifier getAModifier() { result = this.getModifier(_) } - /** Gets the node corresponding to the field `name`. */ - final F::Identifier getName() { unified_constructor_declaration_name(this, result) } + /** Gets the node corresponding to the field `name_node`. */ + final F::NameNode getNameNode() { unified_constructor_declaration_name_node(this, result) } /** Gets the node corresponding to the field `parameter`. */ final F::Parameter getParameter(int i) { @@ -537,51 +539,23 @@ module Unified { final override F::AstNode getAFieldOrChild() { unified_constructor_declaration_def(this, result) or unified_constructor_declaration_modifier(this, _, result) or - unified_constructor_declaration_name(this, result) or + unified_constructor_declaration_name_node(this, result) or unified_constructor_declaration_parameter(this, _, result) } } - /** A class representing `constructor_pattern` nodes. */ - class ConstructorPattern extends @unified_constructor_pattern, F::Pattern { - /** Gets the name of the primary QL class for this element. */ - final override string getAPrimaryQlClass() { result = "ConstructorPattern" } - - /** Gets the node corresponding to the field `constructor`. */ - final F::ExprOrType getConstructor() { unified_constructor_pattern_def(this, result) } - - /** Gets the node corresponding to the field `element`. */ - final F::PatternElement getElement(int i) { - unified_constructor_pattern_element(this, i, result) - } - - /** Gets the node corresponding to the field `element`. */ - final F::PatternElement getAnElement() { result = this.getElement(_) } - - /** Gets the node corresponding to the field `modifier`. */ - final F::Modifier getModifier(int i) { unified_constructor_pattern_modifier(this, i, result) } - - /** Gets the node corresponding to the field `modifier`. */ - final F::Modifier getAModifier() { result = this.getModifier(_) } - - /** Gets a field or child node of this node. */ - final override F::AstNode getAFieldOrChild() { - unified_constructor_pattern_def(this, result) or - unified_constructor_pattern_element(this, _, result) or - unified_constructor_pattern_modifier(this, _, result) - } - } - /** A class representing `continue_expr` nodes. */ class ContinueExpr extends @unified_continue_expr, F::Expr { /** Gets the name of the primary QL class for this element. */ final override string getAPrimaryQlClass() { result = "ContinueExpr" } - /** Gets the node corresponding to the field `label`. */ - final F::Identifier getLabel() { unified_continue_expr_label(this, result) } + /** Gets the node corresponding to the field `label_name_node`. */ + final F::NameNode getLabelNameNode() { unified_continue_expr_label_name_node(this, result) } /** Gets a field or child node of this node. */ - final override F::AstNode getAFieldOrChild() { unified_continue_expr_label(this, result) } + final override F::AstNode getAFieldOrChild() { + unified_continue_expr_label_name_node(this, result) + } } /** A class representing `destructor_declaration` nodes. */ @@ -646,10 +620,10 @@ module Unified { final override string getAPrimaryQlClass() { result = "EqualityTypeConstraint" } /** Gets the node corresponding to the field `left`. */ - final F::TypeExpr getLeft() { unified_equality_type_constraint_def(this, result, _) } + final F::Expr getLeft() { unified_equality_type_constraint_def(this, result, _) } /** Gets the node corresponding to the field `right`. */ - final F::TypeExpr getRight() { unified_equality_type_constraint_def(this, _, result) } + final F::Expr getRight() { unified_equality_type_constraint_def(this, _, result) } /** Gets a field or child node of this node. */ final override F::AstNode getAFieldOrChild() { @@ -658,23 +632,29 @@ module Unified { } } - class Expr extends @unified_expr, F::ExprOrOperator, F::ExprOrType, F::Stmt { } + class Expr extends @unified_expr, F::ExprOrOperator, F::Stmt { } - /** A class representing `expr_equality_pattern` nodes. */ - class ExprEqualityPattern extends @unified_expr_equality_pattern, F::Pattern { + class ExprOrOperator extends @unified_expr_or_operator, F::AstNode { } + + /** A class representing `expr_pattern` nodes. */ + class ExprPattern extends @unified_expr_pattern, F::Expr { /** Gets the name of the primary QL class for this element. */ - final override string getAPrimaryQlClass() { result = "ExprEqualityPattern" } + final override string getAPrimaryQlClass() { result = "ExprPattern" } /** Gets the node corresponding to the field `expr`. */ - final F::Expr getExpr() { unified_expr_equality_pattern_def(this, result) } + final F::Expr getExpr() { unified_expr_pattern_def(this, result) } - /** Gets a field or child node of this node. */ - final override F::AstNode getAFieldOrChild() { unified_expr_equality_pattern_def(this, result) } - } + /** Gets the node corresponding to the field `modifier`. */ + final F::Modifier getModifier(int i) { unified_expr_pattern_modifier(this, i, result) } - class ExprOrOperator extends @unified_expr_or_operator, F::AstNode { } + /** Gets the node corresponding to the field `modifier`. */ + final F::Modifier getAModifier() { result = this.getModifier(_) } - class ExprOrType extends @unified_expr_or_type, F::AstNode { } + /** Gets a field or child node of this node. */ + final override F::AstNode getAFieldOrChild() { + unified_expr_pattern_def(this, result) or unified_expr_pattern_modifier(this, _, result) + } + } /** A class representing `fixity` tokens. */ class Fixity extends @unified_token_fixity, F::AstNode, F::Token { @@ -709,7 +689,7 @@ module Unified { final F::Modifier getAModifier() { result = this.getModifier(_) } /** Gets the node corresponding to the field `pattern`. */ - final F::Pattern getPattern() { unified_for_each_stmt_def(this, _, result) } + final F::Expr getPattern() { unified_for_each_stmt_def(this, _, result) } /** Gets a field or child node of this node. */ final override F::AstNode getAFieldOrChild() { @@ -735,8 +715,8 @@ module Unified { /** Gets the node corresponding to the field `modifier`. */ final F::Modifier getAModifier() { result = this.getModifier(_) } - /** Gets the node corresponding to the field `name`. */ - final F::Identifier getName() { unified_function_declaration_def(this, result) } + /** Gets the node corresponding to the field `name_node`. */ + final F::NameNode getNameNode() { unified_function_declaration_def(this, result) } /** Gets the node corresponding to the field `parameter`. */ final F::Parameter getParameter(int i) { @@ -747,7 +727,7 @@ module Unified { final F::Parameter getAParameter() { result = this.getParameter(_) } /** Gets the node corresponding to the field `return_type`. */ - final F::TypeExpr getReturnType() { unified_function_declaration_return_type(this, result) } + final F::Expr getReturnType() { unified_function_declaration_return_type(this, result) } /** Gets the node corresponding to the field `type_constraint`. */ final F::TypeConstraint getTypeConstraint(int i) { @@ -783,7 +763,7 @@ module Unified { final override string getAPrimaryQlClass() { result = "FunctionExpr" } /** Gets the node corresponding to the field `body`. */ - final F::Block getBody() { unified_function_expr_def(this, result) } + final F::Block getBody() { unified_function_expr_body(this, result) } /** Gets the node corresponding to the field `capture_declaration`. */ final F::VariableDeclaration getCaptureDeclaration(int i) { @@ -806,11 +786,11 @@ module Unified { final F::Parameter getAParameter() { result = this.getParameter(_) } /** Gets the node corresponding to the field `return_type`. */ - final F::TypeExpr getReturnType() { unified_function_expr_return_type(this, result) } + final F::Expr getReturnType() { unified_function_expr_return_type(this, result) } /** Gets a field or child node of this node. */ final override F::AstNode getAFieldOrChild() { - unified_function_expr_def(this, result) or + unified_function_expr_body(this, result) or unified_function_expr_capture_declaration(this, _, result) or unified_function_expr_modifier(this, _, result) or unified_function_expr_parameter(this, _, result) or @@ -818,42 +798,21 @@ module Unified { } } - /** A class representing `function_type_expr` nodes. */ - class FunctionTypeExpr extends @unified_function_type_expr, F::TypeExpr { - /** Gets the name of the primary QL class for this element. */ - final override string getAPrimaryQlClass() { result = "FunctionTypeExpr" } - - /** Gets the node corresponding to the field `parameter`. */ - final F::Parameter getParameter(int i) { unified_function_type_expr_parameter(this, i, result) } - - /** Gets the node corresponding to the field `parameter`. */ - final F::Parameter getAParameter() { result = this.getParameter(_) } - - /** Gets the node corresponding to the field `return_type`. */ - final F::TypeExpr getReturnType() { unified_function_type_expr_def(this, result) } - - /** Gets a field or child node of this node. */ - final override F::AstNode getAFieldOrChild() { - unified_function_type_expr_parameter(this, _, result) or - unified_function_type_expr_def(this, result) - } - } - /** A class representing `generic_type_expr` nodes. */ - class GenericTypeExpr extends @unified_generic_type_expr, F::TypeExpr { + class GenericTypeExpr extends @unified_generic_type_expr, F::Expr { /** Gets the name of the primary QL class for this element. */ final override string getAPrimaryQlClass() { result = "GenericTypeExpr" } /** Gets the node corresponding to the field `base`. */ - final F::TypeExpr getBase() { unified_generic_type_expr_def(this, result) } + final F::Expr getBase() { unified_generic_type_expr_def(this, result) } /** Gets the node corresponding to the field `type_argument`. */ - final F::TypeExpr getTypeArgument(int i) { + final F::Expr getTypeArgument(int i) { unified_generic_type_expr_type_argument(this, i, result) } /** Gets the node corresponding to the field `type_argument`. */ - final F::TypeExpr getATypeArgument() { result = this.getTypeArgument(_) } + final F::Expr getATypeArgument() { result = this.getTypeArgument(_) } /** Gets a field or child node of this node. */ final override F::AstNode getAFieldOrChild() { @@ -879,12 +838,6 @@ module Unified { } } - /** A class representing `identifier` tokens. */ - class Identifier extends @unified_token_identifier, F::AstNode, F::Token { - /** Gets the name of the primary QL class for this element. */ - final override string getAPrimaryQlClass() { result = "Identifier" } - } - /** A class representing `if_expr` nodes. */ class IfExpr extends @unified_if_expr, F::Expr { /** Gets the name of the primary QL class for this element. */ @@ -907,12 +860,6 @@ module Unified { } } - /** A class representing `ignore_pattern` tokens. */ - class IgnorePattern extends @unified_token_ignore_pattern, F::Pattern, F::Token { - /** Gets the name of the primary QL class for this element. */ - final override string getAPrimaryQlClass() { result = "IgnorePattern" } - } - /** A class representing `import_declaration` nodes. */ class ImportDeclaration extends @unified_import_declaration, F::Stmt { /** Gets the name of the primary QL class for this element. */ @@ -928,7 +875,7 @@ module Unified { final F::Modifier getAModifier() { result = this.getModifier(_) } /** Gets the node corresponding to the field `pattern`. */ - final F::Pattern getPattern() { unified_import_declaration_pattern(this, result) } + final F::Expr getPattern() { unified_import_declaration_pattern(this, result) } /** Gets a field or child node of this node. */ final override F::AstNode getAFieldOrChild() { @@ -939,7 +886,7 @@ module Unified { } /** A class representing `inferred_type_expr` tokens. */ - class InferredTypeExpr extends @unified_token_inferred_type_expr, F::Token, F::TypeExpr { + class InferredTypeExpr extends @unified_token_inferred_type_expr, F::Expr, F::Token { /** Gets the name of the primary QL class for this element. */ final override string getAPrimaryQlClass() { result = "InferredTypeExpr" } } @@ -1003,8 +950,8 @@ module Unified { /** Gets the name of the primary QL class for this element. */ final override string getAPrimaryQlClass() { result = "LabeledStmt" } - /** Gets the node corresponding to the field `label`. */ - final F::Identifier getLabel() { unified_labeled_stmt_def(this, result, _) } + /** Gets the node corresponding to the field `label_name_node`. */ + final F::NameNode getLabelNameNode() { unified_labeled_stmt_def(this, result, _) } /** Gets the node corresponding to the field `stmt`. */ final F::Stmt getStmt() { unified_labeled_stmt_def(this, _, result) } @@ -1038,10 +985,10 @@ module Unified { final override string getAPrimaryQlClass() { result = "MemberAccessExpr" } /** Gets the node corresponding to the field `base`. */ - final F::ExprOrType getBase() { unified_member_access_expr_def(this, result, _) } + final F::Expr getBase() { unified_member_access_expr_def(this, result, _) } - /** Gets the node corresponding to the field `member`. */ - final F::Identifier getMember() { unified_member_access_expr_def(this, _, result) } + /** Gets the node corresponding to the field `member_name_node`. */ + final F::NameNode getMemberNameNode() { unified_member_access_expr_def(this, _, result) } /** Gets a field or child node of this node. */ final override F::AstNode getAFieldOrChild() { @@ -1056,57 +1003,34 @@ module Unified { final override string getAPrimaryQlClass() { result = "Modifier" } } - /** A class representing `name_expr` nodes. */ - class NameExpr extends @unified_name_expr, F::Expr { + /** A class representing `name_node` tokens. */ + class NameNode extends @unified_token_name_node, F::Expr, F::Token { /** Gets the name of the primary QL class for this element. */ - final override string getAPrimaryQlClass() { result = "NameExpr" } - - /** Gets the node corresponding to the field `identifier`. */ - final F::Identifier getIdentifier() { unified_name_expr_def(this, result) } - - /** Gets a field or child node of this node. */ - final override F::AstNode getAFieldOrChild() { unified_name_expr_def(this, result) } + final override string getAPrimaryQlClass() { result = "NameNode" } } - /** A class representing `name_pattern` nodes. */ - class NamePattern extends @unified_name_pattern, F::Pattern { + /** A class representing `named_pattern` nodes. */ + class NamedPattern extends @unified_named_pattern, F::Expr { /** Gets the name of the primary QL class for this element. */ - final override string getAPrimaryQlClass() { result = "NamePattern" } - - /** Gets the node corresponding to the field `identifier`. */ - final F::Identifier getIdentifier() { unified_name_pattern_def(this, result) } + final override string getAPrimaryQlClass() { result = "NamedPattern" } /** Gets the node corresponding to the field `modifier`. */ - final F::Modifier getModifier(int i) { unified_name_pattern_modifier(this, i, result) } + final F::Modifier getModifier(int i) { unified_named_pattern_modifier(this, i, result) } /** Gets the node corresponding to the field `modifier`. */ final F::Modifier getAModifier() { result = this.getModifier(_) } - /** Gets the node corresponding to the field `sub_pattern`. */ - final F::Pattern getSubPattern() { unified_name_pattern_sub_pattern(this, result) } - - /** Gets a field or child node of this node. */ - final override F::AstNode getAFieldOrChild() { - unified_name_pattern_def(this, result) or - unified_name_pattern_modifier(this, _, result) or - unified_name_pattern_sub_pattern(this, result) - } - } - - /** A class representing `named_type_expr` nodes. */ - class NamedTypeExpr extends @unified_named_type_expr, F::TypeExpr { - /** Gets the name of the primary QL class for this element. */ - final override string getAPrimaryQlClass() { result = "NamedTypeExpr" } - - /** Gets the node corresponding to the field `name`. */ - final F::Identifier getName() { unified_named_type_expr_def(this, result) } + /** Gets the node corresponding to the field `name_node`. */ + final F::NameNode getNameNode() { unified_named_pattern_def(this, result, _) } - /** Gets the node corresponding to the field `qualifier`. */ - final F::TypeExpr getQualifier() { unified_named_type_expr_qualifier(this, result) } + /** Gets the node corresponding to the field `sub_pattern`. */ + final F::Expr getSubPattern() { unified_named_pattern_def(this, _, result) } /** Gets a field or child node of this node. */ final override F::AstNode getAFieldOrChild() { - unified_named_type_expr_def(this, result) or unified_named_type_expr_qualifier(this, result) + unified_named_pattern_modifier(this, _, result) or + unified_named_pattern_def(this, result, _) or + unified_named_pattern_def(this, _, result) } } @@ -1128,8 +1052,8 @@ module Unified { /** Gets the node corresponding to the field `modifier`. */ final F::Modifier getAModifier() { result = this.getModifier(_) } - /** Gets the node corresponding to the field `name`. */ - final F::Identifier getName() { unified_operator_syntax_declaration_def(this, result) } + /** Gets the node corresponding to the field `name_node`. */ + final F::NameNode getNameNode() { unified_operator_syntax_declaration_def(this, result) } /** Gets the node corresponding to the field `precedence`. */ final F::Expr getPrecedence() { unified_operator_syntax_declaration_precedence(this, result) } @@ -1144,7 +1068,7 @@ module Unified { } /** A class representing `or_pattern` nodes. */ - class OrPattern extends @unified_or_pattern, F::Pattern { + class OrPattern extends @unified_or_pattern, F::Expr { /** Gets the name of the primary QL class for this element. */ final override string getAPrimaryQlClass() { result = "OrPattern" } @@ -1155,10 +1079,10 @@ module Unified { final F::Modifier getAModifier() { result = this.getModifier(_) } /** Gets the node corresponding to the field `pattern`. */ - final F::Pattern getPattern(int i) { unified_or_pattern_pattern(this, i, result) } + final F::Expr getPattern(int i) { unified_or_pattern_pattern(this, i, result) } /** Gets the node corresponding to the field `pattern`. */ - final F::Pattern getAPattern() { result = this.getPattern(_) } + final F::Expr getAPattern() { result = this.getPattern(_) } /** Gets a field or child node of this node. */ final override F::AstNode getAFieldOrChild() { @@ -1174,8 +1098,8 @@ module Unified { /** Gets the node corresponding to the field `default`. */ final F::Expr getDefault() { unified_parameter_default(this, result) } - /** Gets the node corresponding to the field `external_name`. */ - final F::Identifier getExternalName() { unified_parameter_external_name(this, result) } + /** Gets the node corresponding to the field `external_name_node`. */ + final F::NameNode getExternalNameNode() { unified_parameter_external_name_node(this, result) } /** Gets the node corresponding to the field `modifier`. */ final F::Modifier getModifier(int i) { unified_parameter_modifier(this, i, result) } @@ -1184,55 +1108,28 @@ module Unified { final F::Modifier getAModifier() { result = this.getModifier(_) } /** Gets the node corresponding to the field `pattern`. */ - final F::Pattern getPattern() { unified_parameter_pattern(this, result) } + final F::Expr getPattern() { unified_parameter_pattern(this, result) } /** Gets the node corresponding to the field `type`. */ - final F::TypeExpr getType() { unified_parameter_type(this, result) } + final F::Expr getType() { unified_parameter_type(this, result) } /** Gets a field or child node of this node. */ final override F::AstNode getAFieldOrChild() { unified_parameter_default(this, result) or - unified_parameter_external_name(this, result) or + unified_parameter_external_name_node(this, result) or unified_parameter_modifier(this, _, result) or unified_parameter_pattern(this, result) or unified_parameter_type(this, result) } } - class Pattern extends @unified_pattern, F::Expr { } - - /** A class representing `pattern_element` nodes. */ - class PatternElement extends @unified_pattern_element, F::AstNode { - /** Gets the name of the primary QL class for this element. */ - final override string getAPrimaryQlClass() { result = "PatternElement" } - - /** Gets the node corresponding to the field `key`. */ - final F::Identifier getKey() { unified_pattern_element_key(this, result) } - - /** Gets the node corresponding to the field `modifier`. */ - final F::Modifier getModifier(int i) { unified_pattern_element_modifier(this, i, result) } - - /** Gets the node corresponding to the field `modifier`. */ - final F::Modifier getAModifier() { result = this.getModifier(_) } - - /** Gets the node corresponding to the field `pattern`. */ - final F::Pattern getPattern() { unified_pattern_element_def(this, result) } - - /** Gets a field or child node of this node. */ - final override F::AstNode getAFieldOrChild() { - unified_pattern_element_key(this, result) or - unified_pattern_element_modifier(this, _, result) or - unified_pattern_element_def(this, result) - } - } - /** A class representing `pattern_guard_expr` nodes. */ class PatternGuardExpr extends @unified_pattern_guard_expr, F::Expr { /** Gets the name of the primary QL class for this element. */ final override string getAPrimaryQlClass() { result = "PatternGuardExpr" } /** Gets the node corresponding to the field `pattern`. */ - final F::Pattern getPattern() { unified_pattern_guard_expr_def(this, result, _) } + final F::Expr getPattern() { unified_pattern_guard_expr_def(this, result, _) } /** Gets the node corresponding to the field `value`. */ final F::Expr getValue() { unified_pattern_guard_expr_def(this, _, result) } @@ -1303,7 +1200,7 @@ module Unified { final F::Modifier getAModifier() { result = this.getModifier(_) } /** Gets the node corresponding to the field `pattern`. */ - final F::Pattern getPattern() { unified_switch_case_pattern(this, result) } + final F::Expr getPattern() { unified_switch_case_pattern(this, result) } /** Gets a field or child node of this node. */ final override F::AstNode getAFieldOrChild() { @@ -1399,73 +1296,15 @@ module Unified { final override string getAPrimaryQlClass() { result = "TupleExpr" } /** Gets the node corresponding to the field `element`. */ - final F::Expr getElement(int i) { unified_tuple_expr_element(this, i, result) } + final F::Argument getElement(int i) { unified_tuple_expr_element(this, i, result) } /** Gets the node corresponding to the field `element`. */ - final F::Expr getAnElement() { result = this.getElement(_) } + final F::Argument getAnElement() { result = this.getElement(_) } /** Gets a field or child node of this node. */ final override F::AstNode getAFieldOrChild() { unified_tuple_expr_element(this, _, result) } } - /** A class representing `tuple_pattern` nodes. */ - class TuplePattern extends @unified_tuple_pattern, F::Pattern { - /** Gets the name of the primary QL class for this element. */ - final override string getAPrimaryQlClass() { result = "TuplePattern" } - - /** Gets the node corresponding to the field `element`. */ - final F::PatternElement getElement(int i) { unified_tuple_pattern_element(this, i, result) } - - /** Gets the node corresponding to the field `element`. */ - final F::PatternElement getAnElement() { result = this.getElement(_) } - - /** Gets the node corresponding to the field `modifier`. */ - final F::Modifier getModifier(int i) { unified_tuple_pattern_modifier(this, i, result) } - - /** Gets the node corresponding to the field `modifier`. */ - final F::Modifier getAModifier() { result = this.getModifier(_) } - - /** Gets a field or child node of this node. */ - final override F::AstNode getAFieldOrChild() { - unified_tuple_pattern_element(this, _, result) or - unified_tuple_pattern_modifier(this, _, result) - } - } - - /** A class representing `tuple_type_element` nodes. */ - class TupleTypeElement extends @unified_tuple_type_element, F::AstNode { - /** Gets the name of the primary QL class for this element. */ - final override string getAPrimaryQlClass() { result = "TupleTypeElement" } - - /** Gets the node corresponding to the field `name`. */ - final F::Identifier getName() { unified_tuple_type_element_name(this, result) } - - /** Gets the node corresponding to the field `type`. */ - final F::TypeExpr getType() { unified_tuple_type_element_def(this, result) } - - /** Gets a field or child node of this node. */ - final override F::AstNode getAFieldOrChild() { - unified_tuple_type_element_name(this, result) or unified_tuple_type_element_def(this, result) - } - } - - /** A class representing `tuple_type_expr` nodes. */ - class TupleTypeExpr extends @unified_tuple_type_expr, F::TypeExpr { - /** Gets the name of the primary QL class for this element. */ - final override string getAPrimaryQlClass() { result = "TupleTypeExpr" } - - /** Gets the node corresponding to the field `element`. */ - final F::TupleTypeElement getElement(int i) { unified_tuple_type_expr_element(this, i, result) } - - /** Gets the node corresponding to the field `element`. */ - final F::TupleTypeElement getAnElement() { result = this.getElement(_) } - - /** Gets a field or child node of this node. */ - final override F::AstNode getAFieldOrChild() { - unified_tuple_type_expr_element(this, _, result) - } - } - /** A class representing `type_alias_declaration` nodes. */ class TypeAliasDeclaration extends @unified_type_alias_declaration, F::Member, F::Stmt { /** Gets the name of the primary QL class for this element. */ @@ -1479,11 +1318,11 @@ module Unified { /** Gets the node corresponding to the field `modifier`. */ final F::Modifier getAModifier() { result = this.getModifier(_) } - /** Gets the node corresponding to the field `name`. */ - final F::Identifier getName() { unified_type_alias_declaration_def(this, result, _) } + /** Gets the node corresponding to the field `name_node`. */ + final F::NameNode getNameNode() { unified_type_alias_declaration_def(this, result, _) } /** Gets the node corresponding to the field `type`. */ - final F::TypeExpr getType() { unified_type_alias_declaration_def(this, _, result) } + final F::Expr getType() { unified_type_alias_declaration_def(this, _, result) } /** Gets the node corresponding to the field `type_constraint`. */ final F::TypeConstraint getTypeConstraint(int i) { @@ -1523,7 +1362,7 @@ module Unified { final F::InfixOperator getOperator() { unified_type_cast_expr_def(this, _, result, _) } /** Gets the node corresponding to the field `type`. */ - final F::TypeExpr getType() { unified_type_cast_expr_def(this, _, _, result) } + final F::Expr getType() { unified_type_cast_expr_def(this, _, _, result) } /** Gets a field or child node of this node. */ final override F::AstNode getAFieldOrChild() { @@ -1535,15 +1374,13 @@ module Unified { class TypeConstraint extends @unified_type_constraint, F::AstNode { } - class TypeExpr extends @unified_type_expr, F::ExprOrType { } - /** A class representing `type_parameter` nodes. */ class TypeParameter extends @unified_type_parameter, F::AstNode { /** Gets the name of the primary QL class for this element. */ final override string getAPrimaryQlClass() { result = "TypeParameter" } /** Gets the node corresponding to the field `bound`. */ - final F::TypeExpr getBound() { unified_type_parameter_bound(this, result) } + final F::Expr getBound() { unified_type_parameter_bound(this, result) } /** Gets the node corresponding to the field `modifier`. */ final F::Modifier getModifier(int i) { unified_type_parameter_modifier(this, i, result) } @@ -1551,8 +1388,8 @@ module Unified { /** Gets the node corresponding to the field `modifier`. */ final F::Modifier getAModifier() { result = this.getModifier(_) } - /** Gets the node corresponding to the field `name`. */ - final F::Identifier getName() { unified_type_parameter_def(this, result) } + /** Gets the node corresponding to the field `name_node`. */ + final F::NameNode getNameNode() { unified_type_parameter_def(this, result) } /** Gets a field or child node of this node. */ final override F::AstNode getAFieldOrChild() { @@ -1568,37 +1405,19 @@ module Unified { final override string getAPrimaryQlClass() { result = "TypeTestExpr" } /** Gets the node corresponding to the field `expr`. */ - final F::Expr getExpr() { unified_type_test_expr_def(this, result, _, _) } + final F::Expr getExpr() { unified_type_test_expr_def(this, result, _) } /** Gets the node corresponding to the field `operator`. */ - final F::InfixOperator getOperator() { unified_type_test_expr_def(this, _, result, _) } - - /** Gets the node corresponding to the field `type`. */ - final F::TypeExpr getType() { unified_type_test_expr_def(this, _, _, result) } - - /** Gets a field or child node of this node. */ - final override F::AstNode getAFieldOrChild() { - unified_type_test_expr_def(this, result, _, _) or - unified_type_test_expr_def(this, _, result, _) or - unified_type_test_expr_def(this, _, _, result) - } - } - - /** A class representing `type_test_pattern` nodes. */ - class TypeTestPattern extends @unified_type_test_pattern, F::AstNode { - /** Gets the name of the primary QL class for this element. */ - final override string getAPrimaryQlClass() { result = "TypeTestPattern" } - - /** Gets the node corresponding to the field `pattern`. */ - final F::Pattern getPattern() { unified_type_test_pattern_def(this, result, _) } + final F::InfixOperator getOperator() { unified_type_test_expr_operator(this, result) } /** Gets the node corresponding to the field `type`. */ - final F::TypeExpr getType() { unified_type_test_pattern_def(this, _, result) } + final F::Expr getType() { unified_type_test_expr_def(this, _, result) } /** Gets a field or child node of this node. */ final override F::AstNode getAFieldOrChild() { - unified_type_test_pattern_def(this, result, _) or - unified_type_test_pattern_def(this, _, result) + unified_type_test_expr_def(this, result, _) or + unified_type_test_expr_operator(this, result) or + unified_type_test_expr_def(this, _, result) } } @@ -1639,9 +1458,7 @@ module Unified { } /** A class representing `unsupported_node` tokens. */ - class UnsupportedNode extends @unified_token_unsupported_node, F::Expr, F::Member, F::Pattern, - F::Token, F::TypeExpr - { + class UnsupportedNode extends @unified_token_unsupported_node, F::Expr, F::Member, F::Token { /** Gets the name of the primary QL class for this element. */ final override string getAPrimaryQlClass() { result = "UnsupportedNode" } } @@ -1658,10 +1475,10 @@ module Unified { final F::Modifier getAModifier() { result = this.getModifier(_) } /** Gets the node corresponding to the field `pattern`. */ - final F::Pattern getPattern() { unified_variable_declaration_def(this, result) } + final F::Expr getPattern() { unified_variable_declaration_def(this, result) } /** Gets the node corresponding to the field `type`. */ - final F::TypeExpr getType() { unified_variable_declaration_type(this, result) } + final F::Expr getType() { unified_variable_declaration_type(this, result) } /** Gets the node corresponding to the field `value`. */ final F::Expr getValue() { unified_variable_declaration_value(this, result) } @@ -1710,7 +1527,7 @@ module Unified { or result = node.(AccessorDeclaration).getModifier(i) and name = "getModifier" or - result = node.(AccessorDeclaration).getName() and i = -1 and name = "getName" + result = node.(AccessorDeclaration).getNameNode() and i = -1 and name = "getNameNode" or result = node.(AccessorDeclaration).getParameter(i) and name = "getParameter" or @@ -1718,7 +1535,7 @@ module Unified { or result = node.(Argument).getModifier(i) and name = "getModifier" or - result = node.(Argument).getName() and i = -1 and name = "getName" + result = node.(Argument).getNameNode() and i = -1 and name = "getNameNode" or result = node.(Argument).getValue() and i = -1 and name = "getValue" or @@ -1732,7 +1549,7 @@ module Unified { or result = node.(AssociatedTypeDeclaration).getModifier(i) and name = "getModifier" or - result = node.(AssociatedTypeDeclaration).getName() and i = -1 and name = "getName" + result = node.(AssociatedTypeDeclaration).getNameNode() and i = -1 and name = "getNameNode" or result = node.(BaseType).getModifier(i) and name = "getModifier" or @@ -1750,7 +1567,7 @@ module Unified { or result = node.(BoundTypeConstraint).getType() and i = -1 and name = "getType" or - result = node.(BreakExpr).getLabel() and i = -1 and name = "getLabel" + result = node.(BreakExpr).getLabelNameNode() and i = -1 and name = "getLabelNameNode" or result = node.(BulkImportingPattern).getModifier(i) and name = "getModifier" or @@ -1772,7 +1589,7 @@ module Unified { or result = node.(ClassLikeDeclaration).getModifier(i) and name = "getModifier" or - result = node.(ClassLikeDeclaration).getName() and i = -1 and name = "getName" + result = node.(ClassLikeDeclaration).getNameNode() and i = -1 and name = "getNameNode" or result = node.(ClassLikeDeclaration).getTypeConstraint(i) and name = "getTypeConstraint" or @@ -1794,17 +1611,11 @@ module Unified { or result = node.(ConstructorDeclaration).getModifier(i) and name = "getModifier" or - result = node.(ConstructorDeclaration).getName() and i = -1 and name = "getName" + result = node.(ConstructorDeclaration).getNameNode() and i = -1 and name = "getNameNode" or result = node.(ConstructorDeclaration).getParameter(i) and name = "getParameter" or - result = node.(ConstructorPattern).getConstructor() and i = -1 and name = "getConstructor" - or - result = node.(ConstructorPattern).getElement(i) and name = "getElement" - or - result = node.(ConstructorPattern).getModifier(i) and name = "getModifier" - or - result = node.(ContinueExpr).getLabel() and i = -1 and name = "getLabel" + result = node.(ContinueExpr).getLabelNameNode() and i = -1 and name = "getLabelNameNode" or result = node.(DestructorDeclaration).getBody() and i = -1 and name = "getBody" or @@ -1820,7 +1631,9 @@ module Unified { or result = node.(EqualityTypeConstraint).getRight() and i = -1 and name = "getRight" or - result = node.(ExprEqualityPattern).getExpr() and i = -1 and name = "getExpr" + result = node.(ExprPattern).getExpr() and i = -1 and name = "getExpr" + or + result = node.(ExprPattern).getModifier(i) and name = "getModifier" or result = node.(ForEachStmt).getBody() and i = -1 and name = "getBody" or @@ -1836,7 +1649,7 @@ module Unified { or result = node.(FunctionDeclaration).getModifier(i) and name = "getModifier" or - result = node.(FunctionDeclaration).getName() and i = -1 and name = "getName" + result = node.(FunctionDeclaration).getNameNode() and i = -1 and name = "getNameNode" or result = node.(FunctionDeclaration).getParameter(i) and name = "getParameter" or @@ -1856,10 +1669,6 @@ module Unified { or result = node.(FunctionExpr).getReturnType() and i = -1 and name = "getReturnType" or - result = node.(FunctionTypeExpr).getParameter(i) and name = "getParameter" - or - result = node.(FunctionTypeExpr).getReturnType() and i = -1 and name = "getReturnType" - or result = node.(GenericTypeExpr).getBase() and i = -1 and name = "getBase" or result = node.(GenericTypeExpr).getTypeArgument(i) and name = "getTypeArgument" @@ -1888,7 +1697,7 @@ module Unified { or result = node.(KeyValuePair).getValue() and i = -1 and name = "getValue" or - result = node.(LabeledStmt).getLabel() and i = -1 and name = "getLabel" + result = node.(LabeledStmt).getLabelNameNode() and i = -1 and name = "getLabelNameNode" or result = node.(LabeledStmt).getStmt() and i = -1 and name = "getStmt" or @@ -1896,25 +1705,19 @@ module Unified { or result = node.(MemberAccessExpr).getBase() and i = -1 and name = "getBase" or - result = node.(MemberAccessExpr).getMember() and i = -1 and name = "getMember" + result = node.(MemberAccessExpr).getMemberNameNode() and i = -1 and name = "getMemberNameNode" or - result = node.(NameExpr).getIdentifier() and i = -1 and name = "getIdentifier" + result = node.(NamedPattern).getModifier(i) and name = "getModifier" or - result = node.(NamePattern).getIdentifier() and i = -1 and name = "getIdentifier" + result = node.(NamedPattern).getNameNode() and i = -1 and name = "getNameNode" or - result = node.(NamePattern).getModifier(i) and name = "getModifier" - or - result = node.(NamePattern).getSubPattern() and i = -1 and name = "getSubPattern" - or - result = node.(NamedTypeExpr).getName() and i = -1 and name = "getName" - or - result = node.(NamedTypeExpr).getQualifier() and i = -1 and name = "getQualifier" + result = node.(NamedPattern).getSubPattern() and i = -1 and name = "getSubPattern" or result = node.(OperatorSyntaxDeclaration).getFixity() and i = -1 and name = "getFixity" or result = node.(OperatorSyntaxDeclaration).getModifier(i) and name = "getModifier" or - result = node.(OperatorSyntaxDeclaration).getName() and i = -1 and name = "getName" + result = node.(OperatorSyntaxDeclaration).getNameNode() and i = -1 and name = "getNameNode" or result = node.(OperatorSyntaxDeclaration).getPrecedence() and i = -1 and @@ -1926,7 +1729,7 @@ module Unified { or result = node.(Parameter).getDefault() and i = -1 and name = "getDefault" or - result = node.(Parameter).getExternalName() and i = -1 and name = "getExternalName" + result = node.(Parameter).getExternalNameNode() and i = -1 and name = "getExternalNameNode" or result = node.(Parameter).getModifier(i) and name = "getModifier" or @@ -1934,12 +1737,6 @@ module Unified { or result = node.(Parameter).getType() and i = -1 and name = "getType" or - result = node.(PatternElement).getKey() and i = -1 and name = "getKey" - or - result = node.(PatternElement).getModifier(i) and name = "getModifier" - or - result = node.(PatternElement).getPattern() and i = -1 and name = "getPattern" - or result = node.(PatternGuardExpr).getPattern() and i = -1 and name = "getPattern" or result = node.(PatternGuardExpr).getValue() and i = -1 and name = "getValue" @@ -1970,19 +1767,9 @@ module Unified { or result = node.(TupleExpr).getElement(i) and name = "getElement" or - result = node.(TuplePattern).getElement(i) and name = "getElement" - or - result = node.(TuplePattern).getModifier(i) and name = "getModifier" - or - result = node.(TupleTypeElement).getName() and i = -1 and name = "getName" - or - result = node.(TupleTypeElement).getType() and i = -1 and name = "getType" - or - result = node.(TupleTypeExpr).getElement(i) and name = "getElement" - or result = node.(TypeAliasDeclaration).getModifier(i) and name = "getModifier" or - result = node.(TypeAliasDeclaration).getName() and i = -1 and name = "getName" + result = node.(TypeAliasDeclaration).getNameNode() and i = -1 and name = "getNameNode" or result = node.(TypeAliasDeclaration).getType() and i = -1 and name = "getType" or @@ -2000,7 +1787,7 @@ module Unified { or result = node.(TypeParameter).getModifier(i) and name = "getModifier" or - result = node.(TypeParameter).getName() and i = -1 and name = "getName" + result = node.(TypeParameter).getNameNode() and i = -1 and name = "getNameNode" or result = node.(TypeTestExpr).getExpr() and i = -1 and name = "getExpr" or @@ -2008,10 +1795,6 @@ module Unified { or result = node.(TypeTestExpr).getType() and i = -1 and name = "getType" or - result = node.(TypeTestPattern).getPattern() and i = -1 and name = "getPattern" - or - result = node.(TypeTestPattern).getType() and i = -1 and name = "getType" - or result = node.(UnaryExpr).getOperand() and i = -1 and name = "getOperand" or result = node.(UnaryExpr).getOperator() and i = -1 and name = "getOperator" @@ -2087,8 +1870,6 @@ module UnifiedFinal { final class ConstructorDeclaration = F::ConstructorDeclaration; - final class ConstructorPattern = F::ConstructorPattern; - final class ContinueExpr = F::ContinueExpr; final class DestructorDeclaration = F::DestructorDeclaration; @@ -2101,11 +1882,9 @@ module UnifiedFinal { final class Expr = F::Expr; - final class ExprEqualityPattern = F::ExprEqualityPattern; - final class ExprOrOperator = F::ExprOrOperator; - final class ExprOrType = F::ExprOrType; + final class ExprPattern = F::ExprPattern; final class Fixity = F::Fixity; @@ -2117,18 +1896,12 @@ module UnifiedFinal { final class FunctionExpr = F::FunctionExpr; - final class FunctionTypeExpr = F::FunctionTypeExpr; - final class GenericTypeExpr = F::GenericTypeExpr; final class GuardIfStmt = F::GuardIfStmt; - final class Identifier = F::Identifier; - final class IfExpr = F::IfExpr; - final class IgnorePattern = F::IgnorePattern; - final class ImportDeclaration = F::ImportDeclaration; final class InferredTypeExpr = F::InferredTypeExpr; @@ -2151,11 +1924,9 @@ module UnifiedFinal { final class Modifier = F::Modifier; - final class NameExpr = F::NameExpr; - - final class NamePattern = F::NamePattern; + final class NameNode = F::NameNode; - final class NamedTypeExpr = F::NamedTypeExpr; + final class NamedPattern = F::NamedPattern; final class Operator = F::Operator; @@ -2165,10 +1936,6 @@ module UnifiedFinal { final class Parameter = F::Parameter; - final class Pattern = F::Pattern; - - final class PatternElement = F::PatternElement; - final class PatternGuardExpr = F::PatternGuardExpr; final class PostfixOperator = F::PostfixOperator; @@ -2197,26 +1964,16 @@ module UnifiedFinal { final class TupleExpr = F::TupleExpr; - final class TuplePattern = F::TuplePattern; - - final class TupleTypeElement = F::TupleTypeElement; - - final class TupleTypeExpr = F::TupleTypeExpr; - final class TypeAliasDeclaration = F::TypeAliasDeclaration; final class TypeCastExpr = F::TypeCastExpr; final class TypeConstraint = F::TypeConstraint; - final class TypeExpr = F::TypeExpr; - final class TypeParameter = F::TypeParameter; final class TypeTestExpr = F::TypeTestExpr; - final class TypeTestPattern = F::TypeTestPattern; - final class UnaryExpr = F::UnaryExpr; final class UnresolvedOperatorSequence = F::UnresolvedOperatorSequence; diff --git a/unified/ql/lib/codeql/unified/internal/ControlFlowGraph.qll b/unified/ql/lib/codeql/unified/internal/ControlFlowGraph.qll index 15db0eb3836e..4d7c6a9dea83 100644 --- a/unified/ql/lib/codeql/unified/internal/ControlFlowGraph.qll +++ b/unified/ql/lib/codeql/unified/internal/ControlFlowGraph.qll @@ -25,7 +25,7 @@ private module Ast implements AstSig { class AstNode = U::AstNode; - private predicate skipControlFlow(AstNode e) { e instanceof Modifier or e instanceof Identifier } + private predicate skipControlFlow(AstNode e) { e instanceof Modifier or e instanceof NameNode } AstNode getChild(AstNode n, int index) { result.getParent() = n and @@ -128,7 +128,6 @@ private module Ast implements AstSig { // TODO support foreach guard // - // TODO: Expr != Pattern Expr getVariable() { result = super.getPattern() } Expr getCollection() { result = super.getIterable() } @@ -240,9 +239,9 @@ private module Input implements InputSig1, InputSig2 { class Label extends string { Label() { - any(LabeledStmt l).getLabel().getValue() = this or - any(BreakExpr b).getLabel().getValue() = this or - any(ContinueExpr c).getLabel().getValue() = this + any(LabeledStmt l).getLabelName() = this or + any(BreakExpr b).getLabelName() = this or + any(ContinueExpr c).getLabelName() = this } string toString() { result = this } @@ -250,7 +249,7 @@ private module Input implements InputSig1, InputSig2 { private Label getLabelOfStmt(Stmt s) { exists(LabeledStmt l | s = l.getStmt() | - result = l.getLabel().getValue() or + result = l.getLabelName() or result = getLabelOfStmt(l) ) } @@ -258,9 +257,9 @@ private module Input implements InputSig1, InputSig2 { predicate hasLabel(Ast::AstNode n, Label l) { l = getLabelOfStmt(n) or - l = n.(BreakExpr).getLabel().getValue() + l = n.(BreakExpr).getLabelName() or - l = n.(ContinueExpr).getLabel().getValue() + l = n.(ContinueExpr).getLabelName() } class CallableContext = Void; diff --git a/unified/ql/lib/codeql/unified/internal/FacadeAst.qll b/unified/ql/lib/codeql/unified/internal/FacadeAst.qll index 3da8de4b8f03..dcec57f0a4ae 100644 --- a/unified/ql/lib/codeql/unified/internal/FacadeAst.qll +++ b/unified/ql/lib/codeql/unified/internal/FacadeAst.qll @@ -55,6 +55,89 @@ module Unified { // just strip the quotes here and ignore escape sequences. result = this.(StringLiteral).getValue().regexpCapture("\"(.*)\"", 1) } + + /** Gets the immediately-enclosing expression, skipping over intermediate sub-nodes like `Argument`, and without crossing a function boundary. */ + Expr getEnclosingExpr() { + result = this.getParent() and + not result instanceof Callable + or + result = this.getParent().(Argument).getParent() + } + } + + class AccessorDeclaration extends G::AccessorDeclaration { + /** Gets the name of this accessor. */ + string getName() { result = this.getNameNode().getValue() } + } + + class Argument extends G::Argument { + /** Gets the name of this argument. */ + string getName() { result = this.getNameNode().getValue() } + } + + class AssociatedTypeDeclaration extends G::AssociatedTypeDeclaration { + /** Gets the name of this associated type. */ + string getName() { result = this.getNameNode().getValue() } + } + + class BreakExpr extends G::BreakExpr { + /** Gets the label name targeted by this break. */ + string getLabelName() { result = this.getLabelNameNode().getValue() } + } + + class ClassLikeDeclaration extends G::ClassLikeDeclaration { + /** Gets the name of this declaration. */ + string getName() { result = this.getNameNode().getValue() } + } + + class ConstructorDeclaration extends G::ConstructorDeclaration { + /** Gets the name of this constructor. */ + string getName() { result = this.getNameNode().getValue() } + } + + class ContinueExpr extends G::ContinueExpr { + /** Gets the label name targeted by this continue. */ + string getLabelName() { result = this.getLabelNameNode().getValue() } + } + + class FunctionDeclaration extends G::FunctionDeclaration { + /** Gets the name of this function. */ + string getName() { result = this.getNameNode().getValue() } + } + + class LabeledStmt extends G::LabeledStmt { + /** Gets the label name of this statement. */ + string getLabelName() { result = this.getLabelNameNode().getValue() } + } + + class MemberAccessExpr extends G::MemberAccessExpr { + /** Gets the member name of this access. */ + string getMemberName() { result = this.getMemberNameNode().getValue() } + } + + class NamedPattern extends G::NamedPattern { + /** Gets the name bound by this pattern. */ + string getName() { result = this.getNameNode().getValue() } + } + + class OperatorSyntaxDeclaration extends G::OperatorSyntaxDeclaration { + /** Gets the name of this operator. */ + string getName() { result = this.getNameNode().getValue() } + } + + class Parameter extends G::Parameter { + /** Gets the external name of this parameter. */ + string getExternalName() { result = this.getExternalNameNode().getValue() } + } + + class TypeAliasDeclaration extends G::TypeAliasDeclaration { + /** Gets the name of this type alias. */ + string getName() { result = this.getNameNode().getValue() } + } + + class TypeParameter extends G::TypeParameter { + /** Gets the name of this type parameter. */ + string getName() { result = this.getNameNode().getValue() } } /** A binary expression. */ @@ -69,19 +152,9 @@ module Unified { Expr getNamedArgument(string name) { exists(Argument arg | arg = this.getAnArgument() and - arg.getName().getValue() = name and + arg.getName() = name and result = arg.getValue() ) } } - - /** The base class for all patterns. */ - class Pattern extends G::Pattern { - /** Gets the immediately-enclosing pattern in which this is a nested pattern. */ - Pattern getEnclosingPattern() { - result = this.getParent() - or - result = this.getParent().(PatternElement).getParent() - } - } } diff --git a/unified/ql/lib/codeql/unified/internal/LocalNameBinding.qll b/unified/ql/lib/codeql/unified/internal/LocalNameBinding.qll index 5a44080464cc..110b9929f520 100644 --- a/unified/ql/lib/codeql/unified/internal/LocalNameBinding.qll +++ b/unified/ql/lib/codeql/unified/internal/LocalNameBinding.qll @@ -5,6 +5,7 @@ private import unified private import unified as U private import codeql.namebinding.LocalNameBinding +private import codeql.unified.internal.NameBindingPlugin private module LocalNameBindingInput implements LocalNameBindingInputSig { class AstNode = U::AstNode; @@ -99,9 +100,9 @@ private module LocalNameBindingInput implements LocalNameBindingInputSig; */ predicate isTrivialNameAlias(NameDeclaration decl) { exists(ImportDeclaration imprt | - decl = getIdentifierFromRef(imprt.getPattern()) and - decl.getName() = getIdentifierFromRef(imprt.getImportedExpr()).getValue() + decl = getImportBindingNameNode(imprt) and + decl.getName() = getNameNodeFromRef(imprt.getImportedExpr()).getValue() ) } private module TrackNameDeclarationInput implements TrackInputSig { predicate shouldTrack(NameBindingNode node) { exists(NameDeclaration decl | - node.isIdentifier(decl) and + node.isNameNode(decl) and not isTrivialNameAlias(decl) ) } @@ -418,7 +428,7 @@ private module TrackNameDeclaration = Track; /** Gets a name-binding node that may refer to the given declaration. */ NameBindingNode trackNameDeclaration(NameDeclaration decl) { exists(NameBindingNode start | - start.isIdentifier(decl) and + start.isNameNode(decl) and result = TrackNameDeclaration::track(start) ) } @@ -479,7 +489,7 @@ private module FolderHeuristic { not isPrivateToLocalScope(nameDecl) and nameDecl.getDeclaration() = stmt and name = nameDecl.getName() and - node.isIdentifier(nameDecl) + node.isNameNode(nameDecl) ) } @@ -591,11 +601,11 @@ private predicate unqualifiedMemberAccessCand( | instanceAccess = true and namespace.isInstanceMemberNamespace(accessingClass) and - namespace.getMember(name).isIdentifier(target) + namespace.getMember(name).isNameNode(target) or instanceAccess = false and namespace.isStaticMemberNamespace(accessingClass) and - namespace.getMember(name).isIdentifier(target) + namespace.getMember(name).isNameNode(target) ) ) } @@ -619,9 +629,9 @@ predicate unqualifiedMemberAccess( } /** - * An identifier appearing in a unqualified position, referring to a member of an enclosing class. + * A name node appearing in an unqualified position, referring to a member of an enclosing class. */ -class UnqualifiedMemberAccess extends Identifier { +class UnqualifiedMemberAccess extends NameNode { private boolean instanceAccess; private NameDeclaration target; private ClassLikeDeclaration accessingClass; @@ -641,11 +651,11 @@ class UnqualifiedMemberAccess extends Identifier { } /** Gets the declaration being accessed by `access`, as determined by static name binding. */ -NameDeclaration getStaticBindingTarget(Identifier access) { +NameDeclaration getStaticBindingTarget(NameNode access) { // For unqualified accesses, use the shadowing-aware lookup result = access.(UnqualifiedMemberAccess).getTarget() or // For others, just follow the name binding graph not access instanceof UnqualifiedMemberAccess and - trackNameDeclaration(result).asIdentifier() = access + trackNameDeclaration(result).asNameNode() = access } diff --git a/unified/ql/lib/ide-contextual-queries/definitions.ql b/unified/ql/lib/ide-contextual-queries/definitions.ql index f72c91bcd9dd..33afc93f0cf0 100644 --- a/unified/ql/lib/ide-contextual-queries/definitions.ql +++ b/unified/ql/lib/ide-contextual-queries/definitions.ql @@ -13,7 +13,7 @@ import unified external string selectedSourceFile(); -from Identifier reference, NameDeclaration definition, string kind +from NameNode reference, NameDeclaration definition, string kind where definitionOf(reference, definition, kind) and reference.getLocation().getFile() = getFileBySourceArchiveName(selectedSourceFile()) diff --git a/unified/ql/lib/unified.dbscheme b/unified/ql/lib/unified.dbscheme index 56312bb69d2c..70718e26d7fe 100644 --- a/unified/ql/lib/unified.dbscheme +++ b/unified/ql/lib/unified.dbscheme @@ -157,13 +157,13 @@ unified_accessor_declaration_parameter( unified_accessor_declaration_type( unique int unified_accessor_declaration: @unified_accessor_declaration ref, - unique int type__: @unified_type_expr ref + unique int type__: @unified_expr ref ); unified_accessor_declaration_def( unique int id: @unified_accessor_declaration, int accessor_kind: @unified_token_accessor_kind ref, - int name: @unified_token_identifier ref + int name_node: @unified_token_name_node ref ); #keyset[unified_argument, index] @@ -173,9 +173,9 @@ unified_argument_modifier( unique int modifier: @unified_token_modifier ref ); -unified_argument_name( +unified_argument_name_node( unique int unified_argument: @unified_argument ref, - unique int name: @unified_token_identifier ref + unique int name_node: @unified_token_name_node ref ); unified_argument_def( @@ -202,7 +202,7 @@ unified_assign_expr_def( unified_associated_type_declaration_bound( unique int unified_associated_type_declaration: @unified_associated_type_declaration ref, - unique int bound: @unified_type_expr ref + unique int bound: @unified_expr ref ); #keyset[unified_associated_type_declaration, index] @@ -214,7 +214,7 @@ unified_associated_type_declaration_modifier( unified_associated_type_declaration_def( unique int id: @unified_associated_type_declaration, - int name: @unified_token_identifier ref + int name_node: @unified_token_name_node ref ); #keyset[unified_base_type, index] @@ -226,7 +226,7 @@ unified_base_type_modifier( unified_base_type_def( unique int id: @unified_base_type, - int type__: @unified_type_expr ref + int type__: @unified_expr ref ); unified_binary_expr_def( @@ -249,13 +249,13 @@ unified_block_def( unified_bound_type_constraint_def( unique int id: @unified_bound_type_constraint, - int bound: @unified_type_expr ref, - int type__: @unified_type_expr ref + int bound: @unified_expr ref, + int type__: @unified_expr ref ); -unified_break_expr_label( +unified_break_expr_label_name_node( unique int unified_break_expr: @unified_break_expr ref, - unique int label: @unified_token_identifier ref + unique int label_name_node: @unified_token_name_node ref ); unified_break_expr_def( @@ -289,7 +289,7 @@ unified_call_expr_modifier( unified_call_expr_def( unique int id: @unified_call_expr, - int callee: @unified_expr_or_type ref + int callee: @unified_expr ref ); @unified_callable = @unified_accessor_declaration | @unified_constructor_declaration | @unified_destructor_declaration | @unified_function_declaration | @unified_function_expr | @unified_initializer_declaration | @unified_top_level @@ -303,7 +303,7 @@ unified_catch_clause_modifier( unified_catch_clause_pattern( unique int unified_catch_clause: @unified_catch_clause ref, - unique int pattern: @unified_pattern ref + unique int pattern: @unified_expr ref ); unified_catch_clause_def( @@ -332,9 +332,9 @@ unified_class_like_declaration_modifier( unique int modifier: @unified_token_modifier ref ); -unified_class_like_declaration_name( +unified_class_like_declaration_name_node( unique int unified_class_like_declaration: @unified_class_like_declaration ref, - unique int name: @unified_token_identifier ref + unique int name_node: @unified_token_name_node ref ); #keyset[unified_class_like_declaration, index] @@ -372,7 +372,7 @@ unified_conditional_pattern_modifier( unified_conditional_pattern_def( unique int id: @unified_conditional_pattern, int condition: @unified_expr ref, - int pattern: @unified_pattern ref + int pattern: @unified_expr ref ); #keyset[unified_constructor_declaration, index] @@ -382,9 +382,9 @@ unified_constructor_declaration_modifier( unique int modifier: @unified_token_modifier ref ); -unified_constructor_declaration_name( +unified_constructor_declaration_name_node( unique int unified_constructor_declaration: @unified_constructor_declaration ref, - unique int name: @unified_token_identifier ref + unique int name_node: @unified_token_name_node ref ); #keyset[unified_constructor_declaration, index] @@ -399,28 +399,9 @@ unified_constructor_declaration_def( int body: @unified_block ref ); -#keyset[unified_constructor_pattern, index] -unified_constructor_pattern_element( - int unified_constructor_pattern: @unified_constructor_pattern ref, - int index: int ref, - unique int element: @unified_pattern_element ref -); - -#keyset[unified_constructor_pattern, index] -unified_constructor_pattern_modifier( - int unified_constructor_pattern: @unified_constructor_pattern ref, - int index: int ref, - unique int modifier: @unified_token_modifier ref -); - -unified_constructor_pattern_def( - unique int id: @unified_constructor_pattern, - int constructor: @unified_expr_or_type ref -); - -unified_continue_expr_label( +unified_continue_expr_label_name_node( unique int unified_continue_expr: @unified_continue_expr ref, - unique int label: @unified_token_identifier ref + unique int label_name_node: @unified_token_name_node ref ); unified_continue_expr_def( @@ -458,20 +439,25 @@ unified_do_while_stmt_def( unified_equality_type_constraint_def( unique int id: @unified_equality_type_constraint, - int left: @unified_type_expr ref, - int right: @unified_type_expr ref + int left: @unified_expr ref, + int right: @unified_expr ref ); -@unified_expr = @unified_array_literal | @unified_assign_expr | @unified_binary_expr | @unified_block | @unified_break_expr | @unified_call_expr | @unified_compound_assign_expr | @unified_continue_expr | @unified_function_expr | @unified_if_expr | @unified_key_value_pair | @unified_map_literal | @unified_member_access_expr | @unified_name_expr | @unified_pattern | @unified_pattern_guard_expr | @unified_return_expr | @unified_switch_expr | @unified_throw_expr | @unified_token_boolean_literal | @unified_token_builtin_expr | @unified_token_empty_expr | @unified_token_float_literal | @unified_token_int_literal | @unified_token_regex_literal | @unified_token_string_literal | @unified_token_super_expr | @unified_token_unsupported_node | @unified_try_expr | @unified_tuple_expr | @unified_type_cast_expr | @unified_type_test_expr | @unified_unary_expr | @unified_unresolved_operator_sequence - -unified_expr_equality_pattern_def( - unique int id: @unified_expr_equality_pattern, - int expr: @unified_expr ref -); +@unified_expr = @unified_array_literal | @unified_assign_expr | @unified_binary_expr | @unified_block | @unified_break_expr | @unified_bulk_importing_pattern | @unified_call_expr | @unified_compound_assign_expr | @unified_conditional_pattern | @unified_continue_expr | @unified_expr_pattern | @unified_function_expr | @unified_generic_type_expr | @unified_if_expr | @unified_key_value_pair | @unified_map_literal | @unified_member_access_expr | @unified_named_pattern | @unified_or_pattern | @unified_pattern_guard_expr | @unified_return_expr | @unified_switch_expr | @unified_throw_expr | @unified_token_boolean_literal | @unified_token_builtin_expr | @unified_token_empty_expr | @unified_token_float_literal | @unified_token_inferred_type_expr | @unified_token_int_literal | @unified_token_name_node | @unified_token_regex_literal | @unified_token_string_literal | @unified_token_super_expr | @unified_token_unsupported_node | @unified_try_expr | @unified_tuple_expr | @unified_type_cast_expr | @unified_type_test_expr | @unified_unary_expr | @unified_unresolved_operator_sequence @unified_expr_or_operator = @unified_expr | @unified_token_infix_operator -@unified_expr_or_type = @unified_expr | @unified_type_expr +#keyset[unified_expr_pattern, index] +unified_expr_pattern_modifier( + int unified_expr_pattern: @unified_expr_pattern ref, + int index: int ref, + unique int modifier: @unified_token_modifier ref +); + +unified_expr_pattern_def( + unique int id: @unified_expr_pattern, + int expr: @unified_expr ref +); unified_for_each_stmt_body( unique int unified_for_each_stmt: @unified_for_each_stmt ref, @@ -493,7 +479,7 @@ unified_for_each_stmt_modifier( unified_for_each_stmt_def( unique int id: @unified_for_each_stmt, int iterable: @unified_expr ref, - int pattern: @unified_pattern ref + int pattern: @unified_expr ref ); unified_function_declaration_body( @@ -517,7 +503,7 @@ unified_function_declaration_parameter( unified_function_declaration_return_type( unique int unified_function_declaration: @unified_function_declaration ref, - unique int return_type: @unified_type_expr ref + unique int return_type: @unified_expr ref ); #keyset[unified_function_declaration, index] @@ -536,7 +522,12 @@ unified_function_declaration_type_parameter( unified_function_declaration_def( unique int id: @unified_function_declaration, - int name: @unified_token_identifier ref + int name_node: @unified_token_name_node ref +); + +unified_function_expr_body( + unique int unified_function_expr: @unified_function_expr ref, + unique int body: @unified_block ref ); #keyset[unified_function_expr, index] @@ -562,36 +553,23 @@ unified_function_expr_parameter( unified_function_expr_return_type( unique int unified_function_expr: @unified_function_expr ref, - unique int return_type: @unified_type_expr ref + unique int return_type: @unified_expr ref ); unified_function_expr_def( - unique int id: @unified_function_expr, - int body: @unified_block ref -); - -#keyset[unified_function_type_expr, index] -unified_function_type_expr_parameter( - int unified_function_type_expr: @unified_function_type_expr ref, - int index: int ref, - unique int parameter: @unified_parameter ref -); - -unified_function_type_expr_def( - unique int id: @unified_function_type_expr, - int return_type: @unified_type_expr ref + unique int id: @unified_function_expr ); #keyset[unified_generic_type_expr, index] unified_generic_type_expr_type_argument( int unified_generic_type_expr: @unified_generic_type_expr ref, int index: int ref, - unique int type_argument: @unified_type_expr ref + unique int type_argument: @unified_expr ref ); unified_generic_type_expr_def( unique int id: @unified_generic_type_expr, - int base: @unified_type_expr ref + int base: @unified_expr ref ); unified_guard_if_stmt_def( @@ -624,7 +602,7 @@ unified_import_declaration_modifier( unified_import_declaration_pattern( unique int unified_import_declaration: @unified_import_declaration ref, - unique int pattern: @unified_pattern ref + unique int pattern: @unified_expr ref ); unified_import_declaration_def( @@ -652,7 +630,7 @@ unified_key_value_pair_def( unified_labeled_stmt_def( unique int id: @unified_labeled_stmt, - int label: @unified_token_identifier ref, + int label_name_node: @unified_token_name_node ref, int stmt: @unified_stmt ref ); @@ -671,40 +649,21 @@ unified_map_literal_def( unified_member_access_expr_def( unique int id: @unified_member_access_expr, - int base: @unified_expr_or_type ref, - int member: @unified_token_identifier ref -); - -unified_name_expr_def( - unique int id: @unified_name_expr, - int identifier: @unified_token_identifier ref + int base: @unified_expr ref, + int member_name_node: @unified_token_name_node ref ); -#keyset[unified_name_pattern, index] -unified_name_pattern_modifier( - int unified_name_pattern: @unified_name_pattern ref, +#keyset[unified_named_pattern, index] +unified_named_pattern_modifier( + int unified_named_pattern: @unified_named_pattern ref, int index: int ref, unique int modifier: @unified_token_modifier ref ); -unified_name_pattern_sub_pattern( - unique int unified_name_pattern: @unified_name_pattern ref, - unique int sub_pattern: @unified_pattern ref -); - -unified_name_pattern_def( - unique int id: @unified_name_pattern, - int identifier: @unified_token_identifier ref -); - -unified_named_type_expr_qualifier( - unique int unified_named_type_expr: @unified_named_type_expr ref, - unique int qualifier: @unified_type_expr ref -); - -unified_named_type_expr_def( - unique int id: @unified_named_type_expr, - int name: @unified_token_identifier ref +unified_named_pattern_def( + unique int id: @unified_named_pattern, + int name_node: @unified_token_name_node ref, + int sub_pattern: @unified_expr ref ); @unified_operator = @unified_token_infix_operator | @unified_token_postfix_operator | @unified_token_prefix_operator @@ -728,7 +687,7 @@ unified_operator_syntax_declaration_precedence( unified_operator_syntax_declaration_def( unique int id: @unified_operator_syntax_declaration, - int name: @unified_token_identifier ref + int name_node: @unified_token_name_node ref ); #keyset[unified_or_pattern, index] @@ -742,7 +701,7 @@ unified_or_pattern_modifier( unified_or_pattern_pattern( int unified_or_pattern: @unified_or_pattern ref, int index: int ref, - unique int pattern: @unified_pattern ref + unique int pattern: @unified_expr ref ); unified_or_pattern_def( @@ -754,9 +713,9 @@ unified_parameter_default( unique int default: @unified_expr ref ); -unified_parameter_external_name( +unified_parameter_external_name_node( unique int unified_parameter: @unified_parameter ref, - unique int external_name: @unified_token_identifier ref + unique int external_name_node: @unified_token_name_node ref ); #keyset[unified_parameter, index] @@ -768,40 +727,21 @@ unified_parameter_modifier( unified_parameter_pattern( unique int unified_parameter: @unified_parameter ref, - unique int pattern: @unified_pattern ref + unique int pattern: @unified_expr ref ); unified_parameter_type( unique int unified_parameter: @unified_parameter ref, - unique int type__: @unified_type_expr ref + unique int type__: @unified_expr ref ); unified_parameter_def( unique int id: @unified_parameter ); -@unified_pattern = @unified_bulk_importing_pattern | @unified_conditional_pattern | @unified_constructor_pattern | @unified_expr_equality_pattern | @unified_name_pattern | @unified_or_pattern | @unified_token_ignore_pattern | @unified_token_unsupported_node | @unified_tuple_pattern - -unified_pattern_element_key( - unique int unified_pattern_element: @unified_pattern_element ref, - unique int key__: @unified_token_identifier ref -); - -#keyset[unified_pattern_element, index] -unified_pattern_element_modifier( - int unified_pattern_element: @unified_pattern_element ref, - int index: int ref, - unique int modifier: @unified_token_modifier ref -); - -unified_pattern_element_def( - unique int id: @unified_pattern_element, - int pattern: @unified_pattern ref -); - unified_pattern_guard_expr_def( unique int id: @unified_pattern_guard_expr, - int pattern: @unified_pattern ref, + int pattern: @unified_expr ref, int value: @unified_expr ref ); @@ -825,7 +765,7 @@ unified_switch_case_modifier( unified_switch_case_pattern( unique int unified_switch_case: @unified_switch_case ref, - unique int pattern: @unified_pattern ref + unique int pattern: @unified_expr ref ); unified_switch_case_def( @@ -889,52 +829,13 @@ unified_try_expr_def( unified_tuple_expr_element( int unified_tuple_expr: @unified_tuple_expr ref, int index: int ref, - unique int element: @unified_expr ref + unique int element: @unified_argument ref ); unified_tuple_expr_def( unique int id: @unified_tuple_expr ); -#keyset[unified_tuple_pattern, index] -unified_tuple_pattern_element( - int unified_tuple_pattern: @unified_tuple_pattern ref, - int index: int ref, - unique int element: @unified_pattern_element ref -); - -#keyset[unified_tuple_pattern, index] -unified_tuple_pattern_modifier( - int unified_tuple_pattern: @unified_tuple_pattern ref, - int index: int ref, - unique int modifier: @unified_token_modifier ref -); - -unified_tuple_pattern_def( - unique int id: @unified_tuple_pattern -); - -unified_tuple_type_element_name( - unique int unified_tuple_type_element: @unified_tuple_type_element ref, - unique int name: @unified_token_identifier ref -); - -unified_tuple_type_element_def( - unique int id: @unified_tuple_type_element, - int type__: @unified_type_expr ref -); - -#keyset[unified_tuple_type_expr, index] -unified_tuple_type_expr_element( - int unified_tuple_type_expr: @unified_tuple_type_expr ref, - int index: int ref, - unique int element: @unified_tuple_type_element ref -); - -unified_tuple_type_expr_def( - unique int id: @unified_tuple_type_expr -); - #keyset[unified_type_alias_declaration, index] unified_type_alias_declaration_modifier( int unified_type_alias_declaration: @unified_type_alias_declaration ref, @@ -958,24 +859,22 @@ unified_type_alias_declaration_type_parameter( unified_type_alias_declaration_def( unique int id: @unified_type_alias_declaration, - int name: @unified_token_identifier ref, - int type__: @unified_type_expr ref + int name_node: @unified_token_name_node ref, + int type__: @unified_expr ref ); unified_type_cast_expr_def( unique int id: @unified_type_cast_expr, int expr: @unified_expr ref, int operator: @unified_token_infix_operator ref, - int type__: @unified_type_expr ref + int type__: @unified_expr ref ); @unified_type_constraint = @unified_bound_type_constraint | @unified_equality_type_constraint -@unified_type_expr = @unified_function_type_expr | @unified_generic_type_expr | @unified_named_type_expr | @unified_token_inferred_type_expr | @unified_token_unsupported_node | @unified_tuple_type_expr - unified_type_parameter_bound( unique int unified_type_parameter: @unified_type_parameter ref, - unique int bound: @unified_type_expr ref + unique int bound: @unified_expr ref ); #keyset[unified_type_parameter, index] @@ -987,20 +886,18 @@ unified_type_parameter_modifier( unified_type_parameter_def( unique int id: @unified_type_parameter, - int name: @unified_token_identifier ref + int name_node: @unified_token_name_node ref +); + +unified_type_test_expr_operator( + unique int unified_type_test_expr: @unified_type_test_expr ref, + unique int operator: @unified_token_infix_operator ref ); unified_type_test_expr_def( unique int id: @unified_type_test_expr, int expr: @unified_expr ref, - int operator: @unified_token_infix_operator ref, - int type__: @unified_type_expr ref -); - -unified_type_test_pattern_def( - unique int id: @unified_type_test_pattern, - int pattern: @unified_pattern ref, - int type__: @unified_type_expr ref + int type__: @unified_expr ref ); unified_unary_expr_def( @@ -1029,7 +926,7 @@ unified_variable_declaration_modifier( unified_variable_declaration_type( unique int unified_variable_declaration: @unified_variable_declaration ref, - unique int type__: @unified_type_expr ref + unique int type__: @unified_expr ref ); unified_variable_declaration_value( @@ -1039,7 +936,7 @@ unified_variable_declaration_value( unified_variable_declaration_def( unique int id: @unified_variable_declaration, - int pattern: @unified_pattern ref + int pattern: @unified_expr ref ); unified_while_stmt_body( @@ -1072,18 +969,17 @@ case @unified_token.kind of | 4 = @unified_token_empty_expr | 5 = @unified_token_fixity | 6 = @unified_token_float_literal -| 7 = @unified_token_identifier -| 8 = @unified_token_ignore_pattern -| 9 = @unified_token_inferred_type_expr -| 10 = @unified_token_infix_operator -| 11 = @unified_token_int_literal -| 12 = @unified_token_modifier -| 13 = @unified_token_postfix_operator -| 14 = @unified_token_prefix_operator -| 15 = @unified_token_regex_literal -| 16 = @unified_token_string_literal -| 17 = @unified_token_super_expr -| 18 = @unified_token_unsupported_node +| 7 = @unified_token_inferred_type_expr +| 8 = @unified_token_infix_operator +| 9 = @unified_token_int_literal +| 10 = @unified_token_modifier +| 11 = @unified_token_name_node +| 12 = @unified_token_postfix_operator +| 13 = @unified_token_prefix_operator +| 14 = @unified_token_regex_literal +| 15 = @unified_token_string_literal +| 16 = @unified_token_super_expr +| 17 = @unified_token_unsupported_node ; @@ -1093,7 +989,7 @@ unified_trivia_tokeninfo( string value: string ref ); -@unified_ast_node = @unified_accessor_declaration | @unified_argument | @unified_array_literal | @unified_assign_expr | @unified_associated_type_declaration | @unified_base_type | @unified_binary_expr | @unified_block | @unified_bound_type_constraint | @unified_break_expr | @unified_bulk_importing_pattern | @unified_call_expr | @unified_catch_clause | @unified_class_like_declaration | @unified_compound_assign_expr | @unified_conditional_pattern | @unified_constructor_declaration | @unified_constructor_pattern | @unified_continue_expr | @unified_destructor_declaration | @unified_do_while_stmt | @unified_equality_type_constraint | @unified_expr_equality_pattern | @unified_for_each_stmt | @unified_function_declaration | @unified_function_expr | @unified_function_type_expr | @unified_generic_type_expr | @unified_guard_if_stmt | @unified_if_expr | @unified_import_declaration | @unified_initializer_declaration | @unified_key_value_pair | @unified_labeled_stmt | @unified_map_literal | @unified_member_access_expr | @unified_name_expr | @unified_name_pattern | @unified_named_type_expr | @unified_operator_syntax_declaration | @unified_or_pattern | @unified_parameter | @unified_pattern_element | @unified_pattern_guard_expr | @unified_return_expr | @unified_switch_case | @unified_switch_expr | @unified_throw_expr | @unified_token | @unified_top_level | @unified_trivia_token | @unified_try_expr | @unified_tuple_expr | @unified_tuple_pattern | @unified_tuple_type_element | @unified_tuple_type_expr | @unified_type_alias_declaration | @unified_type_cast_expr | @unified_type_parameter | @unified_type_test_expr | @unified_type_test_pattern | @unified_unary_expr | @unified_unresolved_operator_sequence | @unified_variable_declaration | @unified_while_stmt +@unified_ast_node = @unified_accessor_declaration | @unified_argument | @unified_array_literal | @unified_assign_expr | @unified_associated_type_declaration | @unified_base_type | @unified_binary_expr | @unified_block | @unified_bound_type_constraint | @unified_break_expr | @unified_bulk_importing_pattern | @unified_call_expr | @unified_catch_clause | @unified_class_like_declaration | @unified_compound_assign_expr | @unified_conditional_pattern | @unified_constructor_declaration | @unified_continue_expr | @unified_destructor_declaration | @unified_do_while_stmt | @unified_equality_type_constraint | @unified_expr_pattern | @unified_for_each_stmt | @unified_function_declaration | @unified_function_expr | @unified_generic_type_expr | @unified_guard_if_stmt | @unified_if_expr | @unified_import_declaration | @unified_initializer_declaration | @unified_key_value_pair | @unified_labeled_stmt | @unified_map_literal | @unified_member_access_expr | @unified_named_pattern | @unified_operator_syntax_declaration | @unified_or_pattern | @unified_parameter | @unified_pattern_guard_expr | @unified_return_expr | @unified_switch_case | @unified_switch_expr | @unified_throw_expr | @unified_token | @unified_top_level | @unified_trivia_token | @unified_try_expr | @unified_tuple_expr | @unified_type_alias_declaration | @unified_type_cast_expr | @unified_type_parameter | @unified_type_test_expr | @unified_unary_expr | @unified_unresolved_operator_sequence | @unified_variable_declaration | @unified_while_stmt unified_ast_node_location( unique int node: @unified_ast_node ref, diff --git a/unified/ql/lib/utils/test/TestUtils.qll b/unified/ql/lib/utils/test/TestUtils.qll index 8a35f6277465..6a7fbae3d592 100644 --- a/unified/ql/lib/utils/test/TestUtils.qll +++ b/unified/ql/lib/utils/test/TestUtils.qll @@ -4,9 +4,9 @@ private import codeql.unified.internal.StaticNameBinding private string deriveClassName(ClassLikeDeclaration cls) { not exists(cls.getParent().getEnclosingClass()) and - result = cls.getName().getValue() + result = cls.getName() or - result = deriveClassName(cls.getParent().getEnclosingClass()) + "." + cls.getName().getValue() + result = deriveClassName(cls.getParent().getEnclosingClass()) + "." + cls.getName() } private string defaultName(NameDeclaration decl) { diff --git a/unified/ql/src/DummyQuery.ql b/unified/ql/src/DummyQuery.ql index 32890433c103..f890a4191d35 100644 --- a/unified/ql/src/DummyQuery.ql +++ b/unified/ql/src/DummyQuery.ql @@ -11,6 +11,6 @@ import unified -from Identifier id +from NameNode id where id.getValue().length() > 100 select id, "Name is too long: " + id.getValue() diff --git a/unified/ql/test/library-tests/BasicTest/test.expected b/unified/ql/test/library-tests/BasicTest/test.expected index 301cd90ca2a5..7ad344628ec3 100644 --- a/unified/ql/test/library-tests/BasicTest/test.expected +++ b/unified/ql/test/library-tests/BasicTest/test.expected @@ -1,39 +1,155 @@ -nameExpr -| name_expr.swift:1:9:1:9 | NameExpr | y | -| test.swift:1:8:1:17 | NameExpr | Foundation | -| test.swift:8:9:8:13 | NameExpr | items | -| test.swift:8:22:8:25 | NameExpr | item | -| test.swift:12:16:12:20 | NameExpr | items | -| test.swift:12:31:12:34 | NameExpr | item | -| test.swift:25:18:25:22 | NameExpr | Array | -| test.swift:25:24:25:28 | NameExpr | first | -| test.swift:26:17:26:22 | NameExpr | second | -| test.swift:27:13:27:18 | NameExpr | result | -| test.swift:27:29:27:32 | NameExpr | item | -| test.swift:28:13:28:18 | NameExpr | result | -| test.swift:28:27:28:30 | NameExpr | item | -| test.swift:31:12:31:17 | NameExpr | result | -| test.swift:40:16:40:19 | NameExpr | data | -| test.swift:44:9:44:12 | NameExpr | data | -| test.swift:48:15:48:19 | NameExpr | index | -| test.swift:48:29:48:33 | NameExpr | index | -| test.swift:48:37:48:40 | NameExpr | data | -| test.swift:49:16:49:19 | NameExpr | data | -| test.swift:49:21:49:25 | NameExpr | index | -| test.swift:53:9:53:12 | NameExpr | data | -| test.swift:53:21:53:24 | NameExpr | item | -| test.swift:63:16:63:19 | NameExpr | self | -| test.swift:65:29:65:37 | NameExpr | transform | -| test.swift:65:39:65:43 | NameExpr | value | -| test.swift:67:29:67:33 | NameExpr | error | -| test.swift:76:16:76:19 | NameExpr | self | -| test.swift:76:21:76:21 | NameExpr | i | -| test.swift:76:26:76:29 | NameExpr | self | -| test.swift:76:31:76:31 | NameExpr | i | -| test.swift:86:12:86:17 | NameExpr | values | -| test.swift:87:12:87:17 | NameExpr | values | -| test.swift:87:38:87:43 | NameExpr | values | -| test.swift:87:49:87:57 | NameExpr | transform | +nameNode +| name_expr.swift:1:5:1:5 | x | x | +| name_expr.swift:1:9:1:9 | y | y | +| strings.swift:1:5:1:5 | x | x | +| test.swift:1:8:1:17 | Foundation | Foundation | +| test.swift:1:8:1:17 | Foundation | Foundation | +| test.swift:4:8:4:16 | Container | Container | +| test.swift:4:18:4:18 | T | T | +| test.swift:4:21:4:29 | Equatable | Equatable | +| test.swift:5:9:5:13 | items | items | +| test.swift:5:16:5:18 | Array | Array | +| test.swift:5:17:5:17 | T | T | +| test.swift:7:19:7:21 | add | add | +| test.swift:7:23:7:23 | _ | _ | +| test.swift:7:25:7:28 | item | item | +| test.swift:7:31:7:31 | T | T | +| test.swift:8:9:8:13 | items | items | +| test.swift:8:15:8:20 | append | append | +| test.swift:8:22:8:25 | item | item | +| test.swift:11:10:11:17 | contains | contains | +| test.swift:11:19:11:19 | _ | _ | +| test.swift:11:21:11:24 | item | item | +| test.swift:11:27:11:27 | T | T | +| test.swift:11:33:11:36 | Bool | Bool | +| test.swift:12:16:12:20 | items | items | +| test.swift:12:22:12:29 | contains | contains | +| test.swift:12:31:12:34 | item | item | +| test.swift:17:10:17:19 | DataSource | DataSource | +| test.swift:18:20:18:26 | Element | Element | +| test.swift:19:9:19:13 | count | count | +| test.swift:19:16:19:18 | Int | Int | +| test.swift:20:10:20:13 | item | item | +| test.swift:20:15:20:16 | at | at | +| test.swift:20:18:20:22 | index | index | +| test.swift:20:25:20:27 | Int | Int | +| test.swift:20:33:20:39 | Element | Element | +| test.swift:20:33:20:40 | Optional | Optional | +| test.swift:24:6:24:10 | merge | merge | +| test.swift:24:12:24:12 | T | T | +| test.swift:24:15:24:24 | Collection | Collection | +| test.swift:24:27:24:27 | _ | _ | +| test.swift:24:29:24:33 | first | first | +| test.swift:24:36:24:36 | T | T | +| test.swift:24:39:24:39 | _ | _ | +| test.swift:24:41:24:46 | second | second | +| test.swift:24:49:24:49 | T | T | +| test.swift:24:55:24:65 | Array | Array | +| test.swift:24:56:24:56 | T | T | +| test.swift:24:58:24:64 | Element | Element | +| test.swift:25:9:25:14 | result | result | +| test.swift:25:18:25:22 | Array | Array | +| test.swift:25:24:25:28 | first | first | +| test.swift:26:9:26:12 | item | item | +| test.swift:26:17:26:22 | second | second | +| test.swift:27:13:27:18 | result | result | +| test.swift:27:20:27:27 | contains | contains | +| test.swift:27:29:27:32 | item | item | +| test.swift:28:13:28:18 | result | result | +| test.swift:28:20:28:25 | append | append | +| test.swift:28:27:28:30 | item | item | +| test.swift:31:12:31:17 | result | result | +| test.swift:35:7:35:17 | DataManager | DataManager | +| test.swift:35:19:35:19 | T | T | +| test.swift:35:23:35:32 | DataSource | DataSource | +| test.swift:36:15:36:21 | Element | Element | +| test.swift:36:25:36:25 | T | T | +| test.swift:37:17:37:20 | data | data | +| test.swift:37:23:37:25 | Array | Array | +| test.swift:37:24:37:24 | T | T | +| test.swift:39:9:39:13 | count | count | +| test.swift:39:16:39:18 | Int | Int | +| test.swift:40:16:40:19 | data | data | +| test.swift:40:21:40:25 | count | count | +| test.swift:43:9:43:15 | isEmpty | isEmpty | +| test.swift:43:18:43:21 | Bool | Bool | +| test.swift:44:9:44:12 | data | data | +| test.swift:44:14:44:20 | isEmpty | isEmpty | +| test.swift:47:10:47:13 | item | item | +| test.swift:47:15:47:16 | at | at | +| test.swift:47:18:47:22 | index | index | +| test.swift:47:25:47:27 | Int | Int | +| test.swift:47:33:47:33 | T | T | +| test.swift:47:33:47:34 | Optional | Optional | +| test.swift:48:15:48:19 | index | index | +| test.swift:48:29:48:33 | index | index | +| test.swift:48:37:48:40 | data | data | +| test.swift:48:42:48:46 | count | count | +| test.swift:49:16:49:19 | data | data | +| test.swift:49:21:49:25 | index | index | +| test.swift:52:10:52:12 | add | add | +| test.swift:52:14:52:14 | _ | _ | +| test.swift:52:16:52:19 | item | item | +| test.swift:52:22:52:22 | T | T | +| test.swift:53:9:53:12 | data | data | +| test.swift:53:14:53:19 | append | append | +| test.swift:53:21:53:24 | item | item | +| test.swift:58:6:58:11 | Result | Result | +| test.swift:58:13:58:19 | Success | Success | +| test.swift:58:22:58:28 | Failure | Failure | +| test.swift:58:31:58:35 | Error | Error | +| test.swift:59:10:59:16 | success | success | +| test.swift:59:18:59:24 | Success | Success | +| test.swift:60:10:60:16 | failure | failure | +| test.swift:60:18:60:24 | Failure | Failure | +| test.swift:62:10:62:12 | map | map | +| test.swift:62:14:62:14 | U | U | +| test.swift:62:17:62:17 | _ | _ | +| test.swift:62:19:62:27 | transform | transform | +| test.swift:62:31:62:37 | Success | Success | +| test.swift:62:43:62:43 | U | U | +| test.swift:62:49:62:54 | Result | Result | +| test.swift:62:56:62:56 | U | U | +| test.swift:62:59:62:65 | Failure | Failure | +| test.swift:63:16:63:19 | self | self | +| test.swift:64:15:64:21 | success | success | +| test.swift:64:27:64:31 | value | value | +| test.swift:65:21:65:27 | success | success | +| test.swift:65:29:65:37 | transform | transform | +| test.swift:65:39:65:43 | value | value | +| test.swift:66:15:66:21 | failure | failure | +| test.swift:66:27:66:31 | error | error | +| test.swift:67:21:67:27 | failure | failure | +| test.swift:67:29:67:33 | error | error | +| test.swift:73:11:73:15 | Array | Array | +| test.swift:74:10:74:17 | isSorted | isSorted | +| test.swift:74:24:74:27 | Bool | Bool | +| test.swift:75:13:75:13 | i | i | +| test.swift:76:16:76:19 | self | self | +| test.swift:76:21:76:21 | i | i | +| test.swift:76:26:76:29 | self | self | +| test.swift:76:31:76:31 | i | i | +| test.swift:85:6:85:12 | combine | combine | +| test.swift:85:14:85:14 | T | T | +| test.swift:85:17:85:17 | _ | _ | +| test.swift:85:19:85:24 | values | values | +| test.swift:85:27:85:29 | Array | Array | +| test.swift:85:28:85:28 | T | T | +| test.swift:85:32:85:40 | transform | transform | +| test.swift:85:44:85:44 | T | T | +| test.swift:85:47:85:47 | T | T | +| test.swift:85:53:85:53 | T | T | +| test.swift:85:59:85:59 | T | T | +| test.swift:85:59:85:60 | Optional | Optional | +| test.swift:86:12:86:17 | values | values | +| test.swift:86:19:86:25 | isEmpty | isEmpty | +| test.swift:87:12:87:17 | values | values | +| test.swift:87:19:87:27 | dropFirst | dropFirst | +| test.swift:87:31:87:36 | reduce | reduce | +| test.swift:87:38:87:43 | values | values | +| test.swift:87:49:87:57 | transform | transform | +namedPattern +| test.swift:1:1:1:17 | NamedPattern | Foundation | unsupported stringValue | strings.swift:1:9:1:15 | "hello" | "hello" | diff --git a/unified/ql/test/library-tests/BasicTest/test.ql b/unified/ql/test/library-tests/BasicTest/test.ql index 8e30af381d61..29038692b965 100644 --- a/unified/ql/test/library-tests/BasicTest/test.ql +++ b/unified/ql/test/library-tests/BasicTest/test.ql @@ -1,6 +1,8 @@ import unified -query predicate nameExpr(NameExpr node, string value) { value = node.getIdentifier().getValue() } +query predicate nameNode(NameNode node, string value) { value = node.getValue() } + +query predicate namedPattern(NamedPattern node, string value) { value = node.getName() } query predicate unsupported(UnsupportedNode node, string value) { value = node.getValue() } diff --git a/unified/ql/test/library-tests/definitions/test.ql b/unified/ql/test/library-tests/definitions/test.ql index 361a9fd6a03c..42448721f88d 100644 --- a/unified/ql/test/library-tests/definitions/test.ql +++ b/unified/ql/test/library-tests/definitions/test.ql @@ -7,7 +7,7 @@ module DefinitionsTest implements TestSig { string getARelevantTag() { result = "definition" } predicate hasActualResult(Location location, string element, string tag, string value) { - exists(Identifier reference, NameDeclaration definition | + exists(NameNode reference, NameDeclaration definition | definitionOf(reference, definition, "name") and location = reference.getLocation() and element = reference.toString() and diff --git a/unified/ql/test/library-tests/static-name-binding/test.ql b/unified/ql/test/library-tests/static-name-binding/test.ql index e6dd7e64f6b3..78b040b260d6 100644 --- a/unified/ql/test/library-tests/static-name-binding/test.ql +++ b/unified/ql/test/library-tests/static-name-binding/test.ql @@ -7,7 +7,7 @@ module StaticDeclAccess implements TestSig { string getARelevantTag() { result = "access" } predicate hasActualResult(Location location, string element, string tag, string value) { - exists(NameDeclaration decl, Identifier access | + exists(NameDeclaration decl, NameNode access | decl = getStaticBindingTarget(access) and not access instanceof NameDeclaration and location = access.getLocation() and