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);
}
}
}
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()));
}
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;
}
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();
}
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();
}
Aggregations