Identifying subclasses of a given free variable #15675
Unanswered
0x73746F70626F74686572696E676D65
asked this question in
Q&A
Replies: 1 comment
-
Thank you for the question! Perhaps the any(MethodBase b).getAQlClass() For example, consider this query: abstract class Base extends int {
Base() { this in [1..9] }
}
class A extends Base {
A() { this = 1 }
}
class B extends Base {
B() { this = 2 }
}
class C extends Base {
C() { this = 3 }
}
select any(Base b).getAQlClass() The result is:
Note that |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Suppose you have a variable in CodeQL of a given type. You want to identify all of the subtypes it is a part of. For instance a variable of type string and you want all of the subtypes that it is a part of.
Im asking this because I have a variable of MethodBase in the ruby QL library and I want a clean and canonical way of identifying the subclasses (Method or SingletonMethod) it is a part of so that I can represent this as a string in query output.
Example: from a given MethodBase, output if its a Method or SingletonMethod in the query output.
I know I can achieve this using an if else then statement but that seems ugly. Im assuming theres a better way to achieve this since imagine a scenario where we have 3 subtypes. Subtype1, Subtype2, and Subtype3.
How would you retrieve all of the subtypes a given variable belongs to? Thanks.
Beta Was this translation helpful? Give feedback.
All reactions