Skip to content

Commit 982f6a5

Browse files
committed
unified: Move Comments.ql into AstExtra.qll
Also move into 'internal' and expose through a Public module
1 parent cf51664 commit 982f6a5

3 files changed

Lines changed: 23 additions & 19 deletions

File tree

unified/ql/lib/codeql/unified/Comments.qll

Lines changed: 0 additions & 18 deletions
This file was deleted.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* Provides additional AST-like classes outside the generated tree-sitter classes.
3+
*/
4+
5+
private import unified
6+
7+
module Public {
8+
/**
9+
* A comment appearing in the source code.
10+
*/
11+
class Comment extends TriviaToken {
12+
// At the moment, comments are the only type trivia token we extract
13+
/**
14+
* Gets the text inside this comment, not counting the delimeters.
15+
*/
16+
string getCommentText() {
17+
result = this.getValue().regexpCapture("//(.*)", 1)
18+
or
19+
result = this.getValue().regexpCapture("(?s)/\\*(.*)\\*/", 1)
20+
}
21+
}
22+
}

unified/ql/lib/unified.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
import codeql.Locations
66
import codeql.files.FileSystem
77
import codeql.unified.Ast::Unified
8-
import codeql.unified.Comments
8+
import codeql.unified.internal.AstExtra::Public

0 commit comments

Comments
 (0)