Search in sources :

Example 16 with IdeaPluginDescriptor

use of com.intellij.ide.plugins.IdeaPluginDescriptor in project intellij-community by JetBrains.

the class SearchableOptionsRegistrarImpl method loadHugeFilesIfNecessary.

private void loadHugeFilesIfNecessary() {
    if (allTheseHugeFilesAreLoaded) {
        return;
    }
    allTheseHugeFilesAreLoaded = true;
    try {
        //index
        final URL indexResource = ResourceUtil.getResource(SearchableOptionsRegistrar.class, "/search/", "searchableOptions.xml");
        if (indexResource == null) {
            LOG.info("No /search/searchableOptions.xml found, settings search won't work!");
            return;
        }
        Document document = JDOMUtil.loadDocument(indexResource);
        Element root = document.getRootElement();
        List configurables = root.getChildren("configurable");
        for (final Object o : configurables) {
            final Element configurable = (Element) o;
            final String id = configurable.getAttributeValue("id");
            final String groupName = configurable.getAttributeValue("configurable_name");
            final List options = configurable.getChildren("option");
            for (Object o1 : options) {
                Element optionElement = (Element) o1;
                final String option = optionElement.getAttributeValue("name");
                final String path = optionElement.getAttributeValue("path");
                final String hit = optionElement.getAttributeValue("hit");
                putOptionWithHelpId(option, id, groupName, hit, path);
            }
        }
        //synonyms
        document = JDOMUtil.loadDocument(ResourceUtil.getResource(SearchableOptionsRegistrar.class, "/search/", "synonyms.xml"));
        root = document.getRootElement();
        configurables = root.getChildren("configurable");
        for (final Object o : configurables) {
            final Element configurable = (Element) o;
            final String id = configurable.getAttributeValue("id");
            final String groupName = configurable.getAttributeValue("configurable_name");
            final List synonyms = configurable.getChildren("synonym");
            for (Object o1 : synonyms) {
                Element synonymElement = (Element) o1;
                final String synonym = synonymElement.getTextNormalize();
                if (synonym != null) {
                    Set<String> words = getProcessedWords(synonym);
                    for (String word : words) {
                        putOptionWithHelpId(word, id, groupName, synonym, null);
                    }
                }
            }
            final List options = configurable.getChildren("option");
            for (Object o1 : options) {
                Element optionElement = (Element) o1;
                final String option = optionElement.getAttributeValue("name");
                final List list = optionElement.getChildren("synonym");
                for (Object o2 : list) {
                    Element synonymElement = (Element) o2;
                    final String synonym = synonymElement.getTextNormalize();
                    if (synonym != null) {
                        Set<String> words = getProcessedWords(synonym);
                        for (String word : words) {
                            putOptionWithHelpId(word, id, groupName, synonym, null);
                        }
                        final Couple<String> key = Couple.of(option, id);
                        Set<String> foundSynonyms = myHighlightOption2Synonym.get(key);
                        if (foundSynonyms == null) {
                            foundSynonyms = new THashSet<>();
                            myHighlightOption2Synonym.put(key, foundSynonyms);
                        }
                        foundSynonyms.add(synonym);
                    }
                }
            }
        }
    } catch (Exception e) {
        LOG.error(e);
    }
    ApplicationInfoEx applicationInfo = ApplicationInfoEx.getInstanceEx();
    for (IdeaPluginDescriptor plugin : PluginManagerCore.getPlugins()) {
        if (applicationInfo.isEssentialPlugin(plugin.getPluginId().getIdString())) {
            continue;
        }
        final String pluginName = plugin.getName();
        final Set<String> words = getProcessedWordsWithoutStemming(pluginName);
        final String description = plugin.getDescription();
        if (description != null) {
            words.addAll(getProcessedWordsWithoutStemming(description));
        }
        for (String word : words) {
            addOption(word, null, pluginName, PluginManagerConfigurable.ID, PluginManagerConfigurable.DISPLAY_NAME);
        }
    }
}
Also used : ApplicationInfoEx(com.intellij.openapi.application.ex.ApplicationInfoEx) Element(org.jdom.Element) IdeaPluginDescriptor(com.intellij.ide.plugins.IdeaPluginDescriptor) Document(org.jdom.Document) URL(java.net.URL) IOException(java.io.IOException)

Example 17 with IdeaPluginDescriptor

use of com.intellij.ide.plugins.IdeaPluginDescriptor in project intellij-community by JetBrains.

the class GuiTestRunner method loadClassesWithNewPluginClassLoader.

private void loadClassesWithNewPluginClassLoader() throws Exception {
    //ensure that IDEA has been initialized.
    IdeTestApplication.getInstance();
    ParentPlugin testParentPluginAnnotation = getTestClass().getAnnotation(ParentPlugin.class);
    assertNotNull(testParentPluginAnnotation);
    String dependentPluginId = testParentPluginAnnotation.pluginId();
    ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
    String classPath = getTestClass().getJavaClass().getCanonicalName().replace(".", "/").concat(".class");
    URL resource = classLoader.getResource(classPath);
    assertNotNull(resource);
    String pathToTestClass = resource.getPath();
    String containingFolderPath = pathToTestClass.substring(0, pathToTestClass.length() - classPath.length());
    URL urlToTestClass = (new File(containingFolderPath)).toURI().toURL();
    IdeaPluginDescriptor parentPluginDescriptor = PluginManager.getPlugin(PluginId.getId(dependentPluginId));
    assertNotNull(parentPluginDescriptor);
    ClassLoader parentPluginClassLoader = parentPluginDescriptor.getPluginClassLoader();
    ClassLoader[] classLoaders = { parentPluginClassLoader };
    String testPluginId = dependentPluginId + ".guitest";
    PluginClassLoader testPluginClassLoader = new PluginClassLoader(Collections.singletonList(urlToTestClass), classLoaders, PluginId.getId(testPluginId), null, null);
    Thread.currentThread().setContextClassLoader(testPluginClassLoader);
    Class<?> testClass = getTestClass().getJavaClass();
    myTestClass = new TestClass(testPluginClassLoader.loadClass(testClass.getName()));
}
Also used : PluginClassLoader(com.intellij.ide.plugins.cl.PluginClassLoader) TestClass(org.junit.runners.model.TestClass) IdeaPluginDescriptor(com.intellij.ide.plugins.IdeaPluginDescriptor) File(java.io.File) URL(java.net.URL) PluginClassLoader(com.intellij.ide.plugins.cl.PluginClassLoader)

Example 18 with IdeaPluginDescriptor

use of com.intellij.ide.plugins.IdeaPluginDescriptor in project intellij-community by JetBrains.

the class PluginOptionsTopHitProvider method getOptions.

@NotNull
@Override
public Collection<OptionDescription> getOptions(@Nullable Project project) {
    ArrayList<OptionDescription> options = new ArrayList<>();
    ApplicationInfoEx applicationInfo = ApplicationInfoEx.getInstanceEx();
    for (IdeaPluginDescriptor pluginDescriptor : PluginManagerCore.getPlugins()) {
        if (applicationInfo.isEssentialPlugin(pluginDescriptor.getPluginId().getIdString())) {
            continue;
        }
        options.add(new PluginBooleanOptionDescriptor(pluginDescriptor.getPluginId()));
    }
    return options;
}
Also used : OptionDescription(com.intellij.ide.ui.search.OptionDescription) ApplicationInfoEx(com.intellij.openapi.application.ex.ApplicationInfoEx) ArrayList(java.util.ArrayList) IdeaPluginDescriptor(com.intellij.ide.plugins.IdeaPluginDescriptor) NotNull(org.jetbrains.annotations.NotNull)

Example 19 with IdeaPluginDescriptor

use of com.intellij.ide.plugins.IdeaPluginDescriptor in project intellij-community by JetBrains.

the class SelectPluginsStep method toggleSelection.

private void toggleSelection() {
    final IdeaPluginDescriptor descriptor = getSelectedPlugin();
    if (descriptor == null || myModel.isForceEnable(descriptor))
        return;
    boolean willDisable = !myModel.isDisabledPlugin(descriptor);
    final Object[] selection = myPluginsList.getSelectedValues();
    for (Object o : selection) {
        IdeaPluginDescriptor desc = (IdeaPluginDescriptor) o;
        if (!willDisable) {
            myModel.setPluginEnabledWithDependencies(desc);
        } else {
            myModel.setPluginDisabledWithDependents(desc);
        }
    }
    myPluginsList.repaint();
}
Also used : IdeaPluginDescriptor(com.intellij.ide.plugins.IdeaPluginDescriptor)

Example 20 with IdeaPluginDescriptor

use of com.intellij.ide.plugins.IdeaPluginDescriptor in project intellij-community by JetBrains.

the class SelectPluginsStep method buildRequires.

private String buildRequires(final IdeaPluginDescriptor descriptor) {
    StringBuilder requiresBuffer = new StringBuilder();
    for (PluginId id : StartupWizardModel.getNonOptionalDependencies(descriptor)) {
        final IdeaPluginDescriptor dependent = findPlugin(id);
        if (dependent != null) {
            String name = getAbbreviatedName(dependent);
            if (requiresBuffer.length() == 0) {
                requiresBuffer.append("   (requires ");
            } else {
                requiresBuffer.append(", ");
            }
            requiresBuffer.append(name);
        }
    }
    List<IdeaPluginDescriptor> requiredBy = myModel.getDependentsOnEarlierPages(descriptor, false);
    if (requiredBy.size() > 0) {
        if (requiresBuffer.length() > 0) {
            requiresBuffer.append(", ");
        } else {
            requiresBuffer.append("   (");
        }
        requiresBuffer.append("required by ");
        requiresBuffer.append(StringUtil.join(requiredBy, ideaPluginDescriptor -> getAbbreviatedName(ideaPluginDescriptor), ", "));
    }
    if (requiresBuffer.length() > 0) {
        requiresBuffer.append(")");
    }
    return requiresBuffer.toString();
}
Also used : UIUtil(com.intellij.util.ui.UIUtil) ShowSettingsUtil(com.intellij.openapi.options.ShowSettingsUtil) StringUtil(com.intellij.openapi.util.text.StringUtil) WizardNavigationState(com.intellij.ui.wizard.WizardNavigationState) CollectionListModel(com.intellij.ui.CollectionListModel) ArrayList(java.util.ArrayList) java.awt(java.awt) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) java.awt.event(java.awt.event) WizardStep(com.intellij.ui.wizard.WizardStep) NotNull(org.jetbrains.annotations.NotNull) ListSelectionEvent(javax.swing.event.ListSelectionEvent) ListSelectionListener(javax.swing.event.ListSelectionListener) PluginId(com.intellij.openapi.extensions.PluginId) Collections(java.util.Collections) ClickListener(com.intellij.ui.ClickListener) IdeaPluginDescriptor(com.intellij.ide.plugins.IdeaPluginDescriptor) javax.swing(javax.swing) IdeaPluginDescriptor(com.intellij.ide.plugins.IdeaPluginDescriptor) PluginId(com.intellij.openapi.extensions.PluginId)

Aggregations

IdeaPluginDescriptor (com.intellij.ide.plugins.IdeaPluginDescriptor)40 PluginId (com.intellij.openapi.extensions.PluginId)19 NotNull (org.jetbrains.annotations.NotNull)11 Nullable (org.jetbrains.annotations.Nullable)8 Project (com.intellij.openapi.project.Project)4 File (java.io.File)4 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)4 ErrorBean (com.intellij.errorreport.bean.ErrorBean)3 ApplicationInfoEx (com.intellij.openapi.application.ex.ApplicationInfoEx)3 IdeaLoggingEvent (com.intellij.openapi.diagnostic.IdeaLoggingEvent)3 URL (java.net.URL)3 LogMessageEx (com.intellij.diagnostic.LogMessageEx)2 CantRunException (com.intellij.execution.CantRunException)2 PluginClassLoader (com.intellij.ide.plugins.cl.PluginClassLoader)2 DataContext (com.intellij.openapi.actionSystem.DataContext)2 SubmittedReportInfo (com.intellij.openapi.diagnostic.SubmittedReportInfo)2 PluginDescriptor (com.intellij.openapi.extensions.PluginDescriptor)2 ShowSettingsUtil (com.intellij.openapi.options.ShowSettingsUtil)2 EmptyProgressIndicator (com.intellij.openapi.progress.EmptyProgressIndicator)2