tools/gn: move the implementation of IsIdentifierXXX functions to the source file
Does not seem to have a reason to have some functions implemented in the
header while the others are in the source file.
This also allow us to remove the include of string_util.h, and have it
included only in the source file.
BUG=None
R=scottmg@chromium.org
Review URL: https://codereview.chromium.org/1483903004
Cr-Original-Commit-Position: refs/heads/master@{#362285}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 0c60e3a9bb46ef9f3cf92f90f3e6fde598f3b8ee
diff --git a/tools/gn/command_format.cc b/tools/gn/command_format.cc
index 6c199d3..3620a80 100644
--- a/tools/gn/command_format.cc
+++ b/tools/gn/command_format.cc
@@ -7,6 +7,7 @@
#include "base/command_line.h"
#include "base/files/file_util.h"
#include "base/strings/string_split.h"
+#include "base/strings/string_util.h"
#include "tools/gn/commands.h"
#include "tools/gn/filesystem_utils.h"
#include "tools/gn/input_file.h"
diff --git a/tools/gn/tokenizer.cc b/tools/gn/tokenizer.cc
index db10f6a..4dd71d5 100644
--- a/tools/gn/tokenizer.cc
+++ b/tools/gn/tokenizer.cc
@@ -180,6 +180,16 @@
return buffer[offset] == '\n';
}
+// static
+bool Tokenizer::IsIdentifierFirstChar(char c) {
+ return base::IsAsciiAlpha(c) || c == '_';
+}
+
+// static
+bool Tokenizer::IsIdentifierContinuingChar(char c) {
+ // Also allow digits after the first char.
+ return IsIdentifierFirstChar(c) || base::IsAsciiDigit(c);
+}
void Tokenizer::AdvanceToNextToken() {
while (!at_end() && IsCurrentWhitespace())
diff --git a/tools/gn/tokenizer.h b/tools/gn/tokenizer.h
index 5fa48b1..a37f4dc 100644
--- a/tools/gn/tokenizer.h
+++ b/tools/gn/tokenizer.h
@@ -9,7 +9,6 @@
#include "base/macros.h"
#include "base/strings/string_piece.h"
-#include "base/strings/string_util.h"
#include "tools/gn/err.h"
#include "tools/gn/token.h"
@@ -32,14 +31,9 @@
// The offset must be in the buffer.
static bool IsNewline(const base::StringPiece& buffer, size_t offset);
- static bool IsIdentifierFirstChar(char c) {
- return base::IsAsciiAlpha(c) || c == '_';
- }
+ static bool IsIdentifierFirstChar(char c);
- static bool IsIdentifierContinuingChar(char c) {
- // Also allow digits after the first char.
- return IsIdentifierFirstChar(c) || base::IsAsciiDigit(c);
- }
+ static bool IsIdentifierContinuingChar(char c);
private:
// InputFile must outlive the tokenizer and all generated tokens.