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

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

Issue 1649783003: Port "Eclipse CDT settings" file generation from GYP to GN (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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/gn.gyp ('k') | tools/gn/xml_element_writer_unittest.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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/xml_element_writer.h" 5 #include "tools/gn/xml_element_writer.h"
6 6
7 XmlAttributes::XmlAttributes() {} 7 XmlAttributes::XmlAttributes() {}
8 8
9 XmlAttributes::XmlAttributes(const base::StringPiece& attr_key, 9 XmlAttributes::XmlAttributes(const base::StringPiece& attr_key,
10 const base::StringPiece& attr_value) { 10 const base::StringPiece& attr_value) {
(...skipping 20 matching lines...) Expand all
31 indent_(indent), 31 indent_(indent),
32 opening_tag_finished_(false), 32 opening_tag_finished_(false),
33 one_line_(true) { 33 one_line_(true) {
34 out << std::string(indent, ' ') << '<' << tag; 34 out << std::string(indent, ' ') << '<' << tag;
35 for (auto attribute : attributes) 35 for (auto attribute : attributes)
36 out << ' ' << attribute.first << "=\"" << attribute.second << '"'; 36 out << ' ' << attribute.first << "=\"" << attribute.second << '"';
37 } 37 }
38 38
39 XmlElementWriter::~XmlElementWriter() { 39 XmlElementWriter::~XmlElementWriter() {
40 if (!opening_tag_finished_) { 40 if (!opening_tag_finished_) {
41 out_ << "/>" << std::endl; 41 // The XML spec does not require a space before the closing slash. However,
42 // Eclipse is unable to parse XML settings files if there is no space.
43 out_ << " />" << std::endl;
42 } else { 44 } else {
43 if (!one_line_) 45 if (!one_line_)
44 out_ << std::string(indent_, ' '); 46 out_ << std::string(indent_, ' ');
45 out_ << "</" << tag_ << '>' << std::endl; 47 out_ << "</" << tag_ << '>' << std::endl;
46 } 48 }
47 } 49 }
48 50
49 void XmlElementWriter::Text(const base::StringPiece& content) { 51 void XmlElementWriter::Text(const base::StringPiece& content) {
50 StartContent(false); 52 StartContent(false);
51 out_ << content; 53 out_ << content;
(...skipping 18 matching lines...) Expand all
70 opening_tag_finished_ = true; 72 opening_tag_finished_ = true;
71 73
72 if (start_new_line && one_line_) { 74 if (start_new_line && one_line_) {
73 out_ << std::endl; 75 out_ << std::endl;
74 one_line_ = false; 76 one_line_ = false;
75 } 77 }
76 } 78 }
77 79
78 return out_; 80 return out_;
79 } 81 }
OLDNEW
« no previous file with comments | « tools/gn/gn.gyp ('k') | tools/gn/xml_element_writer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698