mirror of
https://github.com/github/codeql.git
synced 2026-07-09 05:25:32 +02:00
unified: Move Comments.ql into AstExtra.qll
Also move into 'internal' and expose through a Public module
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
22
unified/ql/lib/codeql/unified/internal/AstExtra.qll
Normal file
22
unified/ql/lib/codeql/unified/internal/AstExtra.qll
Normal 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)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user