Skip to content

Commit ec6c581

Browse files
committed
Unified: Add Member.getNameNode
1 parent 7d89e49 commit ec6c581

3 files changed

Lines changed: 33 additions & 19 deletions

File tree

‎unified/extractor/ast_types.yml‎

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -80,17 +80,20 @@ supertypes:
8080
body?: block
8181
# A member is anything that can appear in the body of a class-like declaration
8282
member:
83-
- constructor_declaration
84-
- destructor_declaration
85-
- function_declaration
86-
- variable_declaration
87-
- accessor_declaration
88-
- initializer_declaration
89-
- class_like_declaration
90-
- type_alias_declaration
91-
- associated_type_declaration
92-
- unsupported_node
93-
- unhandled_node
83+
subtypes:
84+
- constructor_declaration
85+
- destructor_declaration
86+
- function_declaration
87+
- variable_declaration
88+
- accessor_declaration
89+
- initializer_declaration
90+
- class_like_declaration
91+
- type_alias_declaration
92+
- associated_type_declaration
93+
- unsupported_node
94+
- unhandled_node
95+
fields:
96+
name_node: identifier
9497
type_constraint:
9598
- equality_type_constraint
9699
- bound_type_constraint

‎unified/ql/lib/codeql/unified/internal/Ast.qll‎

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ module Unified {
113113
final F::Modifier getAModifier() { result = this.getModifier(_) }
114114

115115
/** Gets the node corresponding to the field `name_node`. */
116-
final F::Identifier getNameNode() { unified_accessor_declaration_def(this, _, result) }
116+
final override F::Identifier getNameNode() { unified_accessor_declaration_def(this, _, result) }
117117

118118
/** Gets the node corresponding to the field `parameter`. */
119119
final override F::Parameter getParameter(int i) {
@@ -200,7 +200,9 @@ module Unified {
200200
final F::Modifier getAModifier() { result = this.getModifier(_) }
201201

202202
/** Gets the node corresponding to the field `name_node`. */
203-
final F::Identifier getNameNode() { unified_associated_type_declaration_def(this, result) }
203+
final override F::Identifier getNameNode() {
204+
unified_associated_type_declaration_def(this, result)
205+
}
204206

205207
/** Gets a field or child node of this node. */
206208
final override F::AstNode getAFieldOrChild() {
@@ -427,7 +429,9 @@ module Unified {
427429
final F::Modifier getAModifier() { result = this.getModifier(_) }
428430

429431
/** Gets the node corresponding to the field `name_node`. */
430-
final F::Identifier getNameNode() { unified_class_like_declaration_name_node(this, result) }
432+
final override F::Identifier getNameNode() {
433+
unified_class_like_declaration_name_node(this, result)
434+
}
431435

432436
/** Gets the node corresponding to the field `type_constraint`. */
433437
final F::TypeConstraint getTypeConstraint(int i) {
@@ -501,7 +505,9 @@ module Unified {
501505
final F::Modifier getAModifier() { result = this.getModifier(_) }
502506

503507
/** Gets the node corresponding to the field `name_node`. */
504-
final F::Identifier getNameNode() { unified_constructor_declaration_name_node(this, result) }
508+
final override F::Identifier getNameNode() {
509+
unified_constructor_declaration_name_node(this, result)
510+
}
505511

506512
/** Gets the node corresponding to the field `parameter`. */
507513
final override F::Parameter getParameter(int i) {
@@ -704,7 +710,7 @@ module Unified {
704710
final F::Modifier getAModifier() { result = this.getModifier(_) }
705711

706712
/** Gets the node corresponding to the field `name_node`. */
707-
final F::Identifier getNameNode() { unified_function_declaration_def(this, result) }
713+
final override F::Identifier getNameNode() { unified_function_declaration_def(this, result) }
708714

709715
/** Gets the node corresponding to the field `parameter`. */
710716
final override F::Parameter getParameter(int i) {
@@ -979,7 +985,10 @@ module Unified {
979985
final override F::AstNode getAFieldOrChild() { unified_map_literal_element(this, _, result) }
980986
}
981987

982-
class Member extends @unified_member, F::AstNode { }
988+
class Member extends @unified_member, F::AstNode {
989+
/** Gets the node corresponding to the field `name_node`. */
990+
F::Identifier getNameNode() { none() }
991+
}
983992

984993
/** A class representing `member_access_expr` nodes. */
985994
class MemberAccessExpr extends @unified_member_access_expr, F::Expr {
@@ -1341,7 +1350,9 @@ module Unified {
13411350
final F::Modifier getAModifier() { result = this.getModifier(_) }
13421351

13431352
/** Gets the node corresponding to the field `name_node`. */
1344-
final F::Identifier getNameNode() { unified_type_alias_declaration_def(this, result, _) }
1353+
final override F::Identifier getNameNode() {
1354+
unified_type_alias_declaration_def(this, result, _)
1355+
}
13451356

13461357
/** Gets the node corresponding to the field `type`. */
13471358
final F::Expr getType() { unified_type_alias_declaration_def(this, _, result) }

‎unified/ql/lib/codeql/unified/internal/FacadeAst.qll‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ module Unified {
193193

194194
class VariableDeclaration extends G::VariableDeclaration {
195195
/** Gets the name node of this variable declaration, if any. */
196-
Identifier getNameNode() { result = this.getPattern() }
196+
override Identifier getNameNode() { result = this.getPattern() }
197197

198198
/** Gets the name of the variable being declared, if any. */
199199
string getName() { result = this.getNameNode().getValue() }

0 commit comments

Comments
 (0)