Skip to content

Commit 81c6abc

Browse files
committed
feat(ast): Move Call nodes to Stmts
1 parent b6ea1a0 commit 81c6abc

File tree

2 files changed

+94
-89
lines changed

2 files changed

+94
-89
lines changed

ql/lib/codeql/bicep/ast/Calls.qll

Lines changed: 0 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@ private import Idents
44
private import Misc
55
private import internal.Arguments
66
private import internal.CallExpression
7-
private import internal.Parameter
8-
private import internal.Parameters
9-
private import internal.ParameterDeclaration
10-
private import internal.OutputDeclaration
11-
private import internal.UserDefinedFunction
127

138
/**
149
* Represents a callable expression in the AST, such as a function or method call.
@@ -68,87 +63,3 @@ class Arguments extends AstNode instanceof ArgumentsImpl {
6863
/** Gets all arguments. */
6964
Expr getArguments() { result = ArgumentsImpl.super.getArguments() }
7065
}
71-
72-
/**
73-
* Represents a parameter node in the AST.
74-
* Provides access to the parameter's name and type.
75-
*/
76-
class Parameter extends AstNode instanceof ParameterImpl {
77-
/** Gets the name of the parameter. */
78-
Idents getName() { result = ParameterImpl.super.getName() }
79-
80-
/** Gets the type of the parameter. */
81-
Type getType() { result = ParameterImpl.super.getType() }
82-
}
83-
84-
/**
85-
* Represents a parameters node in the AST.
86-
* Provides access to individual parameters by index.
87-
*/
88-
class Parameters extends AstNode instanceof ParametersImpl {
89-
/** Gets the parameter at the specified index. */
90-
Parameter getParameter(int index) { result = ParametersImpl.super.getParameter(index) }
91-
}
92-
93-
/**
94-
* Represents a parameter declaration node in the AST.
95-
* Provides access to the identifier, name, type, and default value of the parameter.
96-
*/
97-
class ParameterDeclaration extends AstNode instanceof ParameterDeclarationImpl {
98-
/** Gets the identifier of the parameter declaration. */
99-
Identifier getIdentifier() { result = ParameterDeclarationImpl.super.getName() }
100-
101-
/** Gets the name of the parameter declaration. */
102-
string getName() { result = this.getIdentifier().getName() }
103-
104-
/** Gets the type of the parameter declaration. */
105-
Type getType() { result = ParameterDeclarationImpl.super.getType() }
106-
107-
/** Gets the default value of the parameter declaration, if any. */
108-
Expr getDefaultValue() { result = ParameterDeclarationImpl.super.getDefaultValue() }
109-
}
110-
111-
/**
112-
* Represents an output declaration node in the AST.
113-
* Provides access to the identifier, name, type, and value of the output.
114-
*/
115-
class OutputDeclaration extends AstNode instanceof OutputDeclarationImpl {
116-
/** Gets the identifier of the output declaration. */
117-
Identifier getIdentifier() { result = OutputDeclarationImpl.super.getIdentifier() }
118-
119-
/** Gets the name of the output declaration. */
120-
string getName() { result = this.getIdentifier().getName() }
121-
122-
/** Gets the type of the output declaration. */
123-
Type getType() { result = OutputDeclarationImpl.super.getType() }
124-
125-
/** Gets the value of the output declaration. */
126-
Expr getValue() { result = OutputDeclarationImpl.super.getValue() }
127-
}
128-
129-
/**
130-
* Represents a user-defined function node in the AST.
131-
* Provides access to the identifier, name, return type, parameters, and body of the function.
132-
*/
133-
class UserDefinedFunction extends AstNode instanceof UserDefinedFunctionImpl {
134-
/** Gets the identifier of the user-defined function. */
135-
Identifier getIdentifier() { result = UserDefinedFunctionImpl.super.getName() }
136-
137-
/** Gets the name of the user-defined function. */
138-
string getName() { result = this.getIdentifier().getName() }
139-
140-
/** Gets the return type of the user-defined function. */
141-
Type getReturnType() { result = UserDefinedFunctionImpl.super.getReturnType() }
142-
143-
/** Gets the declared parameters of the user-defined function. */
144-
Parameters getDeclaredParameters() { result = UserDefinedFunctionImpl.super.getParameters() }
145-
146-
/** Gets all parameters of the user-defined function. */
147-
Parameter getParameters() { result = this.getDeclaredParameters().getParameter(_) }
148-
149-
/** Gets the parameter at the specified index. */
150-
Parameter getParameter(int index) { result = this.getDeclaredParameters().getParameter(index) }
151-
152-
/** Gets the body of the user-defined function. */
153-
Expr getBody() { result = UserDefinedFunctionImpl.super.getBody() }
154-
}

ql/lib/codeql/bicep/ast/Stmts.qll

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
*/
44

55
private import AstNodes
6+
private import Idents
7+
private import Expr
8+
private import Misc
69
private import internal.AstNodes
710
private import internal.TreeSitter
811
private import internal.Stmts
@@ -14,6 +17,11 @@ private import internal.ImportWithStatement
1417
private import internal.Infrastructure
1518
private import internal.Statement
1619
private import internal.UsingStatement
20+
private import internal.Parameter
21+
private import internal.Parameters
22+
private import internal.ParameterDeclaration
23+
private import internal.OutputDeclaration
24+
private import internal.UserDefinedFunction
1725
// CFG
1826
private import codeql.bicep.CFG
1927
private import codeql.bicep.controlflow.internal.ControlFlowGraphImpl as CfgImpl
@@ -57,6 +65,92 @@ class Infrastructure extends AstNode instanceof InfrastructureImpl {
5765
Stmts getStatement(int index) { result = InfrastructureImpl.super.getStatement(index) }
5866
}
5967

68+
/**
69+
* Represents a parameter declaration node in the AST.
70+
* Provides access to the identifier, name, type, and default value of the parameter.
71+
*/
72+
class ParameterDeclaration extends AstNode instanceof ParameterDeclarationImpl {
73+
/** Gets the identifier of the parameter declaration. */
74+
Identifier getIdentifier() { result = ParameterDeclarationImpl.super.getName() }
75+
76+
/** Gets the name of the parameter declaration. */
77+
string getName() { result = this.getIdentifier().getName() }
78+
79+
/** Gets the type of the parameter declaration. */
80+
Type getType() { result = ParameterDeclarationImpl.super.getType() }
81+
82+
/** Gets the default value of the parameter declaration, if any. */
83+
Expr getDefaultValue() { result = ParameterDeclarationImpl.super.getDefaultValue() }
84+
}
85+
86+
87+
/**
88+
* Represents an output declaration node in the AST.
89+
* Provides access to the identifier, name, type, and value of the output.
90+
*/
91+
class OutputDeclaration extends AstNode instanceof OutputDeclarationImpl {
92+
/** Gets the identifier of the output declaration. */
93+
Identifier getIdentifier() { result = OutputDeclarationImpl.super.getIdentifier() }
94+
95+
/** Gets the name of the output declaration. */
96+
string getName() { result = this.getIdentifier().getName() }
97+
98+
/** Gets the type of the output declaration. */
99+
Type getType() { result = OutputDeclarationImpl.super.getType() }
100+
101+
/** Gets the value of the output declaration. */
102+
Expr getValue() { result = OutputDeclarationImpl.super.getValue() }
103+
}
104+
105+
/**
106+
* Represents a user-defined function node in the AST.
107+
* Provides access to the identifier, name, return type, parameters, and body of the function.
108+
*/
109+
class UserDefinedFunction extends AstNode instanceof UserDefinedFunctionImpl {
110+
/** Gets the identifier of the user-defined function. */
111+
Identifier getIdentifier() { result = UserDefinedFunctionImpl.super.getName() }
112+
113+
/** Gets the name of the user-defined function. */
114+
string getName() { result = this.getIdentifier().getName() }
115+
116+
/** Gets the return type of the user-defined function. */
117+
Type getReturnType() { result = UserDefinedFunctionImpl.super.getReturnType() }
118+
119+
/** Gets the declared parameters of the user-defined function. */
120+
Parameters getDeclaredParameters() { result = UserDefinedFunctionImpl.super.getParameters() }
121+
122+
/** Gets all parameters of the user-defined function. */
123+
Parameter getParameters() { result = this.getDeclaredParameters().getParameter(_) }
124+
125+
/** Gets the parameter at the specified index. */
126+
Parameter getParameter(int index) { result = this.getDeclaredParameters().getParameter(index) }
127+
128+
/** Gets the body of the user-defined function. */
129+
Expr getBody() { result = UserDefinedFunctionImpl.super.getBody() }
130+
}
131+
132+
/**
133+
* Represents a parameter node in the AST.
134+
* Provides access to the parameter's name and type.
135+
*/
136+
class Parameter extends AstNode instanceof ParameterImpl {
137+
/** Gets the name of the parameter. */
138+
Idents getName() { result = ParameterImpl.super.getName() }
139+
140+
/** Gets the type of the parameter. */
141+
Type getType() { result = ParameterImpl.super.getType() }
142+
}
143+
144+
/**
145+
* Represents a parameters node in the AST.
146+
* Provides access to individual parameters by index.
147+
*/
148+
class Parameters extends AstNode instanceof ParametersImpl {
149+
/** Gets the parameter at the specified index. */
150+
Parameter getParameter(int index) { result = ParametersImpl.super.getParameter(index) }
151+
}
152+
153+
60154
/**
61155
* A ImportWithStatement statement
62156
*/

0 commit comments

Comments
 (0)