use of org.jdom.JDOMException in project intellij-community by JetBrains.
the class XPathResponseHandler method lazyCompile.
@NotNull
private XPath lazyCompile(@NotNull String path) throws Exception {
XPath xPath = myCompiledCache.get(path);
if (xPath == null) {
try {
xPath = XPath.newInstance(path);
myCompiledCache.put(path, xPath);
} catch (JDOMException e) {
throw new Exception(String.format("Malformed XPath expression '%s'", path));
}
}
return xPath;
}
use of org.jdom.JDOMException in project ideavim by JetBrains.
the class VimPlugin method setupStatisticsReporter.
/**
* Reports statistics about installed IdeaVim and enabled Vim emulation.
*
* See https://github.com/go-lang-plugin-org/go-lang-idea-plugin/commit/5182ab4a1d01ad37f6786268a2fe5e908575a217
*/
private void setupStatisticsReporter(@NotNull EventFacade eventFacade) {
final Application application = ApplicationManager.getApplication();
eventFacade.addEditorFactoryListener(new EditorFactoryAdapter() {
@Override
public void editorCreated(@NotNull EditorFactoryEvent event) {
final PropertiesComponent propertiesComponent = PropertiesComponent.getInstance();
final long lastUpdate = propertiesComponent.getOrInitLong(IDEAVIM_STATISTICS_TIMESTAMP_KEY, 0);
final boolean outOfDate = lastUpdate == 0 || System.currentTimeMillis() - lastUpdate > TimeUnit.DAYS.toMillis(1);
if (outOfDate && isEnabled()) {
application.executeOnPooledThread(new Runnable() {
@Override
public void run() {
try {
final String buildNumber = ApplicationInfo.getInstance().getBuild().asString();
final String pluginId = IDEAVIM_PLUGIN_ID;
final String version = URLEncoder.encode(getVersion(), CharsetToolkit.UTF8);
final String os = URLEncoder.encode(SystemInfo.OS_NAME + " " + SystemInfo.OS_VERSION, CharsetToolkit.UTF8);
final String uid = UpdateChecker.getInstallationUID(PropertiesComponent.getInstance());
final String url = "https://plugins.jetbrains.com/plugins/list" + "?pluginId=" + pluginId + "&build=" + buildNumber + "&pluginVersion=" + version + "&os=" + os + "&uuid=" + uid;
PropertiesComponent.getInstance().setValue(IDEAVIM_STATISTICS_TIMESTAMP_KEY, String.valueOf(System.currentTimeMillis()));
HttpRequests.request(url).connect(new HttpRequests.RequestProcessor<Object>() {
@Override
public Object process(@NotNull HttpRequests.Request request) throws IOException {
LOG.info("Sending statistics: " + url);
try {
JDOMUtil.load(request.getInputStream());
} catch (JDOMException e) {
LOG.warn(e);
}
return null;
}
});
} catch (IOException e) {
LOG.warn(e);
}
}
});
}
}
}, application);
}
use of org.jdom.JDOMException in project intellij-community by JetBrains.
the class CoreModuleManager method createAndLoadModule.
@NotNull
@Override
protected ModuleEx createAndLoadModule(@NotNull String filePath, @NotNull VirtualFile file) throws IOException {
final ModuleEx module = createModule(filePath);
try {
ModuleRootManagerImpl.ModuleRootManagerState state = new ModuleRootManagerImpl.ModuleRootManagerState();
state.readExternal(CoreProjectLoader.loadStorageFile(module, file).get("NewModuleRootManager"));
((ModuleRootManagerImpl) ModuleRootManager.getInstance(module)).loadState(state);
} catch (JDOMException e) {
throw new IOException(e);
}
return module;
}
use of org.jdom.JDOMException in project intellij-community by JetBrains.
the class PathManagerEx method getCommunityModules.
private static synchronized Set<String> getCommunityModules() {
if (ourCommunityModules != null) {
return ourCommunityModules;
}
ourCommunityModules = new THashSet<>();
File modulesXml = findFileUnderCommunityHome(Project.DIRECTORY_STORE_FOLDER + "/modules.xml");
if (!modulesXml.exists()) {
throw new IllegalStateException("Cannot obtain test data path: " + modulesXml.getAbsolutePath() + " not found");
}
try {
Element element = JDomSerializationUtil.findComponent(JDOMUtil.load(modulesXml), ModuleManagerImpl.COMPONENT_NAME);
assert element != null;
for (ModulePath file : ModuleManagerImpl.getPathsToModuleFiles(element)) {
ourCommunityModules.add(file.getModuleName());
}
return ourCommunityModules;
} catch (JDOMException | IOException e) {
throw new RuntimeException("Cannot read modules from " + modulesXml.getAbsolutePath(), e);
}
}
use of org.jdom.JDOMException in project intellij-community by JetBrains.
the class MigrationMapSet method loadMaps.
private void loadMaps() {
myMaps = new ArrayList<>();
File dir = getMapDirectory();
copyPredefinedMaps(dir);
File[] files = getMapFiles(dir);
for (int i = 0; i < files.length; i++) {
try {
MigrationMap map = readMap(files[i]);
if (map != null) {
map.setFileName(FileUtil.getNameWithoutExtension(files[i]));
myMaps.add(map);
}
} catch (InvalidDataException | JDOMException e) {
LOG.error("Invalid data in file: " + files[i].getAbsolutePath());
} catch (IOException e) {
LOG.error(e);
}
}
}
Aggregations