mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
memory optimisation: field removed
This commit is contained in:
+17
-21
@@ -38,8 +38,6 @@ import java.util.*;
|
||||
public class ExtensionPointImpl<T> implements ExtensionPoint<T> {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.extensions.impl.ExtensionPointImpl");
|
||||
|
||||
private final LogProvider myLogger;
|
||||
|
||||
private final AreaInstance myArea;
|
||||
private final String myName;
|
||||
private final String myClassName;
|
||||
@@ -59,13 +57,12 @@ public class ExtensionPointImpl<T> implements ExtensionPoint<T> {
|
||||
|
||||
private static final StringInterner INTERNER = new StringInterner();
|
||||
|
||||
public ExtensionPointImpl(@NotNull String name,
|
||||
@NotNull String className,
|
||||
@NotNull Kind kind,
|
||||
@NotNull ExtensionsAreaImpl owner,
|
||||
AreaInstance area,
|
||||
@NotNull LogProvider logger,
|
||||
@NotNull PluginDescriptor descriptor) {
|
||||
ExtensionPointImpl(@NotNull String name,
|
||||
@NotNull String className,
|
||||
@NotNull Kind kind,
|
||||
@NotNull ExtensionsAreaImpl owner,
|
||||
AreaInstance area,
|
||||
@NotNull PluginDescriptor descriptor) {
|
||||
synchronized (INTERNER) {
|
||||
myName = INTERNER.intern(name);
|
||||
}
|
||||
@@ -73,7 +70,6 @@ public class ExtensionPointImpl<T> implements ExtensionPoint<T> {
|
||||
myKind = kind;
|
||||
myOwner = owner;
|
||||
myArea = area;
|
||||
myLogger = logger;
|
||||
myDescriptor = descriptor;
|
||||
}
|
||||
|
||||
@@ -134,13 +130,13 @@ public class ExtensionPointImpl<T> implements ExtensionPoint<T> {
|
||||
|
||||
private void registerExtension(@NotNull T extension, @NotNull ExtensionComponentAdapter adapter, int index, boolean runNotifications) {
|
||||
if (myExtensions.contains(extension)) {
|
||||
myLogger.error("Extension was already added: " + extension);
|
||||
myOwner.error("Extension was already added: " + extension);
|
||||
return;
|
||||
}
|
||||
|
||||
Class<T> extensionClass = getExtensionClass();
|
||||
if (!extensionClass.isInstance(extension)) {
|
||||
myLogger.error("Extension " + extension.getClass() + " does not implement " + extensionClass);
|
||||
myOwner.error("Extension " + extension.getClass() + " does not implement " + extensionClass);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -156,7 +152,7 @@ public class ExtensionPointImpl<T> implements ExtensionPoint<T> {
|
||||
((Extension)extension).extensionAdded(this);
|
||||
}
|
||||
catch (Throwable e) {
|
||||
myLogger.error(e);
|
||||
myOwner.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,7 +168,7 @@ public class ExtensionPointImpl<T> implements ExtensionPoint<T> {
|
||||
listener.extensionAdded(extension, pluginDescriptor);
|
||||
}
|
||||
catch (Throwable e) {
|
||||
myLogger.error(e);
|
||||
myOwner.error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -315,7 +311,7 @@ public class ExtensionPointImpl<T> implements ExtensionPoint<T> {
|
||||
((Extension)extension).extensionRemoved(this);
|
||||
}
|
||||
catch (Throwable e) {
|
||||
myLogger.error(e);
|
||||
myOwner.error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -326,7 +322,7 @@ public class ExtensionPointImpl<T> implements ExtensionPoint<T> {
|
||||
listener.extensionRemoved(extensionObject, pluginDescriptor);
|
||||
}
|
||||
catch (Throwable e) {
|
||||
myLogger.error(e);
|
||||
myOwner.error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -362,7 +358,7 @@ public class ExtensionPointImpl<T> implements ExtensionPoint<T> {
|
||||
listener.extensionAdded(extension, componentAdapter.getPluginDescriptor());
|
||||
}
|
||||
catch (Throwable e) {
|
||||
myLogger.error(e);
|
||||
myOwner.error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -381,7 +377,7 @@ public class ExtensionPointImpl<T> implements ExtensionPoint<T> {
|
||||
listener.extensionRemoved(extension, componentAdapter.getPluginDescriptor());
|
||||
}
|
||||
catch (Throwable e) {
|
||||
myLogger.error(e);
|
||||
myOwner.error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -406,8 +402,8 @@ public class ExtensionPointImpl<T> implements ExtensionPoint<T> {
|
||||
if (extensionClass == null) {
|
||||
try {
|
||||
ClassLoader pluginClassLoader = myDescriptor.getPluginClassLoader();
|
||||
@SuppressWarnings("unchecked") Class<T> extClass = pluginClassLoader == null
|
||||
? (Class<T>)Class.forName(myClassName) : (Class<T>)Class.forName(myClassName, true, pluginClassLoader);
|
||||
@SuppressWarnings("unchecked") Class<T> extClass =
|
||||
(Class<T>)(pluginClassLoader == null ? Class.forName(myClassName) : Class.forName(myClassName, true, pluginClassLoader));
|
||||
myExtensionClass = extensionClass = extClass;
|
||||
}
|
||||
catch (ClassNotFoundException e) {
|
||||
@@ -430,7 +426,7 @@ public class ExtensionPointImpl<T> implements ExtensionPoint<T> {
|
||||
myExtensionsCache = null;
|
||||
}
|
||||
|
||||
public synchronized boolean unregisterExtensionAdapter(@NotNull ExtensionComponentAdapter adapter) {
|
||||
private synchronized boolean unregisterExtensionAdapter(@NotNull ExtensionComponentAdapter adapter) {
|
||||
try {
|
||||
if (myExtensionAdapters.remove(adapter)) {
|
||||
return true;
|
||||
|
||||
+13
-8
@@ -32,9 +32,7 @@ import org.picocontainer.PicoContainer;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static com.intellij.openapi.extensions.Extensions.isComponentSuitableForOs;
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
@SuppressWarnings("HardCodedStringLiteral")
|
||||
public class ExtensionsAreaImpl implements ExtensionsArea {
|
||||
private final LogProvider myLogger;
|
||||
public static final String ATTRIBUTE_AREA = "area";
|
||||
@@ -139,7 +137,7 @@ public class ExtensionsAreaImpl implements ExtensionsArea {
|
||||
public void registerExtension(@NotNull final PluginDescriptor pluginDescriptor, @NotNull final Element extensionElement) {
|
||||
final PluginId pluginId = pluginDescriptor.getPluginId();
|
||||
|
||||
if (!isComponentSuitableForOs(extensionElement.getAttributeValue("os"))) {
|
||||
if (!Extensions.isComponentSuitableForOs(extensionElement.getAttributeValue("os"))) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -201,7 +199,7 @@ public class ExtensionsAreaImpl implements ExtensionsArea {
|
||||
return myPicoContainer;
|
||||
}
|
||||
|
||||
@SuppressWarnings({"unchecked"})
|
||||
@SuppressWarnings("unchecked")
|
||||
private void initialize() {
|
||||
for (Map.Entry<String, String> entry : ourDefaultEPs.entrySet()) {
|
||||
String epName = entry.getKey();
|
||||
@@ -246,7 +244,7 @@ public class ExtensionsAreaImpl implements ExtensionsArea {
|
||||
return adapter.getComponentInstance(getPicoContainer());
|
||||
}
|
||||
|
||||
@SuppressWarnings({"UnusedDeclaration"})
|
||||
@SuppressWarnings("UnusedDeclaration")
|
||||
public Throwable getCreationTrace() {
|
||||
return myCreationTrace;
|
||||
}
|
||||
@@ -288,7 +286,7 @@ public class ExtensionsAreaImpl implements ExtensionsArea {
|
||||
throw new RuntimeException("Duplicate registration for EP: " + extensionPointName);
|
||||
}
|
||||
|
||||
registerExtensionPoint(new ExtensionPointImpl(extensionPointName, extensionPointBeanClass, kind, this, myAreaInstance, myLogger, descriptor));
|
||||
registerExtensionPoint(new ExtensionPointImpl(extensionPointName, extensionPointBeanClass, kind, this, myAreaInstance, descriptor));
|
||||
}
|
||||
|
||||
public void registerExtensionPoint(@NotNull ExtensionPointImpl extensionPoint) {
|
||||
@@ -408,7 +406,7 @@ public class ExtensionsAreaImpl implements ExtensionsArea {
|
||||
mySuspendedListenerActions.clear();
|
||||
}
|
||||
|
||||
public void removeAllComponents(final Set<ExtensionComponentAdapter> extensionAdapters) {
|
||||
void removeAllComponents(final Set<ExtensionComponentAdapter> extensionAdapters) {
|
||||
for (final Object extensionAdapter : extensionAdapters) {
|
||||
ExtensionComponentAdapter componentAdapter = (ExtensionComponentAdapter)extensionAdapter;
|
||||
internalGetPluginContainer().unregisterComponent(componentAdapter.getComponentKey());
|
||||
@@ -419,4 +417,11 @@ public class ExtensionsAreaImpl implements ExtensionsArea {
|
||||
public String toString() {
|
||||
return (myAreaClass == null ? "Root" : myAreaClass)+" Area";
|
||||
}
|
||||
|
||||
void error(@NotNull String msg) {
|
||||
myLogger.error(msg);
|
||||
}
|
||||
void error(@NotNull Throwable msg) {
|
||||
myLogger.error(msg);
|
||||
}
|
||||
}
|
||||
|
||||
+5
-6
@@ -26,7 +26,6 @@ import org.picocontainer.defaults.DefaultPicoContainer;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static com.intellij.openapi.extensions.impl.ExtensionComponentAdapterTest.readElement;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
@@ -64,7 +63,7 @@ public class ExtensionPointImplTest {
|
||||
final AreaInstance area = new AreaInstance() {};
|
||||
final ExtensionPoint<Object> extensionPoint = new ExtensionPointImpl<Object>(
|
||||
"an.extension.point", Object.class.getName(), ExtensionPoint.Kind.INTERFACE, buildExtensionArea(), area,
|
||||
ourTestLog, new UndefinedPluginDescriptor());
|
||||
new UndefinedPluginDescriptor());
|
||||
|
||||
final boolean[] flags = new boolean[2];
|
||||
Extension extension = new Extension() {
|
||||
@@ -252,7 +251,7 @@ public class ExtensionPointImplTest {
|
||||
private static <T> ExtensionPoint<T> buildExtensionPoint(Class<T> aClass) {
|
||||
return new ExtensionPointImpl<T>(
|
||||
ExtensionsImplTest.EXTENSION_POINT_NAME_1, aClass.getName(), ExtensionPoint.Kind.INTERFACE,
|
||||
buildExtensionArea(), null, ourTestLog, new UndefinedPluginDescriptor());
|
||||
buildExtensionArea(), null, new UndefinedPluginDescriptor());
|
||||
}
|
||||
|
||||
private static ExtensionsAreaImpl buildExtensionArea() {
|
||||
@@ -264,10 +263,10 @@ public class ExtensionPointImplTest {
|
||||
}
|
||||
|
||||
private static class MyShootingComponentAdapter extends ExtensionComponentAdapter {
|
||||
private boolean myFire = false;
|
||||
private boolean myFire;
|
||||
|
||||
public MyShootingComponentAdapter(@NotNull String implementationClass) {
|
||||
super(implementationClass, readElement("<bean/>"), new DefaultPicoContainer(), new DefaultPluginDescriptor("test"), false);
|
||||
MyShootingComponentAdapter(@NotNull String implementationClass) {
|
||||
super(implementationClass, ExtensionComponentAdapterTest.readElement("<bean/>"), new DefaultPicoContainer(), new DefaultPluginDescriptor("test"), false);
|
||||
}
|
||||
|
||||
public void setFire(boolean fire) {
|
||||
|
||||
Reference in New Issue
Block a user