Index: tools/gn/c_include_iterator.h |
diff --git a/tools/gn/c_include_iterator.h b/tools/gn/c_include_iterator.h |
index 2a25ef6f95fa9e13bda9a3df0a8bf13257ff2c37..41c124617ad7814635c16ad42a38e2ad0463efab 100644 |
--- a/tools/gn/c_include_iterator.h |
+++ b/tools/gn/c_include_iterator.h |
@@ -8,32 +8,43 @@ |
#include "base/basictypes.h" |
#include "base/strings/string_piece.h" |
+class InputFile; |
+class LocationRange; |
+ |
// Iterates through #includes in C source and header files. |
// |
// This only returns includes we want to check, which is user includes with |
// double-quotes: #include "..." |
class CIncludeIterator { |
public: |
- // The buffer pointed to must outlive this class. |
- CIncludeIterator(const base::StringPiece& file); |
+ // The InputFile pointed to must outlive this class. |
+ CIncludeIterator(const InputFile* input); |
~CIncludeIterator(); |
- // Fills in the string with the contents of the next include and returns |
- // true, or returns false if there are no more includes. |
- bool GetNextIncludeString(base::StringPiece* out); |
+ // Fills in the string with the contents of the next include, and the |
+ // location with where it came from, and returns true, or returns false if |
+ // there are no more includes. |
+ bool GetNextIncludeString(base::StringPiece* out, LocationRange* location); |
// Maximum numbef of non-includes we'll tolerate before giving up. This does |
// not count comments or preprocessor. |
static const int kMaxNonIncludeLines; |
private: |
- // Returns false on EOF, otherwise fills in the given line. |
- bool GetNextLine(base::StringPiece* line); |
+ // Returns false on EOF, otherwise fills in the given line and the one-based |
+ // line number into *line_number; |
+ bool GetNextLine(base::StringPiece* line, int* line_number); |
+ |
+ const InputFile* input_file_; |
+ // This just points into input_file_.contents() for convenience. |
base::StringPiece file_; |
+ // 0-based offset into the file. |
size_t offset_; |
+ int line_number_; // One-based. Indicates the last line we read. |
+ |
// Number of lines we've processed since seeing the last include (or the |
// beginning of the file) with some exceptions. |
int lines_since_last_include_; |