From 982f6a5e8ab30df3f39b7b636582ea34c18c07fa Mon Sep 17 00:00:00 2001 From: Asger F Date: Wed, 1 Jul 2026 21:49:48 +0200 Subject: [PATCH] unified: Move Comments.ql into AstExtra.qll Also move into 'internal' and expose through a Public module --- unified/ql/lib/codeql/unified/Comments.qll | 18 --------------- .../lib/codeql/unified/internal/AstExtra.qll | 22 +++++++++++++++++++ unified/ql/lib/unified.qll | 2 +- 3 files changed, 23 insertions(+), 19 deletions(-) delete mode 100644 unified/ql/lib/codeql/unified/Comments.qll create mode 100644 unified/ql/lib/codeql/unified/internal/AstExtra.qll diff --git a/unified/ql/lib/codeql/unified/Comments.qll b/unified/ql/lib/codeql/unified/Comments.qll deleted file mode 100644 index e839af2dbee..00000000000 --- a/unified/ql/lib/codeql/unified/Comments.qll +++ /dev/null @@ -1,18 +0,0 @@ -/** Provides classes for working with comments. */ - -private import unified - -/** - * A comment appearing in the source code. - */ -class Comment extends TriviaToken { - // At the moment, comments are the only type trivia token we extract - /** - * Gets the text inside this comment, not counting the delimeters. - */ - string getCommentText() { - result = this.getValue().regexpCapture("//(.*)", 1) - or - result = this.getValue().regexpCapture("(?s)/\\*(.*)\\*/", 1) - } -} diff --git a/unified/ql/lib/codeql/unified/internal/AstExtra.qll b/unified/ql/lib/codeql/unified/internal/AstExtra.qll new file mode 100644 index 00000000000..df98711c975 --- /dev/null +++ b/unified/ql/lib/codeql/unified/internal/AstExtra.qll @@ -0,0 +1,22 @@ +/** + * Provides additional AST-like classes outside the generated tree-sitter classes. + */ + +private import unified + +module Public { + /** + * A comment appearing in the source code. + */ + class Comment extends TriviaToken { + // At the moment, comments are the only type trivia token we extract + /** + * Gets the text inside this comment, not counting the delimeters. + */ + string getCommentText() { + result = this.getValue().regexpCapture("//(.*)", 1) + or + result = this.getValue().regexpCapture("(?s)/\\*(.*)\\*/", 1) + } + } +} diff --git a/unified/ql/lib/unified.qll b/unified/ql/lib/unified.qll index 4f7387ef8f1..73af928aa4e 100644 --- a/unified/ql/lib/unified.qll +++ b/unified/ql/lib/unified.qll @@ -5,4 +5,4 @@ import codeql.Locations import codeql.files.FileSystem import codeql.unified.Ast::Unified -import codeql.unified.Comments +import codeql.unified.internal.AstExtra::Public