Merge pull request #143 from github/aibaars/ast-test

AST: add printAST test case
This commit is contained in:
Arthur Baars
2021-02-26 19:41:56 +01:00
committed by GitHub
5 changed files with 1742 additions and 5 deletions

View File

@@ -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, "/")
}
/**

File diff suppressed because it is too large Load Diff

View 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()
}
}

View File

@@ -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%

View File

@@ -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"