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

Side by Side Diff: tools/gn/location.h

Issue 588893006: gn: attach comments to parse tree (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: x64 Created 6 years, 2 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/header_checker.cc ('k') | tools/gn/location.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 #ifndef TOOLS_GN_LOCATION_H_ 5 #ifndef TOOLS_GN_LOCATION_H_
6 #define TOOLS_GN_LOCATION_H_ 6 #define TOOLS_GN_LOCATION_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 class InputFile; 10 class InputFile;
11 11
12 // Represents a place in a source file. Used for error reporting. 12 // Represents a place in a source file. Used for error reporting.
13 class Location { 13 class Location {
14 public: 14 public:
15 Location(); 15 Location();
16 Location(const InputFile* file, int line_number, int char_offset); 16 Location(const InputFile* file, int line_number, int char_offset, int byte);
17 17
18 const InputFile* file() const { return file_; } 18 const InputFile* file() const { return file_; }
19 int line_number() const { return line_number_; } 19 int line_number() const { return line_number_; }
20 int char_offset() const { return char_offset_; } 20 int char_offset() const { return char_offset_; }
21 int byte() const { return byte_; }
21 22
22 bool operator==(const Location& other) const; 23 bool operator==(const Location& other) const;
23 bool operator!=(const Location& other) const; 24 bool operator!=(const Location& other) const;
24 bool operator<(const Location& other) const; 25 bool operator<(const Location& other) const;
25 26
26 // Returns a string with the file, line, and (optionally) the character 27 // Returns a string with the file, line, and (optionally) the character
27 // offset for this location. If this location is null, returns an empty 28 // offset for this location. If this location is null, returns an empty
28 // string. 29 // string.
29 std::string Describe(bool include_char_offset) const; 30 std::string Describe(bool include_char_offset) const;
30 31
31 private: 32 private:
32 const InputFile* file_; // Null when unset. 33 const InputFile* file_; // Null when unset.
33 int line_number_; // -1 when unset. 34 int line_number_; // -1 when unset. 1-based.
34 int char_offset_; // -1 when unset. 35 int char_offset_; // -1 when unset. 1-based.
36 int byte_; // Index into the buffer, 0-based.
35 }; 37 };
36 38
37 // Represents a range in a source file. Used for error reporting. 39 // Represents a range in a source file. Used for error reporting.
38 // The end is exclusive i.e. [begin, end) 40 // The end is exclusive i.e. [begin, end)
39 class LocationRange { 41 class LocationRange {
40 public: 42 public:
41 LocationRange(); 43 LocationRange();
42 LocationRange(const Location& begin, const Location& end); 44 LocationRange(const Location& begin, const Location& end);
43 45
44 const Location& begin() const { return begin_; } 46 const Location& begin() const { return begin_; }
45 const Location& end() const { return end_; } 47 const Location& end() const { return end_; }
46 48
47 LocationRange Union(const LocationRange& other) const; 49 LocationRange Union(const LocationRange& other) const;
48 50
49 private: 51 private:
50 Location begin_; 52 Location begin_;
51 Location end_; 53 Location end_;
52 }; 54 };
53 55
54 #endif // TOOLS_GN_LOCATION_H_ 56 #endif // TOOLS_GN_LOCATION_H_
OLDNEW
« no previous file with comments | « tools/gn/header_checker.cc ('k') | tools/gn/location.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698