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

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: only continue if at same column 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/parser_unittest.cc ('k') | tools/gn/tokenizer_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/tokenizer.cc
diff --git a/tools/gn/tokenizer.cc b/tools/gn/tokenizer.cc
index 568a20e836b25e7bbc34b0077f12295208fc296e..4f6c5cc209abd801ed3460b9fd9e94b4d50075dc 100644
--- a/tools/gn/tokenizer.cc
+++ b/tools/gn/tokenizer.cc
@@ -120,10 +120,17 @@ std::vector<Token> Tokenizer::Run() {
else if (token_value == "false")
type = Token::FALSE_TOKEN;
} else if (type == Token::UNCLASSIFIED_COMMENT) {
- if (AtStartOfLine(token_begin))
+ if (AtStartOfLine(token_begin) &&
+ // 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() ||
+ tokens_.back().location().char_offset() != location.char_offset())) {
type = Token::LINE_COMMENT;
- else
+ } else {
type = Token::SUFFIX_COMMENT;
+ }
}
tokens_.push_back(Token(location, type, token_value));
« no previous file with comments | « tools/gn/parser_unittest.cc ('k') | tools/gn/tokenizer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698