use of org.jdom.JDOMException in project intellij-plugins by JetBrains.
the class FlashBuilderProjectLoadUtil method loadMapFromDotFxpPropertiesFile.
private static Map<String, String> loadMapFromDotFxpPropertiesFile(final VirtualFile dotProjectFile) {
final Map<String, String> result = new THashMap<>();
final VirtualFile dir = dotProjectFile.getParent();
assert dir != null;
final VirtualFile dotFxpPropertiesFile = dir.findChild(FlashBuilderImporter.DOT_FXP_PROPERTIES);
if (dotFxpPropertiesFile != null) {
try {
final Element fxpPropertiesElement = JDOMUtil.load(dotFxpPropertiesFile.getInputStream());
if (!FXP_PROPERTIES_TAG.equals(fxpPropertiesElement.getName()))
return Collections.emptyMap();
final Element swcElement = fxpPropertiesElement.getChild(SWC_TAG);
if (swcElement != null) {
//noinspection unchecked
for (final Element linkedElement : swcElement.getChildren(LINKED_TAG)) {
final String location = linkedElement.getAttributeValue(LOCATION_ATTR);
final String path = linkedElement.getAttributeValue(PATH_ATTR);
if (!StringUtil.isEmptyOrSpaces(location) && !StringUtil.isEmptyOrSpaces(path)) {
result.put(location, path);
}
}
}
} catch (JDOMException ignored) {
/*ignore*/
} catch (IOException ignored) {
/*ignore*/
}
}
return result;
}
use of org.jdom.JDOMException in project intellij-plugins by JetBrains.
the class ProjectsData method serialize.
public Element serialize() {
XStream xStream = new XStream(new DomDriver());
String s = xStream.toXML(myStatus);
try {
return new SAXBuilder().build(new StringReader(s)).getRootElement();
} catch (JDOMException e) {
LOG.error(e.getMessage(), e);
} catch (IOException e) {
LOG.error(e.getMessage(), e);
}
return new Element("");
}
use of org.jdom.JDOMException in project intellij-plugins by JetBrains.
the class RslUtil method getSwcPathToRslUrlsMap.
private static synchronized Map<String, List<String>> getSwcPathToRslUrlsMap(final String sdkHome) {
final String configFilePath = sdkHome + "/frameworks/flex-config.xml";
final File configFile = new File(configFilePath);
if (!configFile.isFile()) {
LOG.warn("File not found: " + configFilePath);
ourConfigFilePathToTimestampAndSwcPathToRslUrls.remove(configFilePath);
return Collections.emptyMap();
}
Pair<Long, Map<String, List<String>>> data = ourConfigFilePathToTimestampAndSwcPathToRslUrls.get(configFilePath);
final Long currentTimestamp = configFile.lastModified();
final Long cachedTimestamp = data == null ? null : data.first;
if (cachedTimestamp == null || !cachedTimestamp.equals(currentTimestamp)) {
ourConfigFilePathToTimestampAndSwcPathToRslUrls.remove(configFilePath);
final Map<String, List<String>> swcPathToRslMap = new THashMap<>();
try {
final Element rootElement = JDOMUtil.load(configFile);
for (Element rslElement : rootElement.getChildren("runtime-shared-library-path", rootElement.getNamespace())) {
final Element swcPathElement = rslElement.getChild("path-element", rslElement.getNamespace());
if (swcPathElement != null) {
final List<String> rslUrls = new ArrayList<>(2);
for (Element rslUrlElement : rslElement.getChildren("rsl-url", rootElement.getNamespace())) {
final String rslUrl = rslUrlElement.getTextNormalize();
rslUrls.add(rslUrl);
}
final String swcPath = PathUtilRt.getParentPath(configFilePath) + "/" + swcPathElement.getTextNormalize();
swcPathToRslMap.put(SystemInfo.isFileSystemCaseSensitive ? swcPath : swcPath.toLowerCase(), rslUrls);
}
}
} catch (IOException | JDOMException e) {
LOG.warn(configFilePath, e);
}
data = Pair.create(currentTimestamp, swcPathToRslMap);
ourConfigFilePathToTimestampAndSwcPathToRslUrls.put(configFilePath, data);
}
return data.second;
}
use of org.jdom.JDOMException in project intellij-plugins by JetBrains.
the class JSConditionalCompilationDefinitionsProviderImpl method getDefinitionsFromConfigFile.
private Collection<Pair<String, String>> getDefinitionsFromConfigFile(final String configFilePath) {
if (StringUtil.isEmptyOrSpaces(configFilePath))
return Collections.emptyList();
final VirtualFile configFile = LocalFileSystem.getInstance().findFileByPath(configFilePath);
if (configFile == null || configFile.isDirectory())
return Collections.emptyList();
final FileDocumentManager documentManager = FileDocumentManager.getInstance();
final Document cachedDocument = documentManager.getCachedDocument(configFile);
final Long currentTimestamp = cachedDocument != null ? cachedDocument.getModificationStamp() : configFile.getModificationCount();
final Long cachedTimestamp = configFileToTimestamp.get(configFile);
if (cachedTimestamp == null || !cachedTimestamp.equals(currentTimestamp)) {
configFileToTimestamp.remove(configFile);
configFileToConditionalCompilerDefinitions.remove(configFile);
try {
final Element rootElement = cachedDocument == null ? JDOMUtil.load(configFile.getInputStream()) : JDOMUtil.load(cachedDocument.getCharsSequence());
final Collection<Pair<String, String>> result = new ArrayList<>();
if (rootElement.getName().equals(FlexCompilerConfigFileUtilBase.FLEX_CONFIG)) {
// noinspection unchecked
for (Element compilerElement : rootElement.getChildren(FlexCompilerConfigFileUtilBase.COMPILER, rootElement.getNamespace())) {
// noinspection unchecked
for (Element defineElement : compilerElement.getChildren(DEFINE, rootElement.getNamespace())) {
final String name = defineElement.getChildText(NAME, rootElement.getNamespace());
final String value = defineElement.getChildText(VALUE, rootElement.getNamespace());
if (!StringUtil.isEmpty(name) && value != null) {
result.add(Pair.create(name, value));
}
}
}
}
configFileToTimestamp.put(configFile, currentTimestamp);
configFileToConditionalCompilerDefinitions.put(configFile, result);
return result;
} catch (JDOMException ignored) {
/*ignore*/
} catch (IOException ignored) {
/*ignore*/
}
return Collections.emptyList();
} else {
return configFileToConditionalCompilerDefinitions.get(configFile);
}
}
use of org.jdom.JDOMException in project intellij-plugins by JetBrains.
the class FlexCompilationUtils method fixInitialContent.
private static String fixInitialContent(final VirtualFile descriptorFile, final String swfName) throws FlexCompilerException {
try {
final Document document;
try {
document = JDOMUtil.loadDocument(descriptorFile.getInputStream());
} catch (IOException e) {
throw new FlexCompilerException("Failed to read AIR descriptor content: " + e.getMessage(), descriptorFile.getUrl(), -1, -1);
}
final Element rootElement = document.getRootElement();
if (!"application".equals(rootElement.getName())) {
throw new FlexCompilerException("AIR descriptor file has incorrect root tag", descriptorFile.getUrl(), -1, -1);
}
Element initialWindowElement = rootElement.getChild("initialWindow", rootElement.getNamespace());
if (initialWindowElement == null) {
initialWindowElement = new Element("initialWindow", rootElement.getNamespace());
rootElement.addContent(initialWindowElement);
}
Element contentElement = initialWindowElement.getChild("content", rootElement.getNamespace());
if (contentElement == null) {
contentElement = new Element("content", rootElement.getNamespace());
initialWindowElement.addContent(contentElement);
}
contentElement.setText(swfName);
return JDOMUtil.writeDocument(document, SystemProperties.getLineSeparator());
} catch (JDOMException e) {
throw new FlexCompilerException("AIR descriptor file has incorrect format: " + e.getMessage(), descriptorFile.getUrl(), -1, -1);
}
}
Aggregations