diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsProvidersSerializer.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsProvidersSerializer.java
index 02110ec446f..6c75983cc1b 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsProvidersSerializer.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsProvidersSerializer.java
@@ -40,7 +40,6 @@ import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.cdt.core.settings.model.ICSettingEntry;
import org.eclipse.cdt.internal.core.XmlUtil;
-import org.eclipse.cdt.internal.core.model.Util;
import org.eclipse.cdt.internal.core.settings.model.CConfigurationSpecSettings;
import org.eclipse.cdt.internal.core.settings.model.IInternalCCfgInfo;
import org.eclipse.cdt.internal.core.settings.model.SettingsModelMessages;
@@ -588,11 +587,7 @@ public class LanguageSettingsProvidersSerializer {
try {
serializingLockWsp.acquire();
- String eol = Util.getLineSeparator(uriStoreWsp);
- if (eol == null) {
- eol = Util.getDefaultLineSeparator();
- }
- XmlUtil.serializeXml(doc, uriStoreWsp, eol);
+ XmlUtil.serializeXml(doc, uriStoreWsp);
// manufacture events while inside the lock
events = createLanguageSettingsChangeEvents(broadcastingWorkspaceProviders);
} finally {
@@ -915,11 +910,7 @@ public class LanguageSettingsProvidersSerializer {
if (isWorkspaceStoreEmpty) {
new java.io.File(uriStoreWsp).delete();
} else {
- String eol = Util.getLineSeparator(uriStoreWsp);
- if (eol == null) {
- eol = Util.getDefaultLineSeparator(project);
- }
- XmlUtil.serializeXml(docStoreWsp, uriStoreWsp, eol);
+ XmlUtil.serializeXml(docStoreWsp, uriStoreWsp);
}
// manufacture the event only if serialization was successful
diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/XmlUtil.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/XmlUtil.java
index f89e557ec04..5dda1e8c309 100644
--- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/XmlUtil.java
+++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/XmlUtil.java
@@ -279,6 +279,21 @@ public class XmlUtil {
}
}
+ /**
+ * Serialize XML Document into a file.
+ * Note: clients should synchronize access to this method.
+ *
+ * @param doc - DOM Document to serialize.
+ * @param uriLocation - URI of the file.
+ *
+ * @throws IOException in case of problems with file I/O
+ * @throws TransformerException in case of problems with XML output
+ */
+ public static void serializeXml(Document doc, URI uriLocation)
+ throws IOException, TransformerException, CoreException {
+ serializeXmlInternal(doc, uriLocation, null);
+ }
+
/**
* Serialize XML Document into a file.
* Note: clients should synchronize access to this method.
@@ -286,18 +301,24 @@ public class XmlUtil {
* @param doc - DOM Document to serialize.
* @param uriLocation - URI of the file.
* @param lineSeparator - line separator.
+ * Note: This will serialize in pretty format
*
* @throws IOException in case of problems with file I/O
* @throws TransformerException in case of problems with XML output
*/
public static void serializeXml(Document doc, URI uriLocation, String lineSeparator)
throws IOException, TransformerException, CoreException {
+ serializeXmlInternal(doc, uriLocation, lineSeparator);
+ }
+
+ private static void serializeXmlInternal(Document doc, URI uriLocation, String lineSeparator)
+ throws IOException, TransformerException, CoreException {
java.io.File storeFile = new java.io.File(uriLocation);
if (!storeFile.exists()) {
storeFile.createNewFile();
}
- String utfString = toString(doc, lineSeparator);
+ String utfString = lineSeparator != null ? toString(doc, lineSeparator) : toString(doc);
FileOutputStream output = getFileOutputStreamWorkaround(storeFile);
output.write(utfString.getBytes(ENCODING_UTF_8));