tools/gn: rename char_offset to column_number

While looking at Location and trying to understand what char offset meant,
I got very confused, because in some languages, like Portuguese, it is
hard to translate offset and thus understand what it means. Actually
char offset is referring to the column number in text buffer, which is much
easier to understand and its meaning is instantly understood, since everyone is
familiar with the concenpt of rows (lines) and columns in a text editor.

BUG=None
TEST=gn gen + gn_unittests
R=brettw@chromium.org

Review URL: https://codereview.chromium.org/1525183002

Cr-Original-Commit-Position: refs/heads/master@{#367883}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 21aff0d0e90b1fc419971485150f76c4d2458e13
diff --git a/tools/gn/c_include_iterator_unittest.cc b/tools/gn/c_include_iterator_unittest.cc
index 5adbb65..a4278b2 100644
--- a/tools/gn/c_include_iterator_unittest.cc
+++ b/tools/gn/c_include_iterator_unittest.cc
@@ -15,8 +15,8 @@
              int line, int begin_char, int end_char) {
   return range.begin().line_number() == line &&
          range.end().line_number() == line &&
-         range.begin().char_offset() == begin_char &&
-         range.end().char_offset() == end_char;
+         range.begin().column_number() == begin_char &&
+         range.end().column_number() == end_char;
 }
 
 }  // namespace
diff --git a/tools/gn/err.cc b/tools/gn/err.cc
index e10f001..378fb7e 100644
--- a/tools/gn/err.cc
+++ b/tools/gn/err.cc
@@ -39,13 +39,13 @@
   if (range.begin().line_number() < line_number)
     begin_char = 0;
   else
-    begin_char = range.begin().char_offset() - 1;
+    begin_char = range.begin().column_number() - 1;
 
   int end_char;
   if (range.end().line_number() > line_number)
     end_char = static_cast<int>(line->size());  // Ending is non-inclusive.
   else
-    end_char = range.end().char_offset() - 1;
+    end_char = range.end().column_number() - 1;
 
   CHECK(end_char >= begin_char);
   CHECK(begin_char >= 0 && begin_char <= static_cast<int>(line->size()));
@@ -71,9 +71,9 @@
 
   // Allow the marker to be one past the end of the line for marking the end.
   highlight.push_back(' ');
-  CHECK(location.char_offset() - 1 >= 0 &&
-        location.char_offset() - 1 < static_cast<int>(highlight.size()));
-  highlight[location.char_offset() - 1] = '^';
+  CHECK(location.column_number() - 1 >= 0 &&
+        location.column_number() - 1 < static_cast<int>(highlight.size()));
+  highlight[location.column_number() - 1] = '^';
 
   // Trim unused spaces from end of line.
   while (!highlight.empty() && highlight[highlight.size() - 1] == ' ')
diff --git a/tools/gn/header_checker.cc b/tools/gn/header_checker.cc
index 05b624c..ada9d70 100644
--- a/tools/gn/header_checker.cc
+++ b/tools/gn/header_checker.cc
@@ -63,11 +63,11 @@
 
   return LocationRange(Location(clone_input_file,
                                 range.begin().line_number(),
-                                range.begin().char_offset(),
+                                range.begin().column_number(),
                                 -1 /* TODO(scottmg) */),
                        Location(clone_input_file,
                                 range.end().line_number(),
-                                range.end().char_offset(),
+                                range.end().column_number(),
                                 -1 /* TODO(scottmg) */));
 }
 
diff --git a/tools/gn/input_conversion_unittest.cc b/tools/gn/input_conversion_unittest.cc
index aff6667..2c4afea 100644
--- a/tools/gn/input_conversion_unittest.cc
+++ b/tools/gn/input_conversion_unittest.cc
@@ -126,7 +126,7 @@
   ASSERT_TRUE(a_origin);
   LocationRange a_range = a_origin->GetRange();
   EXPECT_EQ(2, a_range.begin().line_number());
-  EXPECT_EQ(6, a_range.begin().char_offset());
+  EXPECT_EQ(6, a_range.begin().column_number());
 
   const InputFile* a_file = a_range.begin().file();
   EXPECT_EQ(input, a_file->contents());
diff --git a/tools/gn/location.cc b/tools/gn/location.cc
index 59b99d6..49ca3ff 100644
--- a/tools/gn/location.cc
+++ b/tools/gn/location.cc
@@ -13,23 +13,23 @@
 Location::Location()
     : file_(nullptr),
       line_number_(-1),
-      char_offset_(-1) {
+      column_number_(-1) {
 }
 
 Location::Location(const InputFile* file,
                    int line_number,
-                   int char_offset,
+                   int column_number,
                    int byte)
     : file_(file),
       line_number_(line_number),
-      char_offset_(char_offset),
+      column_number_(column_number),
       byte_(byte) {
 }
 
 bool Location::operator==(const Location& other) const {
   return other.file_ == file_ &&
          other.line_number_ == line_number_ &&
-         other.char_offset_ == char_offset_;
+         other.column_number_ == column_number_;
 }
 
 bool Location::operator!=(const Location& other) const {
@@ -38,11 +38,11 @@
 
 bool Location::operator<(const Location& other) const {
   DCHECK(file_ == other.file_);
-  return std::tie(line_number_, char_offset_) <
-         std::tie(other.line_number_, other.char_offset_);
+  return std::tie(line_number_, column_number_) <
+         std::tie(other.line_number_, other.column_number_);
 }
 
-std::string Location::Describe(bool include_char_offset) const {
+std::string Location::Describe(bool include_column_number) const {
   if (!file_)
     return std::string();
 
@@ -54,9 +54,9 @@
 
   ret += ":";
   ret += base::IntToString(line_number_);
-  if (include_char_offset) {
+  if (include_column_number) {
     ret += ":";
-    ret += base::IntToString(char_offset_);
+    ret += base::IntToString(column_number_);
   }
   return ret;
 }
diff --git a/tools/gn/location.h b/tools/gn/location.h
index b56e73d..44d1a6f 100644
--- a/tools/gn/location.h
+++ b/tools/gn/location.h
@@ -13,11 +13,11 @@
 class Location {
  public:
   Location();
-  Location(const InputFile* file, int line_number, int char_offset, int byte);
+  Location(const InputFile* file, int line_number, int column_number, int byte);
 
   const InputFile* file() const { return file_; }
   int line_number() const { return line_number_; }
-  int char_offset() const { return char_offset_; }
+  int column_number() const { return column_number_; }
   int byte() const { return byte_; }
 
   bool operator==(const Location& other) const;
@@ -27,12 +27,12 @@
   // Returns a string with the file, line, and (optionally) the character
   // offset for this location. If this location is null, returns an empty
   // string.
-  std::string Describe(bool include_char_offset) const;
+  std::string Describe(bool include_column_number) const;
 
  private:
   const InputFile* file_;  // Null when unset.
   int line_number_;        // -1 when unset. 1-based.
-  int char_offset_;        // -1 when unset. 1-based.
+  int column_number_;      // -1 when unset. 1-based.
   int byte_;               // Index into the buffer, 0-based.
 };
 
diff --git a/tools/gn/parse_tree.cc b/tools/gn/parse_tree.cc
index 2c55037..167531c 100644
--- a/tools/gn/parse_tree.cc
+++ b/tools/gn/parse_tree.cc
@@ -256,7 +256,7 @@
 void AccessorNode::SetNewLocation(int line_number) {
   Location old = base_.location();
   base_.set_location(
-      Location(old.file(), line_number, old.char_offset(), old.byte()));
+      Location(old.file(), line_number, old.column_number(), old.byte()));
 }
 
 // BinaryOpNode ---------------------------------------------------------------
@@ -483,7 +483,7 @@
 void IdentifierNode::SetNewLocation(int line_number) {
   Location old = value_.location();
   value_.set_location(
-      Location(old.file(), line_number, old.char_offset(), old.byte()));
+      Location(old.file(), line_number, old.column_number(), old.byte()));
 }
 
 // ListNode -------------------------------------------------------------------
@@ -742,7 +742,7 @@
 void LiteralNode::SetNewLocation(int line_number) {
   Location old = value_.location();
   value_.set_location(
-      Location(old.file(), line_number, old.char_offset(), old.byte()));
+      Location(old.file(), line_number, old.column_number(), old.byte()));
 }
 
 // UnaryOpNode ----------------------------------------------------------------
diff --git a/tools/gn/parse_tree_unittest.cc b/tools/gn/parse_tree_unittest.cc
index b46114f..fba902a 100644
--- a/tools/gn/parse_tree_unittest.cc
+++ b/tools/gn/parse_tree_unittest.cc
@@ -94,7 +94,7 @@
   // origin will point to the value assigned to the variable (in this case, the
   // "13" assigned to "b".
   EXPECT_EQ(3, err.location().line_number());
-  EXPECT_EQ(7, err.location().char_offset());
+  EXPECT_EQ(7, err.location().column_number());
 }
 
 TEST(ParseTree, OriginForDereference) {
@@ -111,7 +111,7 @@
   // The origin for the "not a string" error message should be where the value
   // was dereferenced (the "a" on the second line).
   EXPECT_EQ(2, err.location().line_number());
-  EXPECT_EQ(20, err.location().char_offset());
+  EXPECT_EQ(20, err.location().column_number());
 }
 
 TEST(ParseTree, SortRangeExtraction) {
diff --git a/tools/gn/parser_unittest.cc b/tools/gn/parser_unittest.cc
index 39b69b7..b6c2009 100644
--- a/tools/gn/parser_unittest.cc
+++ b/tools/gn/parser_unittest.cc
@@ -68,7 +68,7 @@
   }
 
   EXPECT_EQ(err_line, err.location().line_number());
-  EXPECT_EQ(err_char, err.location().char_offset());
+  EXPECT_EQ(err_char, err.location().column_number());
 }
 
 // Expects the tokenizer or parser to identify an error at the given line and
@@ -86,7 +86,7 @@
   }
 
   EXPECT_EQ(err_line, err.location().line_number());
-  EXPECT_EQ(err_char, err.location().char_offset());
+  EXPECT_EQ(err_char, err.location().column_number());
 }
 
 }  // namespace
diff --git a/tools/gn/string_utils.cc b/tools/gn/string_utils.cc
index 7246f75..83a98bd 100644
--- a/tools/gn/string_utils.cc
+++ b/tools/gn/string_utils.cc
@@ -27,12 +27,13 @@
   int int_offset = static_cast<int>(offset);
   Location begin_loc(token.location().file(),
                      token.location().line_number(),
-                     token.location().char_offset() + int_offset + 1,
+                     token.location().column_number() + int_offset + 1,
                      token.location().byte() + int_offset + 1);
   Location end_loc(
       token.location().file(),
       token.location().line_number(),
-      token.location().char_offset() + int_offset + 1 + static_cast<int>(size),
+      token.location().column_number() + int_offset + 1 +
+          static_cast<int>(size),
       token.location().byte() + int_offset + 1 + static_cast<int>(size));
   return Err(LocationRange(begin_loc, end_loc), msg, help);
 }
diff --git a/tools/gn/token.h b/tools/gn/token.h
index 45b6e28..bf87283 100644
--- a/tools/gn/token.h
+++ b/tools/gn/token.h
@@ -68,7 +68,7 @@
         location_,
         Location(location_.file(),
                  location_.line_number(),
-                 location_.char_offset() + static_cast<int>(value_.size()),
+                 location_.column_number() + static_cast<int>(value_.size()),
                  location_.byte() + static_cast<int>(value_.size())));
   }
 
diff --git a/tools/gn/tokenizer.cc b/tools/gn/tokenizer.cc
index 4dd71d5..0568bec 100644
--- a/tools/gn/tokenizer.cc
+++ b/tools/gn/tokenizer.cc
@@ -74,7 +74,7 @@
       err_(err),
       cur_(0),
       line_number_(1),
-      char_in_line_(1) {
+      column_number_(1) {
 }
 
 Tokenizer::~Tokenizer() {
@@ -126,7 +126,8 @@
           (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())) {
+           tokens_.back().location().column_number() !=
+               location.column_number())) {
         type = Token::LINE_COMMENT;
         if (!at_end())  // Could be EOF.
           Advance();  // The current \n.
@@ -374,16 +375,16 @@
   DCHECK(cur_ < input_.size());
   if (IsCurrentNewline()) {
     line_number_++;
-    char_in_line_ = 1;
+    column_number_ = 1;
   } else {
-    char_in_line_++;
+    column_number_++;
   }
   cur_++;
 }
 
 Location Tokenizer::GetCurrentLocation() const {
   return Location(
-      input_file_, line_number_, char_in_line_, static_cast<int>(cur_));
+      input_file_, line_number_, column_number_, static_cast<int>(cur_));
 }
 
 Err Tokenizer::GetErrorForInvalidToken(const Location& location) const {
diff --git a/tools/gn/tokenizer.h b/tools/gn/tokenizer.h
index bf3285b..9b6ef33 100644
--- a/tools/gn/tokenizer.h
+++ b/tools/gn/tokenizer.h
@@ -82,7 +82,7 @@
   size_t cur_;  // Byte offset into input buffer.
 
   int line_number_;
-  int char_in_line_;
+  int column_number_;
 
   DISALLOW_COPY_AND_ASSIGN(Tokenizer);
 };