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

Side by Side Diff: tools/gn/err.cc

Issue 986113002: tools/gn: Convert for loops to use the new range-based loops in C++11. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review fixes Created 5 years, 9 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 unified diff | Download patch
« no previous file with comments | « tools/gn/command_desc.cc ('k') | tools/gn/escape.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "tools/gn/err.h" 5 #include "tools/gn/err.h"
6 6
7 #include "base/strings/string_number_conversions.h" 7 #include "base/strings/string_number_conversions.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "tools/gn/filesystem_utils.h" 9 #include "tools/gn/filesystem_utils.h"
10 #include "tools/gn/input_file.h" 10 #include "tools/gn/input_file.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 void OutputHighlighedPosition(const Location& location, 57 void OutputHighlighedPosition(const Location& location,
58 const Err::RangeList& ranges, 58 const Err::RangeList& ranges,
59 size_t line_length) { 59 size_t line_length) {
60 // Make a buffer of the line in spaces. 60 // Make a buffer of the line in spaces.
61 std::string highlight; 61 std::string highlight;
62 highlight.resize(line_length); 62 highlight.resize(line_length);
63 for (size_t i = 0; i < line_length; i++) 63 for (size_t i = 0; i < line_length; i++)
64 highlight[i] = ' '; 64 highlight[i] = ' ';
65 65
66 // Highlight all the ranges on the line. 66 // Highlight all the ranges on the line.
67 for (size_t i = 0; i < ranges.size(); i++) 67 for (const auto& range : ranges)
68 FillRangeOnLine(ranges[i], location.line_number(), &highlight); 68 FillRangeOnLine(range, location.line_number(), &highlight);
69 69
70 // Allow the marker to be one past the end of the line for marking the end. 70 // Allow the marker to be one past the end of the line for marking the end.
71 highlight.push_back(' '); 71 highlight.push_back(' ');
72 CHECK(location.char_offset() - 1 >= 0 && 72 CHECK(location.char_offset() - 1 >= 0 &&
73 location.char_offset() - 1 < static_cast<int>(highlight.size())); 73 location.char_offset() - 1 < static_cast<int>(highlight.size()));
74 highlight[location.char_offset() - 1] = '^'; 74 highlight[location.char_offset() - 1] = '^';
75 75
76 // Trim unused spaces from end of line. 76 // Trim unused spaces from end of line.
77 while (!highlight.empty() && highlight[highlight.size() - 1] == ' ') 77 while (!highlight.empty() && highlight[highlight.size() - 1] == ' ')
78 highlight.resize(highlight.size() - 1); 78 highlight.resize(highlight.size() - 1);
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 } 182 }
183 183
184 // Optional help text. 184 // Optional help text.
185 if (!help_text_.empty()) 185 if (!help_text_.empty())
186 OutputString(help_text_ + "\n"); 186 OutputString(help_text_ + "\n");
187 187
188 // Sub errors. 188 // Sub errors.
189 for (const auto& sub_err : sub_errs_) 189 for (const auto& sub_err : sub_errs_)
190 sub_err.InternalPrintToStdout(true); 190 sub_err.InternalPrintToStdout(true);
191 } 191 }
OLDNEW
« no previous file with comments | « tools/gn/command_desc.cc ('k') | tools/gn/escape.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698