Add explicit this qualifiers in generated code

This commit is contained in:
Nick Rolfe
2021-10-14 11:52:59 +01:00
parent dde054d5a7
commit ec91111848
2 changed files with 14 additions and 6 deletions

View File

@@ -95,7 +95,11 @@ pub fn create_ast_node_class<'a>(ast_node: &'a str, ast_node_parent: &'a str) ->
name: "concat",
vars: vec![],
range: None,
expr: Box::new(ql::Expression::Pred("getAPrimaryQlClass", vec![])),
expr: Box::new(ql::Expression::Dot(
Box::new(ql::Expression::Var("this")),
"getAPrimaryQlClass",
vec![],
)),
second_expr: Some(Box::new(ql::Expression::String(","))),
}),
),
@@ -146,7 +150,11 @@ pub fn create_token_class<'a>(token_type: &'a str, tokeninfo: &'a str) -> ql::Cl
formal_parameters: vec![],
body: ql::Expression::Equals(
Box::new(ql::Expression::Var("result")),
Box::new(ql::Expression::Pred("getValue", vec![])),
Box::new(ql::Expression::Dot(
Box::new(ql::Expression::Var("this")),
"getValue",
vec![],
)),
),
};
ql::Class {

View File

@@ -28,7 +28,7 @@ module Ruby {
string getAPrimaryQlClass() { result = "???" }
/** Gets a comma-separated list of the names of the primary CodeQL classes to which this element belongs. */
string getPrimaryQlClasses() { result = concat(getAPrimaryQlClass(), ",") }
string getPrimaryQlClasses() { result = concat(this.getAPrimaryQlClass(), ",") }
}
/** A token. */
@@ -40,7 +40,7 @@ module Ruby {
override Location getLocation() { ruby_tokeninfo(this, _, _, result) }
/** Gets a string representation of this element. */
override string toString() { result = getValue() }
override string toString() { result = this.getValue() }
/** Gets the name of the primary QL class for this element. */
override string getAPrimaryQlClass() { result = "Token" }
@@ -1881,7 +1881,7 @@ module Erb {
string getAPrimaryQlClass() { result = "???" }
/** Gets a comma-separated list of the names of the primary CodeQL classes to which this element belongs. */
string getPrimaryQlClasses() { result = concat(getAPrimaryQlClass(), ",") }
string getPrimaryQlClasses() { result = concat(this.getAPrimaryQlClass(), ",") }
}
/** A token. */
@@ -1893,7 +1893,7 @@ module Erb {
override Location getLocation() { erb_tokeninfo(this, _, _, result) }
/** Gets a string representation of this element. */
override string toString() { result = getValue() }
override string toString() { result = this.getValue() }
/** Gets the name of the primary QL class for this element. */
override string getAPrimaryQlClass() { result = "Token" }