Skip to content

Commit

Permalink
Format java files in o.e.equinox.registry
Browse files Browse the repository at this point in the history
This was achieved by running:
eclipse -consolelog -nosplash -application org.eclipse.jdt.core.JavaCodeFormatter \
  -config .settings/org.eclipse.jdt.core.prefs . -data `mktemp -d`

Signed-off-by: Torbjörn SVENSSON <[email protected]>
  • Loading branch information
Torbjorn-Svensson authored and vogella committed Oct 18, 2023
1 parent 9873b9d commit b8735a2
Show file tree
Hide file tree
Showing 75 changed files with 2,609 additions and 1,883 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ class AdapterFactoryProxy implements IAdapterFactory, IAdapterFactoryExt {
private Optional<IAdapterFactory> factory;
private Callable<IAdapterFactory> factoryLoader;
/**
* Store Id of the declaring extension. We might need it in case
* the owner goes away (in this case element becomes invalid).
* Store Id of the declaring extension. We might need it in case the owner goes
* away (in this case element becomes invalid).
*/
private String ownerId;
private int internalOwnerId = -1;

/**
* Creates a new factory proxy based on the given configuration element.
* Returns the new proxy, or null if the element could not be created.
* Creates a new factory proxy based on the given configuration element. Returns
* the new proxy, or null if the element could not be created.
*/
public static AdapterFactoryProxy createProxy(IConfigurationElement element) {
AdapterFactoryProxy result = new AdapterFactoryProxy();
Expand Down Expand Up @@ -130,11 +130,11 @@ IExtension getExtension() {
}

/**
* Loads the real adapter factory, but only if its associated plug-in is
* already loaded. Returns the real factory if it was successfully loaded.
* @param force if <code>true</code> the plugin providing the
* factory will be loaded if necessary, otherwise no plugin activations
* will occur.
* Loads the real adapter factory, but only if its associated plug-in is already
* loaded. Returns the real factory if it was successfully loaded.
*
* @param force if <code>true</code> the plugin providing the factory will be
* loaded if necessary, otherwise no plugin activations will occur.
*/
@Override
public synchronized IAdapterFactory loadFactory(boolean force) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ public AdapterManagerListener() {
}

/**
* Loads adapters registered with the adapters extension point from
* the plug-in registry. Note that the actual factory implementations
* are loaded lazily as they are needed.
* Loads adapters registered with the adapters extension point from the plug-in
* registry. Note that the actual factory implementations are loaded lazily as
* they are needed.
*/
@Override
public boolean addFactories(AdapterManager adapterManager) {
Expand Down Expand Up @@ -84,7 +84,8 @@ public synchronized void removed(IExtension[] extensions) {
theAdapterManager.flushLookup();
for (IExtension extension : extensions) {
for (List<IAdapterFactory> adapterFactories : theAdapterManager.getFactories().values()) {
adapterFactories.removeIf(factory -> factory instanceof AdapterFactoryProxy && ((AdapterFactoryProxy) factory).originatesFrom(extension));
adapterFactories.removeIf(factory -> factory instanceof AdapterFactoryProxy
&& ((AdapterFactoryProxy) factory).originatesFrom(extension));
}
}
}
Expand All @@ -96,13 +97,14 @@ public synchronized void added(IExtensionPoint[] extensionPoints) {

@Override
public synchronized void removed(IExtensionPoint[] extensionPoints) {
// all extensions should have been removed by this point by #removed(IExtension[] extensions)
// all extensions should have been removed by this point by
// #removed(IExtension[] extensions)
// nothing to do
}

/*
* Shuts down the listener by removing the registry change listener. Should only be
* invoked during platform shutdown.
* Shuts down the listener by removing the registry change listener. Should only
* be invoked during platform shutdown.
*/
public synchronized void stop() {
RegistryFactory.getRegistry().removeListener(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
import org.eclipse.core.runtime.*;

/**
* This is the copy of the ExtensionHandle minus the getDeclaringPluginDescriptor()
* method that was moved into compatibility plugin.
* This is the copy of the ExtensionHandle minus the
* getDeclaringPluginDescriptor() method that was moved into compatibility
* plugin.
*
* This class should not be used directly. Use ExtensionHandle instead.
*
Expand Down Expand Up @@ -88,7 +89,8 @@ public String getUniqueIdentifier() {

@Override
public IConfigurationElement[] getConfigurationElements() {
return (IConfigurationElement[]) objectManager.getHandles(getExtension().getRawChildren(), RegistryObjectManager.CONFIGURATION_ELEMENT);
return (IConfigurationElement[]) objectManager.getHandles(getExtension().getRawChildren(),
RegistryObjectManager.CONFIGURATION_ELEMENT);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
import org.eclipse.core.runtime.*;

/**
* This is the copy of the ExtensionPointHandle minus the getDeclaringPluginDescriptor()
* method that was moved into compatibility plugin.
* This is the copy of the ExtensionPointHandle minus the
* getDeclaringPluginDescriptor() method that was moved into compatibility
* plugin.
*
* This class should not be used directly. Use ExtensionPointHandle instead.
*
Expand All @@ -33,7 +34,8 @@ public BaseExtensionPointHandle(IObjectManager objectManager, int id) {

@Override
public IExtension[] getExtensions() {
return (IExtension[]) objectManager.getHandles(getExtensionPoint().getRawChildren(), RegistryObjectManager.EXTENSION);
return (IExtension[]) objectManager.getHandles(getExtensionPoint().getRawChildren(),
RegistryObjectManager.EXTENSION);
}

// This method is left for backward compatibility only
Expand Down Expand Up @@ -61,23 +63,28 @@ public IExtension getExtension(String extensionId) {
if (extensionId == null)
return null;
for (int element : getExtensionPoint().getRawChildren()) {
// Here we directly get the object because it avoids the creation of garbage and because we'll need the object anyway to compare the value
if (extensionId.equals(((Extension) objectManager.getObject(element, RegistryObjectManager.EXTENSION)).getUniqueIdentifier()))
// Here we directly get the object because it avoids the creation of garbage and
// because we'll need the object anyway to compare the value
if (extensionId.equals(((Extension) objectManager.getObject(element, RegistryObjectManager.EXTENSION))
.getUniqueIdentifier()))
return (ExtensionHandle) objectManager.getHandle(element, RegistryObjectManager.EXTENSION);
}
return null;
}

@Override
public IConfigurationElement[] getConfigurationElements() {
//get the actual extension objects since we'll need to get the configuration elements information.
Extension[] tmpExtensions = (Extension[]) objectManager.getObjects(getExtensionPoint().getRawChildren(), RegistryObjectManager.EXTENSION);
// get the actual extension objects since we'll need to get the configuration
// elements information.
Extension[] tmpExtensions = (Extension[]) objectManager.getObjects(getExtensionPoint().getRawChildren(),
RegistryObjectManager.EXTENSION);
if (tmpExtensions.length == 0)
return ConfigurationElementHandle.EMPTY_ARRAY;

ArrayList<Handle> result = new ArrayList<>();
for (Extension tmpExtension : tmpExtensions) {
result.addAll(Arrays.asList(objectManager.getHandles(tmpExtension.getRawChildren(), RegistryObjectManager.CONFIGURATION_ELEMENT)));
result.addAll(Arrays.asList(objectManager.getHandles(tmpExtension.getRawChildren(),
RegistryObjectManager.CONFIGURATION_ELEMENT)));
}
return result.toArray(new IConfigurationElement[result.size()]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public int read(byte b[], int off, int len) throws IOException {
int available = buffer_size - buffer_pos;
if (available < 0)
return -1;
//the buffer contains all the bytes we need, so copy over and return
// the buffer contains all the bytes we need, so copy over and return
if (len <= available) {
System.arraycopy(buffer, buffer_pos, b, off, len);
buffer_pos += len;
Expand All @@ -86,7 +86,7 @@ public int read(byte b[], int off, int len) throws IOException {
System.arraycopy(buffer, buffer_pos, b, off, available);
if (fillBuffer() <= 0)
return available;
//recursive call to read again until we have the bytes we need
// recursive call to read again until we have the bytes we need
return available + read(b, off + available, len - available);
}

Expand Down Expand Up @@ -132,10 +132,10 @@ public String toString() {
*/
public void seek(long pos) throws IOException {
if (pos >= buffer_start && pos < buffer_start + buffer_size) {
//seeking within the current buffer
// seeking within the current buffer
buffer_pos = (int) (pos - buffer_start);
} else {
//seeking outside the buffer - just discard the buffer
// seeking outside the buffer - just discard the buffer
inputFile.seek(pos);
file_pointer = pos;
resetBuffer();
Expand All @@ -144,6 +144,7 @@ public void seek(long pos) throws IOException {

/**
* Supplies functionality of the {@link java.io.RandomAccessFile#length()}.
*
* @return file length
* @throws IOException
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,16 @@
* The class stores extensions and extensions points that have been actually
* modified by a registry operation.
*
* For performance, modified extensions and extension points are stored in two forms:
* - organized in buckets by IDs of extension points (for listeners on specific ext.point)
* - aggregated in one list (for global listeners)
* For performance, modified extensions and extension points are stored in two
* forms: - organized in buckets by IDs of extension points (for listeners on
* specific ext.point) - aggregated in one list (for global listeners)
*/
public class CombinedEventDelta {

final private boolean addition; // true: objects were added; false: objects were removed

// the object manager from which all the objects contained in this delta will be found
// the object manager from which all the objects contained in this delta will be
// found
private IObjectManager objectManager;

// an empty array trail used to reduce re-allocations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,36 +19,42 @@
import org.eclipse.osgi.util.NLS;

/**
* An object which represents the user-defined contents of an extension
* in a plug-in manifest.
* An object which represents the user-defined contents of an extension in a
* plug-in manifest.
*/
public class ConfigurationElement extends RegistryObject {
static final ConfigurationElement[] EMPTY_ARRAY = new ConfigurationElement[0];

//The id of the parent element. It can be a configuration element or an extension
// The id of the parent element. It can be a configuration element or an
// extension
int parentId;
byte parentType; //This value is only interesting when running from cache.

//Store the properties and the value of the configuration element.
//The format is the following:
// [p1, v1, p2, v2, configurationElementValue]
//If the array size is even, there is no "configurationElementValue (ie getValue returns null)".
//The properties and their values are alternated (v1 is the value of p1).
byte parentType; // This value is only interesting when running from cache.

// Store the properties and the value of the configuration element.
// The format is the following:
// [p1, v1, p2, v2, configurationElementValue]
// If the array size is even, there is no "configurationElementValue (ie
// getValue returns null)".
// The properties and their values are alternated (v1 is the value of p1).
protected String[] propertiesAndValue;

//The name of the configuration element
// The name of the configuration element
private String name;

//ID of the actual contributor of this element
//This value can be null when the element is loaded from disk and the owner has been uninstalled.
//This happens when the configuration is obtained from a delta containing removed extension.
// ID of the actual contributor of this element
// This value can be null when the element is loaded from disk and the owner has
// been uninstalled.
// This happens when the configuration is obtained from a delta containing
// removed extension.
private String contributorId;

protected ConfigurationElement(ExtensionRegistry registry, boolean persist) {
super(registry, persist);
}

protected ConfigurationElement(int self, String contributorId, String name, String[] propertiesAndValue, int[] children, int extraDataOffset, int parent, byte parentType, ExtensionRegistry registry, boolean persist) {
protected ConfigurationElement(int self, String contributorId, String name, String[] propertiesAndValue,
int[] children, int extraDataOffset, int parent, byte parentType, ExtensionRegistry registry,
boolean persist) {
super(registry, persist);

setObjectId(self);
Expand All @@ -62,7 +68,8 @@ protected ConfigurationElement(int self, String contributorId, String name, Stri
}

void throwException(String message, Throwable exception) throws CoreException {
throw new CoreException(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, IRegistryConstants.PLUGIN_ERROR, message, exception));
throw new CoreException(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, IRegistryConstants.PLUGIN_ERROR,
message, exception));
}

protected String getValue() {
Expand Down Expand Up @@ -112,7 +119,7 @@ protected String[] getPropertiesAndValue() {

void setValue(String value) {
if (propertiesAndValue.length == 0) {
propertiesAndValue = new String[] {value};
propertiesAndValue = new String[] { value };
return;
}
if (propertiesAndValue.length % 2 == 1) {
Expand All @@ -137,11 +144,13 @@ public ConfigurationElement[] getChildren(String childrenName) {
if (getRawChildren().length == 0)
return ConfigurationElement.EMPTY_ARRAY;

ConfigurationElement[] result = new ConfigurationElement[1]; //Most of the time there is only one match
ConfigurationElement[] result = new ConfigurationElement[1]; // Most of the time there is only one match
int idx = 0;
RegistryObjectManager objectManager = registry.getObjectManager();
for (int child : children) {
ConfigurationElement toTest = (ConfigurationElement) objectManager.getObject(child, noExtraData() ? RegistryObjectManager.CONFIGURATION_ELEMENT : RegistryObjectManager.THIRDLEVEL_CONFIGURATION_ELEMENT);
ConfigurationElement toTest = (ConfigurationElement) objectManager.getObject(child,
noExtraData() ? RegistryObjectManager.CONFIGURATION_ELEMENT
: RegistryObjectManager.THIRDLEVEL_CONFIGURATION_ELEMENT);
if (toTest.name.equals(childrenName)) {
if (idx != 0) {
ConfigurationElement[] copy = new ConfigurationElement[result.length + 1];
Expand Down Expand Up @@ -249,15 +258,17 @@ protected Object createExecutableExtension(String attributeName) throws CoreExce
// Make the call even if the initialization string is null
try {
// We need to take into account both "old" and "new" style executable extensions
ConfigurationElementHandle confElementHandle = new ConfigurationElementHandle(registry.getObjectManager(), getObjectId());
ConfigurationElementHandle confElementHandle = new ConfigurationElementHandle(registry.getObjectManager(),
getObjectId());
if (result instanceof IExecutableExtension)
((IExecutableExtension) result).setInitializationData(confElementHandle, attributeName, initData);
} catch (CoreException ce) {
// user code threw exception
throw ce;
} catch (Exception te) {
// user code caused exception
throwException(NLS.bind(RegistryMessages.plugin_initObjectError, getContributor().getName(), className), te);
throwException(NLS.bind(RegistryMessages.plugin_initObjectError, getContributor().getName(), className),
te);
}

// Deal with executable extension factories.
Expand Down
Loading

0 comments on commit b8735a2

Please sign in to comment.