OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/c_include_iterator.h" | 5 #include "tools/gn/c_include_iterator.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "tools/gn/input_file.h" | 10 #include "tools/gn/input_file.h" |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 | 127 |
128 bool CIncludeIterator::GetNextIncludeString(base::StringPiece* out, | 128 bool CIncludeIterator::GetNextIncludeString(base::StringPiece* out, |
129 LocationRange* location) { | 129 LocationRange* location) { |
130 base::StringPiece line; | 130 base::StringPiece line; |
131 int cur_line_number = 0; | 131 int cur_line_number = 0; |
132 while (lines_since_last_include_ <= kMaxNonIncludeLines && | 132 while (lines_since_last_include_ <= kMaxNonIncludeLines && |
133 GetNextLine(&line, &cur_line_number)) { | 133 GetNextLine(&line, &cur_line_number)) { |
134 base::StringPiece include_contents; | 134 base::StringPiece include_contents; |
135 int begin_char; | 135 int begin_char; |
136 IncludeType type = ExtractInclude(line, &include_contents, &begin_char); | 136 IncludeType type = ExtractInclude(line, &include_contents, &begin_char); |
137 if (type == INCLUDE_USER && !HasNoCheckAnnotation(line)) { | 137 if (type != INCLUDE_NONE && !HasNoCheckAnnotation(line)) { |
138 // Only count user includes for now. | |
139 *out = include_contents; | 138 *out = include_contents; |
140 *location = LocationRange( | 139 *location = LocationRange( |
141 Location(input_file_, | 140 Location(input_file_, |
142 cur_line_number, | 141 cur_line_number, |
143 begin_char, | 142 begin_char, |
144 -1 /* TODO(scottmg): Is this important? */), | 143 -1 /* TODO(scottmg): Is this important? */), |
145 Location(input_file_, | 144 Location(input_file_, |
146 cur_line_number, | 145 cur_line_number, |
147 begin_char + static_cast<int>(include_contents.size()), | 146 begin_char + static_cast<int>(include_contents.size()), |
148 -1 /* TODO(scottmg): Is this important? */)); | 147 -1 /* TODO(scottmg): Is this important? */)); |
(...skipping 18 matching lines...) Expand all Loading... |
167 line_number_++; | 166 line_number_++; |
168 | 167 |
169 *line = file_.substr(begin, offset_ - begin); | 168 *line = file_.substr(begin, offset_ - begin); |
170 *line_number = line_number_; | 169 *line_number = line_number_; |
171 | 170 |
172 // If we didn't hit EOF, skip past the newline for the next one. | 171 // If we didn't hit EOF, skip past the newline for the next one. |
173 if (offset_ < file_.size()) | 172 if (offset_ < file_.size()) |
174 offset_++; | 173 offset_++; |
175 return true; | 174 return true; |
176 } | 175 } |
OLD | NEW |