Search in sources :

Example 1 with IdeaPluginDescriptorImpl

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;
}
Also used : IdeaPluginDescriptorImpl(com.intellij.ide.plugins.IdeaPluginDescriptorImpl)

Example 2 with IdeaPluginDescriptorImpl

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;
}
Also used : File(java.io.File) IdeaPluginDescriptorImpl(com.intellij.ide.plugins.IdeaPluginDescriptorImpl)

Example 3 with IdeaPluginDescriptorImpl

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());
}
Also used : HttpURLConnection(java.net.HttpURLConnection) OutputStream(java.io.OutputStream) IdeaPluginDescriptorImpl(com.intellij.ide.plugins.IdeaPluginDescriptorImpl)

Example 4 with IdeaPluginDescriptorImpl

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);
            }
        }
    }
}
Also used : PluginDescriptor(com.intellij.openapi.extensions.PluginDescriptor) PluginClassLoader(com.intellij.ide.plugins.cl.PluginClassLoader) UrlClassLoader(com.intellij.util.lang.UrlClassLoader) IOException(java.io.IOException) URL(java.net.URL) IdeaPluginDescriptorImpl(com.intellij.ide.plugins.IdeaPluginDescriptorImpl) PluginClassLoader(com.intellij.ide.plugins.cl.PluginClassLoader)

Example 5 with IdeaPluginDescriptorImpl

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;
}
Also used : Attribute(org.jdom.Attribute) PsiElement(com.intellij.psi.PsiElement) Element(org.jdom.Element) IdeaPluginDescriptor(com.intellij.ide.plugins.IdeaPluginDescriptor) PluginId(com.intellij.openapi.extensions.PluginId) HashSet(java.util.HashSet) IdeaPluginDescriptorImpl(com.intellij.ide.plugins.IdeaPluginDescriptorImpl)

Aggregations

IdeaPluginDescriptorImpl (com.intellij.ide.plugins.IdeaPluginDescriptorImpl)5 IdeaPluginDescriptor (com.intellij.ide.plugins.IdeaPluginDescriptor)1 PluginClassLoader (com.intellij.ide.plugins.cl.PluginClassLoader)1 PluginDescriptor (com.intellij.openapi.extensions.PluginDescriptor)1 PluginId (com.intellij.openapi.extensions.PluginId)1 PsiElement (com.intellij.psi.PsiElement)1 UrlClassLoader (com.intellij.util.lang.UrlClassLoader)1 File (java.io.File)1 IOException (java.io.IOException)1 OutputStream (java.io.OutputStream)1 HttpURLConnection (java.net.HttpURLConnection)1 URL (java.net.URL)1 HashSet (java.util.HashSet)1 Attribute (org.jdom.Attribute)1 Element (org.jdom.Element)1