44overlay [ local?]
55module ;
66
7+ private import AstPlugin
78private import codeql.files.FileSystem
89private import codeql.unified.internal.NameBinding as NameBinding
910
@@ -153,17 +154,18 @@ module Unified {
153154 NameBinding:: getStaticBindingTargetFromRef ( this .getABaseType ( ) .getType ( ) )
154155 }
155156
156- private string getKind ( ) {
157- this .hasModifier ( result ) and
158- result in [ "class" , "struct" , "interface" , "enum" , "actor" , "extension" , "protocol" ]
157+ override string toString ( ) {
158+ result = concat ( getClassLikeDeclarationKeyword ( this ) + " " ) + concat ( this .getName ( ) )
159159 }
160-
161- override string toString ( ) { result = concat ( this .getKind ( ) + " " ) + concat ( this .getName ( ) ) }
162160 }
163161
164162 class ConstructorDeclaration extends G:: ConstructorDeclaration {
165163 /** Gets the name of this constructor. */
166164 string getName ( ) { result = this .getNameNode ( ) .getValue ( ) }
165+
166+ override string toString ( ) {
167+ result = concat ( getConstructorDeclarationKeyword ( this ) + " " ) + concat ( this .getName ( ) )
168+ }
167169 }
168170
169171 class ContinueExpr extends G:: ContinueExpr {
@@ -174,6 +176,22 @@ module Unified {
174176 class FunctionDeclaration extends G:: FunctionDeclaration {
175177 /** Gets the name of this function. */
176178 string getName ( ) { result = this .getNameNode ( ) .getValue ( ) }
179+
180+ override string toString ( ) {
181+ result = concat ( getFunctionDeclarationKeyword ( this ) + " " ) + concat ( this .getName ( ) )
182+ }
183+ }
184+
185+ class VariableDeclaration extends G:: VariableDeclaration {
186+ /** Gets the name node of this variable declaration, if any. */
187+ Identifier getNameNode ( ) { result = this .getPattern ( ) }
188+
189+ /** Gets the name of the variable being declared, if any. */
190+ string getName ( ) { result = this .getNameNode ( ) .getValue ( ) }
191+
192+ override string toString ( ) {
193+ result = concat ( getVariableDeclarationKeyword ( this ) + " " ) + concat ( this .getName ( ) )
194+ }
177195 }
178196
179197 class LabeledStmt extends G:: LabeledStmt {
0 commit comments