unified: Move Comments.ql into AstExtra.qll

Also move into 'internal' and expose through a Public module
This commit is contained in:
Asger F
2026-07-01 21:49:48 +02:00
parent cf51664d69
commit 982f6a5e8a
3 changed files with 23 additions and 19 deletions

View File

@@ -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)
}
}

View File

@@ -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)
}
}
}

View File

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