// Path: src/java/krasa/formatter/exception/FileDoesNotExistsException.java
// public class FileDoesNotExistsException extends RuntimeException {
// 
// 	public FileDoesNotExistsException(File file) {
// 		super("Configured settings file does not exist, path=\"" + file.getPath() + "\"");
// 	}
// 
// 	public FileDoesNotExistsException(String message) {
// 		super(message);
// 	}
// }
// 
// Path: src/java/krasa/formatter/plugin/InvalidPropertyFile.java
// public class InvalidPropertyFile extends RuntimeException {
// 
// 	public InvalidPropertyFile(String s, File file) {
// 		super(s);
// 	}
// 
// 	public InvalidPropertyFile(File file) {
// 		super("Property file does not contains any properties, " + file.getAbsolutePath());
// 	}
// 
// 	public InvalidPropertyFile(String message, Throwable cause) {
// 		super(message, cause);
// 	}
// 
// 	public InvalidPropertyFile(Throwable cause) {
// 		super(cause);
// 	}
// }


import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Properties;
import javax.xml.parsers.DocumentBuilderFactory;
import org.apache.commons.io.IOUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.fileTypes.StdFileTypes;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.vfs.ReadonlyStatusHandler;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
import krasa.formatter.exception.FileDoesNotExistsException;
import krasa.formatter.exception.ParsingFailedException;
import krasa.formatter.plugin.InvalidPropertyFile;
		if (!file.exists()) {
			throw new FileDoesNotExistsException(file);
		}
		BufferedInputStream stream = null;
		final Properties formatterOptions;
		try {
			stream = new BufferedInputStream(new FileInputStream(file));
			formatterOptions = new Properties(defaultConfig);
			String s = IOUtils.toString(stream, StandardCharsets.UTF_8);
			StringReader reader = new StringReader(s.replace("=\\#", "=#"));
			formatterOptions.load(reader);
		} catch (IOException e) {
			throw new RuntimeException("config file read error", e);
		} finally {
			if (stream != null) {
				try {
					stream.close();
				} catch (IOException e) { /* ignore */
				}
			}
		}
		return formatterOptions;
	}

	public static Properties readPropertiesFile(@NotNull File file) {
		return readPropertiesFile(file, null);
	}

	public static Properties readXmlJavaSettingsFile(File file, Properties properties, String profile) {
		if (!file.exists()) {
// Path: src/java/krasa/formatter/exception/FileDoesNotExistsException.java
// public class FileDoesNotExistsException extends RuntimeException {
// 
// 	public FileDoesNotExistsException(File file) {
// 		super("Configured settings file does not exist, path=\"" + file.getPath() + "\"");
// 	}
// 
// 	public FileDoesNotExistsException(String message) {
// 		super(message);
// 	}
// }
// 
// Path: src/java/krasa/formatter/plugin/InvalidPropertyFile.java
// public class InvalidPropertyFile extends RuntimeException {
// 
// 	public InvalidPropertyFile(String s, File file) {
// 		super(s);
// 	}
// 
// 	public InvalidPropertyFile(File file) {
// 		super("Property file does not contains any properties, " + file.getAbsolutePath());
// 	}
// 
// 	public InvalidPropertyFile(String message, Throwable cause) {
// 		super(message, cause);
// 	}
// 
// 	public InvalidPropertyFile(Throwable cause) {
// 		super(cause);
// 	}
// }


// Path: src/java/krasa/formatter/utils/FileUtils.java
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Properties;
import javax.xml.parsers.DocumentBuilderFactory;
import org.apache.commons.io.IOUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.fileTypes.StdFileTypes;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.vfs.ReadonlyStatusHandler;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
import krasa.formatter.exception.FileDoesNotExistsException;
import krasa.formatter.exception.ParsingFailedException;
import krasa.formatter.plugin.InvalidPropertyFile;

		if (!file.exists()) {
			throw new FileDoesNotExistsException(file);
		}
		BufferedInputStream stream = null;
		final Properties formatterOptions;
		try {
			stream = new BufferedInputStream(new FileInputStream(file));
			formatterOptions = new Properties(defaultConfig);
			String s = IOUtils.toString(stream, StandardCharsets.UTF_8);
			StringReader reader = new StringReader(s.replace("=\\#", "=#"));
			formatterOptions.load(reader);
		} catch (IOException e) {
			throw new RuntimeException("config file read error", e);
		} finally {
			if (stream != null) {
				try {
					stream.close();
				} catch (IOException e) { /* ignore */
				}
			}
		}
		return formatterOptions;
	}

	public static Properties readPropertiesFile(@NotNull File file) {
		return readPropertiesFile(file, null);
	}

	public static Properties readXmlJavaSettingsFile(File file, Properties properties, String profile) {
		if (!file.exists()) {
			throw new FileDoesNotExistsException(file);