diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 38b4e81bd72..ca5ce23787c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -46,8 +46,8 @@ jobs: - uses: actions/upload-artifact@v2 if: ${{ matrix.os == 'ubuntu-latest' }} with: - name: Generated.qll - path: ql/src/codeql_ruby/Generated.qll + name: TreeSitter.qll + path: ql/src/codeql_ruby/ast/internal/TreeSitter.qll - uses: actions/upload-artifact@v2 with: name: extractor-${{ matrix.os }} diff --git a/README.md b/README.md index 1be806ecb76..888ce7ea10f 100644 --- a/README.md +++ b/README.md @@ -12,13 +12,13 @@ cargo build --release ## Generating the database schema and QL library -The generated `ql/src/ruby.dbscheme` and `ql/src/codeql_ruby/Generated.qll` files are included in the repository, but they can be re-generated as follows: +The generated `ql/src/ruby.dbscheme` and `ql/src/codeql_ruby/ast/internal/TreeSitter.qll` files are included in the repository, but they can be re-generated as follows: ```bash # Run the generator cargo run --release -p ruby-generator # Then auto-format the QL library -codeql query format -i ql/src/codeql_ruby/Generated.qll +codeql query format -i ql/src/codeql_ruby/ast/internal/TreeSitter.qll ``` ## Building a CodeQL database for a Ruby program diff --git a/create-extractor-pack.ps1 b/create-extractor-pack.ps1 index f5b5c506dd2..31cb276f4fd 100644 --- a/create-extractor-pack.ps1 +++ b/create-extractor-pack.ps1 @@ -1,7 +1,7 @@ cargo build --release cargo run --release -p ruby-generator -codeql query format -i ql\src\codeql_ruby\Generated.qll +codeql query format -i ql\src\codeql_ruby\ast\internal\TreeSitter.qll rm -Recurse -Force extractor-pack mkdir extractor-pack | Out-Null diff --git a/create-extractor-pack.sh b/create-extractor-pack.sh index 98a7fcd4f65..a182af30427 100755 --- a/create-extractor-pack.sh +++ b/create-extractor-pack.sh @@ -13,7 +13,7 @@ fi cargo build --release cargo run --release -p ruby-generator -codeql query format -i ql/src/codeql_ruby/Generated.qll +codeql query format -i ql/src/codeql_ruby/ast/internal/TreeSitter.qll rm -rf extractor-pack mkdir -p extractor-pack diff --git a/generator/src/main.rs b/generator/src/main.rs index 330eef50ce9..88acbfdc3f0 100644 --- a/generator/src/main.rs +++ b/generator/src/main.rs @@ -574,7 +574,7 @@ fn main() { name: "Ruby".to_owned(), node_types: tree_sitter_ruby::NODE_TYPES, dbscheme_path: PathBuf::from("ql/src/ruby.dbscheme"), - ql_library_path: PathBuf::from("ql/src/codeql_ruby/Generated.qll"), + ql_library_path: PathBuf::from("ql/src/codeql_ruby/ast/internal/TreeSitter.qll"), }; match node_types::read_node_types_str(&ruby.node_types) { Err(e) => { diff --git a/ql/src/codeql_ruby/AST.qll b/ql/src/codeql_ruby/AST.qll index 1e47ac4b82e..5618873fab3 100644 --- a/ql/src/codeql_ruby/AST.qll +++ b/ql/src/codeql_ruby/AST.qll @@ -1,9 +1,9 @@ import codeql.Locations -import codeql_ruby.ast.Method -import codeql_ruby.ast.Parameter -import codeql_ruby.ast.Pattern -import codeql_ruby.ast.Variable -private import codeql_ruby.Generated +import ast.Method +import ast.Parameter +import ast.Pattern +import ast.Variable +private import ast.internal.TreeSitter /** * A node in the abstract syntax tree. This class is the base class for all Ruby diff --git a/ql/src/codeql_ruby/ast/Method.qll b/ql/src/codeql_ruby/ast/Method.qll index 7581d92ff39..47cf9d36f09 100644 --- a/ql/src/codeql_ruby/ast/Method.qll +++ b/ql/src/codeql_ruby/ast/Method.qll @@ -1,5 +1,5 @@ import codeql_ruby.AST -private import codeql_ruby.Generated +private import internal.TreeSitter private import internal.Method /** A callable. */ diff --git a/ql/src/codeql_ruby/ast/Parameter.qll b/ql/src/codeql_ruby/ast/Parameter.qll index 704468cb754..87be195530b 100644 --- a/ql/src/codeql_ruby/ast/Parameter.qll +++ b/ql/src/codeql_ruby/ast/Parameter.qll @@ -1,7 +1,7 @@ import codeql_ruby.AST -private import codeql_ruby.Generated private import Variable private import Pattern +private import internal.TreeSitter private import internal.Variable /** A parameter. */ diff --git a/ql/src/codeql_ruby/ast/Pattern.qll b/ql/src/codeql_ruby/ast/Pattern.qll index d8e277a0018..530a11ea2c7 100644 --- a/ql/src/codeql_ruby/ast/Pattern.qll +++ b/ql/src/codeql_ruby/ast/Pattern.qll @@ -1,7 +1,7 @@ import codeql_ruby.AST -private import codeql_ruby.Generated private import codeql.Locations private import internal.Pattern +private import internal.TreeSitter private import internal.Variable private import Variable diff --git a/ql/src/codeql_ruby/ast/Variable.qll b/ql/src/codeql_ruby/ast/Variable.qll index d55016797b8..dbc36512d49 100644 --- a/ql/src/codeql_ruby/ast/Variable.qll +++ b/ql/src/codeql_ruby/ast/Variable.qll @@ -1,8 +1,8 @@ /** Provides classes for modeling program variables. */ import codeql_ruby.AST -private import codeql_ruby.Generated private import codeql.Locations +private import internal.TreeSitter private import internal.Variable /** A scope in which variables can be declared. */ diff --git a/ql/src/codeql_ruby/ast/internal/Method.qll b/ql/src/codeql_ruby/ast/internal/Method.qll index b2519a8e3d0..43602e66dd4 100644 --- a/ql/src/codeql_ruby/ast/internal/Method.qll +++ b/ql/src/codeql_ruby/ast/internal/Method.qll @@ -1,5 +1,5 @@ import codeql_ruby.AST -private import codeql_ruby.Generated +private import TreeSitter abstract class CallableRange extends AstNode { abstract Parameter getParameter(int n); diff --git a/ql/src/codeql_ruby/ast/internal/Pattern.qll b/ql/src/codeql_ruby/ast/internal/Pattern.qll index 35ebc7c69d5..eb34db359a5 100644 --- a/ql/src/codeql_ruby/ast/internal/Pattern.qll +++ b/ql/src/codeql_ruby/ast/internal/Pattern.qll @@ -1,5 +1,5 @@ import codeql_ruby.AST -private import codeql_ruby.Generated +private import TreeSitter private import codeql.Locations private predicate tuplePatternNode(Generated::AstNode n, boolean parameter) { diff --git a/ql/src/codeql_ruby/Generated.qll b/ql/src/codeql_ruby/ast/internal/TreeSitter.qll similarity index 100% rename from ql/src/codeql_ruby/Generated.qll rename to ql/src/codeql_ruby/ast/internal/TreeSitter.qll diff --git a/ql/src/codeql_ruby/ast/internal/Variable.qll b/ql/src/codeql_ruby/ast/internal/Variable.qll index 7d68a85b85d..6dab791c9e9 100644 --- a/ql/src/codeql_ruby/ast/internal/Variable.qll +++ b/ql/src/codeql_ruby/ast/internal/Variable.qll @@ -1,5 +1,5 @@ import codeql_ruby.AST -private import codeql_ruby.Generated +private import TreeSitter private import codeql.Locations private import Pattern diff --git a/ql/src/codeql_ruby/controlflow/BasicBlocks.qll b/ql/src/codeql_ruby/controlflow/BasicBlocks.qll index 0fcbe5411cd..15b5934224f 100644 --- a/ql/src/codeql_ruby/controlflow/BasicBlocks.qll +++ b/ql/src/codeql_ruby/controlflow/BasicBlocks.qll @@ -1,6 +1,6 @@ /** Provides classes representing basic blocks. */ -private import codeql_ruby.Generated::Generated +private import codeql_ruby.ast.internal.TreeSitter::Generated private import codeql_ruby.controlflow.ControlFlowGraph private import internal.ControlFlowGraphImpl private import SuccessorTypes diff --git a/ql/src/codeql_ruby/controlflow/ControlFlowGraph.qll b/ql/src/codeql_ruby/controlflow/ControlFlowGraph.qll index 660777f5eb7..9d2eedb36d7 100644 --- a/ql/src/codeql_ruby/controlflow/ControlFlowGraph.qll +++ b/ql/src/codeql_ruby/controlflow/ControlFlowGraph.qll @@ -1,6 +1,6 @@ /** Provides classes representing the control flow graph. */ -private import codeql_ruby.Generated::Generated +private import codeql_ruby.ast.internal.TreeSitter::Generated private import codeql_ruby.controlflow.BasicBlocks private import SuccessorTypes private import internal.ControlFlowGraphImpl diff --git a/ql/src/codeql_ruby/controlflow/internal/AstNodes.qll b/ql/src/codeql_ruby/controlflow/internal/AstNodes.qll index d941e4b9acd..3692e3473f3 100644 --- a/ql/src/codeql_ruby/controlflow/internal/AstNodes.qll +++ b/ql/src/codeql_ruby/controlflow/internal/AstNodes.qll @@ -3,7 +3,7 @@ * will likely be part of the hand-written user-facing AST layer. */ -private import codeql_ruby.Generated::Generated +private import codeql_ruby.ast.internal.TreeSitter::Generated class LogicalNotAstNode extends Unary { AstNode operand; diff --git a/ql/src/codeql_ruby/controlflow/internal/Completion.qll b/ql/src/codeql_ruby/controlflow/internal/Completion.qll index f0a82b0077e..29f51c46111 100644 --- a/ql/src/codeql_ruby/controlflow/internal/Completion.qll +++ b/ql/src/codeql_ruby/controlflow/internal/Completion.qll @@ -4,7 +4,7 @@ * A completion represents how a statement or expression terminates. */ -private import codeql_ruby.Generated::Generated +private import codeql_ruby.ast.internal.TreeSitter::Generated private import codeql_ruby.controlflow.ControlFlowGraph private import AstNodes private import NonReturning diff --git a/ql/src/codeql_ruby/controlflow/internal/Consistency.qll b/ql/src/codeql_ruby/controlflow/internal/Consistency.qll index 8e48975d412..b631ec3a405 100644 --- a/ql/src/codeql_ruby/controlflow/internal/Consistency.qll +++ b/ql/src/codeql_ruby/controlflow/internal/Consistency.qll @@ -1,4 +1,4 @@ -private import codeql_ruby.Generated::Generated +private import codeql_ruby.ast.internal.TreeSitter::Generated private import codeql_ruby.controlflow.ControlFlowGraph private import Completion private import Splitting diff --git a/ql/src/codeql_ruby/controlflow/internal/ControlFlowGraphImpl.qll b/ql/src/codeql_ruby/controlflow/internal/ControlFlowGraphImpl.qll index dbca2e553a0..3e61e4c06ef 100644 --- a/ql/src/codeql_ruby/controlflow/internal/ControlFlowGraphImpl.qll +++ b/ql/src/codeql_ruby/controlflow/internal/ControlFlowGraphImpl.qll @@ -31,7 +31,7 @@ * caught up by its surrounding loop and turned into a `NormalCompletion`. */ -private import codeql_ruby.Generated::Generated +private import codeql_ruby.ast.internal.TreeSitter::Generated private import AstNodes private import codeql_ruby.controlflow.ControlFlowGraph private import Completion diff --git a/ql/src/codeql_ruby/controlflow/internal/NonReturning.qll b/ql/src/codeql_ruby/controlflow/internal/NonReturning.qll index f19c16e8975..29fcfb7fd6a 100644 --- a/ql/src/codeql_ruby/controlflow/internal/NonReturning.qll +++ b/ql/src/codeql_ruby/controlflow/internal/NonReturning.qll @@ -1,6 +1,6 @@ /** Provides a simple analysis for identifying calls that will not return. */ -private import codeql_ruby.Generated::Generated +private import codeql_ruby.ast.internal.TreeSitter::Generated private import Completion /** A call that definitely does not return (conservative analysis). */ diff --git a/ql/src/codeql_ruby/controlflow/internal/Splitting.qll b/ql/src/codeql_ruby/controlflow/internal/Splitting.qll index baa4e1753e7..6f8498b3f24 100644 --- a/ql/src/codeql_ruby/controlflow/internal/Splitting.qll +++ b/ql/src/codeql_ruby/controlflow/internal/Splitting.qll @@ -2,7 +2,7 @@ * Provides classes and predicates relevant for splitting the control flow graph. */ -private import codeql_ruby.Generated::Generated +private import codeql_ruby.ast.internal.TreeSitter::Generated private import AstNodes private import Completion private import ControlFlowGraphImpl diff --git a/ql/src/codeql_ruby/printAst.qll b/ql/src/codeql_ruby/printAst.qll index 7b8c70b1edd..dd6ef39d3b6 100644 --- a/ql/src/codeql_ruby/printAst.qll +++ b/ql/src/codeql_ruby/printAst.qll @@ -6,7 +6,7 @@ * to hold for only the AST nodes you wish to view. */ -import codeql_ruby.Generated +import ast.internal.TreeSitter /** * The query can extend this class to control which nodes are printed.