use of com.intellij.ide.plugins.IdeaPluginDescriptorImpl in project intellij-community by JetBrains.
the class ConfigImportHelper method loadOldPlugins.
private static boolean loadOldPlugins(File plugins, File dest) throws IOException {
if (plugins.exists()) {
List<IdeaPluginDescriptorImpl> descriptors = new SmartList<>();
PluginManagerCore.loadDescriptors(plugins, descriptors, null, 0);
List<String> oldPlugins = new SmartList<>();
for (IdeaPluginDescriptorImpl descriptor : descriptors) {
// check isBundled also - probably plugin is bundled in new IDE version
if (descriptor.isEnabled() && !descriptor.isBundled()) {
oldPlugins.add(descriptor.getPluginId().getIdString());
}
}
if (!oldPlugins.isEmpty()) {
PluginManagerCore.savePluginsList(oldPlugins, false, new File(dest, PluginManager.INSTALLED_TXT));
}
return true;
}
return false;
}
use of com.intellij.ide.plugins.IdeaPluginDescriptorImpl in project intellij-community by JetBrains.
the class UpdatePluginsFromCustomRepositoryTest method loadDescriptor.
private IdeaPluginDescriptor loadDescriptor(String filePath) throws InvalidDataException, FileNotFoundException, MalformedURLException {
String path = PlatformTestUtil.getCommunityPath() + "/platform/platform-tests/testData/updates/customRepositories/" + getTestName(true);
File descriptorFile = new File(path, filePath);
IdeaPluginDescriptorImpl descriptor = new IdeaPluginDescriptorImpl(descriptorFile.getParentFile());
descriptor.readExternal(descriptorFile.toURI().toURL());
return descriptor;
}
use of com.intellij.ide.plugins.IdeaPluginDescriptorImpl in project smali by JesusFreke.
the class GithubFeedbackTask method sendFeedback.
public static String sendFeedback(Map<String, String> environmentDetails) throws IOException {
String url = "https://api.github.com/repos/JesusFreke/smalidea-issues/issues";
String userAgent = "smalidea plugin";
IdeaPluginDescriptorImpl pluginDescriptor = (IdeaPluginDescriptorImpl) PluginManager.getPlugin(PluginId.getId("org.jf.smalidea"));
if (pluginDescriptor != null) {
String name = pluginDescriptor.getName();
String version = pluginDescriptor.getVersion();
userAgent = name + " (" + version + ")";
}
HttpURLConnection httpURLConnection = connect(url);
httpURLConnection.setDoOutput(true);
httpURLConnection.setRequestMethod("POST");
httpURLConnection.setRequestProperty("User-Agent", userAgent);
httpURLConnection.setRequestProperty("Content-Type", "application/json");
String token = getToken();
if (token != null) {
httpURLConnection.setRequestProperty("Authorization", "token " + token);
}
OutputStream outputStream = httpURLConnection.getOutputStream();
try {
outputStream.write(convertToGithubIssueFormat(environmentDetails));
} finally {
outputStream.close();
}
int responseCode = httpURLConnection.getResponseCode();
if (responseCode != 201) {
throw new RuntimeException("Expected HTTP_CREATED (201), obtained " + responseCode);
}
return Long.toString(System.currentTimeMillis());
}
use of com.intellij.ide.plugins.IdeaPluginDescriptorImpl in project intellij-community by JetBrains.
the class FileTemplatesLoader method loadDefaultTemplates.
private void loadDefaultTemplates() {
final Set<URL> processedUrls = new HashSet<>();
for (PluginDescriptor plugin : PluginManagerCore.getPlugins()) {
if (plugin instanceof IdeaPluginDescriptorImpl && ((IdeaPluginDescriptorImpl) plugin).isEnabled()) {
final ClassLoader loader = plugin.getPluginClassLoader();
if (loader instanceof PluginClassLoader && ((PluginClassLoader) loader).getUrls().isEmpty()) {
// development mode, when IDEA_CORE's loader contains all the classpath
continue;
}
try {
final Enumeration<URL> systemResources = loader.getResources(DEFAULT_TEMPLATES_ROOT);
if (systemResources.hasMoreElements()) {
while (systemResources.hasMoreElements()) {
final URL url = systemResources.nextElement();
if (processedUrls.contains(url)) {
continue;
}
processedUrls.add(url);
loadDefaultsFromRoot(url);
}
}
} catch (IOException e) {
LOG.error(e);
}
}
}
}
use of com.intellij.ide.plugins.IdeaPluginDescriptorImpl in project phpinspectionsea by kalessil.
the class UnknownInspectionInspector method collectKnownInspections.
private static Set<String> collectKnownInspections() {
final Set<String> names = new HashSet<>();
final PluginId phpSupport = PluginId.getId("com.jetbrains.php");
for (IdeaPluginDescriptor plugin : PluginManager.getPlugins()) {
/* check plugins' dependencies and extensions */
/* we have to rely on impl-class, see */
final MultiMap<String, Element> extensions = ((IdeaPluginDescriptorImpl) plugin).getExtensions();
final boolean isPhpPlugin = plugin.getPluginId().equals(phpSupport);
if (null == extensions || (!ArrayUtils.contains(plugin.getDependentPluginIds(), phpSupport)) && !isPhpPlugin) {
continue;
}
/* extract inspections; short names */
for (Element node : extensions.values()) {
final String nodeName = node.getName();
if (null == nodeName || !nodeName.equals("localInspection")) {
continue;
}
final Attribute name = node.getAttribute("shortName");
final String shortName = null == name ? null : name.getValue();
if (null != shortName && shortName.length() > 0) {
names.add(shortName);
}
}
}
return names;
}
Aggregations