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

Unified Diff: tools/gn/tokenizer.cc

Issue 595753002: gn: handle continued suffix comments (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gn-append-comment
Patch Set: 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
Index: tools/gn/tokenizer.cc
diff --git a/tools/gn/tokenizer.cc b/tools/gn/tokenizer.cc
index ea7c55ab8b95ea10892bcb39d672ea7e5c844961..318a310a4db4cd37e05c34c93c9dfe8822881408 100644
--- a/tools/gn/tokenizer.cc
+++ b/tools/gn/tokenizer.cc
@@ -128,10 +128,17 @@ std::vector<Token> Tokenizer::Run() {
std::string trimmed;
// TODO(scottmg): Should write TrimWhitespace for StringPiece.
base::TrimWhitespace(to_newline.as_string(), base::TRIM_ALL, &trimmed);
- if (trimmed.empty())
+ if (trimmed.empty() &&
+ // If it's a standalone comment, but is a continuation of a comment
+ // on a previous line, then instead make it a continued suffix
+ // comment.
+ (tokens_.empty() || tokens_.back().type() != Token::SUFFIX_COMMENT ||
+ tokens_.back().location().line_number() + 1 !=
+ location.line_number())) {
type = Token::LINE_COMMENT;
- else
+ } else {
type = Token::SUFFIX_COMMENT;
+ }
}
tokens_.push_back(Token(location, type, token_value));

Powered by Google App Engine
This is Rietveld 408576698