diff options
author | Federico Guerinoni <guerinoni.federico@gmail.com> | 2021-05-17 22:14:59 +0200 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-06-23 19:00:11 +0100 |
commit | c397e030f40e9126b98eb3c203daeb40d00fef40 (patch) | |
tree | 4ade9b15dc7dea6efae85cc56c0046d22267c5a5 /Userland | |
parent | fcef84c4612d3d19b840bf6bdb7da764684f4bd1 (diff) | |
download | serenity-c397e030f40e9126b98eb3c203daeb40d00fef40.zip |
LibCpp: Add function for retrieving TODO comments from the parser
Now `get_todo_entries` collects all TODO found within a comment
statement.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibCpp/Parser.cpp | 13 | ||||
-rw-r--r-- | Userland/Libraries/LibCpp/Parser.h | 1 |
2 files changed, 14 insertions, 0 deletions
diff --git a/Userland/Libraries/LibCpp/Parser.cpp b/Userland/Libraries/LibCpp/Parser.cpp index 0eee97958a..c4b913ef6a 100644 --- a/Userland/Libraries/LibCpp/Parser.cpp +++ b/Userland/Libraries/LibCpp/Parser.cpp @@ -961,6 +961,19 @@ void Parser::print_tokens() const } } +Vector<String> Parser::get_todo_entries() const +{ + Vector<String> ret; + for (auto& token : m_tokens) { + if (token.type() == Token::Type::Comment) { + if (token.text().contains("TODO")) { + ret.append(token.text()); + } + } + } + return ret; +} + NonnullRefPtr<StringLiteral> Parser::parse_string_literal(ASTNode& parent) { ScopeLogger<CPP_DEBUG> logger; diff --git a/Userland/Libraries/LibCpp/Parser.h b/Userland/Libraries/LibCpp/Parser.h index 22e294fbf0..1ac0226151 100644 --- a/Userland/Libraries/LibCpp/Parser.h +++ b/Userland/Libraries/LibCpp/Parser.h @@ -35,6 +35,7 @@ public: void print_tokens() const; const Vector<String>& errors() const { return m_state.errors; } const Preprocessor::Definitions& preprocessor_definitions() const { return m_preprocessor_definitions; } + Vector<String> get_todo_entries() const; struct TokenAndPreprocessorDefinition { Token token; |