diff --git a/platform/core-impl/src/com/intellij/ide/plugins/IdeaPluginDescriptorImpl.java b/platform/core-impl/src/com/intellij/ide/plugins/IdeaPluginDescriptorImpl.java index 72d290e61e25..939ab753574b 100644 --- a/platform/core-impl/src/com/intellij/ide/plugins/IdeaPluginDescriptorImpl.java +++ b/platform/core-impl/src/com/intellij/ide/plugins/IdeaPluginDescriptorImpl.java @@ -53,17 +53,17 @@ import java.util.*; * @author mike */ public class IdeaPluginDescriptorImpl implements IdeaPluginDescriptor { - private static final Logger LOG = Logger.getInstance("#com.intellij.ide.plugins.PluginDescriptor"); - public static final IdeaPluginDescriptorImpl[] EMPTY_ARRAY = new IdeaPluginDescriptorImpl[0]; - private String myName; - private PluginId myId; + private static final Logger LOG = Logger.getInstance("#com.intellij.ide.plugins.PluginDescriptor"); + private static final StringInterner ourInterner = new WeakStringInterner(); private final NullableLazyValue myDescription = new NullableLazyValue() { @Override protected String compute() { return computeDescription(); } }; + private String myName; + private PluginId myId; private String myResourceBundleBaseName; private String myChangeNotes; private String myVersion; @@ -93,32 +93,15 @@ public class IdeaPluginDescriptorImpl implements IdeaPluginDescriptor { private boolean myUseIdeaClassLoader; private boolean myUseCoreClassLoader; private boolean myEnabled = true; - private String mySinceBuild; private String myUntilBuild; - private Boolean mySkipped; - private List myModules = null; public IdeaPluginDescriptorImpl(@NotNull File pluginPath) { myPath = pluginPath; } - IdeaPluginDescriptorImpl() { - } - - public void setPath(@NotNull File path) { - myPath = path; - } - - @Override - public File getPath() { - return myPath; - } - - private static final StringInterner ourInterner = new WeakStringInterner(); - @NotNull public static String intern(@NotNull String s) { return ourInterner.intern(s); @@ -128,6 +111,46 @@ public class IdeaPluginDescriptorImpl implements IdeaPluginDescriptor { JDOMUtil.internElement(rootElement, ourInterner); } + @Nullable + private static List copyElements(final Element[] elements) { + if (elements != null) { + List result = new ArrayList(); + for (Element extensionsRoot : elements) { + for (final Object o : extensionsRoot.getChildren()) { + Element element = (Element)o; + internJDOMElement(element); + result.add(element); + } + } + return result; + } + return null; + } + + @SuppressWarnings({"HardCodedStringLiteral"}) + private static String createDescriptionKey(final PluginId id) { + return "plugin." + id + ".description"; + } + + private static ComponentConfig[] mergeComponents(ComponentConfig[] first, ComponentConfig[] second) { + if (first == null) { + return second; + } + if (second == null) { + return first; + } + return ArrayUtil.mergeArrays(first, second); + } + + @Override + public File getPath() { + return myPath; + } + + public void setPath(@NotNull File path) { + myPath = path; + } + public void readExternal(@NotNull Document document, @NotNull URL url) throws InvalidDataException, FileNotFoundException { Application application = ApplicationManager.getApplication(); readExternal(document, url, application != null && application.isUnitTestMode()); @@ -243,7 +266,7 @@ public class IdeaPluginDescriptorImpl implements IdeaPluginDescriptor { myExtensions.putValue(ExtensionsAreaImpl.extractEPName(extension), extension); } } - + List extensionPoints = copyElements(pluginBean.extensionPoints); if (extensionPoints != null) { myExtensionsPoints = new MultiMap(); @@ -251,7 +274,7 @@ public class IdeaPluginDescriptorImpl implements IdeaPluginDescriptor { myExtensionsPoints.putValue(extensionPoint.getAttributeValue(ExtensionsAreaImpl.ATTRIBUTE_AREA), extensionPoint); } } - + myActionsElements = copyElements(pluginBean.actions); if (pluginBean.modules != null && !pluginBean.modules.isEmpty()) { @@ -259,27 +282,6 @@ public class IdeaPluginDescriptorImpl implements IdeaPluginDescriptor { } } - @Nullable - private static List copyElements(final Element[] elements) { - if (elements != null) { - List result = new ArrayList(); - for (Element extensionsRoot : elements) { - for (final Object o : extensionsRoot.getChildren()) { - Element element = (Element)o; - internJDOMElement(element); - result.add(element); - } - } - return result; - } - return null; - } - - @SuppressWarnings({"HardCodedStringLiteral"}) - private static String createDescriptionKey(final PluginId id) { - return "plugin." + id + ".description"; - } - void registerExtensionPoints(ExtensionsArea area) { if (myExtensionsPoints != null) { for (Element element : myExtensionsPoints.get(area.getAreaClass())) { @@ -317,7 +319,6 @@ public class IdeaPluginDescriptorImpl implements IdeaPluginDescriptor { return myDependencies; } - @Override @NotNull public PluginId[] getOptionalDependentPluginIds() { @@ -329,6 +330,11 @@ public class IdeaPluginDescriptorImpl implements IdeaPluginDescriptor { return myVendor; } + public void setVendor( final String val ) + { + myVendor = val; + } + @Override public String getVersion() { return myVersion; @@ -344,6 +350,17 @@ public class IdeaPluginDescriptorImpl implements IdeaPluginDescriptor { return myCategory; } + /* + This setter was explicitly defined to be able to set a category for a + descriptor outside its loading from the xml file. + Problem was that most commonly plugin authors do not publish the plugin's + category in its .xml file so to be consistent in plugins representation + (e.g. in the Plugins form) we have to set this value outside. + */ + public void setCategory( String category ){ + myCategory = category; + } + @SuppressWarnings("UnusedDeclaration") // Used in Upsource @Nullable public MultiMap getExtensionsPoints() { @@ -418,16 +435,31 @@ public class IdeaPluginDescriptorImpl implements IdeaPluginDescriptor { return myVendorEmail; } + public void setVendorEmail( final String val ) + { + myVendorEmail = val; + } + @Override public String getVendorUrl() { return myVendorUrl; } + public void setVendorUrl( final String val ) + { + myVendorUrl = val; + } + @Override public String getUrl() { return url; } + public void setUrl( final String val ) + { + url = val; + } + @NonNls public String toString() { return "PluginDescriptor[name='" + myName + "', classpath='" + myPath + "']"; @@ -469,17 +501,6 @@ public class IdeaPluginDescriptorImpl implements IdeaPluginDescriptor { return myId; } - /* - This setter was explicitly defined to be able to set a category for a - descriptor outside its loading from the xml file. - Problem was that most commonly plugin authors do not publish the plugin's - category in its .xml file so to be consistent in plugins representation - (e.g. in the Plugins form) we have to set this value outside. - */ - public void setCategory( String category ){ - myCategory = category; - } - /* This setter was explicitly defined to be able to set downloads count for a descriptor outside its loading from the xml file since this information @@ -494,6 +515,10 @@ public class IdeaPluginDescriptorImpl implements IdeaPluginDescriptor { return myDownloadCounter; } + public long getDate(){ + return myDate; + } + /* This setter was explicitly defined to be able to set date for a descriptor outside its loading from the xml file since this information @@ -503,27 +528,6 @@ public class IdeaPluginDescriptorImpl implements IdeaPluginDescriptor { myDate = date; } - public long getDate(){ - return myDate; - } - - public void setVendor( final String val ) - { - myVendor = val; - } - public void setVendorEmail( final String val ) - { - myVendorEmail = val; - } - public void setVendorUrl( final String val ) - { - myVendorUrl = val; - } - public void setUrl( final String val ) - { - url = val; - } - @Override public ClassLoader getPluginClassLoader() { return myLoader != null ? myLoader : getClass().getClassLoader(); @@ -534,6 +538,10 @@ public class IdeaPluginDescriptorImpl implements IdeaPluginDescriptor { return myVendorLogoPath; } + public void setVendorLogoPath(final String vendorLogoPath) { + myVendorLogoPath = vendorLogoPath; + } + @Override public boolean getUseIdeaClassLoader() { return myUseIdeaClassLoader; @@ -547,10 +555,6 @@ public class IdeaPluginDescriptorImpl implements IdeaPluginDescriptor { myUseCoreClassLoader = useCoreClassLoader; } - public void setVendorLogoPath(final String vendorLogoPath) { - myVendorLogoPath = vendorLogoPath; - } - private String computeDescription() { ResourceBundle bundle = null; if (myResourceBundleBaseName != null) { @@ -635,16 +639,6 @@ public class IdeaPluginDescriptorImpl implements IdeaPluginDescriptor { myModuleComponents = mergeComponents(myModuleComponents, descriptor.myModuleComponents); } - private static ComponentConfig[] mergeComponents(ComponentConfig[] first, ComponentConfig[] second) { - if (first == null) { - return second; - } - if (second == null) { - return first; - } - return ArrayUtil.mergeArrays(first, second); - } - public Boolean getSkipped() { return mySkipped; }