Skip to content

Commit 1920cd1

Browse files
authored
Merge pull request #359 from github/explicit_this
Add explicit `this` qualifiers in generated code
2 parents dde054d + ec91111 commit 1920cd1

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

generator/src/ql_gen.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,11 @@ pub fn create_ast_node_class<'a>(ast_node: &'a str, ast_node_parent: &'a str) ->
9595
name: "concat",
9696
vars: vec![],
9797
range: None,
98-
expr: Box::new(ql::Expression::Pred("getAPrimaryQlClass", vec![])),
98+
expr: Box::new(ql::Expression::Dot(
99+
Box::new(ql::Expression::Var("this")),
100+
"getAPrimaryQlClass",
101+
vec![],
102+
)),
99103
second_expr: Some(Box::new(ql::Expression::String(","))),
100104
}),
101105
),
@@ -146,7 +150,11 @@ pub fn create_token_class<'a>(token_type: &'a str, tokeninfo: &'a str) -> ql::Cl
146150
formal_parameters: vec![],
147151
body: ql::Expression::Equals(
148152
Box::new(ql::Expression::Var("result")),
149-
Box::new(ql::Expression::Pred("getValue", vec![])),
153+
Box::new(ql::Expression::Dot(
154+
Box::new(ql::Expression::Var("this")),
155+
"getValue",
156+
vec![],
157+
)),
150158
),
151159
};
152160
ql::Class {

ql/lib/codeql/ruby/ast/internal/TreeSitter.qll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ module Ruby {
2828
string getAPrimaryQlClass() { result = "???" }
2929

3030
/** Gets a comma-separated list of the names of the primary CodeQL classes to which this element belongs. */
31-
string getPrimaryQlClasses() { result = concat(getAPrimaryQlClass(), ",") }
31+
string getPrimaryQlClasses() { result = concat(this.getAPrimaryQlClass(), ",") }
3232
}
3333

3434
/** A token. */
@@ -40,7 +40,7 @@ module Ruby {
4040
override Location getLocation() { ruby_tokeninfo(this, _, _, result) }
4141

4242
/** Gets a string representation of this element. */
43-
override string toString() { result = getValue() }
43+
override string toString() { result = this.getValue() }
4444

4545
/** Gets the name of the primary QL class for this element. */
4646
override string getAPrimaryQlClass() { result = "Token" }
@@ -1881,7 +1881,7 @@ module Erb {
18811881
string getAPrimaryQlClass() { result = "???" }
18821882

18831883
/** Gets a comma-separated list of the names of the primary CodeQL classes to which this element belongs. */
1884-
string getPrimaryQlClasses() { result = concat(getAPrimaryQlClass(), ",") }
1884+
string getPrimaryQlClasses() { result = concat(this.getAPrimaryQlClass(), ",") }
18851885
}
18861886

18871887
/** A token. */
@@ -1893,7 +1893,7 @@ module Erb {
18931893
override Location getLocation() { erb_tokeninfo(this, _, _, result) }
18941894

18951895
/** Gets a string representation of this element. */
1896-
override string toString() { result = getValue() }
1896+
override string toString() { result = this.getValue() }
18971897

18981898
/** Gets the name of the primary QL class for this element. */
18991899
override string getAPrimaryQlClass() { result = "Token" }

0 commit comments

Comments
 (0)