mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
plugin descriptor — make getModules not-null to simplify code, read not using xml serializer
This commit is contained in:
@@ -1,15 +1,12 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.ide.plugins;
|
||||
|
||||
import com.intellij.util.SmartList;
|
||||
import com.intellij.util.xmlb.annotations.Attribute;
|
||||
import com.intellij.util.xmlb.annotations.Property;
|
||||
import com.intellij.util.xmlb.annotations.Tag;
|
||||
import com.intellij.util.xmlb.annotations.XCollection;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class OptimizedPluginBean {
|
||||
@NonNls public static final String APPLICATION_COMPONENTS = "application-components";
|
||||
@NonNls public static final String PROJECT_COMPONENTS = "project-components";
|
||||
@@ -67,8 +64,4 @@ public class OptimizedPluginBean {
|
||||
|
||||
@Attribute("allow-bundled-update")
|
||||
public boolean allowBundledUpdate;
|
||||
|
||||
@Property(surroundWithTag = false)
|
||||
@XCollection(elementName = "module")
|
||||
public List<String> modules = new SmartList<>();
|
||||
}
|
||||
|
||||
@@ -2,10 +2,14 @@
|
||||
package com.intellij.ide.plugins;
|
||||
|
||||
import com.intellij.openapi.components.OldComponentConfig;
|
||||
import com.intellij.util.SmartList;
|
||||
import com.intellij.util.xmlb.annotations.Property;
|
||||
import com.intellij.util.xmlb.annotations.Tag;
|
||||
import com.intellij.util.xmlb.annotations.XCollection;
|
||||
import org.jdom.Element;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PluginBean extends OptimizedPluginBean {
|
||||
@XCollection(propertyElementName = APPLICATION_COMPONENTS)
|
||||
public OldComponentConfig[] applicationComponents;
|
||||
@@ -24,4 +28,8 @@ public class PluginBean extends OptimizedPluginBean {
|
||||
|
||||
@Tag("extensionPoints")
|
||||
public Element[] extensionPoints;
|
||||
|
||||
@Property(surroundWithTag = false)
|
||||
@XCollection(elementName = "module")
|
||||
public List<String> modules = new SmartList<>();
|
||||
}
|
||||
|
||||
@@ -287,6 +287,17 @@ public class IdeaPluginDescriptorImpl implements IdeaPluginDescriptor {
|
||||
}
|
||||
break;
|
||||
|
||||
case "module": {
|
||||
String moduleName = child.getAttributeValue("value");
|
||||
if (moduleName != null) {
|
||||
if (myModules == null) {
|
||||
myModules = new SmartList<>();
|
||||
}
|
||||
myModules.add(moduleName);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case OptimizedPluginBean.APPLICATION_COMPONENTS: {
|
||||
// because of x-pointer, maybe several application-components tag in document
|
||||
if (myAppComponents == Collections.<ComponentConfig>emptyList()) {
|
||||
@@ -313,10 +324,6 @@ public class IdeaPluginDescriptorImpl implements IdeaPluginDescriptor {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (pluginBean.modules != null && !pluginBean.modules.isEmpty()) {
|
||||
myModules = pluginBean.modules;
|
||||
}
|
||||
}
|
||||
|
||||
private static void readComponents(@NotNull Element parent, @NotNull Ref<BeanBinding> oldComponentConfigBean, @NotNull ArrayList<ComponentConfig> result) {
|
||||
@@ -749,8 +756,8 @@ public class IdeaPluginDescriptorImpl implements IdeaPluginDescriptor {
|
||||
return myAllowBundledUpdate;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@NotNull
|
||||
public List<String> getModules() {
|
||||
return myModules;
|
||||
return ContainerUtil.notNullize(myModules);
|
||||
}
|
||||
}
|
||||
@@ -1498,11 +1498,9 @@ public class PluginManagerCore {
|
||||
|
||||
if (toNotLoadReason == null) {
|
||||
List<String> modules = descriptor.getModules();
|
||||
if (modules != null) {
|
||||
for (String module : modules) {
|
||||
if (!ourModulesToContainingPlugins.containsKey(module)) {
|
||||
ourModulesToContainingPlugins.put(module, descriptor);
|
||||
}
|
||||
for (String module : modules) {
|
||||
if (!ourModulesToContainingPlugins.containsKey(module)) {
|
||||
ourModulesToContainingPlugins.put(module, descriptor);
|
||||
}
|
||||
}
|
||||
result.add(descriptor);
|
||||
|
||||
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.ide.plugins;
|
||||
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
@@ -23,6 +9,7 @@ import java.io.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* @author Ivan Chirkov
|
||||
@@ -60,11 +47,9 @@ public class BundledPluginsLister extends ApplicationStarterEx {
|
||||
IdeaPluginDescriptor[] plugins = PluginManagerCore.getPlugins();
|
||||
|
||||
List<String> modules = Arrays.stream(plugins)
|
||||
.filter(IdeaPluginDescriptorImpl.class::isInstance)
|
||||
.filter(plugin -> ((IdeaPluginDescriptorImpl)plugin).getModules() != null)
|
||||
.flatMap(plugin -> ((IdeaPluginDescriptorImpl)plugin).getModules().stream())
|
||||
.sorted()
|
||||
.collect(Collectors.toList());
|
||||
.flatMap(it -> it instanceof IdeaPluginDescriptorImpl ? ((IdeaPluginDescriptorImpl)it).getModules().stream() : Stream.empty())
|
||||
.sorted()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
List<String> pluginIds = Arrays.stream(plugins)
|
||||
.map(plugin -> plugin.getPluginId().getIdString())
|
||||
|
||||
+1
-2
@@ -1533,8 +1533,7 @@ public class PluginManagerConfigurableNew
|
||||
if (plugin == null && PluginManagerCore.isModuleDependency(id)) {
|
||||
for (IdeaPluginDescriptor descriptor : PluginManagerCore.getPlugins()) {
|
||||
if (descriptor instanceof IdeaPluginDescriptorImpl) {
|
||||
List<String> modules = ((IdeaPluginDescriptorImpl)descriptor).getModules();
|
||||
if (modules != null && modules.contains(id.getIdString())) {
|
||||
if (((IdeaPluginDescriptorImpl)descriptor).getModules().contains(id.getIdString())) {
|
||||
plugin = descriptor;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -442,8 +442,7 @@ public class MyPluginModel extends InstalledPluginsTableModel implements PluginM
|
||||
if (result == null && PluginManagerCore.isModuleDependency(pluginId)) {
|
||||
result = ContainerUtil.find(allPlugins, d -> {
|
||||
if (d instanceof IdeaPluginDescriptorImpl) {
|
||||
List<String> modules = ((IdeaPluginDescriptorImpl)d).getModules();
|
||||
return modules != null && modules.contains(pluginId.getIdString());
|
||||
return ((IdeaPluginDescriptorImpl)d).getModules().contains(pluginId.getIdString());
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user