Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Unified Diff: tools/gn/parse_tree.h

Issue 588893006: gn: attach comments to parse tree (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: x64 Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/gn/location.cc ('k') | tools/gn/parse_tree.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/parse_tree.h
diff --git a/tools/gn/parse_tree.h b/tools/gn/parse_tree.h
index f9ec54362ad2434545fc4997da97e3e0b1b8cb5d..470a0577dd86f8663ab580d297d7bc4eaa31e402 100644
--- a/tools/gn/parse_tree.h
+++ b/tools/gn/parse_tree.h
@@ -25,6 +25,40 @@ class LiteralNode;
class Scope;
class UnaryOpNode;
+class Comments {
+ public:
+ Comments();
+ virtual ~Comments();
+
+ const std::vector<Token>& before() const { return before_; }
+ void append_before(Token c) {
+ before_.push_back(c);
+ }
+
+ const std::vector<Token>& suffix() const { return suffix_; }
+ void append_suffix(Token c) {
+ suffix_.push_back(c);
+ }
+
+ const std::vector<Token>& after() const { return after_; }
+ void append_after(Token c) {
+ after_.push_back(c);
+ }
+
+ private:
+ // Whole line comments before the expression.
+ std::vector<Token> before_;
+
+ // End-of-line comments after this expression.
+ std::vector<Token> suffix_;
+
+ // For top-level expressions only, after_ lists whole-line comments
+ // following the expression.
+ std::vector<Token> after_;
+
+ DISALLOW_COPY_AND_ASSIGN(Comments);
+};
+
// ParseNode -------------------------------------------------------------------
// A node in the AST.
@@ -57,7 +91,13 @@ class ParseNode {
// by the given number of spaces.
virtual void Print(std::ostream& out, int indent) const = 0;
+ const Comments* comments() const { return comments_.get(); }
+ Comments* comments_mutable();
+ void PrintComments(std::ostream& out, int indent) const;
+
private:
+ scoped_ptr<Comments> comments_;
+
DISALLOW_COPY_AND_ASSIGN(ParseNode);
};
« no previous file with comments | « tools/gn/location.cc ('k') | tools/gn/parse_tree.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698