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

Side by Side Diff: tools/gn/input_conversion.cc

Issue 63153003: mac: Prepare for -Wunused-functions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « net/spdy/spdy_session.cc ('k') | tools/gn/parser.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 #include "tools/gn/input_conversion.h" 5 #include "tools/gn/input_conversion.h"
6 6
7 #include "base/strings/string_split.h" 7 #include "base/strings/string_split.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "tools/gn/build_settings.h" 9 #include "tools/gn/build_settings.h"
10 #include "tools/gn/err.h" 10 #include "tools/gn/err.h"
11 #include "tools/gn/input_file.h" 11 #include "tools/gn/input_file.h"
12 #include "tools/gn/label.h" 12 #include "tools/gn/label.h"
13 #include "tools/gn/parse_tree.h" 13 #include "tools/gn/parse_tree.h"
14 #include "tools/gn/parser.h" 14 #include "tools/gn/parser.h"
15 #include "tools/gn/scope.h" 15 #include "tools/gn/scope.h"
16 #include "tools/gn/settings.h" 16 #include "tools/gn/settings.h"
17 #include "tools/gn/tokenizer.h" 17 #include "tools/gn/tokenizer.h"
18 #include "tools/gn/value.h" 18 #include "tools/gn/value.h"
19 19
20 namespace { 20 namespace {
21 21
22 // Returns the "first bit" of some script output for writing to error messages.
23 std::string GetExampleOfBadInput(const std::string& input) {
24 std::string result(input);
25
26 // Maybe the result starts with a blank line or something, which we don't
27 // want.
28 TrimWhitespaceASCII(result, TRIM_ALL, &result);
29
30 // Now take the first line, or the first set of chars, whichever is shorter.
31 bool trimmed = false;
32 size_t newline_offset = result.find('\n');
33 if (newline_offset != std::string::npos) {
34 trimmed = true;
35 result.resize(newline_offset);
36 }
37 TrimWhitespaceASCII(result, TRIM_ALL, &result);
38
39 const size_t kMaxSize = 50;
40 if (result.size() > kMaxSize) {
41 trimmed = true;
42 result.resize(kMaxSize);
43 }
44
45 if (trimmed)
46 result.append("...");
47 return result;
48 }
49
50 // When parsing the result as a value, we may get various types of errors. 22 // When parsing the result as a value, we may get various types of errors.
51 // This creates an error message for this case with an optional nested error 23 // This creates an error message for this case with an optional nested error
52 // message to reference. If there is no nested err, pass Err(). 24 // message to reference. If there is no nested err, pass Err().
53 // 25 //
54 // This code also takes care to rewrite the original error which will reference 26 // This code also takes care to rewrite the original error which will reference
55 // the temporary InputFile which won't exist when the error is propogated 27 // the temporary InputFile which won't exist when the error is propogated
56 // out to a higher level. 28 // out to a higher level.
57 Err MakeParseErr(const std::string& input, 29 Err MakeParseErr(const std::string& input,
58 const ParseNode* origin, 30 const ParseNode* origin,
59 const Err& nested) { 31 const Err& nested) {
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 return ParseString(input, origin, err); 166 return ParseString(input, origin, err);
195 if (input_conversion == "string") 167 if (input_conversion == "string")
196 return Value(origin, input); 168 return Value(origin, input);
197 if (input_conversion == "list lines") 169 if (input_conversion == "list lines")
198 return ParseList(input, origin, err); 170 return ParseList(input, origin, err);
199 171
200 *err = Err(input_conversion_value, "Not a valid read file mode.", 172 *err = Err(input_conversion_value, "Not a valid read file mode.",
201 "Have you considered a career in retail?"); 173 "Have you considered a career in retail?");
202 return Value(); 174 return Value();
203 } 175 }
OLDNEW
« no previous file with comments | « net/spdy/spdy_session.cc ('k') | tools/gn/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698