API consolidation:
- fully separate API/non-API for org.eclipse.objectteams.otdt
- cleanup some interfaces
diff --git a/plugins/org.eclipse.objectteams.otdt/plugin.xml b/plugins/org.eclipse.objectteams.otdt/plugin.xml
index b1df675..2d66070 100644
--- a/plugins/org.eclipse.objectteams.otdt/plugin.xml
+++ b/plugins/org.eclipse.objectteams.otdt/plugin.xml
@@ -40,7 +40,7 @@
<extension point="org.eclipse.jdt.core.classpathVariableInitializer">
<classpathVariableInitializer
variable="OTDT_INSTALLDIR"
- class="org.eclipse.objectteams.otdt.core.ext.OTVariableInitializer"/>
+ class="org.eclipse.objectteams.otdt.internal.core.ext.OTVariableInitializer"/>
</extension>
<extension
@@ -48,7 +48,7 @@
id="org.eclipse.objectteams.otdt.otreContainerInitializer">
<classpathContainerInitializer
id="OTRE"
- class="org.eclipse.objectteams.otdt.core.ext.OTREContainerInitializer"/>
+ class="org.eclipse.objectteams.otdt.internal.core.ext.OTREContainerInitializer"/>
</extension>
<extension
point="org.eclipse.objectteams.otequinox.aspectBindings">
diff --git a/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/ext/OTDTPlugin.java b/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/ext/OTDTPlugin.java
index f5626b9..95d6419 100644
--- a/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/ext/OTDTPlugin.java
+++ b/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/ext/OTDTPlugin.java
@@ -43,60 +43,162 @@
public static final String OTDT_INSTALLDIR = "OTDT_INSTALLDIR"; //$NON-NLS-1$
// === IDs for configurable options for the compiler : ===
- public static final String OT_COMPILER_BASE_CALL =
- PLUGIN_ID + ".compiler.problem.basecall"; //$NON-NLS-1$
- public static final String OT_COMPILER_BASECLASS_CYCLE =
- PLUGIN_ID + ".compiler.problem.baseclass_cycle"; //$NON-NLS-1$
- public static final String OT_COMPILER_UNSAFE_ROLE_INSTANTIATION =
- PLUGIN_ID + ".compiler.problem.unsafe_role_instantiation"; //$NON-NLS-1$
+ /**
+ * Compiler option ID: Reporting missing or duplicate basecalls in a callin method.
+ * <dl>
+ * <dt>Possible values:</dt><dd><code>{ "error", "warning", "ignore" }</code></dd>
+ * <dt>Default:</dt><dd><code>"warning"</code></dd>
+ * </dl>
+ * @category CompilerOptionID
+ */
+ public static final String OT_COMPILER_BASE_CALL = PLUGIN_ID + ".compiler.problem.basecall"; //$NON-NLS-1$
+ /**
+ * Compiler option ID: Reporting cycles in playedBy and containment relationships.
+ * <dl>
+ * <dt>Possible values:</dt><dd><code>{ "error", "warning", "ignore" }</code></dd>
+ * <dt>Default:</dt><dd><code>"warning"</code></dd>
+ * </dl>
+ * @category CompilerOptionID
+ */
+ public static final String OT_COMPILER_BASECLASS_CYCLE = PLUGIN_ID + ".compiler.problem.baseclass_cycle"; //$NON-NLS-1$
+ /**
+ * Compiler option ID: Reporting role instantiations that might conflict
+ * with an existing role for the same base object.
+ * <dl>
+ * <dt>Possible values:</dt><dd><code>{ "error", "warning", "ignore" }</code></dd>
+ * <dt>Default:</dt><dd><code>"warning"</code></dd>
+ * </dl>
+ * @category CompilerOptionID
+ */
+ public static final String OT_COMPILER_UNSAFE_ROLE_INSTANTIATION = PLUGIN_ID + ".compiler.problem.unsafe_role_instantiation"; //$NON-NLS-1$
+ /**
+ * Compiler option ID: Reporting a callin binding that requires a base call to provide the required return value.
+ * <dl>
+ * <dt>Possible values:</dt><dd><code>{ "error", "warning", "ignore" }</code></dd>
+ * <dt>Default:</dt><dd><code>"warning"</code></dd>
+ * </dl>
+ * @category CompilerOptionID
+ */
+ public static final String OT_COMPILER_FRAGILE_CALLIN = PLUGIN_ID + ".compiler.problem.fragile_callin"; //$NON-NLS-1$
+ /**
+ * Compiler option ID: Reporting if playedBy bindings of multiple roles may create an ambiguity.
+ * <dl>
+ * <dt>Possible values:</dt><dd><code>{ "error", "warning", "ignore" }</code></dd>
+ * <dt>Default:</dt><dd><code>"warning"</code></dd>
+ * </dl>
+ * @category CompilerOptionID
+ */
+ public static final String OT_COMPILER_POTENTIAL_AMBIGUOUS_PLAYEDBY = PLUGIN_ID + ".compiler.problem.potential_ambiguous_playedby"; //$NON-NLS-1$
+ /**
+ * Compiler option ID: Reporting an abstract role class that might be relevant for instantiation (e.g., lifting).
+ * <dl>
+ * <dt>Possible values:</dt><dd><code>{ "error", "warning", "ignore" }</code></dd>
+ * <dt>Default:</dt><dd><code>"warning"</code></dd>
+ * </dl>
+ * @category CompilerOptionID
+ */
+ public static final String OT_COMPILER_ABSTRACT_POTENTIAL_RELEVANT_ROLE = PLUGIN_ID + ".compiler.problem.abstract_potential_relevant_role"; //$NON-NLS-1$
+ /**
+ * Compiler option ID: Reporting decapsulation.
+ * <dl>
+ * <dt>Possible values:</dt><dd><code>{ "error", "warning", "ignore" }</code></dd>
+ * <dt>Default:</dt><dd><code>"warning"</code></dd>
+ * </dl>
+ * @category CompilerOptionID
+ */
+ public static final String OT_COMPILER_DECAPSULATION = PLUGIN_ID + ".compiler.problem.decapsulation"; //$NON-NLS-1$
+ /**
+ * Compiler option ID: Reporting violations of binding conventions, notably the rule that
+ * types after the playedBy keyword should be imported with the base modifier.
+ * <dl>
+ * <dt>Possible values:</dt><dd><code>{ "error", "warning", "ignore" }</code></dd>
+ * <dt>Default:</dt><dd><code>"warning"</code> (except for OT-Plugin Projects which set this to <code>"error"</code></dd>
+ * </dl>
+ * @category CompilerOptionID
+ */
+ public static final String OT_COMPILER_BINDING_CONVENTIONS = PLUGIN_ID + ".compiler.problem.binding_conventions"; //$NON-NLS-1$
+ /**
+ * Compiler option ID: Reporting the use of inferred callout bindings.
+ * <dl>
+ * <dt>Possible values:</dt><dd><code>{ "error", "warning", "ignore" }</code></dd>
+ * <dt>Default:</dt><dd><code>"error"</code></dd>
+ * </dl>
+ * @category CompilerOptionID
+ */
+ public static final String OT_COMPILER_INFERRED_CALLOUT = PLUGIN_ID + ".compiler.problem.inferred_callout"; //$NON-NLS-1$
+ /**
+ * Compiler option ID: Reporting attempts to weave into a system class.
+ * <dl>
+ * <dt>Possible values:</dt><dd><code>{ "error", "warning", "ignore" }</code></dd>
+ * <dt>Default:</dt><dd><code>"warning"</code></dd>
+ * </dl>
+ * @category CompilerOptionID
+ */
+ public static final String OT_COMPILER_WEAVE_INTO_SYSTEM_CLASS = PLUGIN_ID + ".compiler.problem.weave_into_system_class"; //$NON-NLS-1$
+ /**
+ * Compiler option ID: Reporting when overriding a final roles.
+ * <dl>
+ * <dt>Possible values:</dt><dd><code>{ "error", "warning", "ignore" }</code></dd>
+ * <dt>Default:</dt><dd><code>"error"</code></dd>
+ * </dl>
+ * @category CompilerOptionID
+ */
+ public static final String OT_COMPILER_OVERRIDE_FINAL_ROLE = PLUGIN_ID + ".compiler.problem.override_final_role"; //$NON-NLS-1$
+ /**
+ * Compiler option ID: Reporting when a guard predicate may throw a checked exception.
+ * <dl>
+ * <dt>Possible values:</dt><dd><code>{ "error", "warning", "ignore" }</code></dd>
+ * <dt>Default:</dt><dd><code>"error"</code></dd>
+ * </dl>
+ * @category CompilerOptionID
+ */
+ public static final String OT_COMPILER_EXCEPTION_IN_GUARD = PLUGIN_ID + ".compiler.problem.exception_in_guard"; //$NON-NLS-1$
+ /**
+ * Compiler option ID: Reporting when lowering and upcast to Object are ambiguous.
+ * <dl>
+ * <dt>Possible values:</dt><dd><code>{ "error", "warning", "ignore" }</code></dd>
+ * <dt>Default:</dt><dd><code>"warning"</code></dd>
+ * </dl>
+ * @category CompilerOptionID
+ */
+ public static final String OT_COMPILER_AMBIGUOUS_LOWERING = PLUGIN_ID + ".compiler.problem.ambiguous_lowering"; //$NON-NLS-1$
+ /**
+ * Compiler option ID: Reporting when binding to a deprecated class (playedBy) or method (callin binding).
+ * <dl>
+ * <dt>Possible values:</dt><dd><code>{ "error", "warning", "ignore" }</code></dd>
+ * <dt>Default:</dt><dd><code>"error"</code></dd>
+ * </dl>
+ * @category CompilerOptionID
+ */
+ public static final String OT_COMPILER_ADAPTING_DEPRECATED = PLUGIN_ID + ".compiler.problem.adapting_deprecated"; //$NON-NLS-1$
+ /**
+ * Compiler option ID: Reporting when a callin after method will ignore the return value of the role method.
+ * <dl>
+ * <dt>Possible values:</dt><dd><code>{ "error", "warning", "ignore" }</code></dd>
+ * <dt>Default:</dt><dd><code>"warning"</code></dd>
+ * </dl>
+ * @category CompilerOptionID
+ */
+ public static final String OT_COMPILER_IGNORING_ROLE_RETURN = PLUGIN_ID + ".compiler.problem.ignoring_role_return"; //$NON-NLS-1$
+ /**
+ * Compiler option ID: Reporting use of the old path syntax for dependent types.
+ * <dl>
+ * <dt>Possible values:</dt><dd><code>{ "error", "warning", "ignore" }</code></dd>
+ * <dt>Default:</dt><dd><code>"warning"</code></dd>
+ * </dl>
+ * @category CompilerOptionID
+ */
+ public static final String OT_COMPILER_DEPRECATED_PATH_SYNTAX = PLUGIN_ID + ".compiler.problem.deprecated_path_syntax"; //$NON-NLS-1$;
+ /**
+ * Compiler option ID: Enabling scoped detection of keywords.
+ * <dl>
+ * <dt>Possible values:</dt><dd><code>{ "enabled", "disabled" }</code></dd>
+ * <dt>Default:</dt><dd><code>"enabled"</code></dd>
+ * </dl>
+ * @category CompilerOptionID
+ */
+ public static final String OT_COMPILER_SCOPED_KEYWORDS = PLUGIN_ID + ".compiler.option.scoped_keywords"; //$NON-NLS-1$
- public static final String OT_COMPILER_EFFECTLESS_FIELDACCESS =
- PLUGIN_ID + ".compiler.problem.effectless_fieldaccess"; //$NON-NLS-1$
- public static final String OT_COMPILER_FRAGILE_CALLIN =
- PLUGIN_ID + ".compiler.problem.fragile_callin"; //$NON-NLS-1$
- public static final String OT_COMPILER_UNUSED_PARAMMAP =
- PLUGIN_ID + ".compiler.problem.unused_parammap"; //$NON-NLS-1$
-
- public static final String OT_COMPILER_POTENTIAL_AMBIGUOUS_PLAYEDBY =
- PLUGIN_ID + ".compiler.problem.potential_ambiguous_playedby"; //$NON-NLS-1$
- public static final String OT_COMPILER_ABSTRACT_POTENTIAL_RELEVANT_ROLE =
- PLUGIN_ID + ".compiler.problem.abstract_potential_relevant_role"; //$NON-NLS-1$
-
- public static final String OT_COMPILER_DECAPSULATION =
- PLUGIN_ID + ".compiler.problem.decapsulation"; //$NON-NLS-1$
-
- public static final String OT_COMPILER_BINDING_CONVENTIONS =
- PLUGIN_ID + ".compiler.problem.binding_conventions"; //$NON-NLS-1$
-
- public static final String OT_COMPILER_INFERRED_CALLOUT =
- PLUGIN_ID + ".compiler.problem.inferred_callout"; //$NON-NLS-1$
-
- public static final String OT_COMPILER_INCOMPLETE_BUILD =
- PLUGIN_ID + ".compiler.problem.incomplete_build"; //$NON-NLS-1$
-
- public static final String OT_COMPILER_WEAVE_INTO_SYSTEM_CLASS =
- PLUGIN_ID + ".compiler.problem.weave_into_system_class"; //$NON-NLS-1$
-
- public static final String OT_COMPILER_OVERRIDE_FINAL_ROLE =
- PLUGIN_ID + ".compiler.problem.override_final_role"; //$NON-NLS-1$
-
- public static final String OT_COMPILER_EXCEPTION_IN_GUARD =
- PLUGIN_ID + ".compiler.problem.exception_in_guard"; //$NON-NLS-1$
-
- public static final String OT_COMPILER_AMBIGUOUS_LOWERING =
- PLUGIN_ID + ".compiler.problem.ambiguous_lowering"; //$NON-NLS-1$
-
- public static final String OT_COMPILER_ADAPTING_DEPRECATED =
- PLUGIN_ID + ".compiler.problem.adapting_deprecated"; //$NON-NLS-1$
-
- public static final String OT_COMPILER_IGNORING_ROLE_RETURN =
- PLUGIN_ID + ".compiler.problem.ignoring_role_return"; //$NON-NLS-1$
-
- public static final String OT_COMPILER_SCOPED_KEYWORDS =
- PLUGIN_ID + ".compiler.option.scoped_keywords"; //$NON-NLS-1$
-
- public static final String OT_COMPILER_DEPRECATED_PATH_SYNTAX =
- PLUGIN_ID + ".compiler.problem.deprecated_path_syntax"; //$NON-NLS-1$;
private static OTDTPlugin _singleton = null;
@@ -107,6 +209,7 @@
_singleton = this;
}
+ /** Get the singleton activator instance. */
public static OTDTPlugin getDefault()
{
return _singleton;
@@ -122,6 +225,11 @@
}
}
+ /**
+ * Add the OT/J nature to the natures of a given project.
+ * @param prjDesc start from the natures of this project.
+ * @return a fresh array including the natures of prjDesc plus the OT/J nature.
+ */
public static String[] createProjectNatures(IProjectDescription prjDesc)
{
String[] natures = prjDesc.getNatureIds();
@@ -134,11 +242,21 @@
return result;
}
+ /**
+ * Add the OT/J builder to the build commands of a given project.
+ * @param project start from the builders of this project.
+ * @return a fresh array including the build commands of project plus the OT/J builder.
+ */
public static ICommand[] createProjectBuildCommands(IProjectDescription project)
{
return new ICommand[] { createProjectBuildCommand(project) };
}
+ /**
+ * Create a build command for the OT/J builder.
+ * @param project the project to which the command shall be applied.
+ * @return a fresh build command
+ */
public static ICommand createProjectBuildCommand(IProjectDescription project)
{
ICommand otBuildCmd = project.newCommand();
@@ -146,17 +264,21 @@
return otBuildCmd;
}
+ /**
+ * Log an exception.
+ * @param message detail message
+ * @param exception the exception
+ */
public static void logException(String message, Throwable exception) {
- _singleton.getLog().log(createErrorStatus(message, exception));
+ _singleton.getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.OK, message, exception));
}
- public static Status createErrorStatus(String message, Throwable exception)
- {
- return new Status(IStatus.ERROR, PLUGIN_ID, IStatus.OK, message, exception);
- }
/**
* Take relativeFileName relative to a given classpath variable and make an absolute path from that.
+ * @param variableName a classpath variable
+ * @param relativeFilename a filename relative to the classpath variable
+ * @return the resolved combined path.
*/
public static IPath getResolvedVariablePath(String variableName, String relativeFilename)
{
diff --git a/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/ext/OTJavaNature.java b/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/ext/OTJavaNature.java
index 42d7520..aa8c6d4 100644
--- a/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/ext/OTJavaNature.java
+++ b/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/ext/OTJavaNature.java
@@ -30,6 +30,8 @@
/**
+ * Project nature for OT/J.
+ *
* @author jwloka
* @version $Id: OTJavaNature.java 23427 2010-02-03 22:23:59Z stephan $
*/
@@ -38,6 +40,12 @@
{
private IProject _prj;
+ /**
+ * {@inheritDoc}
+ * <p>
+ * Here: Add the OT/J builder to the project
+ * </p>
+ */
public void configure() throws CoreException
{
IProjectDescription projectDescription = _prj.getDescription();
@@ -65,7 +73,13 @@
projectDescription.setBuildSpec(newBuildCommands);
_prj.setDescription(projectDescription, null);
}
-
+
+ /**
+ * {@inheritDoc}
+ * <p>
+ * Here: Remove the OT/J builder from the project
+ * </p>
+ */
public void deconfigure() throws CoreException
{
IProjectDescription description = _prj.getDescription();
@@ -90,16 +104,23 @@
_prj.setDescription(description, null);
}
+ /** {@inheritDoc} */
public IProject getProject()
{
return _prj;
}
+ /** {@inheritDoc} */
public void setProject(IProject value)
{
_prj = value;
}
+ /**
+ * Check if a project has the OT/J nature.
+ * @param project
+ * @return true if the project has the OT/J nature.
+ */
public static boolean hasOTJavaNature(IProject project) {
try {
return project.hasNature(JavaCore.OTJ_NATURE_ID);
@@ -110,62 +131,42 @@
return false;
}
- private boolean contains(ICommand[] commands, String builderId)
- {
+ private boolean contains(ICommand[] commands, String builderId) {
for (int i = 0; i < commands.length; i++)
- {
- if (commands[i].getBuilderName().equals(builderId))
+ if (commands[i].getBuilderName().equals(builderId))
return true;
- }
-
return false;
}
- private ICommand[] replace(
- ICommand[] sourceCommands, String oldBuilderId, ICommand newCommand)
- {
+ private ICommand[] replace(ICommand[] sourceCommands, String oldBuilderId, ICommand newCommand) {
ICommand[] newCommands = new ICommand[sourceCommands.length];
for (int i = 0; i < sourceCommands.length; i++)
- {
- if (sourceCommands[i].getBuilderName().equals(oldBuilderId))
- {
- newCommands[i] = newCommand;
- }
- else
- {
- newCommands[i] = sourceCommands[i];
- }
- }
+ if (sourceCommands[i].getBuilderName().equals(oldBuilderId))
+ newCommands[i] = newCommand;
+ else
+ newCommands[i] = sourceCommands[i];
return newCommands;
}
- private ICommand[] insert(ICommand[] sourceCommands, ICommand command)
- {
+ private ICommand[] insert(ICommand[] sourceCommands, ICommand command) {
ICommand[] newCommands = new ICommand[sourceCommands.length + 1];
newCommands[0] = command;
for (int i = 0; i < sourceCommands.length; i++)
- {
- newCommands[i + 1] = sourceCommands[i];
- }
+ newCommands[i + 1] = sourceCommands[i];
return newCommands;
}
- private ICommand[] remove(ICommand[] sourceCommands, String builderId)
- {
+ private ICommand[] remove(ICommand[] sourceCommands, String builderId) {
ICommand[] newCommands = new ICommand[sourceCommands.length - 1];
int newCommandIndex = 0;
for (int i = 0; i < sourceCommands.length; i++)
- {
- if (!sourceCommands[i].getBuilderName().equals(builderId))
- {
- newCommands[newCommandIndex++] = sourceCommands[i];
- }
- }
+ if (!sourceCommands[i].getBuilderName().equals(builderId))
+ newCommands[newCommandIndex++] = sourceCommands[i];
return newCommands;
}
diff --git a/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/ext/OTREContainer.java b/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/ext/OTREContainer.java
index c880ded..2209862 100644
--- a/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/ext/OTREContainer.java
+++ b/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/ext/OTREContainer.java
@@ -34,6 +34,8 @@
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.objectteams.otdt.internal.core.ext.OTCoreExtMessages;
+import org.eclipse.objectteams.otdt.internal.core.ext.OTVariableInitializer;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
@@ -69,6 +71,10 @@
private IClasspathEntry[] _cpEntries;
+ /**
+ * Return a an array of classpath entry representing the OTRE.
+ * @return a singleton array.
+ */
public IClasspathEntry[] getClasspathEntries()
{
if (_cpEntries == null)
@@ -80,28 +86,43 @@
return _cpEntries;
}
+ /** Answer the text that describes the OTRE container in the UI. */
public String getDescription()
{
return OTCoreExtMessages.OTREContainer__Description;
}
+ /**
+ * Answer the kind of this classpath container, value = {@link IClasspathContainer#K_APPLICATION}.
+ */
public int getKind()
{
// don't mark as K_SYSTEM or K_SYSTEM_DEFAULT, which would prevent jdt.debug from adding this to the runtime classpath.
return IClasspathContainer.K_APPLICATION;
}
+ /**
+ * The name of this classpath container as a path, value = "OTRE".
+ */
public IPath getPath()
{
return OTRE_CONTAINER_PATH;
}
+ /**
+ * Answer the path of the "otre_min.jar" archive, which is placed on the bootclasspath when running OT/J programs.
+ * @return resolved path
+ */
public static IPath getOtreMinJarPath () {
if (OTRE_MIN_JAR_PATH == null)
OTRE_MIN_JAR_PATH = OTDTPlugin.getResolvedVariablePath(OTDTPlugin.OTDT_INSTALLDIR, "lib/"+OTRE_MIN_JAR_FILENAME); //$NON-NLS-1$
return OTRE_MIN_JAR_PATH;
}
+ /**
+ * Answer the path of the "otre_agent.jar" archive, which is passed as a -javaagent to the JVM.
+ * @return resolved path
+ */
public static IPath getOtreAgentJarPath() {
if (OTRE_AGENT_JAR_PATH == null)
OTRE_AGENT_JAR_PATH = OTDTPlugin.getResolvedVariablePath(OTDTPlugin.OTDT_INSTALLDIR, "lib/"+OTRE_AGENT_JAR_FILENAME); //$NON-NLS-1$
@@ -140,15 +161,11 @@
}
}
- private static boolean isOTREAlreadyInClasspath(IClasspathEntry[] classpath)
- {
- for (int idx = 0; classpath != null && idx < classpath.length; idx++)
- {
+ private static boolean isOTREAlreadyInClasspath(IClasspathEntry[] classpath) {
+ for (int idx = 0; classpath != null && idx < classpath.length; idx++) {
IClasspathEntry entry = classpath[idx];
if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER && entry.getPath().equals(OTRE_CONTAINER_PATH))
- {
- return true;
- }
+ return true;
}
return false;
@@ -167,35 +184,26 @@
newClasspath[classpath.length] = JavaCore.newContainerEntry(OTRE_CONTAINER_PATH, false);
if (newClasspath[classpath.length] != null)
- {
javaPrj.setRawClasspath( newClasspath, null );
- }
else
- {
- Status reason = new Status(
- IStatus.ERROR,
- OTDTPlugin.PLUGIN_ID,
- IStatus.OK,
- OTCoreExtMessages.OTREContainer_otre_not_found, null);
-
- throw new CoreException( reason );
- }
+ throw new CoreException( new Status(
+ IStatus.ERROR,
+ OTDTPlugin.PLUGIN_ID,
+ IStatus.OK,
+ OTCoreExtMessages.OTREContainer_otre_not_found,
+ null) );
}
/** Fetch the location of the bcel bundle into BCEL_PATH. */
static void findBCEL(BundleContext context) throws IOException {
- ServiceReference ref= context.getServiceReference(PackageAdmin.class.getName());
+ ServiceReference<PackageAdmin> ref= (ServiceReference<PackageAdmin>) context.getServiceReference(PackageAdmin.class);
if (ref == null)
throw new IllegalStateException("Cannot connect to PackageAdmin"); //$NON-NLS-1$
- PackageAdmin packageAdmin = (PackageAdmin)context.getService(ref);
+ PackageAdmin packageAdmin = context.getService(ref);
for (Bundle bundle : packageAdmin.getBundles(BCEL_BUNDLE_NAME, BCEL_VERSION_RANGE)) {
BCEL_PATH = new Path(FileLocator.toFileURL(bundle.getEntry("/")).getFile()); //$NON-NLS-1$
return;
}
throw new RuntimeException("bundle org.apache.bcel not found"); //$NON-NLS-1$
}
-
- public String getResolvedPathString() {
- return getClasspathEntries()[0].getPath().toOSString();
- }
}
diff --git a/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/hierarchy/InheritedMethodsRequestor.java b/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/hierarchy/InheritedMethodsRequestor.java
index 316c949..a6a0b92 100644
--- a/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/hierarchy/InheritedMethodsRequestor.java
+++ b/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/hierarchy/InheritedMethodsRequestor.java
@@ -30,6 +30,7 @@
import org.eclipse.objectteams.otdt.core.compiler.IOTConstants;
/**
+ * Strategy for the {@link OTTypeHierarchyTraverser}.
* @author svacina
*/
@@ -39,11 +40,17 @@
private boolean _overwriteCollectedMethods;
private boolean _checkVisibility;
- // TODO (jsv): can this class cope with IOTTypes as well? If not, it should use its correspondingJavaElement()
+ /**
+ * Create a requestor the will collect inherited methods.
+ * @param type the focus type of the traversal
+ * @param overwriteCollectedMethods if methods with the same signature should overwrite previously collected methods
+ * @param checkVisibility if method visibility should be checked.
+ */
public InheritedMethodsRequestor(IType type,
boolean overwriteCollectedMethods,
boolean checkVisibility)
{
+ // TODO (jsv): can this class cope with IOTTypes as well? If not, it should use its correspondingJavaElement()
_result = new HashMap<String, IMethod>();
_focusType = type;
_overwriteCollectedMethods = overwriteCollectedMethods;
@@ -51,42 +58,25 @@
}
@Override
- public void report(IType type, HierarchyContext context)
- {
- boolean checkVisibility;
+ void report(IType type, HierarchyContext context) {
- try
- {
- if (!_checkVisibility)
- {
+ boolean checkVisibility;
+ try {
+ if (!_checkVisibility) {
checkVisibility = false;
- }
- else if (type.isInterface())
- {
+ } else if (type.isInterface()) {
if (_focusType.isInterface())
- {
- checkVisibility = false;
- }
- else
- {
- return;
- }
- }
- else
- {
+ checkVisibility = false;
+ else
+ return;
+ } else {
if (context.isFocusType)
- {
- checkVisibility = false;
- }
- else
- {
- checkVisibility = context.isExplicitSuperclass || context.isBehindExplicitInheritance;
- }
+ checkVisibility = false;
+ else
+ checkVisibility = context.isExplicitSuperclass || context.isBehindExplicitInheritance;
}
writeMethodsToResult(type,checkVisibility);
- }
- catch (JavaModelException e)
- {
+ } catch (JavaModelException e) {
// TODO(jsv)handle exception
e.printStackTrace();
}
@@ -103,43 +93,24 @@
{
currMethod = methods[methodIdx];
if (currMethod.getElementName().startsWith(IOTConstants.OT_DOLLAR))
- {
- continue;
- }
+ continue;
if (currMethod.isConstructor())
- {
- continue;
- }
+ continue;
// TODO(jsv) check completeness
if (checkVisibility)
{
// private
if (Flags.isPrivate(currMethod.getFlags()))
- {
- continue;
- }
- // public , protected
- else if (Flags.isPublic(currMethod.getFlags()) ||
- Flags.isProtected(currMethod.getFlags()) )
- {
- storeMethod(currMethod);
- }
- // default
- else
- {
- if (type.getPackageFragment().equals(_focusType.getPackageFragment()))
- {
- storeMethod(currMethod);
- }
- else
- {
- continue;
- }
- }
- }
- else
- {
+ continue;
+ else if ( Flags.isPublic(currMethod.getFlags())
+ || Flags.isProtected(currMethod.getFlags()) )
+ storeMethod(currMethod);
+ else if (type.getPackageFragment().equals(_focusType.getPackageFragment()))
+ storeMethod(currMethod);
+ else
+ continue;
+ } else {
storeMethod(currMethod);
}
}
@@ -149,21 +120,19 @@
{
String key = TypeHelper.getMethodSignature(method);
- if (!_overwriteCollectedMethods)
- {
+ if (!_overwriteCollectedMethods) {
if (!_result.containsKey(key))
- {
_result.put(key, method);
- }
- }
- else
- {
+ } else {
_result.put(key, method);
}
}
- public IMethod[] getResult()
- {
+ /**
+ * Retrieve the result of the traverse operation.
+ * @return a non-null array of methods.
+ */
+ public IMethod[] getResult() {
return _result.values().toArray(new IMethod[_result.size()]);
}
}
diff --git a/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/hierarchy/OTTypeHierarchies.java b/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/hierarchy/OTTypeHierarchies.java
index ad55a49..66e6712 100644
--- a/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/hierarchy/OTTypeHierarchies.java
+++ b/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/hierarchy/OTTypeHierarchies.java
@@ -108,6 +108,9 @@
// === singleton infrastructure: ===
private static OTTypeHierarchies instance;
+ /**
+ * @noreference for use via extension point org.eclipse.objectteams.otequinox.aspectBindings only.
+ */
public OTTypeHierarchies() {
instance = this;
}
@@ -875,7 +878,7 @@
}
/**
- * Configure whether the given hierarchy should consider phantom roles or not.
+ * API: Configure whether the given hierarchy should consider phantom roles or not.
* Depending on the query used, phantom roles will either be filtered out or replaced with their real origins.
* In order for the phantom modes to be respected, the hierarchy must not be directly consulted but only
* via the fassade methods of this team.
diff --git a/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/hierarchy/OTTypeHierarchyTraverser.java b/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/hierarchy/OTTypeHierarchyTraverser.java
index 3d58b41..3fd863a 100644
--- a/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/hierarchy/OTTypeHierarchyTraverser.java
+++ b/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/hierarchy/OTTypeHierarchyTraverser.java
@@ -45,10 +45,7 @@
// TODO(jsv) use better class name
public class OTTypeHierarchyTraverser
{
- public static final int TRAVERSE_IMPLICIT_FIRST = 2;
- public static final int TRAVERSE_EXPLICIT_FIRST = 3;
-
private boolean _traverseImplicitFirst;
private boolean _includeFocusType;
private boolean _includeRootClass;
@@ -58,54 +55,55 @@
private IProgressMonitor _progressMonitor;
private TraverseRequestor _requestor;
- // TODO(jsv) change constructor
+ /**
+ * Create a new hierarchy traverser.
+ * @param hierarchy the underlying type hierarchy
+ * @param requestor a requestor for collecting elements
+ * @param traverseImplicitFirst whether to traverse along implicit inheritance first.
+ * @param includeFocusType whether to include the focus type
+ * @param includeRootClass whether to include the root classes <code>java.lang.Object</code> and <code>org.objectteams.Team</code>.
+ */
public OTTypeHierarchyTraverser(
ITypeHierarchy hierarchy,
TraverseRequestor requestor,
boolean traverseImplicitFirst,
boolean includeFocusType,
- boolean includeRootClass,
- IProgressMonitor progressMonitor)
+ boolean includeRootClass)
{
_hierarchy = hierarchy;
_requestor = requestor;
_traverseImplicitFirst = traverseImplicitFirst;
_includeFocusType = includeFocusType;
_includeRootClass = includeRootClass;
-
-
- if (progressMonitor != null)
- {
- _progressMonitor = progressMonitor;
- }
- else
- {
- _progressMonitor = new NullProgressMonitor();
- }
}
- private void initializeHierarchy() throws JavaModelException
- {
+ private void initializeHierarchy() throws JavaModelException {
if (_hierarchy == null)
_hierarchy = _focusType.newSupertypeHierarchy(_progressMonitor);
}
- public void traverse() throws JavaModelException
+ /**
+ * Traverse the hierarchy, results will be collected by the requestor.
+ * @param progressMonitor to report progress, if null a {@link NullProgressMonitor} will be used.
+ * @throws JavaModelException when any of the java elements could not be accessed.
+ */
+ public void traverse(IProgressMonitor progressMonitor) throws JavaModelException
{
+ if (progressMonitor != null)
+ _progressMonitor = progressMonitor;
+ else
+ _progressMonitor = new NullProgressMonitor();
+
assert _requestor != null : "Use only with valid requestor!"; //$NON-NLS-1$
_focusType = _requestor.getFocusType();
if (_focusType instanceof IOTType)
- {
- _focusType = (IType)((IOTType)_focusType).getCorrespondingJavaElement();
- }
+ _focusType = (IType)((IOTType)_focusType).getCorrespondingJavaElement();
initializeHierarchy();
if (_includeFocusType)
- {
report(_focusType, new HierarchyContext(true,false,false));
- }
IType explicitSuperclass = null;
IType[] implicitSuperclasses = null;
@@ -116,8 +114,7 @@
IType currentType = _focusType;
ObjectQueue queue = new ObjectQueue();
- do
- {
+ do {
explicitSuperclass = OTTypeHierarchies.getInstance().getExplicitSuperclass(_hierarchy, currentType);
implicitSuperclasses = OTTypeHierarchies.getInstance().getTSuperTypes(_hierarchy, currentType);
superInterface = _hierarchy.getSuperInterfaces(currentType);
@@ -172,8 +169,7 @@
currentTypeInfo.isBehindExplicitInheritance()));
}
}
- }
- while (currentTypeInfo != null);
+ } while (currentTypeInfo != null);
}
private void report(IType type, HierarchyContext context) throws JavaModelException
@@ -185,15 +181,11 @@
_requestor.report(type,context);
// report methods
for (int idx = 0; idx < type.getMethods().length; idx++)
- {
_requestor.report(type.getMethods()[idx], context);
- }
// report fields
for (int idx = 0; idx < type.getFields().length; idx++)
- {
_requestor.report(type.getFields()[idx],context);
- }
// report callin / callout if possible
if (otType != null && otType instanceof IRoleType )
@@ -201,34 +193,27 @@
IRoleType roleType = (IRoleType)otType;
// report callin
for (int idx = 0; idx < roleType.getMethodMappings(IRoleType.CALLINS).length; idx++)
- {
_requestor.report((ICallinMapping)roleType.getMethodMappings(IRoleType.CALLINS)[idx],context);
- }
//report callout
for (int idx = 0; idx < roleType.getMethodMappings(IRoleType.CALLOUTS).length; idx++)
{
IMethodMapping mapping = roleType.getMethodMappings(IRoleType.CALLOUTS)[idx];
if (mapping instanceof ICalloutToFieldMapping)
- {
_requestor.report((ICalloutToFieldMapping)mapping,context);
- }
else
- {
_requestor.report((ICalloutMapping)mapping,context);
- }
}
}
}
}
-class AdditionalTypeInfo
-{
+class AdditionalTypeInfo {
private IType _type;
private boolean _isExplicitSuperclass;
private boolean _isBehindExplicitInheritance;
- public AdditionalTypeInfo(IType type,
+ AdditionalTypeInfo(IType type,
boolean isExplicitSuperclass,
boolean isBehindExplicitInheritance)
{
@@ -237,16 +222,15 @@
this._isExplicitSuperclass = isExplicitSuperclass;
}
- public boolean isExplicitSuperclass(){
+ boolean isExplicitSuperclass() {
return _isExplicitSuperclass;
}
- public boolean isBehindExplicitInheritance(){
+ boolean isBehindExplicitInheritance() {
return _isBehindExplicitInheritance;
}
- public IType getType()
- {
+ IType getType() {
return _type;
}
@@ -259,31 +243,25 @@
}
}
-class ObjectQueue
-{
+class ObjectQueue {
private ArrayList<Object> _list;
- public ObjectQueue()
- {
+ ObjectQueue() {
_list = new ArrayList<Object>();
}
- public void put(Object o)
- {
+ void put(Object o) {
_list.add(o);
}
- public Object take()
- {
+ Object take() {
return _list.size() <= 0 ? null : _list.remove(0);
}
- public boolean isEmpty()
- {
+ boolean isEmpty() {
return _list.size() == 0;
}
- public int size()
- {
+ int size() {
return _list.size();
}
}
diff --git a/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/hierarchy/TraverseRequestor.java b/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/hierarchy/TraverseRequestor.java
index 85a91a9..4f812a3 100644
--- a/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/hierarchy/TraverseRequestor.java
+++ b/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/hierarchy/TraverseRequestor.java
@@ -30,15 +30,14 @@
/**
* @author svacina
*/
-abstract public class TraverseRequestor
+abstract class TraverseRequestor
{
-
static class HierarchyContext {
boolean isFocusType;
boolean isExplicitSuperclass;
boolean isBehindExplicitInheritance;
- public HierarchyContext(boolean isFocusType, boolean isExplicitSuperclass, boolean isBehindExplicitInheritance) {
+ HierarchyContext(boolean isFocusType, boolean isExplicitSuperclass, boolean isBehindExplicitInheritance) {
super();
this.isFocusType = isFocusType;
this.isExplicitSuperclass = isExplicitSuperclass;
@@ -49,19 +48,19 @@
protected IType _focusType = null;
- public void report(IType type, HierarchyContext context){}
+ void report(IType type, HierarchyContext context) { /* default: empty */ }
- public void report(IMethod method, HierarchyContext context){}
+ void report(IMethod method, HierarchyContext context) { /* default: empty */ }
- public void report(ICallinMapping callinMapping, HierarchyContext context){}
+ void report(ICallinMapping callinMapping, HierarchyContext context) { /* default: empty */ }
- public void report(ICalloutMapping calloutMapping, HierarchyContext context){}
+ void report(ICalloutMapping calloutMapping, HierarchyContext context) { /* default: empty */ }
- public void report(ICalloutToFieldMapping calloutToFieldMapping, HierarchyContext context){}
+ void report(ICalloutToFieldMapping calloutToFieldMapping, HierarchyContext context) { /* default: empty */ }
- public void report(IField field, HierarchyContext context){}
+ void report(IField field, HierarchyContext context) { /* default: empty */ }
- public IType getFocusType()
+ IType getFocusType()
{
return _focusType;
}
diff --git a/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/ext/OTCoreExtMessages.java b/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/internal/core/ext/OTCoreExtMessages.java
similarity index 92%
rename from plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/ext/OTCoreExtMessages.java
rename to plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/internal/core/ext/OTCoreExtMessages.java
index 8ee956f..84cce6f 100644
--- a/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/ext/OTCoreExtMessages.java
+++ b/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/internal/core/ext/OTCoreExtMessages.java
@@ -18,12 +18,12 @@
* Fraunhofer FIRST - Initial API and implementation
* Technical University Berlin - Initial API and implementation
**********************************************************************/
-package org.eclipse.objectteams.otdt.core.ext;
+package org.eclipse.objectteams.otdt.internal.core.ext;
import org.eclipse.osgi.util.NLS;
public class OTCoreExtMessages extends NLS {
- private static final String BUNDLE_NAME = "org.eclipse.objectteams.otdt.core.ext.OTCoreExtMessages"; //$NON-NLS-1$
+ private static final String BUNDLE_NAME = "org.eclipse.objectteams.otdt.internal.core.ext.OTCoreExtMessages"; //$NON-NLS-1$
public static String OTREContainer__Description;
diff --git a/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/ext/OTCoreExtMessages.properties b/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/internal/core/ext/OTCoreExtMessages.properties
similarity index 100%
rename from plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/ext/OTCoreExtMessages.properties
rename to plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/internal/core/ext/OTCoreExtMessages.properties
diff --git a/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/ext/OTREContainerInitializer.java b/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/internal/core/ext/OTREContainerInitializer.java
similarity index 94%
rename from plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/ext/OTREContainerInitializer.java
rename to plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/internal/core/ext/OTREContainerInitializer.java
index 6bd9c28..c837d75 100644
--- a/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/ext/OTREContainerInitializer.java
+++ b/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/internal/core/ext/OTREContainerInitializer.java
@@ -18,7 +18,7 @@
* Fraunhofer FIRST - Initial API and implementation
* Technical University Berlin - Initial API and implementation
**********************************************************************/
-package org.eclipse.objectteams.otdt.core.ext;
+package org.eclipse.objectteams.otdt.internal.core.ext;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
@@ -26,6 +26,7 @@
import org.eclipse.jdt.core.IClasspathContainer;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.objectteams.otdt.core.ext.OTREContainer;
/**
* This class creates the OTREContainer. Installed from plugin.xml as an extension.
diff --git a/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/ext/OTVariableInitializer.java b/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/internal/core/ext/OTVariableInitializer.java
similarity index 97%
rename from plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/ext/OTVariableInitializer.java
rename to plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/internal/core/ext/OTVariableInitializer.java
index 40c2d76..efcad19 100644
--- a/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/core/ext/OTVariableInitializer.java
+++ b/plugins/org.eclipse.objectteams.otdt/src/org/eclipse/objectteams/otdt/internal/core/ext/OTVariableInitializer.java
@@ -18,7 +18,7 @@
* Fraunhofer FIRST - Initial API and implementation
* Technical University Berlin - Initial API and implementation
**********************************************************************/
-package org.eclipse.objectteams.otdt.core.ext;
+package org.eclipse.objectteams.otdt.internal.core.ext;
import java.io.File;
import java.net.URL;
@@ -32,6 +32,7 @@
import org.eclipse.jdt.core.ClasspathVariableInitializer;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.objectteams.otdt.core.ext.OTDTPlugin;
import org.osgi.framework.Bundle;