mirror of
https://github.com/github/codeql.git
synced 2026-02-19 16:33:40 +01:00
Move semmle.order property to printAst.qll
This commit is contained in:
@@ -27,6 +27,19 @@ class PrintAstNode extends AstNode {
|
||||
string getProperty(string key) {
|
||||
key = "semmle.label" and
|
||||
result = "[" + concat(this.getAPrimaryQlClass(), ", ") + "] " + this.toString()
|
||||
or
|
||||
key = "semmle.order" and
|
||||
result =
|
||||
any(int i |
|
||||
this =
|
||||
rank[i](AstNode p |
|
||||
|
|
||||
p
|
||||
order by
|
||||
p.getLocation().getFile().getBaseName(), p.getLocation().getFile().getAbsolutePath(),
|
||||
p.getLocation().getStartLine(), p.getLocation().getStartColumn()
|
||||
)
|
||||
).toString()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -62,9 +75,14 @@ query predicate nodes(PrintAstNode node, string key, string value) {
|
||||
query predicate edges(PrintAstNode source, PrintAstNode target, string key, string value) {
|
||||
source.shouldPrint() and
|
||||
target.shouldPrint() and
|
||||
key = "semmle.label" and
|
||||
target = source.getAChild() and
|
||||
value = concat(string name | source.getChild(name) = target | name, "/")
|
||||
(
|
||||
key = "semmle.label" and
|
||||
value = concat(string name | source.getChild(name) = target | name, "/")
|
||||
or
|
||||
key = "semmle.order" and
|
||||
value = target.getProperty("semmle.order")
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,35 +2,4 @@
|
||||
* @kind graph
|
||||
*/
|
||||
|
||||
import codeql_ruby.printAst as P
|
||||
|
||||
query predicate nodes = P::nodes/3;
|
||||
|
||||
query predicate graphProperties = P::graphProperties/2;
|
||||
|
||||
query predicate edges(P::PrintAstNode source, P::PrintAstNode target, string key, string value) {
|
||||
P::edges(source, target, key, value)
|
||||
or
|
||||
P::edges(source, target, _, _) and
|
||||
key = "semmle.order" and
|
||||
value = target.(OrderedAstNode).getProperty("semmle.order")
|
||||
}
|
||||
|
||||
class OrderedAstNode extends P::PrintAstNode {
|
||||
override string getProperty(string key) {
|
||||
result = super.getProperty(key)
|
||||
or
|
||||
key = "semmle.order" and
|
||||
result =
|
||||
any(int i |
|
||||
this =
|
||||
rank[i](P::AstNode p |
|
||||
|
|
||||
p
|
||||
order by
|
||||
p.getLocation().getFile().getBaseName(), p.getLocation().getFile().getAbsolutePath(),
|
||||
p.getLocation().getStartLine(), p.getLocation().getStartColumn()
|
||||
)
|
||||
).toString()
|
||||
}
|
||||
}
|
||||
import codeql_ruby.printAst
|
||||
|
||||
Reference in New Issue
Block a user