use of com.intellij.openapi.options.SchemeImportException in project intellij-community by JetBrains.
the class EclipseCodeStyleSchemeImporter method readFromStream.
private static void readFromStream(@NotNull final VirtualFile file, @NotNull final ThrowableConsumer<InputStream, SchemeImportException> consumer) throws SchemeImportException {
InputStream inputStream = null;
try {
inputStream = file.getInputStream();
consumer.consume(inputStream);
} catch (IOException e) {
throw new SchemeImportException(e);
} finally {
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e) {
//
}
}
}
}
use of com.intellij.openapi.options.SchemeImportException in project intellij-community by JetBrains.
the class EclipseXmlProfileReader method readSettings.
/**
* Reads either basic profile info (name) or all the settings depending on whether <code>settings</code> parameter is null.
*
* @param input The input stream to read from.
* @throws SchemeImportException
*/
protected void readSettings(InputStream input) throws SchemeImportException {
SAXParserFactory spf = SAXParserFactory.newInstance();
spf.setValidating(false);
SAXParser parser;
try {
parser = spf.newSAXParser();
parser.parse(input, this);
} catch (Exception e) {
if (e.getCause() instanceof NonEclipseXmlFileException) {
throw new SchemeImportException("The input file is not a valid Eclipse XML profile.");
} else {
throw new SchemeImportException(e);
}
}
}
use of com.intellij.openapi.options.SchemeImportException in project intellij-community by JetBrains.
the class EclipseThemeReader method readSettings.
protected void readSettings(InputStream input) throws SchemeImportException {
SAXParserFactory spf = SAXParserFactory.newInstance();
spf.setValidating(false);
SAXParser parser;
try {
parser = spf.newSAXParser();
parser.parse(input, this);
} catch (Exception e) {
if (e.getCause() instanceof NotAnEclipseThemeException) {
throw new SchemeImportException("The input file is not a valid Eclipse theme.");
} else {
throw new SchemeImportException(e);
}
}
}
use of com.intellij.openapi.options.SchemeImportException in project intellij-community by JetBrains.
the class FormatterStarter method readSettings.
private static CodeStyleSettings readSettings(@NotNull String settingsPath) throws SchemeImportException {
VirtualFile vFile = VfsUtil.findFileByIoFile(new File(settingsPath), true);
CodeStyleSettingsLoader loader = new CodeStyleSettingsLoader();
if (vFile == null) {
throw new SchemeImportException("Cannot find file " + settingsPath);
}
return loader.loadSettings(vFile);
}
use of com.intellij.openapi.options.SchemeImportException in project intellij-community by JetBrains.
the class FormatterStarter method main.
@Override
public void main(String[] args) {
@SuppressWarnings("UseOfSystemOutOrSystemErr") MessageOutput messageOutput = new MessageOutput(new PrintWriter(System.out), new PrintWriter(System.err));
messageOutput.info(getAppInfo() + " Formatter\n");
FileSetFormatter fileSetFormatter = new FileSetFormatter(messageOutput);
logArgs(args);
if (args.length < 2) {
showUsageInfo(messageOutput);
}
for (int i = 1; i < args.length; i++) {
if (args[i].startsWith("-")) {
if (checkOption(args[i], "-h", "-help")) {
showUsageInfo(messageOutput);
}
if (checkOption(args[i], "-s", "-settings")) {
//noinspection AssignmentToForLoopParameter
i++;
if (i >= args.length) {
fatalError(messageOutput, "Missing settings file path.");
}
try {
CodeStyleSettings settings = readSettings(args[i]);
fileSetFormatter.setCodeStyleSettings(settings);
} catch (SchemeImportException e) {
fatalError(messageOutput, e.getLocalizedMessage() + "\n");
}
} else if (checkOption(args[i], "-r", "-R")) {
fileSetFormatter.setRecursive();
} else if (checkOption(args[i], "-m", "-mask")) {
//noinspection AssignmentToForLoopParameter
i++;
if (i >= args.length) {
fatalError(messageOutput, "Missing file mask(s).");
}
for (String mask : args[i].split(",")) {
if (!mask.isEmpty()) {
fileSetFormatter.addFileMask(mask);
}
}
} else {
fatalError(messageOutput, "Unknown option " + args[i]);
}
} else {
try {
fileSetFormatter.addEntry(args[i]);
} catch (IOException e) {
fatalError(messageOutput, e.getLocalizedMessage());
}
}
}
try {
fileSetFormatter.processFiles();
messageOutput.info("\n" + fileSetFormatter.getProcessedFiles() + " file(s) formatted.\n");
} catch (IOException e) {
fatalError(messageOutput, e.getLocalizedMessage());
}
((ApplicationEx) ApplicationManager.getApplication()).exit(true, true);
}
Aggregations