OLD | NEW |
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/eclipse_writer.h" | 5 #include "tools/gn/eclipse_writer.h" |
6 | 6 |
7 #include <fstream> | 7 #include <fstream> |
| 8 #include <memory> |
8 | 9 |
9 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
10 #include "base/memory/scoped_ptr.h" | |
11 #include "tools/gn/builder.h" | 11 #include "tools/gn/builder.h" |
12 #include "tools/gn/config_values_extractors.h" | 12 #include "tools/gn/config_values_extractors.h" |
13 #include "tools/gn/filesystem_utils.h" | 13 #include "tools/gn/filesystem_utils.h" |
14 #include "tools/gn/loader.h" | 14 #include "tools/gn/loader.h" |
15 #include "tools/gn/xml_element_writer.h" | 15 #include "tools/gn/xml_element_writer.h" |
16 | 16 |
17 namespace { | 17 namespace { |
18 | 18 |
19 // Escapes |unescaped| for use in XML element content. | 19 // Escapes |unescaped| for use in XML element content. |
20 std::string EscapeForXML(const std::string& unescaped) { | 20 std::string EscapeForXML(const std::string& unescaped) { |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 } | 120 } |
121 | 121 |
122 void EclipseWriter::WriteCDTSettings() { | 122 void EclipseWriter::WriteCDTSettings() { |
123 out_ << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << std::endl; | 123 out_ << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << std::endl; |
124 XmlElementWriter cdt_properties_element(out_, "cdtprojectproperties", | 124 XmlElementWriter cdt_properties_element(out_, "cdtprojectproperties", |
125 XmlAttributes()); | 125 XmlAttributes()); |
126 | 126 |
127 { | 127 { |
128 const char* kIncludesSectionName = | 128 const char* kIncludesSectionName = |
129 "org.eclipse.cdt.internal.ui.wizards.settingswizards.IncludePaths"; | 129 "org.eclipse.cdt.internal.ui.wizards.settingswizards.IncludePaths"; |
130 scoped_ptr<XmlElementWriter> section_element = | 130 std::unique_ptr<XmlElementWriter> section_element = |
131 cdt_properties_element.SubElement( | 131 cdt_properties_element.SubElement( |
132 "section", XmlAttributes("name", kIncludesSectionName)); | 132 "section", XmlAttributes("name", kIncludesSectionName)); |
133 | 133 |
134 section_element->SubElement( | 134 section_element->SubElement( |
135 "language", XmlAttributes("name", "holder for library settings")); | 135 "language", XmlAttributes("name", "holder for library settings")); |
136 | 136 |
137 for (const std::string& language : languages_) { | 137 for (const std::string& language : languages_) { |
138 scoped_ptr<XmlElementWriter> language_element = | 138 std::unique_ptr<XmlElementWriter> language_element = |
139 section_element->SubElement("language", | 139 section_element->SubElement("language", |
140 XmlAttributes("name", language)); | 140 XmlAttributes("name", language)); |
141 for (const std::string& include_dir : include_dirs_) { | 141 for (const std::string& include_dir : include_dirs_) { |
142 language_element | 142 language_element |
143 ->SubElement("includepath", | 143 ->SubElement("includepath", |
144 XmlAttributes("workspace_path", "false")) | 144 XmlAttributes("workspace_path", "false")) |
145 ->Text(EscapeForXML(include_dir)); | 145 ->Text(EscapeForXML(include_dir)); |
146 } | 146 } |
147 } | 147 } |
148 } | 148 } |
149 | 149 |
150 { | 150 { |
151 const char* kMacrosSectionName = | 151 const char* kMacrosSectionName = |
152 "org.eclipse.cdt.internal.ui.wizards.settingswizards.Macros"; | 152 "org.eclipse.cdt.internal.ui.wizards.settingswizards.Macros"; |
153 scoped_ptr<XmlElementWriter> section_element = | 153 std::unique_ptr<XmlElementWriter> section_element = |
154 cdt_properties_element.SubElement( | 154 cdt_properties_element.SubElement( |
155 "section", XmlAttributes("name", kMacrosSectionName)); | 155 "section", XmlAttributes("name", kMacrosSectionName)); |
156 | 156 |
157 section_element->SubElement( | 157 section_element->SubElement( |
158 "language", XmlAttributes("name", "holder for library settings")); | 158 "language", XmlAttributes("name", "holder for library settings")); |
159 | 159 |
160 for (const std::string& language : languages_) { | 160 for (const std::string& language : languages_) { |
161 scoped_ptr<XmlElementWriter> language_element = | 161 std::unique_ptr<XmlElementWriter> language_element = |
162 section_element->SubElement("language", | 162 section_element->SubElement("language", |
163 XmlAttributes("name", language)); | 163 XmlAttributes("name", language)); |
164 for (const auto& key_val : defines_) { | 164 for (const auto& key_val : defines_) { |
165 scoped_ptr<XmlElementWriter> macro_element = | 165 std::unique_ptr<XmlElementWriter> macro_element = |
166 language_element->SubElement("macro"); | 166 language_element->SubElement("macro"); |
167 macro_element->SubElement("name")->Text(EscapeForXML(key_val.first)); | 167 macro_element->SubElement("name")->Text(EscapeForXML(key_val.first)); |
168 macro_element->SubElement("value")->Text(EscapeForXML(key_val.second)); | 168 macro_element->SubElement("value")->Text(EscapeForXML(key_val.second)); |
169 } | 169 } |
170 } | 170 } |
171 } | 171 } |
172 } | 172 } |
OLD | NEW |