mirror of
https://github.com/github/codeql.git
synced 2026-04-22 23:35:14 +02:00
Merge pull request #143 from github/aibaars/ast-test
AST: add printAST test case
This commit is contained in:
@@ -26,7 +26,7 @@ class PrintAstConfiguration extends string {
|
||||
class PrintAstNode extends AstNode {
|
||||
string getProperty(string key) {
|
||||
key = "semmle.label" and
|
||||
result = "[" + this.getAPrimaryQlClass() + "] " + this.toString()
|
||||
result = "[" + concat(this.getAPrimaryQlClass(), ", ") + "] " + this.toString()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -63,7 +63,8 @@ query predicate edges(PrintAstNode source, PrintAstNode target, string key, stri
|
||||
source.shouldPrint() and
|
||||
target.shouldPrint() and
|
||||
key = "semmle.label" and
|
||||
source.getChild(value) = target
|
||||
target = source.getAChild() and
|
||||
value = concat(string name | source.getChild(name) = target | name, "/")
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
1697
ql/test/library-tests/ast/Ast.expected
Normal file
1697
ql/test/library-tests/ast/Ast.expected
Normal file
File diff suppressed because it is too large
Load Diff
24
ql/test/library-tests/ast/Ast.ql
Normal file
24
ql/test/library-tests/ast/Ast.ql
Normal file
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* @kind graph
|
||||
*/
|
||||
|
||||
import codeql_ruby.printAst
|
||||
|
||||
class OrderedAstNode extends PrintAstNode {
|
||||
override string getProperty(string key) {
|
||||
result = super.getProperty(key)
|
||||
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()
|
||||
)
|
||||
).toString()
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,11 @@
|
||||
@echo off
|
||||
|
||||
CALL "%CODEQL_EXTRACTOR_RUBY_ROOT%\tools\autobuild.cmd"
|
||||
type NUL && "%CODEQL_DIST%\codeql.exe" database index-files ^
|
||||
--prune=**/*.testproj ^
|
||||
--include-extension=.rb ^
|
||||
--include-extension=.erb ^
|
||||
--size-limit=5m ^
|
||||
--language=ruby ^
|
||||
"%CODEQL_EXTRACTOR_RUBY_WIP_DATABASE%"
|
||||
|
||||
exit /b %ERRORLEVEL%
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
#! /bin/sh
|
||||
#!/bin/sh
|
||||
|
||||
exec "${CODEQL_EXTRACTOR_RUBY_ROOT}/tools/autobuild.sh"
|
||||
set -eu
|
||||
|
||||
exec "${CODEQL_DIST}/codeql" database index-files \
|
||||
--prune="**/*.testproj" \
|
||||
--include-extension=.rb \
|
||||
--include-extension=.erb \
|
||||
--size-limit=5m \
|
||||
--language=ruby \
|
||||
--working-dir=.\
|
||||
"$CODEQL_EXTRACTOR_RUBY_WIP_DATABASE"
|
||||
|
||||
Reference in New Issue
Block a user