Search in sources :

Example 1 with SearchableOptionsRegistrar

use of com.intellij.ide.ui.search.SearchableOptionsRegistrar in project intellij-community by JetBrains.

the class IntentionManagerSettings method processMetaData.

private static synchronized void processMetaData(@NotNull final IntentionActionMetaData metaData) {
    final Application app = ApplicationManager.getApplication();
    if (app.isUnitTestMode() || app.isHeadlessEnvironment())
        return;
    final TextDescriptor description = metaData.getDescription();
    app.executeOnPooledThread(() -> {
        try {
            SearchableOptionsRegistrar registrar = SearchableOptionsRegistrar.getInstance();
            if (registrar == null)
                return;
            @NonNls String descriptionText = description.getText().toLowerCase();
            descriptionText = HTML_PATTERN.matcher(descriptionText).replaceAll(" ");
            final Set<String> words = registrar.getProcessedWordsWithoutStemming(descriptionText);
            words.addAll(registrar.getProcessedWords(metaData.getFamily()));
            for (String word : words) {
                registrar.addOption(word, metaData.getFamily(), metaData.getFamily(), IntentionSettingsConfigurable.HELP_ID, IntentionSettingsConfigurable.DISPLAY_NAME);
            }
        } catch (IOException e) {
            LOG.error(e);
        }
    });
}
Also used : NonNls(org.jetbrains.annotations.NonNls) IOException(java.io.IOException) Application(com.intellij.openapi.application.Application) SearchableOptionsRegistrar(com.intellij.ide.ui.search.SearchableOptionsRegistrar)

Example 2 with SearchableOptionsRegistrar

use of com.intellij.ide.ui.search.SearchableOptionsRegistrar in project Perl5-IDEA by Camelcade.

the class PerlSearchableOptionsLoader method initComponent.

@Override
public void initComponent() {
    SearchableOptionsRegistrar registrar = SearchableOptionsRegistrar.getInstance();
    if (registrar == null) {
        return;
    }
    try {
        // index
        final URL indexResource = ResourceUtil.getResource(PerlSearchableOptionsLoader.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 configurableId = configurable.getAttributeValue("id");
            final String configurableDisplayName = 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");
                registrar.addOption(option, path, hit, configurableId, configurableDisplayName);
            }
        }
    } catch (Exception e) {
        LOG.error(e);
    }
}
Also used : Element(org.jdom.Element) List(java.util.List) Document(org.jdom.Document) SearchableOptionsRegistrar(com.intellij.ide.ui.search.SearchableOptionsRegistrar) URL(java.net.URL)

Aggregations

SearchableOptionsRegistrar (com.intellij.ide.ui.search.SearchableOptionsRegistrar)2 Application (com.intellij.openapi.application.Application)1 IOException (java.io.IOException)1 URL (java.net.URL)1 List (java.util.List)1 Document (org.jdom.Document)1 Element (org.jdom.Element)1 NonNls (org.jetbrains.annotations.NonNls)1