summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbkolb2007-09-26 09:26:57 (EDT)
committerbkolb2007-09-26 09:26:57 (EDT)
commitad0186e726badf962dee7010de4dc6edb9f03871 (patch)
tree08325363bb6bb01d41c8a91c889cb7b66e09013d
parent72cd233f6fd40159fd9765d2478037618a8c6ead (diff)
downloadorg.eclipse.mwe-ad0186e726badf962dee7010de4dc6edb9f03871.zip
org.eclipse.mwe-ad0186e726badf962dee7010de4dc6edb9f03871.tar.gz
org.eclipse.mwe-ad0186e726badf962dee7010de4dc6edb9f03871.tar.bz2
cleanUP
-rw-r--r--plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/WorkflowRunner.java65
-rw-r--r--plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/ant/WorkflowAntTask.java4
-rw-r--r--plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/ao/AbstractWorkflowAdvice.java14
-rw-r--r--plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/config/AttributeNotFound.java2
-rw-r--r--plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/config/FeatureComponent.java35
-rw-r--r--plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/config/FeatureNotFound.java2
-rw-r--r--plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/config/GlobalConfigurationHolder.java2
-rw-r--r--plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/container/CompositeComponent.java119
-rw-r--r--plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/container/ConditionEvaluationException.java2
-rw-r--r--plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/container/ConditionalComponent.java6
-rw-r--r--plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/container/IfComponent.java3
-rw-r--r--plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/customizer/CustomizationException.java2
-rw-r--r--plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/customizer/WorkflowCustomization.java6
-rw-r--r--plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/debug/model/SyntaxElement.java8
-rw-r--r--plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/issues/IssuesImpl.java41
-rw-r--r--plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/issues/MWEDiagnostic.java24
-rw-r--r--plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/lib/AbstractWorkflowComponent.java11
-rw-r--r--plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/lib/WorkflowComponentWithModelSlot.java5
-rw-r--r--plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/monitor/NullProgressMonitor.java10
-rw-r--r--plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/resources/ResourceLoaderFactory.java7
-rw-r--r--plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/Workflow.java2
-rw-r--r--plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/WorkflowContextDefaultImpl.java10
-rw-r--r--plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/WorkfowComponentHelper.java18
-rw-r--r--plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/ast/AbstractASTBase.java2
-rw-r--r--plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/ast/DeclaredPropertyAST.java2
-rw-r--r--plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/ast/DeclaredPropertyFileAST.java10
-rw-r--r--plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/ast/SimpleParamAST.java2
-rw-r--r--plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/ast/parser/Location.java10
-rw-r--r--plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/ast/parser/ParseException.java2
-rw-r--r--plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/ast/parser/WorkflowParser.java15
-rw-r--r--plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/ast/parser/XmlLocationAnalyser.java95
-rw-r--r--plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/ast/util/InjectorFactory.java52
-rw-r--r--plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/ast/util/VisitorAnalyzer.java16
-rw-r--r--plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/ast/util/VisitorBase.java12
-rw-r--r--plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/ast/util/VisitorCreator.java14
-rw-r--r--plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/ast/util/VisitorInitializer.java71
-rw-r--r--plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/ast/util/WorkflowFactory.java15
-rw-r--r--plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/communication/Connection.java38
-rw-r--r--plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/communication/PacketReceiver.java43
-rw-r--r--plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/communication/PacketSender.java19
-rw-r--r--plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/communication/packets/AbstractPacket.java11
-rw-r--r--plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/communication/packets/BreakpointPacket.java6
-rw-r--r--plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/communication/packets/CommandPacket.java6
-rw-r--r--plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/communication/packets/ConfirmationPacket.java6
-rw-r--r--plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/communication/packets/EventPacket.java6
-rw-r--r--plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/communication/packets/EventPacketWithFrames.java9
-rw-r--r--plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/communication/packets/HandshakePacket.java4
-rw-r--r--plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/communication/packets/RegisterPacket.java10
-rw-r--r--plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/communication/packets/RequireVarPacket.java6
-rw-r--r--plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/communication/packets/VarDataPacket.java10
-rw-r--r--plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/model/NameValuePair.java2
-rw-r--r--plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/model/VarValue.java2
-rw-r--r--plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/model/VarValueTO.java6
-rw-r--r--plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/mwe/ReflectionUtil.java40
-rw-r--r--plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/mwe/WorkflowElementAdapter.java70
-rw-r--r--plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/processing/DebugMonitor.java108
-rw-r--r--plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/processing/DebuggerInterruptedException.java4
-rw-r--r--plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/processing/RuntimeHandlerManager.java9
-rw-r--r--plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/processing/handlers/BreakpointRuntimeHandler.java47
-rw-r--r--plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/processing/handlers/CommandRuntimeHandler.java28
-rw-r--r--plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/processing/handlers/EventRuntimeHandler.java22
-rw-r--r--plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/processing/handlers/VariablesRuntimeHandler.java66
-rw-r--r--plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/resources/ResourceLoaderDefaultImpl.java8
-rw-r--r--plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/resources/ResourceLoaderImpl.java2
-rw-r--r--plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/util/ComponentPrinter.java33
-rw-r--r--plugins/org.eclipse.emf.mwe.ui.simpleEditor/src/org/eclipse/emf/mwe/ui/internal/simpleEditor/ColorManager.java5
-rw-r--r--plugins/org.eclipse.emf.mwe.ui.simpleEditor/src/org/eclipse/emf/mwe/ui/internal/simpleEditor/NonRuleBasedDamagerRepairer.java13
-rw-r--r--plugins/org.eclipse.emf.mwe.ui.simpleEditor/src/org/eclipse/emf/mwe/ui/internal/simpleEditor/WorkflowEditor.java6
-rw-r--r--plugins/org.eclipse.emf.mwe.ui.simpleEditor/src/org/eclipse/emf/mwe/ui/internal/simpleEditor/XMLConfiguration.java7
-rw-r--r--plugins/org.eclipse.emf.mwe.ui.simpleEditor/src/org/eclipse/emf/mwe/ui/internal/simpleEditor/XMLDoubleClickStrategy.java35
-rw-r--r--plugins/org.eclipse.emf.mwe.ui.simpleEditor/src/org/eclipse/emf/mwe/ui/internal/simpleEditor/XMLWhitespaceDetector.java2
-rw-r--r--plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/breakpoint/actions/BreakpointActionGroup.java36
-rw-r--r--plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/breakpoint/actions/EnableDisableBreakpointAction.java13
-rw-r--r--plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/breakpoint/actions/ToggleBreakpointAction.java15
-rw-r--r--plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/launching/ui/MWELaunchConfigMainTab.java40
-rw-r--r--plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/launching/ui/MWELaunchConfigTabGroup.java2
-rw-r--r--plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/model/DebugElement.java4
-rw-r--r--plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/model/DebugStackFrame.java8
-rw-r--r--plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/model/DebugTarget.java51
-rw-r--r--plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/model/DebugThread.java26
-rw-r--r--plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/model/DebugValue.java23
-rw-r--r--plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/model/DebugVariable.java17
-rw-r--r--plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/model/MWEBreakpoint.java4
-rw-r--r--plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/model/ui/DebugModelPresentation.java25
-rw-r--r--plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/model/ui/JarEntryEditorInput.java7
-rw-r--r--plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/model/ui/VariableSorter.java7
-rw-r--r--plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/processing/DebugModelManager.java40
-rw-r--r--plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/processing/PluginExtensionManager.java48
-rw-r--r--plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/processing/handlers/BreakpointPluginHandler.java8
-rw-r--r--plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/processing/handlers/CommandPluginHandler.java4
-rw-r--r--plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/processing/handlers/EventPluginHandler.java13
-rw-r--r--plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/processing/handlers/VariablesPluginHandler.java8
-rw-r--r--plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/sourcelookup/MWESourceLookupParticipant.java2
-rw-r--r--plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/sourcelookup/MWESourcePathComputerDelegate.java2
-rw-r--r--plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/sourcelookup/PackageFragmentRootContainer.java11
-rw-r--r--plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/sourcelookup/SourceFolderSourceContainer.java12
-rw-r--r--plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/sourcelookup/SourceLookupUtil.java33
-rw-r--r--plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/eclipse/launch/MWEDebuggerLauncher.java44
-rw-r--r--plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/eclipse/launch/MWELaunchDelegate.java17
-rw-r--r--plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/eclipse/launch/MWELaunchShortcut.java21
-rw-r--r--plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/wizard/NewWorkflowFileWizard.java11
-rw-r--r--plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/workflow/Activator.java12
-rw-r--r--plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/workflow/debug/MWEPluginAdapter.java47
-rw-r--r--plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/workflow/util/PluginConfigurationElementUtil.java14
-rw-r--r--plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/workflow/util/ProjectIncludingResourceLoader.java13
-rw-r--r--plugins/org.eclipse.emf.mwe.utils/src/org/eclipse/emf/mwe/utils/AbstractEMFWorkflowComponent.java9
-rw-r--r--plugins/org.eclipse.emf.mwe.utils/src/org/eclipse/emf/mwe/utils/DirectoryCleaner.java18
-rw-r--r--plugins/org.eclipse.emf.mwe.utils/src/org/eclipse/emf/mwe/utils/Reader.java27
-rw-r--r--plugins/org.eclipse.emf.mwe.utils/src/org/eclipse/emf/mwe/utils/StandaloneSetup.java37
-rw-r--r--plugins/org.eclipse.emf.mwe.utils/src/org/eclipse/emf/mwe/utils/Writer.java33
110 files changed, 1207 insertions, 960 deletions
diff --git a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/WorkflowRunner.java b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/WorkflowRunner.java
index 7df196d..f6b9ee9 100644
--- a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/WorkflowRunner.java
+++ b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/WorkflowRunner.java
@@ -15,7 +15,6 @@ import java.lang.reflect.Method;
import java.net.URL;
import java.util.Enumeration;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.Map;
import java.util.jar.Manifest;
@@ -129,19 +128,22 @@ public class WorkflowRunner {
final Class<?> clazz = ResourceLoaderFactory
.createResourceLoader().loadClass(
monitorOptValues[0]);
- if (clazz == null)
+ if (clazz == null) {
throw new ClassNotFoundException("Didn't find class "
+ monitorOptValues[0]);
+ }
monitor = (ProgressMonitor) clazz.newInstance();
Method method = monitor.getClass().getMethod("init",
new Class[] { String[].class });
- if (method != null)
+ if (method != null) {
method.invoke(monitor,
new Object[] { monitorOptValues });
+ }
} catch (final Exception e) {
logger.error(e.getMessage(), e);
- if (line.hasOption(ANT))
+ if (line.hasOption(ANT)) {
System.exit(1);
+ }
return;
}
}
@@ -161,18 +163,20 @@ public class WorkflowRunner {
wfUrl = Thread.currentThread().getContextClassLoader().getResource(wfFile);
if (wfUrl == null) {
index = wfFile.indexOf('/');
- if (index >= 0)
+ if (index >= 0) {
wfFile = wfFile.substring(index + 1);
+ }
}
- } while (wfUrl == null && index >= 0);
+ } while ((wfUrl == null) && (index >= 0));
WorkflowRunner runner = new WorkflowRunner();
if (wfUrl == null) {
runner.logger.error("can't find the workflow file '"
+ line.getArgs()[0] + "' in the current class path");
- if (line.hasOption(ANT))
+ if (line.hasOption(ANT)) {
System.exit(1);
+ }
return;
}
@@ -193,13 +197,15 @@ public class WorkflowRunner {
*/
private static Map<String, String> resolveParams(final String[] args) {
final Map<String, String> params = new HashMap<String, String>();
- if (args == null)
+ if (args == null) {
return params;
- for (int i = 0; i < args.length; i++) {
- final String[] string = args[i].split("=");
- if (string.length != 2)
+ }
+ for (String element : args) {
+ final String[] string = element.split("=");
+ if (string.length != 2) {
throw new IllegalArgumentException(
- "wrong param syntax (-pkey=value). was : " + args[i]);
+ "wrong param syntax (-pkey=value). was : " + element);
+ }
params.put(string[0], string[1]);
}
return params;
@@ -231,21 +237,24 @@ public class WorkflowRunner {
final Map<String, ?> externalSlotContents) {
final boolean configOK = prepare(workFlowFile, theMonitor, theParams);
final Issues issues = new IssuesImpl();
- if (configOK)
+ if (configOK) {
return executeWorkflow(externalSlotContents, issues);
+ }
return false;
}
public boolean prepare(final String workFlowFile,
final ProgressMonitor theMonitor,
final Map<String, String> theParams) {
- if (workFlowFile == null)
+ if (workFlowFile == null) {
throw new NullPointerException("workflowFile is null");
+ }
- if (theMonitor == null)
+ if (theMonitor == null) {
monitor = new NullProgressMonitor();
- else
+ } else {
monitor = theMonitor;
+ }
params = theParams;
logger
@@ -284,8 +293,9 @@ public class WorkflowRunner {
.error("Workflow interrupted because of configuration errors.");
return false;
}
- if (workflow != null)
+ if (workflow != null) {
workflow.checkConfiguration(issues);
+ }
logIssues(logger, issues);
if (issues.hasErrors()) {
logger
@@ -313,14 +323,16 @@ public class WorkflowRunner {
monitor.finished(workflow, wfContext);
final long duration = System.currentTimeMillis() - time;
logger.info("workflow completed in " + duration + "ms!");
- if (issues.getErrors().length > 0)
+ if (issues.getErrors().length > 0) {
return false;
+ }
return true;
} catch (final Exception e) {
- if (e.getClass().getName().indexOf("Interrupt") > -1)
+ if (e.getClass().getName().indexOf("Interrupt") > -1) {
logger.error("Workflow interrupted. Reason: " + e.getMessage());
- else
+ } else {
logger.error(e.getMessage(), e);
+ }
} finally {
logIssues(logger, issues);
}
@@ -328,20 +340,19 @@ public class WorkflowRunner {
}
private void addExternalSlotContents(final Map<?, ?> slotContents) {
- if (slotContents == null)
+ if (slotContents == null) {
return;
- for (final Iterator<?> iter = slotContents.keySet().iterator(); iter
- .hasNext();) {
- final String key = (String) iter.next();
- wfContext.set(key, slotContents.get(key));
}
+ for (Object name : slotContents.keySet()) {
+final String key = (String) name;
+wfContext.set(key, slotContents.get(key));
+}
}
private void logIssues(final Log logger, final Issues issues) {
// log any configuration warning messages
Diagnostic[] issueArray = issues.getIssues();
- for (int i = 0; i < issueArray.length; i++) {
- final Diagnostic issue = issueArray[i];
+ for (final Diagnostic issue : issueArray) {
if (issue.getSeverity() == Diagnostic.ERROR) {
logger.error(issue.toString());
}
diff --git a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/ant/WorkflowAntTask.java b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/ant/WorkflowAntTask.java
index 2d09588..bcc4e4b 100644
--- a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/ant/WorkflowAntTask.java
+++ b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/ant/WorkflowAntTask.java
@@ -15,7 +15,6 @@
package org.eclipse.emf.mwe.core.ant;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import org.apache.tools.ant.BuildException;
@@ -46,8 +45,7 @@ public class WorkflowAntTask extends Java {
*/
@Override
public void execute() throws BuildException {
- for (final Iterator<Parameter> iter = params.iterator(); iter.hasNext();) {
- final Parameter param = iter.next();
+ for (Parameter param : params) {
if (param != null) {
final String paramString = "-p" + param.getName() + "=" + param.getValue();
super.createArg().setValue(paramString);
diff --git a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/ao/AbstractWorkflowAdvice.java b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/ao/AbstractWorkflowAdvice.java
index 4976d31..d0c30a9 100644
--- a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/ao/AbstractWorkflowAdvice.java
+++ b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/ao/AbstractWorkflowAdvice.java
@@ -22,14 +22,15 @@ public abstract class AbstractWorkflowAdvice extends AbstractWorkflowComponent {
private String target;
- public final void invokeInternal(WorkflowContext ctx,
- ProgressMonitor monitor, Issues issues) {
+ @Override
+ public final void invokeInternal(final WorkflowContext ctx,
+ final ProgressMonitor monitor, final Issues issues) {
}
- public void checkConfiguration(Issues issues) {
+ public void checkConfiguration(final Issues issues) {
}
- public void setAdviceTarget(String adviceTarget) {
+ public void setAdviceTarget(final String adviceTarget) {
this.target = adviceTarget;
}
@@ -39,12 +40,13 @@ public abstract class AbstractWorkflowAdvice extends AbstractWorkflowComponent {
public abstract void weave(WorkflowComponent c, Issues issues);
- protected String buildList(List<String> list) {
+ protected String buildList(final List<String> list) {
StringBuilder b = new StringBuilder();
boolean firstTime = true;
for (String s : list) {
- if (!firstTime)
+ if (!firstTime) {
b.append(", ");
+ }
b.append(s);
firstTime = false;
}
diff --git a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/config/AttributeNotFound.java b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/config/AttributeNotFound.java
index e679aed..7bc48eb 100644
--- a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/config/AttributeNotFound.java
+++ b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/config/AttributeNotFound.java
@@ -7,7 +7,7 @@ public class AttributeNotFound extends Exception {
super();
}
- public AttributeNotFound(String message) {
+ public AttributeNotFound(final String message) {
super(message);
}
diff --git a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/config/FeatureComponent.java b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/config/FeatureComponent.java
index bf1f813..1d0368c 100644
--- a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/config/FeatureComponent.java
+++ b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/config/FeatureComponent.java
@@ -24,31 +24,43 @@ public class FeatureComponent extends ConditionalComponent {
private String isSelected = null;
private String isNotSelected = null;
- public void setIsSelected( String name ) {
+ public void setIsSelected( final String name ) {
this.isSelected = name;
}
- public void setIsNotSelected( String name ) {
+ public void setIsNotSelected( final String name ) {
this.isNotSelected = name;
}
@Override
- public void checkConfiguration(Issues issues) throws ConfigurationException {
+ public void checkConfiguration(final Issues issues) throws ConfigurationException {
super.checkConfiguration(issues);
- if ( isSelected == null && isNotSelected == null ) {
+ if ( (isSelected == null) && (isNotSelected == null) ) {
issues.addError(this, "you have to specify eithre an exists or notExits.");
}
}
public boolean evaluate() {
ConfigurationModel configuration = GlobalConfigurationHolder.getConfiguration();
- if ( configuration == null ) throw new ConditionEvaluationException("no configuration model specified.");
- if ( isSelected != null && !configuration.featureExists(isSelected) ) throw new ConditionEvaluationException("the feature '"+isSelected+"' is not defined in the configuration model.");
- if ( isNotSelected != null && !configuration.featureExists(isNotSelected) ) throw new ConditionEvaluationException("the feature '"+isNotSelected+"' is not defined in the configuration model.");
+ if ( configuration == null ) {
+ throw new ConditionEvaluationException("no configuration model specified.");
+ }
+ if ( (isSelected != null) && !configuration.featureExists(isSelected) ) {
+ throw new ConditionEvaluationException("the feature '"+isSelected+"' is not defined in the configuration model.");
+ }
+ if ( (isNotSelected != null) && !configuration.featureExists(isNotSelected) ) {
+ throw new ConditionEvaluationException("the feature '"+isNotSelected+"' is not defined in the configuration model.");
+ }
try {
- if ( isSelected != null && isNotSelected == null ) return configuration.isFeatureSelected(isSelected);
- if ( isSelected == null && isNotSelected != null ) return !configuration.isFeatureSelected(isNotSelected);
- if ( isSelected != null && isNotSelected != null ) return configuration.isFeatureSelected(isSelected) && !configuration.isFeatureSelected(isNotSelected);
+ if ( (isSelected != null) && (isNotSelected == null) ) {
+ return configuration.isFeatureSelected(isSelected);
+ }
+ if ( (isSelected == null) && (isNotSelected != null) ) {
+ return !configuration.isFeatureSelected(isNotSelected);
+ }
+ if ( (isSelected != null) && (isNotSelected != null) ) {
+ return configuration.isFeatureSelected(isSelected) && !configuration.isFeatureSelected(isNotSelected);
+ }
} catch ( FeatureNotFound cannotHappen ) {
// this has been handled before in the checks above.
throw new ConditionEvaluationException("exception: "+cannotHappen.getMessage());
@@ -56,7 +68,8 @@ public class FeatureComponent extends ConditionalComponent {
return false;
}
- public String getLogMessage() {
+ @Override
+ public String getLogMessage() {
try {
return "feature ( exists "+isSelected+" ): "+evaluate();
} catch ( ConditionEvaluationException ex ) {
diff --git a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/config/FeatureNotFound.java b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/config/FeatureNotFound.java
index 1f72b53..7cef83e 100644
--- a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/config/FeatureNotFound.java
+++ b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/config/FeatureNotFound.java
@@ -7,7 +7,7 @@ public class FeatureNotFound extends Exception {
super();
}
- public FeatureNotFound(String message) {
+ public FeatureNotFound(final String message) {
super(message);
}
diff --git a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/config/GlobalConfigurationHolder.java b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/config/GlobalConfigurationHolder.java
index 85475e3..aff76d2 100644
--- a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/config/GlobalConfigurationHolder.java
+++ b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/config/GlobalConfigurationHolder.java
@@ -6,7 +6,7 @@ public class GlobalConfigurationHolder {
private static ConfigurationModel configModel = null;
- public static void setConfigurationModel( ConfigurationModel cm, Issues issues ) {
+ public static void setConfigurationModel( final ConfigurationModel cm, final Issues issues ) {
if ( configModel != null ) {
if ( !configModel.equals(cm)) {
issues.addError("configuration model already set!");
diff --git a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/container/CompositeComponent.java b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/container/CompositeComponent.java
index 72d0690..5c71a6f 100644
--- a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/container/CompositeComponent.java
+++ b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/container/CompositeComponent.java
@@ -16,7 +16,6 @@ package org.eclipse.emf.mwe.core.container;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Iterator;
import java.util.List;
import org.apache.commons.logging.Log;
@@ -40,7 +39,7 @@ import org.eclipse.emf.mwe.internal.core.util.ComponentPrinter;
public class CompositeComponent implements WorkflowComponentWithID {
protected static final Log log = LogFactory.getLog(CompositeComponent.class);
- private String name;
+ private final String name;
private String resource;
@@ -67,7 +66,7 @@ public class CompositeComponent implements WorkflowComponentWithID {
return id;
}
- public void setId(String id) {
+ public void setId(final String id) {
this.id = id;
}
@@ -85,71 +84,68 @@ public class CompositeComponent implements WorkflowComponentWithID {
private void internalInvoke(final WorkflowContext model,
final ProgressMonitor monitor, final Issues issues) {
- for (final Iterator<WorkflowComponent> iter = components.iterator(); iter
- .hasNext();) {
- final WorkflowComponent comp = iter.next();
- if ((!(comp instanceof AbstractWorkflowAdvice))) {
- comp.setContainer(this);
- if (monitor != null)
- monitor.preTask(comp, model);
- log.info(ComponentPrinter.getString(comp));
- comp.invoke(model, monitor, issues);
- if (monitor != null)
- monitor.postTask(comp, model);
- }
+ for (WorkflowComponent comp : components) {
+if ((!(comp instanceof AbstractWorkflowAdvice))) {
+ comp.setContainer(this);
+ if (monitor != null) {
+ monitor.preTask(comp, model);
+ }
+ log.info(ComponentPrinter.getString(comp));
+ comp.invoke(model, monitor, issues);
+ if (monitor != null) {
+ monitor.postTask(comp, model);
}
+}
+}
}
public void checkConfiguration(final Issues issues)
throws ConfigurationException {
- for (final Iterator<WorkflowComponent> iter = components.iterator(); iter
- .hasNext();) {
- final WorkflowComponent comp = iter.next();
- if (comp instanceof AbstractWorkflowAdvice) {
- AbstractWorkflowAdvice advice = (AbstractWorkflowAdvice) comp;
- String adviceTargetID = advice.getAdviceTarget();
- if (adviceTargetID == null) {
- issues.addError(advice, "No 'adviceTarget' given.");
- continue;
- }
- // log.info("Weaving Advice: " +
- // ComponentPrinter.getString(comp));
- Collection<WorkflowComponent> targetComponents = findComponentByID(adviceTargetID);
- if (targetComponents.size() == 0) {
- issues.addWarning(advice, "No component with ID '"
- + adviceTargetID + "' found.");
- }
- if (targetComponents.size() > 1) {
- issues.addWarning(advice,
- "More than on component with ID '" + adviceTargetID
- + "' found.");
- }
- if (needsToWeave(comp, issues)) {
- for (WorkflowComponent c : targetComponents) {
- ((AbstractWorkflowAdvice) comp).weave(c, issues);
- }
- }
- }
+ for (WorkflowComponent comp : components) {
+if (comp instanceof AbstractWorkflowAdvice) {
+ AbstractWorkflowAdvice advice = (AbstractWorkflowAdvice) comp;
+ String adviceTargetID = advice.getAdviceTarget();
+ if (adviceTargetID == null) {
+ issues.addError(advice, "No 'adviceTarget' given.");
+ continue;
}
- for (final Iterator<WorkflowComponent> iter = components.iterator(); iter
- .hasNext();) {
- final WorkflowComponent comp = iter.next();
- if ((!(comp instanceof AbstractWorkflowAdvice))) {
- log.debug("Checking configuration of: "
- + ComponentPrinter.getString(comp));
- comp.checkConfiguration(issues);
+ // log.info("Weaving Advice: " +
+ // ComponentPrinter.getString(comp));
+ Collection<WorkflowComponent> targetComponents = findComponentByID(adviceTargetID);
+ if (targetComponents.size() == 0) {
+ issues.addWarning(advice, "No component with ID '"
+ + adviceTargetID + "' found.");
+ }
+ if (targetComponents.size() > 1) {
+ issues.addWarning(advice,
+ "More than on component with ID '" + adviceTargetID
+ + "' found.");
+ }
+ if (needsToWeave(comp, issues)) {
+ for (WorkflowComponent c : targetComponents) {
+ ((AbstractWorkflowAdvice) comp).weave(c, issues);
}
}
+}
+}
+ for (WorkflowComponent comp : components) {
+if ((!(comp instanceof AbstractWorkflowAdvice))) {
+ log.debug("Checking configuration of: "
+ + ComponentPrinter.getString(comp));
+ comp.checkConfiguration(issues);
+}
+}
}
- private boolean needsToWeave(WorkflowComponent comp, Issues issues) {
+ private boolean needsToWeave(final WorkflowComponent comp, final Issues issues) {
try {
WorkflowComponent current = comp;
while (current != null) {
if (current instanceof WorkflowConditional) {
WorkflowConditional cond = (WorkflowConditional) current;
- if (!cond.evaluate())
+ if (!cond.evaluate()) {
return false;
+ }
}
current = current.getContainer();
}
@@ -161,22 +157,24 @@ public class CompositeComponent implements WorkflowComponentWithID {
}
private Collection<WorkflowComponent> findComponentByID(
- String adviceTargetID) {
+ final String adviceTargetID) {
List<WorkflowComponent> hits = new ArrayList<WorkflowComponent>();
WorkflowComponent c = this;
- while (c.getContainer() != null)
+ while (c.getContainer() != null) {
c = c.getContainer();
+ }
((CompositeComponent) c).resolveComponentByID(adviceTargetID, hits);
return hits;
}
- private void resolveComponentByID(String adviceTargetID,
- List<WorkflowComponent> hits) {
+ private void resolveComponentByID(final String adviceTargetID,
+ final List<WorkflowComponent> hits) {
for (WorkflowComponent component : components) {
if (component instanceof WorkflowComponentWithID) {
if (adviceTargetID.equals(((WorkflowComponentWithID) component)
- .getId()))
+ .getId())) {
hits.add(component);
+ }
}
}
for (WorkflowComponent component : components) {
@@ -215,7 +213,7 @@ public class CompositeComponent implements WorkflowComponentWithID {
}
// locations are set from VisitorCreator by reflection
- public void setOwnLocation(Location endLocation) {
+ public void setOwnLocation(final Location endLocation) {
this.ownLocation = endLocation;
}
@@ -263,12 +261,13 @@ public class CompositeComponent implements WorkflowComponentWithID {
return container;
}
- public void setContainer(CompositeComponent container) {
+ public void setContainer(final CompositeComponent container) {
this.container = container;
}
public void put(@SuppressWarnings("unused")
- String name, WorkflowComponent comp) {
+ final
+ String name, final WorkflowComponent comp) {
addComponent(comp);
}
diff --git a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/container/ConditionEvaluationException.java b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/container/ConditionEvaluationException.java
index 3dd244a..b25062a 100644
--- a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/container/ConditionEvaluationException.java
+++ b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/container/ConditionEvaluationException.java
@@ -7,7 +7,7 @@ public class ConditionEvaluationException extends RuntimeException {
super();
}
- public ConditionEvaluationException( String message ) {
+ public ConditionEvaluationException( final String message ) {
super( message );
}
diff --git a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/container/ConditionalComponent.java b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/container/ConditionalComponent.java
index 5d3dc87..5c1552d 100644
--- a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/container/ConditionalComponent.java
+++ b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/container/ConditionalComponent.java
@@ -10,7 +10,6 @@
*******************************************************************************/
package org.eclipse.emf.mwe.core.container;
-import java.util.Iterator;
import org.eclipse.emf.mwe.core.WorkflowComponent;
import org.eclipse.emf.mwe.core.WorkflowContext;
@@ -23,7 +22,7 @@ public abstract class ConditionalComponent extends CompositeComponent implements
private WorkflowComponent elseComp;
- public ConditionalComponent( String name ) {
+ public ConditionalComponent( final String name ) {
super(name);
}
@@ -42,8 +41,7 @@ public abstract class ConditionalComponent extends CompositeComponent implements
private void internalInvoke(final WorkflowContext model, final ProgressMonitor monitor, final Issues issues) {
try {
if (evaluate()) {
- for (final Iterator<WorkflowComponent> iter = components.iterator(); iter.hasNext();) {
- final WorkflowComponent comp = iter.next();
+ for (WorkflowComponent comp : components) {
try {
log.info(ComponentPrinter.getString(comp));
} catch (final WorkflowInterruptedException wfi) {
diff --git a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/container/IfComponent.java b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/container/IfComponent.java
index 06ec3a6..5da2e64 100644
--- a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/container/IfComponent.java
+++ b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/container/IfComponent.java
@@ -27,7 +27,8 @@ public class IfComponent extends ConditionalComponent {
return Boolean.valueOf(condition).booleanValue();
}
- public String getLogMessage() {
+ @Override
+ public String getLogMessage() {
return "if ( "+condition+" ): "+evaluate();
}
diff --git a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/customizer/CustomizationException.java b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/customizer/CustomizationException.java
index df726b0..6d18b54 100644
--- a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/customizer/CustomizationException.java
+++ b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/customizer/CustomizationException.java
@@ -7,7 +7,7 @@ public class CustomizationException extends RuntimeException {
super();
}
- public CustomizationException( String message ) {
+ public CustomizationException( final String message ) {
super(message);
}
diff --git a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/customizer/WorkflowCustomization.java b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/customizer/WorkflowCustomization.java
index b0a6848..83e15db 100644
--- a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/customizer/WorkflowCustomization.java
+++ b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/customizer/WorkflowCustomization.java
@@ -12,11 +12,11 @@ public class WorkflowCustomization {
private static final Log logger = LogFactory.getLog(WorkflowCustomization.class);
- public static void registerKeywordMapping( String keyword, Class<?> componentClass ) {
+ public static void registerKeywordMapping( final String keyword, final Class<?> componentClass ) {
keywordmapping .put( keyword, componentClass );
}
- public static void registerKeywordMapping( String keyword, String componentClassName ) {
+ public static void registerKeywordMapping( final String keyword, final String componentClassName ) {
try {
keywordmapping .put( keyword, Class.forName(componentClassName) );
} catch (ClassNotFoundException e) {
@@ -24,7 +24,7 @@ public class WorkflowCustomization {
}
}
- public static Class<?> getKeywordMapping( String keyword ) {
+ public static Class<?> getKeywordMapping( final String keyword ) {
return keywordmapping.get(keyword);
}
diff --git a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/debug/model/SyntaxElement.java b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/debug/model/SyntaxElement.java
index f271899..cc70403 100644
--- a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/debug/model/SyntaxElement.java
+++ b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/debug/model/SyntaxElement.java
@@ -40,7 +40,7 @@ public class SyntaxElement {
// -------------------------------------------------------------------------
- public void readContent(DataInputStream in) throws IOException {
+ public void readContent(final DataInputStream in) throws IOException {
resource = in.readUTF();
start = in.readInt();
end = in.readInt();
@@ -52,7 +52,7 @@ public class SyntaxElement {
visible = in.readBoolean();
}
- public void writeContent(DataOutputStream out) throws IOException {
+ public void writeContent(final DataOutputStream out) throws IOException {
out.writeUTF(resource);
out.writeInt(start);
out.writeInt(end);
@@ -64,8 +64,8 @@ public class SyntaxElement {
out.writeBoolean(visible);
}
- public boolean equalsBP(SyntaxElement se){
- return resource.equals(se.resource) && line == se.line && start == se.start;
+ public boolean equalsBP(final SyntaxElement se){
+ return resource.equals(se.resource) && (line == se.line) && (start == se.start);
}
}
diff --git a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/issues/IssuesImpl.java b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/issues/IssuesImpl.java
index 6cb598e..b932cf3 100644
--- a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/issues/IssuesImpl.java
+++ b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/issues/IssuesImpl.java
@@ -29,7 +29,7 @@ public class IssuesImpl implements Issues {
}
public void addError(final WorkflowComponent ctx, final String msg,
- final Object element, Throwable t, List<Object> additionalData) {
+ final Object element, final Throwable t, final List<Object> additionalData) {
add(createError(ctx, msg, element, t, additionalData));
}
@@ -62,7 +62,7 @@ public class IssuesImpl implements Issues {
}
public void addWarning(final WorkflowComponent ctx, final String msg,
- final Object element, Throwable t, List<Object> additionalData) {
+ final Object element, final Throwable t, final List<Object> additionalData) {
add(createWarning(ctx, msg, element, t, additionalData));
}
@@ -87,7 +87,7 @@ public class IssuesImpl implements Issues {
}
public void addInfo(final WorkflowComponent ctx, final String msg,
- final Object element, Throwable t, List<Object> additionalData) {
+ final Object element, final Throwable t, final List<Object> additionalData) {
add(createInfo(ctx, msg, element, t, additionalData));
}
@@ -107,18 +107,15 @@ public class IssuesImpl implements Issues {
public String toString() {
final StringBuffer buff = new StringBuffer();
Diagnostic[] issues = getInfos();
- for (int i = 0; i < issues.length; i++) {
- final Diagnostic issue = issues[i];
+ for (final Diagnostic issue : issues) {
buff.append("\n" + issue.toString());
}
issues = getWarnings();
- for (int i = 0; i < issues.length; i++) {
- final Diagnostic issue = issues[i];
+ for (final Diagnostic issue : issues) {
buff.append("\n" + issue.toString());
}
issues = getErrors();
- for (int i = 0; i < issues.length; i++) {
- final Diagnostic issue = issues[i];
+ for (final Diagnostic issue : issues) {
buff.append("\n" + issue.toString());
}
return buff.toString();
@@ -128,49 +125,49 @@ public class IssuesImpl implements Issues {
issues.clear();
}
- private static MWEDiagnostic createDiagnostic(int severity,
- WorkflowComponent ctx, String msg, Object element, Throwable t,
- List<Object> additionalData) {
+ private static MWEDiagnostic createDiagnostic(final int severity,
+ final WorkflowComponent ctx, final String msg, final Object element, final Throwable t,
+ final List<Object> additionalData) {
MWEDiagnostic diagnostic = new MWEDiagnostic(severity, msg, element, t,
additionalData, ctx);
return diagnostic;
}
- private static MWEDiagnostic createInfo(WorkflowComponent ctx, String msg,
- Object element, Throwable t, List<Object> additionalData) {
+ private static MWEDiagnostic createInfo(final WorkflowComponent ctx, final String msg,
+ final Object element, final Throwable t, final List<Object> additionalData) {
MWEDiagnostic diagnostic = createDiagnostic(Diagnostic.INFO, ctx, msg,
element, t, additionalData);
return diagnostic;
}
- private static MWEDiagnostic createInfo(String msg, Object element) {
+ private static MWEDiagnostic createInfo(final String msg, final Object element) {
return createWarning(null, msg, element, null, Collections.emptyList());
}
- private static MWEDiagnostic createWarning(WorkflowComponent ctx,
- String msg, Object element, Throwable t, List<Object> additionalData) {
+ private static MWEDiagnostic createWarning(final WorkflowComponent ctx,
+ final String msg, final Object element, final Throwable t, final List<Object> additionalData) {
MWEDiagnostic diagnostic = createDiagnostic(Diagnostic.WARNING, ctx,
msg, element, t, additionalData);
;
return diagnostic;
}
- private static MWEDiagnostic createWarning(String msg, Object element) {
+ private static MWEDiagnostic createWarning(final String msg, final Object element) {
return createWarning(null, msg, element, null, Collections.emptyList());
}
- private static MWEDiagnostic createError(WorkflowComponent ctx, String msg,
- Object element, Throwable t, List<Object> additionalData) {
+ private static MWEDiagnostic createError(final WorkflowComponent ctx, final String msg,
+ final Object element, final Throwable t, final List<Object> additionalData) {
MWEDiagnostic diagnostic = createDiagnostic(Diagnostic.ERROR, ctx, msg,
element, t, additionalData);
return diagnostic;
}
- private static MWEDiagnostic createError(String msg, Object element) {
+ private static MWEDiagnostic createError(final String msg, final Object element) {
return createWarning(null, msg, element, null, Collections.emptyList());
}
- private Diagnostic[] filterIssues(int severity) {
+ private Diagnostic[] filterIssues(final int severity) {
List<Diagnostic>result = new ArrayList<Diagnostic>();
for (Diagnostic diagnostic : issues) {
if ( diagnostic.getSeverity()==severity){
diff --git a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/issues/MWEDiagnostic.java b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/issues/MWEDiagnostic.java
index cf44a4c..2a414f4 100644
--- a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/issues/MWEDiagnostic.java
+++ b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/issues/MWEDiagnostic.java
@@ -66,8 +66,8 @@ public class MWEDiagnostic implements Diagnostic, DiagnosticChain {
private final Throwable throwable;
- public MWEDiagnostic(int severity, String msg, Object element, Throwable t,
- List<Object> additionalData, WorkflowComponent ctx) {
+ public MWEDiagnostic(final int severity, final String msg, final Object element, final Throwable t,
+ final List<Object> additionalData, final WorkflowComponent ctx) {
throwable = t;
message = msg;
setSeverity(severity);
@@ -87,7 +87,7 @@ public class MWEDiagnostic implements Diagnostic, DiagnosticChain {
}
}
- protected void setSeverity(int severity) {
+ protected void setSeverity(final int severity) {
this.severity = severity;
}
@@ -110,7 +110,7 @@ public class MWEDiagnostic implements Diagnostic, DiagnosticChain {
return Collections.unmodifiableList(children);
}
- protected void setSource(String source) {
+ protected void setSource(final String source) {
this.source = source;
}
@@ -118,7 +118,7 @@ public class MWEDiagnostic implements Diagnostic, DiagnosticChain {
return source;
}
- protected void setCode(int code) {
+ protected void setCode(final int code) {
this.code = code;
}
@@ -126,7 +126,7 @@ public class MWEDiagnostic implements Diagnostic, DiagnosticChain {
return code;
}
- public void add(Diagnostic diagnostic) {
+ public void add(final Diagnostic diagnostic) {
if (children == null) {
children = new BasicEList<Diagnostic>();
}
@@ -138,13 +138,13 @@ public class MWEDiagnostic implements Diagnostic, DiagnosticChain {
}
}
- public void addAll(Diagnostic diagnostic) {
+ public void addAll(final Diagnostic diagnostic) {
for (Diagnostic child : diagnostic.getChildren()) {
add(child);
}
}
- public void merge(Diagnostic diagnostic) {
+ public void merge(final Diagnostic diagnostic) {
if (diagnostic.getChildren().isEmpty()) {
add(diagnostic);
} else {
@@ -229,8 +229,9 @@ public class MWEDiagnostic implements Diagnostic, DiagnosticChain {
if (element instanceof EObject) {
EObject eo = (EObject) element;
String name = getEName(eo);
- if (name == null)
+ if (name == null) {
return eo.toString();
+ }
StringBuffer qfn = new StringBuffer();
qfn.append(name);
while (eo.eContainer() != null) {
@@ -245,10 +246,11 @@ public class MWEDiagnostic implements Diagnostic, DiagnosticChain {
return element.toString();
}
- private String getEName(EObject eo) {
+ private String getEName(final EObject eo) {
EStructuralFeature f = eo.eClass().getEStructuralFeature("name");
- if (f == null)
+ if (f == null) {
return null;
+ }
return (String) eo.eGet(f);
}
diff --git a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/lib/AbstractWorkflowComponent.java b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/lib/AbstractWorkflowComponent.java
index d5508a6..a44d58e 100644
--- a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/lib/AbstractWorkflowComponent.java
+++ b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/lib/AbstractWorkflowComponent.java
@@ -67,7 +67,7 @@ public abstract class AbstractWorkflowComponent implements WorkflowComponentWith
* @param container
* The containing component
*/
- public void setContainer(CompositeComponent container) {
+ public void setContainer(final CompositeComponent container) {
this.container = container;
}
@@ -106,7 +106,7 @@ public abstract class AbstractWorkflowComponent implements WorkflowComponentWith
* @param issues
* The Issues instance.
*/
- public void checkRequiredConfigProperty(String configPropertyName, Object configPropertyValue, Issues issues) {
+ public void checkRequiredConfigProperty(final String configPropertyName, final Object configPropertyValue, final Issues issues) {
boolean isError = false;
if (configPropertyValue == null) {
isError = true;
@@ -114,12 +114,13 @@ public abstract class AbstractWorkflowComponent implements WorkflowComponentWith
isError = true;
}
- if (isError)
+ if (isError) {
issues.addError("'" + configPropertyName + "' not specified.");
+ }
}
- private boolean isBlank(String string) {
- if (string == null || string.trim().equals("")) {
+ private boolean isBlank(final String string) {
+ if ((string == null) || string.trim().equals("")) {
return true;
}
return false;
diff --git a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/lib/WorkflowComponentWithModelSlot.java b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/lib/WorkflowComponentWithModelSlot.java
index e49ac0b..de9428c 100644
--- a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/lib/WorkflowComponentWithModelSlot.java
+++ b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/lib/WorkflowComponentWithModelSlot.java
@@ -25,8 +25,9 @@ public abstract class WorkflowComponentWithModelSlot extends AbstractWorkflowCom
}
public void checkConfiguration(final Issues issues) {
- if (modelSlot == null)
- issues.addError(this, "modelSlot not specified.");
+ if (modelSlot == null) {
+ issues.addError(this, "modelSlot not specified.");
+ }
}
}
diff --git a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/monitor/NullProgressMonitor.java b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/monitor/NullProgressMonitor.java
index 77906d2..785b03b 100644
--- a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/monitor/NullProgressMonitor.java
+++ b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/monitor/NullProgressMonitor.java
@@ -88,23 +88,23 @@ public class NullProgressMonitor implements ProgressMonitor {
public void worked(final int work) {
}
- public void started(Object element, Object context){
+ public void started(final Object element, final Object context){
}
- public void finished(Object element, Object context){
+ public void finished(final Object element, final Object context){
}
- public void postTask(Object element, Object context) {
+ public void postTask(final Object element, final Object context) {
}
- public void preTask(Object element, Object context) {
+ public void preTask(final Object element, final Object context) {
}
public void clearBlocked() {
}
- public void setBlocked(Diagnostic reason) {
+ public void setBlocked(final Diagnostic reason) {
}
}
diff --git a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/resources/ResourceLoaderFactory.java b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/resources/ResourceLoaderFactory.java
index 3c950ef..60b9386 100644
--- a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/resources/ResourceLoaderFactory.java
+++ b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/core/resources/ResourceLoaderFactory.java
@@ -42,7 +42,7 @@ public class ResourceLoaderFactory {
final String name = System.getProperty(PARAM_RESOURCELOADER_CLASS, ResourceLoaderDefaultImpl.class.getName());
// enable changing implementations at runtime.
// preliminary implemented for the unittest of this class
- if (resourceLoaderImpl == null || (name != null && !name.equals(resourceLoaderImpl.getName()))) {
+ if ((resourceLoaderImpl == null) || ((name != null) && !name.equals(resourceLoaderImpl.getName()))) {
try {
resourceLoaderImpl = Class.forName(name);
} catch (final ClassNotFoundException e) {
@@ -59,8 +59,9 @@ public class ResourceLoaderFactory {
* In any case that an instance could not be created.
*/
public static ResourceLoader createResourceLoader() throws RuntimeException {
- if (current.get() != null)
- return current.get();
+ if (current.get() != null) {
+ return current.get();
+ }
initResourceLoaderClass();
try {
return (ResourceLoader) resourceLoaderImpl.newInstance();
diff --git a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/Workflow.java b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/Workflow.java
index 0f52710..28a7099 100644
--- a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/Workflow.java
+++ b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/Workflow.java
@@ -20,7 +20,7 @@ public class Workflow extends CompositeComponent {
super("workflow");
}
- public void setAbstract( boolean b ) {
+ public void setAbstract( final boolean b ) {
isAbstract = b;
}
diff --git a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/WorkflowContextDefaultImpl.java b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/WorkflowContextDefaultImpl.java
index 84a5fe3..7ed077a 100644
--- a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/WorkflowContextDefaultImpl.java
+++ b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/WorkflowContextDefaultImpl.java
@@ -37,10 +37,12 @@ public class WorkflowContextDefaultImpl implements WorkflowContext {
* @see WorkflowContext#set(String, Object)
*/
public void set(final String slotName, final Object model) {
- if (slotName == null)
- throw new IllegalArgumentException("slotName must not be null!");
- if (!slotName.matches("[\\w_]+"))
- throw new IllegalArgumentException("slotName '" + slotName + "' contains invalid characters!");
+ if (slotName == null) {
+ throw new IllegalArgumentException("slotName must not be null!");
+ }
+ if (!slotName.matches("[\\w_]+")) {
+ throw new IllegalArgumentException("slotName '" + slotName + "' contains invalid characters!");
+ }
if (model == null) {
models.remove(slotName);
}
diff --git a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/WorkfowComponentHelper.java b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/WorkfowComponentHelper.java
index ac711c9..7622500 100644
--- a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/WorkfowComponentHelper.java
+++ b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/WorkfowComponentHelper.java
@@ -33,10 +33,12 @@ public class WorkfowComponentHelper {
*/
public static boolean isLegalFile(final String filename) {
final File f = new File(filename);
- if (!f.exists())
+ if (!f.exists()) {
return false;
- if (f.isDirectory())
+ }
+ if (f.isDirectory()) {
return false;
+ }
return true;
}
@@ -50,10 +52,12 @@ public class WorkfowComponentHelper {
*/
public static boolean isLegalDir(final String dirname) {
final File f = new File(dirname);
- if (!f.exists())
+ if (!f.exists()) {
return false;
- if (f.isFile())
+ }
+ if (f.isFile()) {
return false;
+ }
return true;
}
@@ -67,8 +71,9 @@ public class WorkfowComponentHelper {
* <tt>false</tt>.
*/
public static boolean isLegalURL(final String url) {
- if (url == null || url.trim().length() == 0)
+ if ((url == null) || (url.trim().length() == 0)) {
return false;
+ }
try {
final URL u = new URL(url);
@@ -120,8 +125,9 @@ public class WorkfowComponentHelper {
*/
public static boolean isResource(final String uri,
final String contextClassName) {
- if (!isLoadableClass(contextClassName))
+ if (!isLoadableClass(contextClassName)) {
return false;
+ }
try {
final Class<?> context = Class.forName(contextClassName);
final URL u = context.getResource(uri);
diff --git a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/ast/AbstractASTBase.java b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/ast/AbstractASTBase.java
index d68ebe3..3c91954 100644
--- a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/ast/AbstractASTBase.java
+++ b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/ast/AbstractASTBase.java
@@ -24,7 +24,7 @@ public abstract class AbstractASTBase {
return location;
}
- public void setLocation(Location location) {
+ public void setLocation(final Location location) {
this.location = location;
}
diff --git a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/ast/DeclaredPropertyAST.java b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/ast/DeclaredPropertyAST.java
index faad711..317fc72 100644
--- a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/ast/DeclaredPropertyAST.java
+++ b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/ast/DeclaredPropertyAST.java
@@ -15,7 +15,7 @@ import org.eclipse.emf.mwe.internal.core.ast.parser.WorkflowParser;
public class DeclaredPropertyAST extends AbstractASTBase {
- private String name;
+ private final String name;
private String value;
diff --git a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/ast/DeclaredPropertyFileAST.java b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/ast/DeclaredPropertyFileAST.java
index a8e2e86..85a1457 100644
--- a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/ast/DeclaredPropertyFileAST.java
+++ b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/ast/DeclaredPropertyFileAST.java
@@ -48,8 +48,9 @@ public class DeclaredPropertyFileAST extends AbstractASTBase {
public Properties getProperties(final ResourceLoader loader) {
if (properties == null) {
final InputStream in = loader.getResourceAsStream(getFile());
- if (in == null)
+ if (in == null) {
return null;
+ }
try {
properties = new Properties();
properties.load(in);
@@ -86,15 +87,16 @@ public class DeclaredPropertyFileAST extends AbstractASTBase {
inStream, "8859_1"));
while (true) {
final String line = in.readLine();
- if (line == null)
+ if (line == null) {
return;
+ }
if (line.length() > 0) {
final int sep = line.indexOf('=');
if (sep != -1) {
final String key = line.substring(0, sep).trim();
- if (key.length() > 0 && key.indexOf(' ') == -1
- && key.indexOf('#') == -1 && key.indexOf('!') == -1) {
+ if ((key.length() > 0) && (key.indexOf(' ') == -1)
+ && (key.indexOf('#') == -1) && (key.indexOf('!') == -1)) {
propertyNames.add(key);
}
}
diff --git a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/ast/SimpleParamAST.java b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/ast/SimpleParamAST.java
index 6666070..6a97432 100644
--- a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/ast/SimpleParamAST.java
+++ b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/ast/SimpleParamAST.java
@@ -14,7 +14,7 @@ import org.eclipse.emf.mwe.internal.core.ast.parser.Location;
public class SimpleParamAST extends AbstractASTBase implements NamedAST {
- private String name;
+ private final String name;
private String value;
diff --git a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/ast/parser/Location.java b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/ast/parser/Location.java
index 3c0e455..1de55e2 100644
--- a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/ast/parser/Location.java
+++ b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/ast/parser/Location.java
@@ -19,7 +19,7 @@ public class Location {
private int nameEnd;
- private String resource;
+ private final String resource;
public Location(final int line, final int column, final String resource) {
lineNumber = line;
@@ -35,7 +35,7 @@ public class Location {
return lineNumber;
}
- public void setLineNumber(int lineNumber) {
+ public void setLineNumber(final int lineNumber) {
this.lineNumber = lineNumber;
}
@@ -43,7 +43,7 @@ public class Location {
return columnNumber;
}
- public void setColumnNumber(int columnNumber) {
+ public void setColumnNumber(final int columnNumber) {
this.columnNumber = columnNumber;
}
@@ -51,7 +51,7 @@ public class Location {
return nameStart;
}
- public void setNameStart(int nameStart) {
+ public void setNameStart(final int nameStart) {
this.nameStart = nameStart;
}
@@ -59,7 +59,7 @@ public class Location {
return nameEnd;
}
- public void setNameEnd(int nameEnd) {
+ public void setNameEnd(final int nameEnd) {
this.nameEnd = nameEnd;
}
diff --git a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/ast/parser/ParseException.java b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/ast/parser/ParseException.java
index 02e12ef..e50ef0f 100644
--- a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/ast/parser/ParseException.java
+++ b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/ast/parser/ParseException.java
@@ -16,7 +16,7 @@ public class ParseException extends RuntimeException {
*
*/
private static final long serialVersionUID = 1943730836608506785L;
- private Location location;
+ private final Location location;
public ParseException(final String string, final Location location) {
super(string);
diff --git a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/ast/parser/WorkflowParser.java b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/ast/parser/WorkflowParser.java
index 41ca50b..a8094d6 100644
--- a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/ast/parser/WorkflowParser.java
+++ b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/ast/parser/WorkflowParser.java
@@ -13,7 +13,6 @@ package org.eclipse.emf.mwe.internal.core.ast.parser;
import java.io.InputStream;
import java.util.Arrays;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.Set;
import java.util.Stack;
@@ -86,7 +85,7 @@ public class WorkflowParser extends DefaultHandler implements ContentHandler {
}
@Override
- public void setDocumentLocator (Locator locator){
+ public void setDocumentLocator (final Locator locator){
this.locator = locator;
}
@@ -131,7 +130,7 @@ public class WorkflowParser extends DefaultHandler implements ContentHandler {
} else if (attributes.getValue(IDREF) != null) {
validateAttributes("reference " + name, attributes, new String[] { IDREF }, new String[0]);
return new ReferenceAST(getLocation(), name, attributes.getValue(IDREF));
- } else if (attributes.getValue(VALUE) != null && attributes.getValue(NAME) == null) {
+ } else if ((attributes.getValue(VALUE) != null) && (attributes.getValue(NAME) == null)) {
validateAttributes("simpleparam " + name, attributes, new String[] { VALUE }, new String[] {});
return new SimpleParamAST(getLocation(), name, attributes.getValue(VALUE));
} else {
@@ -167,18 +166,18 @@ public class WorkflowParser extends DefaultHandler implements ContentHandler {
final Set<String> mandatoryFound = new HashSet<String>();
for (int i = 0; i < attributes.getLength(); i++) {
final String name = attributes.getQName(i);
- if (name != null && !name.trim().equals("")) {
+ if ((name != null) && !name.trim().equals("")) {
if (!(mandatorySet.contains(name) || optionalSet.contains(name))) {
issues.addError("Unkown attribute " + name + " for element " + eleName, getLocation());
}
}
- if (mandatorySet.contains(name))
- mandatoryFound.add(name);
+ if (mandatorySet.contains(name)) {
+ mandatoryFound.add(name);
+ }
}
mandatorySet.removeAll(mandatoryFound);
if (!mandatorySet.isEmpty()) {
- for (final Iterator<String> iter = mandatorySet.iterator(); iter.hasNext();) {
- final String name = iter.next();
+ for (String name : mandatorySet) {
issues.addError("Attribute " + name + " is mandatory for element " + eleName, getLocation());
}
}
diff --git a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/ast/parser/XmlLocationAnalyser.java b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/ast/parser/XmlLocationAnalyser.java
index 47f3571..364219c 100644
--- a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/ast/parser/XmlLocationAnalyser.java
+++ b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/ast/parser/XmlLocationAnalyser.java
@@ -21,7 +21,7 @@ import org.eclipse.emf.mwe.core.resources.ResourceLoader;
import org.eclipse.emf.mwe.core.resources.ResourceLoaderFactory;
public class XmlLocationAnalyser {
- private Map<String, XmlFileEvaluator> repository = new HashMap<String, XmlFileEvaluator>();
+ private final Map<String, XmlFileEvaluator> repository = new HashMap<String, XmlFileEvaluator>();
protected ResourceLoader loader;
@@ -31,28 +31,29 @@ public class XmlLocationAnalyser {
*
* @param loc the (raw) location to be adapted
*/
- public Location adapt(Location loc) {
+ public Location adapt(final Location loc) {
String resource = loc.getResource();
XmlFileEvaluator evaluator = evaluateResource(resource);
return evaluator.adapt(loc);
}
- public Location adaptEnd(Location loc) {
+ public Location adaptEnd(final Location loc) {
String resource = loc.getResource();
XmlFileEvaluator evaluator = evaluateResource(resource);
return evaluator.adaptEnd(loc);
}
- public int findFirstLineOfTag(String resource, int lineNumber) {
+ public int findFirstLineOfTag(final String resource, final int lineNumber) {
if (!repository.containsKey(resource)) {
evaluateResource(resource);
}
return repository.get(resource).findFirstLineOfTag(lineNumber);
}
- private XmlFileEvaluator evaluateResource(String resource) {
- if (loader == null)
+ private XmlFileEvaluator evaluateResource(final String resource) {
+ if (loader == null) {
loader = ResourceLoaderFactory.createResourceLoader();
+ }
InputStream is = loader.getResourceAsStream(resource);
XmlFileEvaluator evaluator = new XmlFileEvaluator();
evaluator.evaluate(is);
@@ -73,7 +74,7 @@ public class XmlLocationAnalyser {
public class XmlFileEvaluator {
- private List<XmlTagValues> values = new ArrayList<XmlTagValues>();
+ private final List<XmlTagValues> values = new ArrayList<XmlTagValues>();
// for test only
private List<Object[]> result;
@@ -83,8 +84,9 @@ public class XmlLocationAnalyser {
protected boolean inTag, isClosingTag, inName, inInstruction, inComment = false;
public void evaluate(final InputStream is) {
- if (is == null)
+ if (is == null) {
return;
+ }
int c;
result = new ArrayList<Object[]>();
int offset = 0, column = 0, nameStart = 0, nameEnd = 0, line = 0, tagLine = 0, firstColumn = 0;
@@ -102,10 +104,12 @@ public class XmlLocationAnalyser {
break;
case '>':
if (inTag) {
- if (nameEnd == 0)
+ if (nameEnd == 0) {
nameEnd = offset - specChar.length();
- if (line != tagLine)
+ }
+ if (line != tagLine) {
firstColumn = 0;
+ }
XmlTagValues value = new XmlTagValues();
value.firstLineOfTag = tagLine + 1;
value.lastLineOfTag = line + 1;
@@ -129,21 +133,24 @@ public class XmlLocationAnalyser {
}
break;
case '/':
- if (inTag && !inInstruction && name.length() == 0)
+ if (inTag && !inInstruction && (name.length() == 0)) {
isClosingTag = true;
+ }
specChar.append((char) c);
break;
case '!':
- if (inTag && !inInstruction && name.length() == 0) {
+ if (inTag && !inInstruction && (name.length() == 0)) {
specChar.append((char) c);
- } else
+ } else {
consume(c);
+ }
break;
case '-':
- if (inTag && name.length() == 0 || inComment) {
+ if ((inTag && (name.length() == 0)) || inComment) {
specChar.append((char) c);
- } else
+ } else {
consume(c);
+ }
if (specChar.toString().endsWith("!--")) {
inTag = false;
inInstruction = false;
@@ -152,13 +159,14 @@ public class XmlLocationAnalyser {
}
break;
case '?':
- if (inTag && !inInstruction && name.length() == 0) {
+ if (inTag && !inInstruction && (name.length() == 0)) {
inTag = false;
inInstruction = true;
} else if (inInstruction) {
specChar.append((char) c);
- } else
+ } else {
consume(c);
+ }
break;
case ' ':
case '\t':
@@ -185,7 +193,7 @@ public class XmlLocationAnalyser {
consume(c);
break;
default:
- if (inTag && !inName && name.length() == 0) {
+ if (inTag && !inName && (name.length() == 0)) {
specChar = new StringBuffer();
inName = true;
nameStart = offset;
@@ -202,13 +210,15 @@ public class XmlLocationAnalyser {
}
}
- private void consume(int c) {
- if (inName)
+ private void consume(final int c) {
+ if (inName) {
name.append(specChar.toString() + (char) c);
- else if (name.length() > 0)
+ } else if (name.length() > 0) {
otherText.append(specChar.toString() + (char) c);
- if (specChar.length() > 0)
+ }
+ if (specChar.length() > 0) {
specChar = new StringBuffer();
+ }
}
private void reset() {
@@ -222,35 +232,38 @@ public class XmlLocationAnalyser {
inComment = false;
}
- protected int findFirstLineOfTag(int lineNumber) {
+ protected int findFirstLineOfTag(final int lineNumber) {
for (XmlTagValues value : values) {
- if (lineNumber >= value.firstLineOfTag && lineNumber <= value.lastLineOfTag)
+ if ((lineNumber >= value.firstLineOfTag) && (lineNumber <= value.lastLineOfTag)) {
return value.firstLineOfTag;
+ }
}
return -1;
}
- public Location adapt(Location rawLoc) {
+ public Location adapt(final Location rawLoc) {
XmlTagValues value = findLine(rawLoc);
- if (value == null) // should not occur
+ if (value == null) {
return null;
+ }
Location loc = new Location(value.firstLineOfTag, 0, rawLoc.getResource());
loc.setNameStart(value.nameStart);
loc.setNameEnd(value.nameEnd);
return loc;
}
- protected Location adaptEnd(Location rawLoc) {
+ protected Location adaptEnd(final Location rawLoc) {
int line = rawLoc.getLineNumber();
int col = rawLoc.getColumnNumber();
String name1 = null;
XmlTagValues potentialValue = null;
for (XmlTagValues value : values) {
- if (name1 == null && line == value.firstLineOfTag && col >= value.firstColumn && col <= value.endColumn)
+ if ((name1 == null) && (line == value.firstLineOfTag) && (col >= value.firstColumn) && (col <= value.endColumn)) {
name1 = value.name;
- if (name1 == null && line < value.firstLineOfTag)
+ }
+ if ((name1 == null) && (line < value.firstLineOfTag)) {
name1 = potentialValue.name;
- else if (value.name.equals(name1) && value.isClosingTag) {
+ } else if (value.name.equals(name1) && value.isClosingTag) {
Location loc = new Location(value.firstLineOfTag, 0, rawLoc.getResource());
loc.setNameStart(value.nameStart);
loc.setNameEnd(value.nameEnd);
@@ -262,9 +275,10 @@ public class XmlLocationAnalyser {
}
@SuppressWarnings("null")
- protected XmlTagValues findLine(Location loc) {
- if (values.isEmpty())
+ protected XmlTagValues findLine(final Location loc) {
+ if (values.isEmpty()) {
return null;
+ }
int line = loc.getRawLineNumber();
int col = loc.getColumnNumber();
List<XmlTagValues> potentialValues = new ArrayList<XmlTagValues>();
@@ -278,30 +292,35 @@ public class XmlLocationAnalyser {
}
continue;
}
- if (line >= value.firstLineOfTag && line < nextValue.firstLineOfTag || value.firstLineOfTag == nextValue.firstLineOfTag)
+ if (((line >= value.firstLineOfTag) && (line < nextValue.firstLineOfTag)) || (value.firstLineOfTag == nextValue.firstLineOfTag)) {
potentialValues.add(value);
+ }
value = nextValue; // TODO: CK: low: check when we can break
}
// last tag
- if (potentialValues.isEmpty() || line == value.firstLineOfTag)
+ if (potentialValues.isEmpty() || (line == value.firstLineOfTag)) {
potentialValues.add(value);
+ }
value = handleColumns(col, potentialValues);
return value;
}
- protected XmlTagValues handleColumns(int col, List<XmlTagValues> values) {
- if (values.size() == 1)
+ protected XmlTagValues handleColumns(final int col, final List<XmlTagValues> values) {
+ if (values.size() == 1) {
return values.get(0);
+ }
XmlTagValues value = null;
for (XmlTagValues nextValue : values) {
if (value == null) {
value = nextValue;
- if (col < value.firstColumn)
+ if (col < value.firstColumn) {
return value;
+ }
continue;
}
- if (col >= value.firstColumn && col < nextValue.firstColumn)
+ if ((col >= value.firstColumn) && (col < nextValue.firstColumn)) {
return value;
+ }
value = nextValue;
}
return value;
diff --git a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/ast/util/InjectorFactory.java b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/ast/util/InjectorFactory.java
index 0771559..c185ba8 100644
--- a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/ast/util/InjectorFactory.java
+++ b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/ast/util/InjectorFactory.java
@@ -30,13 +30,13 @@ public class InjectorFactory {
private final static Injector getInjector1(final Class<?> c, final String name) {
final String adderName = "add" + firstUpper(name);
final Method[] ms = c.getMethods();
- for (int i = 0; i < ms.length; i++) {
- final Method method = ms[i];
+ for (final Method method : ms) {
final int mod = method.getModifiers();
- if (Modifier.isPublic(mod) && !Modifier.isStatic(mod) && method.getParameterTypes().length == 1) {
+ if (Modifier.isPublic(mod) && !Modifier.isStatic(mod) && (method.getParameterTypes().length == 1)) {
final String mn = method.getName();
- if (mn.equals(adderName))
- return new InjectorSimple(method, name);
+ if (mn.equals(adderName)) {
+ return new InjectorSimple(method, name);
+ }
}
}
return null;
@@ -45,13 +45,13 @@ public class InjectorFactory {
private final static Injector getInjector2(final Class<?> c, final String name) {
final String getterName = "get" + firstUpper(name);
final Method[] ms = c.getMethods();
- for (int i = 0; i < ms.length; i++) {
- final Method method = ms[i];
+ for (final Method method : ms) {
final int mod = method.getModifiers();
- if (Modifier.isPublic(mod) && !Modifier.isStatic(mod) && method.getParameterTypes().length == 0) {
+ if (Modifier.isPublic(mod) && !Modifier.isStatic(mod) && (method.getParameterTypes().length == 0)) {
final String mn = method.getName();
- if (mn.equals(getterName) && List.class.isAssignableFrom(method.getReturnType()))
- return new InjectorList(method, name);
+ if (mn.equals(getterName) && List.class.isAssignableFrom(method.getReturnType())) {
+ return new InjectorList(method, name);
+ }
}
}
return null;
@@ -60,13 +60,13 @@ public class InjectorFactory {
private final static Injector getInjector3(final Class<?> c, final String name) {
final String setterName = "set" + firstUpper(name);
final Method[] ms = c.getMethods();
- for (int i = 0; i < ms.length; i++) {
- final Method method = ms[i];
+ for (final Method method : ms) {
final int mod = method.getModifiers();
- if (Modifier.isPublic(mod) && !Modifier.isStatic(mod) && method.getParameterTypes().length == 1) {
+ if (Modifier.isPublic(mod) && !Modifier.isStatic(mod) && (method.getParameterTypes().length == 1)) {
final String mn = method.getName();
- if (mn.equals(setterName) && !List.class.isAssignableFrom(method.getParameterTypes()[0]))
- return new InjectorSimple(method, name);
+ if (mn.equals(setterName) && !List.class.isAssignableFrom(method.getParameterTypes()[0])) {
+ return new InjectorSimple(method, name);
+ }
}
}
return null;
@@ -74,13 +74,13 @@ public class InjectorFactory {
private final static Injector getInjector4(final Class<?> c, final String name) {
final Method[] ms = c.getMethods();
- for (int i = 0; i < ms.length; i++) {
- final Method method = ms[i];
+ for (final Method method : ms) {
final int mod = method.getModifiers();
- if (Modifier.isPublic(mod) && !Modifier.isStatic(mod) && method.getParameterTypes().length == 2) {
+ if (Modifier.isPublic(mod) && !Modifier.isStatic(mod) && (method.getParameterTypes().length == 2)) {
final String mn = method.getName();
- if (mn.equals("put") && method.getParameterTypes()[0].isAssignableFrom(String.class))
- return new InjectorPut(method, name);
+ if (mn.equals("put") && method.getParameterTypes()[0].isAssignableFrom(String.class)) {
+ return new InjectorPut(method, name);
+ }
}
}
return null;
@@ -89,19 +89,19 @@ public class InjectorFactory {
private final static Injector getInjector5(final Class<?> c, final String name) {
final String setterName = "addComponent";
final Method[] ms = c.getMethods();
- for (int i = 0; i < ms.length; i++) {
- final Method method = ms[i];
+ for (final Method method : ms) {
final int mod = method.getModifiers();
- if (Modifier.isPublic(mod) && !Modifier.isStatic(mod) && method.getParameterTypes().length == 1) {
+ if (Modifier.isPublic(mod) && !Modifier.isStatic(mod) && (method.getParameterTypes().length == 1)) {
final String mn = method.getName();
- if (mn.equals(setterName) && !WorkflowComponent.class.isAssignableFrom(method.getParameterTypes()[0]))
- return new InjectorSimple(method, name);
+ if (mn.equals(setterName) && !WorkflowComponent.class.isAssignableFrom(method.getParameterTypes()[0])) {
+ return new InjectorSimple(method, name);
+ }
}
}
return null;
}
- public static String firstUpper(String str) {
+ public static String firstUpper(final String str) {
return str.substring(0, 1).toUpperCase().concat(str.substring(1));
}
diff --git a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/ast/util/VisitorAnalyzer.java b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/ast/util/VisitorAnalyzer.java
index ade31e5..bc30144 100644
--- a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/ast/util/VisitorAnalyzer.java
+++ b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/ast/util/VisitorAnalyzer.java
@@ -11,7 +11,6 @@
package org.eclipse.emf.mwe.internal.core.ast.util;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.Map;
import org.eclipse.emf.mwe.core.customizer.CustomizationException;
@@ -48,8 +47,9 @@ public class VisitorAnalyzer extends VisitorBase {
public VisitorAnalyzer(final Issues issues,
final Map<Class<?>, Converter> converter,
final Class<?> currentComponentClass) {
- if (currentComponentClass == null)
+ if (currentComponentClass == null) {
throw new NullPointerException("currentComponentClass");
+ }
this.issues = issues;
this.converter = converter;
this.currentComponentClass = currentComponentClass;
@@ -88,10 +88,9 @@ public class VisitorAnalyzer extends VisitorBase {
}
componentAST.setAnalyzedType(expected);
final VisitorAnalyzer v = cloneWithCurrentClass(expected);
- for (final Iterator<?> iter = componentAST.getChildren().iterator(); iter
- .hasNext();) {
- ((AbstractASTBase) iter.next()).accept(v);
- }
+ for (Object name : componentAST.getChildren()) {
+((AbstractASTBase) name).accept(v);
+}
}
return expected;
}
@@ -117,7 +116,7 @@ public class VisitorAnalyzer extends VisitorBase {
+ " not resolved!", ele);
} else {
final Class<?> c = (Class<?>) ele.getReference().getAnalyzedType();
- if (c != null && !expected.isAssignableFrom(c)) {
+ if ((c != null) && !expected.isAssignableFrom(c)) {
issues.addWarning("The type of the refered bean ("
+ c.getName() + ") is nat assignable to "
+ expected.getName());
@@ -157,8 +156,9 @@ public class VisitorAnalyzer extends VisitorBase {
if (currentComponentClass != null) {
final Injector inj = InjectorFactory.getInjector(
currentComponentClass, name);
- if (inj != null)
+ if (inj != null) {
return inj.getRequiredType();
+ }
}
return null;
}
diff --git a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/ast/util/VisitorBase.java b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/ast/util/VisitorBase.java
index 7df8905..a593f75 100644
--- a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/ast/util/VisitorBase.java
+++ b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/ast/util/VisitorBase.java
@@ -31,22 +31,22 @@ public abstract class VisitorBase {
public final Object visit(final AbstractASTBase ele) {
Object result = visitAbstractASTBase(ele);
- if (result == null && ele instanceof InclusionAST) {
+ if ((result == null) && (ele instanceof InclusionAST)) {
result = visitInclusionAST((InclusionAST) ele);
}
- if (result == null && ele instanceof ComponentAST) {
+ if ((result == null) && (ele instanceof ComponentAST)) {
result = visitComponentAST((ComponentAST) ele);
}
- if (result == null && ele instanceof DeclaredPropertyAST) {
+ if ((result == null) && (ele instanceof DeclaredPropertyAST)) {
result = visitDeclaredPropertyAST((DeclaredPropertyAST) ele);
}
- if (result == null && ele instanceof DeclaredPropertyFileAST) {
+ if ((result == null) && (ele instanceof DeclaredPropertyFileAST)) {
result = visitDeclaredPropertyFileAST((DeclaredPropertyFileAST) ele);
}
- if (result == null && ele instanceof ReferenceAST) {
+ if ((result == null) && (ele instanceof ReferenceAST)) {
result = visitReferenceAST((ReferenceAST) ele);
}
- if (result == null && ele instanceof SimpleParamAST) {
+ if ((result == null) && (ele instanceof SimpleParamAST)) {
result = visitSimpleParamAST((SimpleParamAST) ele);
}
return result;
diff --git a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/ast/util/VisitorCreator.java b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/ast/util/VisitorCreator.java
index d3457c3..17474d7 100644
--- a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/ast/util/VisitorCreator.java
+++ b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/ast/util/VisitorCreator.java
@@ -11,7 +11,6 @@
package org.eclipse.emf.mwe.internal.core.ast.util;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.Map;
import org.eclipse.emf.mwe.core.ConfigurationException;
@@ -64,11 +63,10 @@ public class VisitorCreator extends VisitorBase {
if (cart.isInheritAll()) {
beansToPass.putAll(this.beans);
}
- for (final Iterator<?> iter = cart.getChildren().iterator(); iter.hasNext();) {
- final Object o = iter.next();
- if (o instanceof InclusionAST)
- throw new ConfigurationException("Nested inclusions are not supported!");
- else if (o instanceof ComponentAST) {
+ for (Object o : cart.getChildren()) {
+ if (o instanceof InclusionAST) {
+ throw new ConfigurationException("Nested inclusions are not supported!");
+ } else if (o instanceof ComponentAST) {
final ComponentAST p = (ComponentAST) o;
final Object bean = createBean(p, null);
beansToPass.put(p.getName(), bean);
@@ -150,8 +148,8 @@ public class VisitorCreator extends VisitorBase {
}
}
final VisitorBase vis = cloneWithBean(bean);
- for (final Iterator<?> iter = comp.getChildren().iterator(); iter.hasNext();) {
- ((AbstractASTBase) iter.next()).accept(vis);
+ for (Object name : comp.getChildren()) {
+ ((AbstractASTBase) name).accept(vis);
}
} catch (final Exception e) {
log.error(e);
diff --git a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/ast/util/VisitorInitializer.java b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/ast/util/VisitorInitializer.java
index bda9f29..8d31f61 100644
--- a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/ast/util/VisitorInitializer.java
+++ b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/ast/util/VisitorInitializer.java
@@ -13,7 +13,6 @@ package org.eclipse.emf.mwe.internal.core.ast.util;
import java.io.InputStream;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
@@ -59,11 +58,10 @@ public class VisitorInitializer extends VisitorBase {
private Map<String, String> props = null;
private void traverseChildren(final ComponentAST c) {
- for (final Iterator<?> iter = c.getChildren().iterator(); iter
- .hasNext();) {
- final AbstractASTBase element = (AbstractASTBase) iter.next();
- element.accept(cloneThis());
- }
+ for (Object name : c.getChildren()) {
+final AbstractASTBase element = (AbstractASTBase) name;
+element.accept(cloneThis());
+}
}
@Override
@@ -94,20 +92,18 @@ public class VisitorInitializer extends VisitorBase {
params.putAll(this.props);
paramBeans.putAll(this.beans);
}
- for (final Iterator<?> iter = comp.getChildren().iterator(); iter
- .hasNext();) {
- final Object o = iter.next();
- if (o instanceof SimpleParamAST) {
- final SimpleParamAST p = (SimpleParamAST) o;
- params.put(p.getName(), p.getValue());
- } else if (o instanceof ComponentAST) {
- final ComponentAST p = (ComponentAST) o;
- paramBeans.put(p.getName(), p);
- } else if (o instanceof ReferenceAST) {
- final ReferenceAST ref = (ReferenceAST) o;
- paramBeans.put(ref.getName(), ref.getReference());
- }
- }
+ for (Object o : comp.getChildren()) {
+if (o instanceof SimpleParamAST) {
+ final SimpleParamAST p = (SimpleParamAST) o;
+ params.put(p.getName(), p.getValue());
+} else if (o instanceof ComponentAST) {
+ final ComponentAST p = (ComponentAST) o;
+ paramBeans.put(p.getName(), p);
+} else if (o instanceof ReferenceAST) {
+ final ReferenceAST ref = (ReferenceAST) o;
+ paramBeans.put(ref.getName(), ref.getReference());
+}
+}
comp.setPassedBeans(paramBeans);
comp.setPassedProperties(params);
if (comp.getFile() != null) {
@@ -143,7 +139,7 @@ public class VisitorInitializer extends VisitorBase {
return comp;
}
- private String translateFileURI(String file, String extension) {
+ private String translateFileURI(String file, final String extension) {
if (file.indexOf("::") != -1) {
file = file.replaceAll("::", "/");
}
@@ -196,19 +192,18 @@ public class VisitorInitializer extends VisitorBase {
issues.addError("Couldn't resolve properties file!", propFile);
return new HashMap<Object, Object>();
}
- for (final Iterator<String> iter = propFile.getPropertyNames(loader)
- .iterator(); iter.hasNext();) {
- final String name = replaceProperties(iter.next(), propFile);
- final String val = replaceProperties((String) properties.get(name),
- propFile);
- if (!props.containsKey(name)) {
- props.put(name, val);
- } else {
- if (!declaredPropertyNames.add(name)) {
- issues.addError("Duplicate property " + name, propFile);
- }
- }
+ for (String string : propFile.getPropertyNames(loader)) {
+final String name = replaceProperties(string, propFile);
+final String val = replaceProperties((String) properties.get(name),
+ propFile);
+if (!props.containsKey(name)) {
+ props.put(name, val);
+} else {
+ if (!declaredPropertyNames.add(name)) {
+ issues.addError("Duplicate property " + name, propFile);
}
+}
+}
return props;
}
@@ -216,16 +211,17 @@ public class VisitorInitializer extends VisitorBase {
.compile("\\$\\{([\\w_\\.-]+)\\}");
protected String replaceProperties(final String toResolve,
- AbstractASTBase ast) {
+ final AbstractASTBase ast) {
return replaceProperties(toResolve, true, ast);
}
private final Stack<String> currentProp = new Stack<String>();
protected String replaceProperties(final String toResolve,
- final boolean logIssues, AbstractASTBase ast) {
- if (toResolve == null)
+ final boolean logIssues, final AbstractASTBase ast) {
+ if (toResolve == null) {
return null;
+ }
// if (currentProp.contains(toResolve)) {
// issues.addError("property "+toResolve+" not found!");
// return null;
@@ -240,10 +236,11 @@ public class VisitorInitializer extends VisitorBase {
final String varName = m.group(1);
String propValue = props.get(varName);
if (propValue == null) {
- if (logIssues)
+ if (logIssues) {
issues.addError("property " + varName
+ " not specified. Dereferenced at "
+ ast.getLocation().toString());
+ }
return null;
}
diff --git a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/ast/util/WorkflowFactory.java b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/ast/util/WorkflowFactory.java
index 822a092..584ca5b 100644
--- a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/ast/util/WorkflowFactory.java
+++ b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/ast/util/WorkflowFactory.java
@@ -16,7 +16,6 @@ package org.eclipse.emf.mwe.internal.core.ast.util;
import java.io.InputStream;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.Map;
import java.util.Set;
@@ -47,8 +46,9 @@ public class WorkflowFactory {
@SuppressWarnings("unchecked")
public Workflow parseInitAndCreate(final String fileName, final Map<String, String> params, final Map<Class<?>, Converter> converter, final Issues issues) {
final InputStream in = loader.getResourceAsStream(fileName);
- if (in == null)
+ if (in == null) {
throw new IllegalArgumentException("Couldn't load file " + fileName);
+ }
return parseInitAndCreate(in, fileName, params, converter, issues);
}
@@ -62,22 +62,23 @@ public class WorkflowFactory {
.addError("This workflow file is abstract and cannot be run directly. It must be called from another workflow, passing in the required parameters.");
return null;
}
- if (issues.hasErrors())
+ if (issues.hasErrors()) {
return null;
+ }
final WorkflowContainer wc = new WorkflowContainer();
wfast.accept(new VisitorAnalyzer(issues, converters, wc.getClass()));
- if (issues.hasErrors())
+ if (issues.hasErrors()) {
return null;
+ }
wfast.accept(new VisitorCreator(issues, converters, wc));
Workflow wfRoot = (Workflow) wc.getRoot();
return wfRoot;
}
- private boolean isAbstract(AbstractASTBase wfast) {
+ private boolean isAbstract(final AbstractASTBase wfast) {
if (wfast instanceof ComponentAST) {
ComponentAST ca = (ComponentAST) wfast;
- for (Iterator<AbstractASTBase> iter = ca.getChildren().iterator(); iter.hasNext();) {
- AbstractASTBase child = iter.next();
+ for (AbstractASTBase child : ca.getChildren()) {
if (child instanceof SimpleParamAST) {
SimpleParamAST spa = (SimpleParamAST) child;
if (spa.getName().toLowerCase().equals("abstract") && spa.getValue().toLowerCase().equals("true")) {
diff --git a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/communication/Connection.java b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/communication/Connection.java
index f9d6e69..59b1208 100644
--- a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/communication/Connection.java
+++ b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/communication/Connection.java
@@ -44,17 +44,18 @@ public class Connection {
// -------------------------------------------------------------------------
// *the* main operation methods
- public AbstractPacket listenForPacket(Class<? extends AbstractPacket> type) throws InterruptedIOException {
+ public AbstractPacket listenForPacket(final Class<? extends AbstractPacket> type) throws InterruptedIOException {
return receiver.getPacket(type, -1);
}
- public AbstractPacket listenForPacket(Class<? extends AbstractPacket> type, int refId) throws InterruptedIOException {
+ public AbstractPacket listenForPacket(final Class<? extends AbstractPacket> type, final int refId) throws InterruptedIOException {
return receiver.getPacket(type, refId, -1);
}
- public int sendPacket(AbstractPacket packet) throws IOException {
- if (sender == null)
+ public int sendPacket(final AbstractPacket packet) throws IOException {
+ if (sender == null) {
return -1;
+ }
return sender.sendPacket(packet);
}
@@ -67,7 +68,7 @@ public class Connection {
* @param port the communication port
* @throws IOException
*/
- public void startListeningSocket(int port) throws IOException {
+ public void startListeningSocket(final int port) throws IOException {
ssocket = new ServerSocket(port);
}
@@ -78,13 +79,14 @@ public class Connection {
* @param timeout
* @throws IOException
*/
- public void accept(int timeout) throws IOException {
+ public void accept(final int timeout) throws IOException {
ssocket.setSoTimeout(timeout);
// will throw SocketTimeoutException, if nobody connects
socket = ssocket.accept();
establishReaderAndWriter();
- if (!writeHandshake())
+ if (!writeHandshake()) {
throw new IOException("handshake failed");
+ }
}
/**
@@ -94,7 +96,7 @@ public class Connection {
* @param port
* @throws IOException
*/
- public void connect(int port) throws IOException {
+ public void connect(final int port) throws IOException {
socket = new Socket("localhost", port);
establishReaderAndWriter();
replyHandshake();
@@ -104,7 +106,7 @@ public class Connection {
* @return if the socket connection is still active
*/
public boolean isConnected() {
- return socket != null && !socket.isClosed();
+ return (socket != null) && !socket.isClosed();
}
/**
@@ -112,8 +114,9 @@ public class Connection {
*/
public void close() {
try {
- if (sender != null)
+ if (sender != null) {
sender.close();
+ }
if (socket != null) {
out.close();
in.close();
@@ -142,7 +145,7 @@ public class Connection {
}
@SuppressWarnings("unchecked")
- private AbstractPacket instantiatePacket(String className) throws IOException {
+ private AbstractPacket instantiatePacket(final String className) throws IOException {
Class<? extends AbstractPacket> packetClass = null;
AbstractPacket packet = null;
String msg = null;
@@ -156,9 +159,11 @@ public class Connection {
Constructor c = packetClass.getConstructors()[0];
Class[] parmTypes = c.getParameterTypes();
Object[] initargs = new Object[parmTypes.length];
- for (int i = 0; i < parmTypes.length; i++)
- if (parmTypes[i] == int.class)
+ for (int i = 0; i < parmTypes.length; i++) {
+ if (parmTypes[i] == int.class) {
initargs[i] = 0;
+ }
+ }
try {
packet = (AbstractPacket) c.newInstance(initargs);
} catch (IllegalArgumentException e) {
@@ -179,7 +184,7 @@ public class Connection {
return packet;
}
- protected void writePacket(AbstractPacket packet) throws IOException {
+ protected void writePacket(final AbstractPacket packet) throws IOException {
out.writeUTF(packet.getClass().getName());
packet.writeContent(out);
// System.out.println(Thread.currentThread().getName() + "-SENT-----: " + packet);
@@ -204,10 +209,11 @@ public class Connection {
}
private void replyHandshake() throws IOException {
- if (listenForPacket(HandshakePacket.class).getClass().equals(HandshakePacket.class))
+ if (listenForPacket(HandshakePacket.class).getClass().equals(HandshakePacket.class)) {
sendPacket(new HandshakePacket());
- else
+ } else {
throw new IOException("handshake failed");
+ }
}
}
diff --git a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/communication/PacketReceiver.java b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/communication/PacketReceiver.java
index 7b4d786..8c31c92 100644
--- a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/communication/PacketReceiver.java
+++ b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/communication/PacketReceiver.java
@@ -23,11 +23,11 @@ import org.eclipse.emf.mwe.internal.core.debug.communication.packets.AbstractPac
* customers.
*/
public class PacketReceiver implements Runnable {
- private ArrayList<AbstractPacket> receivedPackets;
+ private final ArrayList<AbstractPacket> receivedPackets;
private static final Log logger = LogFactory.getLog(PacketReceiver.class);
- private Connection connection;
+ private final Connection connection;
private boolean interrupt = false;
@@ -39,7 +39,7 @@ public class PacketReceiver implements Runnable {
* @param connection the <code>Connection</code> that controls this data receiver.
* @return the instance
*/
- public static PacketReceiver newPacketReceiver(Connection connection) {
+ public static PacketReceiver newPacketReceiver(final Connection connection) {
PacketReceiver receiver = new PacketReceiver(connection);
Thread thread = new Thread(receiver, "PacketReceiver");
thread.setDaemon(true);
@@ -47,7 +47,7 @@ public class PacketReceiver implements Runnable {
return receiver;
}
- private PacketReceiver(Connection connection) {
+ private PacketReceiver(final Connection connection) {
this.connection = connection;
receivedPackets = new ArrayList<AbstractPacket>();
}
@@ -61,7 +61,7 @@ public class PacketReceiver implements Runnable {
* @return the received packet
* @throws InterruptedIOException
*/
- public AbstractPacket getPacket(Class<? extends AbstractPacket> type, long timeToWait) throws InterruptedIOException {
+ public AbstractPacket getPacket(final Class<? extends AbstractPacket> type, final long timeToWait) throws InterruptedIOException {
return getPacket(type, 0, timeToWait);
}
@@ -76,7 +76,7 @@ public class PacketReceiver implements Runnable {
* @throws InterruptedIOException
* @throws InterruptedIOException
*/
- public AbstractPacket getPacket(Class<? extends AbstractPacket> type, int refId, long timeToWait) throws InterruptedIOException {
+ public AbstractPacket getPacket(final Class<? extends AbstractPacket> type, final int refId, final long timeToWait) throws InterruptedIOException {
AbstractPacket packet = null;
//sync to be able to wait
@@ -85,8 +85,8 @@ public class PacketReceiver implements Runnable {
long timeBeforeWait;
// Wait until type is available.
- while ((packet = popReceivedPacket(type, refId)) == null && connection.isConnected() && !interrupt
- && (timeToWait < 0 || remainingTime > 0)) {
+ while (((packet = popReceivedPacket(type, refId)) == null) && connection.isConnected() && !interrupt
+ && ((timeToWait < 0) || (remainingTime > 0))) {
timeBeforeWait = System.currentTimeMillis();
try {
waitForPacketAvailable(remainingTime);
@@ -108,10 +108,10 @@ public class PacketReceiver implements Runnable {
}
}
- private void waitForPacketAvailable(long timeToWait) throws InterruptedException {
- if (timeToWait == 0)
+ private void waitForPacketAvailable(final long timeToWait) throws InterruptedException {
+ if (timeToWait == 0) {
return;
- else if (timeToWait < 0) {
+ } else if (timeToWait < 0) {
receivedPackets.wait();
} else {
receivedPackets.wait(timeToWait);
@@ -121,26 +121,31 @@ public class PacketReceiver implements Runnable {
/**
* Returns the first packet of the specified type and removes from the packet list.
*/
- private synchronized AbstractPacket popReceivedPacket(Class<? extends AbstractPacket> type, int refId) {
+ private synchronized AbstractPacket popReceivedPacket(final Class<? extends AbstractPacket> type, final int refId) {
for (AbstractPacket packet : receivedPackets) {
- if (!type.isInstance(packet) || (refId != 0 && packet.refId != refId))
+ if (!type.isInstance(packet) || ((refId != 0) && (packet.refId != refId))) {
continue;
+ }
receivedPackets.remove(packet);
return packet;
}
return null;
}
- private void checkForException(AbstractPacket packet) throws InterruptedIOException {
- if (packet != null)
+ private void checkForException(final AbstractPacket packet) throws InterruptedIOException {
+ if (packet != null) {
return;
- if (exception != null && !(exception instanceof IOException))
+ }
+ if ((exception != null) && !(exception instanceof IOException)) {
// print stack trace if it is not an IOException
logger.error(exception.getMessage(), exception);
- if (interrupt)
+ }
+ if (interrupt) {
throw new InterruptedIOException("packet receiver is going to close");
- if (exception != null)
+ }
+ if (exception != null) {
throw new InterruptedIOException(exception.getMessage());
+ }
throw new InterruptedIOException("timeout reading a packet");
}
@@ -164,7 +169,7 @@ public class PacketReceiver implements Runnable {
addPacketToList(connection.readPacket());
}
- private void addPacketToList(AbstractPacket packet) {
+ private void addPacketToList(final AbstractPacket packet) {
synchronized (receivedPackets) {
receivedPackets.add(packet);
receivedPackets.notifyAll();
diff --git a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/communication/PacketSender.java b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/communication/PacketSender.java
index 0300ca5..624b4d9 100644
--- a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/communication/PacketSender.java
+++ b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/communication/PacketSender.java
@@ -23,11 +23,11 @@ import org.eclipse.emf.mwe.internal.core.debug.communication.packets.AbstractPac
*/
public class PacketSender implements Runnable {
- private ArrayList<AbstractPacket> outgoingPackets;
+ private final ArrayList<AbstractPacket> outgoingPackets;
private static final Log logger = LogFactory.getLog(PacketSender.class);
- private Connection connection;
+ private final Connection connection;
private boolean interrupt = false;
@@ -37,7 +37,7 @@ public class PacketSender implements Runnable {
* @param connection the <code>Connection</code> that controls this data receiver.
* @return the instance
*/
- public static PacketSender newPacketSender(Connection connection) {
+ public static PacketSender newPacketSender(final Connection connection) {
PacketSender sender = new PacketSender(connection);
Thread thread = new Thread(sender, "PacketSender");
thread.setDaemon(true);
@@ -45,7 +45,7 @@ public class PacketSender implements Runnable {
return sender;
}
- private PacketSender(Connection connection) {
+ private PacketSender(final Connection connection) {
this.connection = connection;
outgoingPackets = new ArrayList<AbstractPacket>();
}
@@ -57,10 +57,11 @@ public class PacketSender implements Runnable {
* @return the packet id after it was sent
* @throws InterruptedIOException
*/
- public int sendPacket(AbstractPacket packet) throws InterruptedIOException {
- if (!connection.isConnected())
+ public int sendPacket(final AbstractPacket packet) throws InterruptedIOException {
+ if (!connection.isConnected()) {
throw new InterruptedIOException();
// log.debug("send: " + packet);
+ }
synchronized (outgoingPackets) {
outgoingPackets.add(packet);
@@ -85,14 +86,16 @@ public class PacketSender implements Runnable {
* @see java.lang.Runnable#run()
*/
public void run() {
- while (!interrupt && connection.isConnected())
+ while (!interrupt && connection.isConnected()) {
try {
sendAvailablePackets();
} catch (Exception e) {
- if (!(e instanceof IOException))
+ if (!(e instanceof IOException)) {
logger.error(e.getMessage(), e);
+ }
interrupt = true;
}
+ }
connection.close();
}
diff --git a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/communication/packets/AbstractPacket.java b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/communication/packets/AbstractPacket.java
index 74f7179..20f2626 100644
--- a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/communication/packets/AbstractPacket.java
+++ b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/communication/packets/AbstractPacket.java
@@ -55,20 +55,23 @@ public abstract class AbstractPacket {
@Override
public String toString() {
StringBuilder sb = new StringBuilder(getClass().getSimpleName() + " ");
- if (id != 0)
+ if (id != 0) {
sb.append(" id=" + id);
- if (refId != 0)
+ }
+ if (refId != 0) {
sb.append(" refId=" + refId);
+ }
return sb.toString();
}
// -------------------------------------------------------------------------
protected void setNextId() {
- if (nextId == Integer.MAX_VALUE)
+ if (nextId == Integer.MAX_VALUE) {
nextId = 1;
- else
+ } else {
id = ++nextId;
+ }
}
}
diff --git a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/communication/packets/BreakpointPacket.java b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/communication/packets/BreakpointPacket.java
index d99a372..bd9a1e4 100644
--- a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/communication/packets/BreakpointPacket.java
+++ b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/communication/packets/BreakpointPacket.java
@@ -27,7 +27,7 @@ public class BreakpointPacket extends AbstractPacket {
// -------------------------------------------------------------------------
- public BreakpointPacket(int type, SyntaxElement se) {
+ public BreakpointPacket(final int type, final SyntaxElement se) {
super();
this.type = type;
this.se = se;
@@ -36,7 +36,7 @@ public class BreakpointPacket extends AbstractPacket {
// -------------------------------------------------------------------------
@Override
- public void readContent(DataInputStream in) throws IOException {
+ public void readContent(final DataInputStream in) throws IOException {
type = in.readInt();
se = new SyntaxElement();
se.readContent(in);
@@ -44,7 +44,7 @@ public class BreakpointPacket extends AbstractPacket {
}
@Override
- public void writeContent(DataOutputStream out) throws IOException {
+ public void writeContent(final DataOutputStream out) throws IOException {
out.writeInt(type);
se.writeContent(out);
}
diff --git a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/communication/packets/CommandPacket.java b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/communication/packets/CommandPacket.java
index 7291dfd..366f86e 100644
--- a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/communication/packets/CommandPacket.java
+++ b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/communication/packets/CommandPacket.java
@@ -23,20 +23,20 @@ public class CommandPacket extends AbstractPacket {
// -------------------------------------------------------------------------
- public CommandPacket(int command) {
+ public CommandPacket(final int command) {
this.command = command;
}
// -------------------------------------------------------------------------
@Override
- public void readContent(DataInputStream in) throws IOException {
+ public void readContent(final DataInputStream in) throws IOException {
command = in.readInt();
}
@Override
- public void writeContent(DataOutputStream out) throws IOException {
+ public void writeContent(final DataOutputStream out) throws IOException {
out.writeInt(command);
}
diff --git a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/communication/packets/ConfirmationPacket.java b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/communication/packets/ConfirmationPacket.java
index e406d94..95d338e 100644
--- a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/communication/packets/ConfirmationPacket.java
+++ b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/communication/packets/ConfirmationPacket.java
@@ -21,19 +21,19 @@ public class ConfirmationPacket extends AbstractPacket {
// -------------------------------------------------------------------------
- public ConfirmationPacket(int packId) {
+ public ConfirmationPacket(final int packId) {
refId = packId;
}
// -------------------------------------------------------------------------
@Override
- public void readContent(DataInputStream in) throws IOException {
+ public void readContent(final DataInputStream in) throws IOException {
refId = in.readInt();
}
@Override
- public void writeContent(DataOutputStream out) throws IOException {
+ public void writeContent(final DataOutputStream out) throws IOException {
out.writeInt(refId);
}
diff --git a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/communication/packets/EventPacket.java b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/communication/packets/EventPacket.java
index cad1ffa..e8d9f28 100644
--- a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/communication/packets/EventPacket.java
+++ b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/communication/packets/EventPacket.java
@@ -23,7 +23,7 @@ public class EventPacket extends AbstractPacket {
// -------------------------------------------------------------------------
- public EventPacket(int event) {
+ public EventPacket(final int event) {
this.event = event;
setNextId();
}
@@ -31,14 +31,14 @@ public class EventPacket extends AbstractPacket {
// -------------------------------------------------------------------------
@Override
- public void readContent(DataInputStream in) throws IOException {
+ public void readContent(final DataInputStream in) throws IOException {
id = in.readInt();
event = in.readInt();
}
@Override
- public void writeContent(DataOutputStream out) throws IOException {
+ public void writeContent(final DataOutputStream out) throws IOException {
out.writeInt(id);
out.writeInt(event);
}
diff --git a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/communication/packets/EventPacketWithFrames.java b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/communication/packets/EventPacketWithFrames.java
index e2ab17d..043f06b 100644
--- a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/communication/packets/EventPacketWithFrames.java
+++ b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/communication/packets/EventPacketWithFrames.java
@@ -29,14 +29,14 @@ public class EventPacketWithFrames extends EventPacket {
// -------------------------------------------------------------------------
- public EventPacketWithFrames(int event) {
+ public EventPacketWithFrames(final int event) {
super(event);
}
// -------------------------------------------------------------------------
@Override
- public void readContent(DataInputStream in) throws IOException {
+ public void readContent(final DataInputStream in) throws IOException {
super.readContent(in);
cleanStackLevel = in.readInt();
int noOfFrames = in.readInt();
@@ -48,12 +48,13 @@ public class EventPacketWithFrames extends EventPacket {
}
@Override
- public void writeContent(DataOutputStream out) throws IOException {
+ public void writeContent(final DataOutputStream out) throws IOException {
super.writeContent(out);
out.writeInt(cleanStackLevel);
out.writeInt(frames.size());
- for (SyntaxElement frame : frames)
+ for (SyntaxElement frame : frames) {
frame.writeContent(out);
+ }
}
@Override
diff --git a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/communication/packets/HandshakePacket.java b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/communication/packets/HandshakePacket.java
index 09d5727..3fc3ae2 100644
--- a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/communication/packets/HandshakePacket.java
+++ b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/communication/packets/HandshakePacket.java
@@ -19,11 +19,11 @@ import java.io.DataOutputStream;
public class HandshakePacket extends AbstractPacket {
@Override
- public void readContent(DataInputStream in) {
+ public void readContent(final DataInputStream in) {
}
@Override
- public void writeContent(DataOutputStream out) {
+ public void writeContent(final DataOutputStream out) {
}
}
diff --git a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/communication/packets/RegisterPacket.java b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/communication/packets/RegisterPacket.java
index ed12507..3ab5bb9 100644
--- a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/communication/packets/RegisterPacket.java
+++ b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/communication/packets/RegisterPacket.java
@@ -32,19 +32,21 @@ public class RegisterPacket extends AbstractPacket {
// -------------------------------------------------------------------------
@Override
- public void readContent(DataInputStream in) throws IOException {
+ public void readContent(final DataInputStream in) throws IOException {
type = in.readInt();
int noOfHandlers = in.readInt();
- for (int i = 0; i < noOfHandlers; i++)
+ for (int i = 0; i < noOfHandlers; i++) {
classNames.add(in.readUTF());
+ }
}
@Override
- public void writeContent(DataOutputStream out) throws IOException {
+ public void writeContent(final DataOutputStream out) throws IOException {
out.writeInt(type);
out.writeInt(classNames.size());
- for (String name : classNames)
+ for (String name : classNames) {
out.writeUTF(name);
+ }
}
@Override
diff --git a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/communication/packets/RequireVarPacket.java b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/communication/packets/RequireVarPacket.java
index 3ac4f4b..2154123 100644
--- a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/communication/packets/RequireVarPacket.java
+++ b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/communication/packets/RequireVarPacket.java
@@ -25,7 +25,7 @@ public class RequireVarPacket extends AbstractPacket {
// -------------------------------------------------------------------------
- public RequireVarPacket(int frameId, int varId) {
+ public RequireVarPacket(final int frameId, final int varId) {
setNextId();
this.frameId = frameId;
this.varId = varId;
@@ -34,14 +34,14 @@ public class RequireVarPacket extends AbstractPacket {
// -------------------------------------------------------------------------
@Override
- public void readContent(DataInputStream in) throws IOException {
+ public void readContent(final DataInputStream in) throws IOException {
id = in.readInt();
frameId = in.readInt();
varId = in.readInt();
}
@Override
- public void writeContent(DataOutputStream out) throws IOException {
+ public void writeContent(final DataOutputStream out) throws IOException {
out.writeInt(id);
out.writeInt(frameId);
out.writeInt(varId);
diff --git a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/communication/packets/VarDataPacket.java b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/communication/packets/VarDataPacket.java
index 5de4a03..436a4f9 100644
--- a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/communication/packets/VarDataPacket.java
+++ b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/communication/packets/VarDataPacket.java
@@ -29,7 +29,7 @@ public class VarDataPacket extends AbstractPacket {
// -------------------------------------------------------------------------
@Override
- public void readContent(DataInputStream in) throws IOException {
+ public void readContent(final DataInputStream in) throws IOException {
refId = in.readInt();
int noOfValues = in.readInt();
for (int i = 0; i < noOfValues; i++) {
@@ -40,18 +40,20 @@ public class VarDataPacket extends AbstractPacket {
}
@Override
- public void writeContent(DataOutputStream out) throws IOException {
+ public void writeContent(final DataOutputStream out) throws IOException {
out.writeInt(refId);
out.writeInt(valueList.size());
- for (VarValueTO var : valueList)
+ for (VarValueTO var : valueList) {
var.writeContent(out);
+ }
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder(super.toString() + " [");
- for (VarValueTO var : valueList)
+ for (VarValueTO var : valueList) {
sb.append(var.name + " ");
+ }
sb.append("]");
return sb.toString();
}
diff --git a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/model/NameValuePair.java b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/model/NameValuePair.java
index ee46588..0b62c7d 100644
--- a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/model/NameValuePair.java
+++ b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/model/NameValuePair.java
@@ -18,7 +18,7 @@ public class NameValuePair {
public Object value;
- public NameValuePair(String name, Object value) {
+ public NameValuePair(final String name, final Object value) {
this.name = name;
this.value = value;
}
diff --git a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/model/VarValue.java b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/model/VarValue.java
index 48041b4..d3d96d9 100644
--- a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/model/VarValue.java
+++ b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/model/VarValue.java
@@ -29,7 +29,7 @@ public class VarValue {
// -------------------------------------------------------------------------
- public VarValue(Object element, int id) {
+ public VarValue(final Object element, final int id) {
this.element = element;
this.id = id;
}
diff --git a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/model/VarValueTO.java b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/model/VarValueTO.java
index 2e1e815..0ed7b50 100644
--- a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/model/VarValueTO.java
+++ b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/model/VarValueTO.java
@@ -34,13 +34,13 @@ public class VarValueTO {
public VarValueTO() {
}
- public VarValueTO(String name) {
+ public VarValueTO(final String name) {
this.name = name;
}
// -------------------------------------------------------------------------
- public void writeContent(DataOutputStream out) throws IOException {
+ public void writeContent(final DataOutputStream out) throws IOException {
out.writeUTF(name);
out.writeInt(valueId);
out.writeUTF(stringRep);
@@ -52,7 +52,7 @@ public class VarValueTO {
out.writeBoolean(hasMembers);
}
- public void readContent(DataInputStream in) throws IOException {
+ public void readContent(final DataInputStream in) throws IOException {
name = in.readUTF();
valueId = in.readInt();
stringRep = in.readUTF();
diff --git a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/mwe/ReflectionUtil.java b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/mwe/ReflectionUtil.java
index 1ad53fb..2305adf 100644
--- a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/mwe/ReflectionUtil.java
+++ b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/mwe/ReflectionUtil.java
@@ -40,7 +40,7 @@ public class ReflectionUtil {
* @param element the element
* @return the string representation
*/
- public static String getSimpleName(Object element) {
+ public static String getSimpleName(final Object element) {
return (element == null ? "null" : (element instanceof String) ? (String) element : getSimpleClassName(element));
}
@@ -49,7 +49,7 @@ public class ReflectionUtil {
* @param element the element
* @return the string representation
*/
- public static String getNameToString(Object element) {
+ public static String getNameToString(final Object element) {
return (element == null ? "null" : element.toString());
}
@@ -59,11 +59,13 @@ public class ReflectionUtil {
* @param element the element
* @return yes or no
*/
- public static boolean checkFields(Object element) {
- if (element == null || element instanceof String)
+ public static boolean checkFields(final Object element) {
+ if ((element == null) || (element instanceof String)) {
return false;
- if (Object[].class.isAssignableFrom(element.getClass()))
+ }
+ if (Object[].class.isAssignableFrom(element.getClass())) {
return ((Object[]) element).length > 0;
+ }
Map<String, Field> fields = getFieldMap(element.getClass());
return !fields.isEmpty();
}
@@ -75,13 +77,15 @@ public class ReflectionUtil {
* @param element
* @return
*/
- public static List<String> getFieldNames(Object element) {
+ public static List<String> getFieldNames(final Object element) {
List<String> result = new ArrayList<String>();
- if (element instanceof Object[])
- for (int i = 0; i < ((Object[]) element).length; i++)
+ if (element instanceof Object[]) {
+ for (int i = 0; i < ((Object[]) element).length; i++) {
result.add("[" + i + "]");
- else
+ }
+ } else {
result.addAll(getFieldMap(element.getClass()).keySet());
+ }
return result;
}
@@ -94,12 +98,13 @@ public class ReflectionUtil {
* @param name the name of the field
* @return the value
*/
- public static Object getFieldValue(Object object, String name) {
+ public static Object getFieldValue(final Object object, final String name) {
try {
Field field = getField(object, name);
Class<?> type = field.getType();
- if (type.isPrimitive() || (type == String.class))
+ if (type.isPrimitive() || (type == String.class)) {
return field.get(object).toString();
+ }
return field.get(object);
} catch (Exception e) {
// IllegalAccessException and NullPointerException
@@ -110,15 +115,16 @@ public class ReflectionUtil {
// -------------------------------------------------------------------------
// similar to getClass().getSimpleName(), but handles arrays differently
- private static String getSimpleClassName(Object element) {
+ private static String getSimpleClassName(final Object element) {
String fqn = element.getClass().getName();
int index = fqn.lastIndexOf('.');
- if (element instanceof Object[])
+ if (element instanceof Object[]) {
return fqn.substring(index + 1, fqn.length() - 1) + "[" + ((Object[]) element).length + "]";
+ }
return fqn.substring(index + 1);
}
- private static Field getField(Object object, String name) {
+ private static Field getField(final Object object, final String name) {
try {
return getFieldMap(object.getClass()).get(name);
} catch (Exception e) {
@@ -135,12 +141,12 @@ public class ReflectionUtil {
Class<?> clazz = cls;
while (!Object.class.equals(clazz)) {
Field[] fields = cls.getDeclaredFields();
- for (int i = 0; i < fields.length; i++) {
- Field field = fields[i];
+ for (Field field : fields) {
field.setAccessible(true);
// super class fields are not considered if the same name was already in an inheriting class
- if (!fieldMap.containsKey(field.getName()))
+ if (!fieldMap.containsKey(field.getName())) {
fieldMap.put(field.getName(), field);
+ }
}
clazz = clazz.getSuperclass();
}
diff --git a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/mwe/WorkflowElementAdapter.java b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/mwe/WorkflowElementAdapter.java
index c29198e..e873bf7 100644
--- a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/mwe/WorkflowElementAdapter.java
+++ b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/mwe/WorkflowElementAdapter.java
@@ -34,7 +34,7 @@ public class WorkflowElementAdapter implements ElementAdapter {
private CompositeComponent root;
- private XmlLocationAnalyser locationAnalyser;
+ private final XmlLocationAnalyser locationAnalyser;
// -------------------------------------------------------------------------
@@ -48,7 +48,7 @@ public class WorkflowElementAdapter implements ElementAdapter {
return context;
}
- public void setContext(Object context) {
+ public void setContext(final Object context) {
this.context = context;
}
@@ -58,10 +58,11 @@ public class WorkflowElementAdapter implements ElementAdapter {
// -------------------------------------------------------------------------
- public boolean canHandle(Object element) {
+ public boolean canHandle(final Object element) {
if (element instanceof WorkflowComponent) {
- if (root == null)
+ if (root == null) {
root = ((WorkflowComponent) element).getContainer();
+ }
return true;
}
if (element instanceof SyntaxElement) {
@@ -72,21 +73,21 @@ public class WorkflowElementAdapter implements ElementAdapter {
return false;
}
- public boolean shallHandle(Object element) {
+ public boolean shallHandle(final Object element) {
// no special treatment for workflow components
return true;
}
- public boolean shallSuspend(Object element, int flag) {
+ public boolean shallSuspend(final Object element, final int flag) {
// no special treatment for workflow components
return true;
}
- public boolean isSurroundingElement(Object element) {
+ public boolean isSurroundingElement(final Object element) {
return CompositeComponent.class.isAssignableFrom(element.getClass());
}
- public SyntaxElement createElementTO(Object element) {
+ public SyntaxElement createElementTO(final Object element) {
WorkflowComponent comp = (WorkflowComponent) element;
SyntaxElement se = new SyntaxElement();
Location loc = comp.getLocation();
@@ -101,13 +102,14 @@ public class WorkflowElementAdapter implements ElementAdapter {
return se;
}
- public SyntaxElement createEndElementTO(Object element) {
+ public SyntaxElement createEndElementTO(final Object element) {
CompositeComponent comp = (CompositeComponent) element;
SyntaxElement se = new SyntaxElement();
Location loc = comp.getOwnLocation();
- if (loc == null)
+ if (loc == null) {
// for root
loc = comp.getLocation();
+ }
loc = initializeEndLocation(loc);
se.containerName = ComponentPrinter.getElementName(comp);
se.elementName = "end of cartridge";
@@ -120,7 +122,7 @@ public class WorkflowElementAdapter implements ElementAdapter {
return se;
}
- public List<NameValuePair> getVariables(Object element) {
+ public List<NameValuePair> getVariables(final Object element) {
List<NameValuePair> list = new ArrayList<NameValuePair>();
if (element instanceof WorkflowComponent) {
@@ -137,61 +139,71 @@ public class WorkflowElementAdapter implements ElementAdapter {
for (String name : ReflectionUtil.getFieldNames(element)) {
Object childElement;
// ReflectionUtil returns a name format "[" + i + "]" for arrays, therefore we can't use name here
- if (element instanceof Object[])
+ if (element instanceof Object[]) {
childElement = ((Object[]) element)[i++];
- else
+ } else {
childElement = ReflectionUtil.getFieldValue(element, name);
+ }
list.add(new NameValuePair(name, childElement));
}
}
return list;
}
- public String getVariableDetailRep(Object element) {
+ public String getVariableDetailRep(final Object element) {
return ReflectionUtil.getNameToString(element);
}
- public String getVariableSimpleRep(Object element) {
+ public String getVariableSimpleRep(final Object element) {
return ReflectionUtil.getSimpleName(element);
}
- public boolean checkVariableHasMembers(Object element) {
+ public boolean checkVariableHasMembers(final Object element) {
return ReflectionUtil.checkFields(element);
}
- public Object findElement(SyntaxElement se, Object actual, int flag) {
- if (root == null)
+ public Object findElement(final SyntaxElement se, final Object actual, final int flag) {
+ if (root == null) {
return null;
+ }
return findComponent(root, se.resource, se.line);
}
- private Object findComponent(CompositeComponent parent, String resource, int lineNo) {
+ private Object findComponent(final CompositeComponent parent, final String resource, final int lineNo) {
Location loc = parent.getOwnLocation();
- if (loc == null)
+ if (loc == null) {
loc = parent.getLocation();
- if (resource.endsWith(loc.getResource()))
- for (WorkflowComponent comp : parent.getComponents())
- if (comp.getLocation().getLineNumber() == lineNo)
+ }
+ if (resource.endsWith(loc.getResource())) {
+ for (WorkflowComponent comp : parent.getComponents()) {
+ if (comp.getLocation().getLineNumber() == lineNo) {
return comp;
- for (WorkflowComponent comp : parent.getComponents())
+ }
+ }
+ }
+ for (WorkflowComponent comp : parent.getComponents()) {
if (comp instanceof CompositeComponent) {
CompositeComponent child = (CompositeComponent) comp;
Object found = findComponent(child, resource, lineNo);
- if (found != null)
+ if (found != null) {
return found;
+ }
}
+ }
return null;
}
- private Location initialize(Location loc) {
- if (loc.getResource() == null)
+ private Location initialize(final Location loc) {
+ if (loc.getResource() == null) {
return null;
+ }
return locationAnalyser.adapt(loc);
}
- private Location initializeEndLocation(Location loc) {
- if (loc.getResource() == null)
+ private Location initializeEndLocation(final Location loc) {
+ if (loc.getResource() == null) {
return null;
+ }
return locationAnalyser.adaptEnd(loc);
}
diff --git a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/processing/DebugMonitor.java b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/processing/DebugMonitor.java
index 22d3081..6fd547a 100644
--- a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/processing/DebugMonitor.java
+++ b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/processing/DebugMonitor.java
@@ -47,15 +47,15 @@ public class DebugMonitor implements ProgressMonitor {
private static final int TERMINATED = 6;
- private Connection connection = new Connection();
+ private final Connection connection = new Connection();
private CommandListener commandListener;
- private Set<ProcessHandler> processHandlers = new HashSet<ProcessHandler>();
+ private final Set<ProcessHandler> processHandlers = new HashSet<ProcessHandler>();
- private Set<EventHandler> eventHandlers = new HashSet<EventHandler>();
+ private final Set<EventHandler> eventHandlers = new HashSet<EventHandler>();
- private Set<ElementAdapter> elementAdapters = new HashSet<ElementAdapter>();
+ private final Set<ElementAdapter> elementAdapters = new HashSet<ElementAdapter>();
private boolean missingAdapterReported;
@@ -70,7 +70,7 @@ public class DebugMonitor implements ProgressMonitor {
* @param args arg[1] must be the port to be connected with
* @throws IOException
*/
- public void init(String[] args) throws IOException {
+ public void init(final String[] args) throws IOException {
// args[0] is the class name
int port = new Integer(args[1]);
try {
@@ -84,36 +84,39 @@ public class DebugMonitor implements ProgressMonitor {
handler.startListener();
} catch (Exception e) {
connection.close();
- if (e instanceof RuntimeException)
+ if (e instanceof RuntimeException) {
throw (RuntimeException) e;
+ }
throw (IOException) e;
}
}
// -------------------------------------------------------------------------
- public void setCommandListener(CommandListener commandListener) {
+ public void setCommandListener(final CommandListener commandListener) {
this.commandListener = commandListener;
}
- public void addProcessHandler(ProcessHandler handler) {
+ public void addProcessHandler(final ProcessHandler handler) {
processHandlers.add(handler);
}
- public void addEventHandler(EventHandler handler) {
+ public void addEventHandler(final EventHandler handler) {
eventHandlers.add(handler);
}
// -------------------------------------------------------------------------
- public void addAdapter(ElementAdapter adapter) {
+ public void addAdapter(final ElementAdapter adapter) {
elementAdapters.add(adapter);
}
- public ElementAdapter getAdapter(Object element) {
- for (ElementAdapter adapter : elementAdapters)
- if (adapter.canHandle(element))
+ public ElementAdapter getAdapter(final Object element) {
+ for (ElementAdapter adapter : elementAdapters) {
+ if (adapter.canHandle(element)) {
return adapter;
+ }
+ }
if (!missingAdapterReported) {
System.out.println("Warning: Element can't be debugged.\nDidn't find an adapter for element of type "
+ element.getClass().getSimpleName());
@@ -129,7 +132,7 @@ public class DebugMonitor implements ProgressMonitor {
*
* @see org.eclipse.emf.mwe.core.monitor.ProgressMonitor#started(java.lang.Object, java.lang.Object)
*/
- public void started(Object element, Object context) {
+ public void started(final Object element, final Object context) {
fireEvent(STARTED);
}
@@ -139,15 +142,17 @@ public class DebugMonitor implements ProgressMonitor {
*
* @see org.eclipse.emf.mwe.core.monitor.ProgressMonitor#preTask(java.lang.Object, java.lang.Object)
*/
- public void preTask(Object element, Object context) {
+ public void preTask(final Object element, final Object context) {
this.context = context;
ElementAdapter adapter = getAdapter(element);
- if (adapter == null)
+ if (adapter == null) {
return;
+ }
adapter.setContext(context);
- if (!ask(SHALL_HANDLE, element, PUSH))
+ if (!ask(SHALL_HANDLE, element, PUSH)) {
return;
+ }
fireEvent(PRE_TASK, element, NORMAL_FRAME);
checkInterrupt();
@@ -170,18 +175,20 @@ public class DebugMonitor implements ProgressMonitor {
*
* @see org.eclipse.emf.mwe.core.monitor.ProgressMonitor#postTask(java.lang.Object, java.lang.Object)
*/
- public void postTask(Object element, Object context) {
+ public void postTask(final Object element, final Object context) {
this.context = context;
ElementAdapter adapter = getAdapter(element);
- if (adapter == null)
+ if (adapter == null) {
return;
+ }
adapter.setContext(context);
- if (!ask(SHALL_HANDLE, element, POP))
+ if (!ask(SHALL_HANDLE, element, POP)) {
return;
+ }
try {
- if (adapter.isSurroundingElement(element))
+ if (adapter.isSurroundingElement(element)) {
if (ask(SUSPEND, element, END_FRAME)) {
// if we are at the end of a "subroutine" and going to stop at the next lower level task
// anyway
@@ -193,6 +200,7 @@ public class DebugMonitor implements ProgressMonitor {
fireEvent(RESUMED);
fireEvent(POST_TASK);
}
+ }
fireEvent(POST_TASK);
} catch (IOException e) {
throw new DebuggerInterruptedException(e);
@@ -204,7 +212,7 @@ public class DebugMonitor implements ProgressMonitor {
*
* @see org.eclipse.emf.mwe.core.monitor.ProgressMonitor#finished(java.lang.Object, java.lang.Object)
*/
- public void finished(Object element, Object context) {
+ public void finished(final Object element, final Object context) {
getAdapter(element).setContext(context);
fireEvent(PRE_TASK, element, END_FRAME);
fireEvent(SUSPENDED);
@@ -215,67 +223,73 @@ public class DebugMonitor implements ProgressMonitor {
// -------------------------------------------------------------------------
private void checkInterrupt() {
- if (ask(INTERRUPT, null, 0))
+ if (ask(INTERRUPT, null, 0)) {
// we throw an exception since the preTask() method is called
// iteratively and we want to come back to the most outer loop
throw new DebuggerInterruptedException("User interrupt");
+ }
}
// -------------------------------------------------------------------------
- private void fireEvent(int event) {
+ private void fireEvent(final int event) {
fireEvent(event, null, 0);
}
- private void fireEvent(int event, Object element, int state) {
+ private void fireEvent(final int event, final Object element, final int state) {
for (EventHandler handler : eventHandlers) {
try {
- if (event == PRE_TASK)
+ if (event == PRE_TASK) {
handler.preTask(element, context, state);
- else if (event == POST_TASK)
+ } else if (event == POST_TASK) {
handler.postTask(context);
- else if (event == STARTED)
+ } else if (event == STARTED) {
handler.started();
- else if (event == SUSPENDED)
+ } else if (event == SUSPENDED) {
handler.suspended();
- else if (event == RESUMED)
+ } else if (event == RESUMED) {
handler.resumed();
- else if (event == TERMINATED)
+ } else if (event == TERMINATED) {
handler.terminated();
+ }
} catch (IOException e) {
throw new DebuggerInterruptedException(e);
}
}
}
- private boolean ask(int event, Object element, int state) {
+ private boolean ask(final int event, final Object element, final int state) {
boolean result = false;
ProcessHandler lastHandler = null;
- for (ProcessHandler handler : processHandlers)
- if (handler.isLastCall())
+ for (ProcessHandler handler : processHandlers) {
+ if (handler.isLastCall()) {
lastHandler = handler;
- else
+ } else {
result = ask(event, element, state, result, handler);
- if(lastHandler != null)
+ }
+ }
+ if(lastHandler != null) {
result = ask(event, element, state, result, lastHandler);
+ }
return result;
}
- private boolean ask(int event, Object element, int state, boolean lastState, ProcessHandler handler) {
+ private boolean ask(final int event, final Object element, final int state, final boolean lastState, final ProcessHandler handler) {
boolean result = lastState;
- if (event == SHALL_HANDLE)
+ if (event == SHALL_HANDLE) {
result = handler.shallHandle(result, element, state);
- else if (event == SUSPEND)
+ } else if (event == SUSPEND) {
result = handler.shallSuspend(result, element, state);
- else if (event == INTERRUPT)
+ } else if (event == INTERRUPT) {
result = handler.shallInterrupt(result);
+ }
return result;
}
// ************************** unused Progress Monitor implementation methods
- public void beginTask(String name, int totalWork) {
+ public void beginTask(final String name, final int totalWork) {
//
}
@@ -283,7 +297,7 @@ public class DebugMonitor implements ProgressMonitor {
//
}
- public void internalWorked(double work) {
+ public void internalWorked(final double work) {
//
}
@@ -291,19 +305,19 @@ public class DebugMonitor implements ProgressMonitor {
return false;
}
- public void setCanceled(boolean value) {
+ public void setCanceled(final boolean value) {
//
}
- public void setTaskName(String name) {
+ public void setTaskName(final String name) {
//
}
- public void subTask(String name) {
+ public void subTask(final String name) {
//
}
- public void worked(int work) {
+ public void worked(final int work) {
//
}
@@ -311,7 +325,7 @@ public class DebugMonitor implements ProgressMonitor {
//
}
- public void setBlocked(Diagnostic reason) {
+ public void setBlocked(final Diagnostic reason) {
//
}
diff --git a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/processing/DebuggerInterruptedException.java b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/processing/DebuggerInterruptedException.java
index cdc0957..b5941f2 100644
--- a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/processing/DebuggerInterruptedException.java
+++ b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/processing/DebuggerInterruptedException.java
@@ -20,11 +20,11 @@ public class DebuggerInterruptedException extends RuntimeException {
private static final long serialVersionUID = 8297242905634686930L;
- public DebuggerInterruptedException(IOException e) {
+ public DebuggerInterruptedException(final IOException e) {
super(e);
}
- public DebuggerInterruptedException(String msg) {
+ public DebuggerInterruptedException(final String msg) {
super(msg);
}
diff --git a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/processing/RuntimeHandlerManager.java b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/processing/RuntimeHandlerManager.java
index 18d3dbd..e1a0908 100644
--- a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/processing/RuntimeHandlerManager.java
+++ b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/processing/RuntimeHandlerManager.java
@@ -27,19 +27,19 @@ public class RuntimeHandlerManager implements Runnable {
private Connection connection;
- private DebugMonitor monitor;
+ private final DebugMonitor monitor;
private static final Log logger = LogFactory.getLog(RuntimeHandlerManager.class);
// -------------------------------------------------------------------------
- public RuntimeHandlerManager(DebugMonitor monitor) {
+ public RuntimeHandlerManager(final DebugMonitor monitor) {
this.monitor = monitor;
}
// -------------------------------------------------------------------------
- public void setConnection(Connection connection) {
+ public void setConnection(final Connection connection) {
this.connection = connection;
}
@@ -63,8 +63,9 @@ public class RuntimeHandlerManager implements Runnable {
listenAndRegisterClasses();
}
} catch (Exception e) {
- if (!(e instanceof IOException))
+ if (!(e instanceof IOException)) {
logger.error(e.getMessage(), e);
+ }
}
}
diff --git a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/processing/handlers/BreakpointRuntimeHandler.java b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/processing/handlers/BreakpointRuntimeHandler.java
index 1cfe05f..5588daa 100644
--- a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/processing/handlers/BreakpointRuntimeHandler.java
+++ b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/processing/handlers/BreakpointRuntimeHandler.java
@@ -37,11 +37,11 @@ public class BreakpointRuntimeHandler implements RuntimeHandler, ProcessHandler,
protected DebugMonitor monitor;
- private List<Object> breakpoints = new ArrayList<Object>();
+ private final List<Object> breakpoints = new ArrayList<Object>();
- private List<SyntaxElement> breakpointTOs = new ArrayList<SyntaxElement>();
+ private final List<SyntaxElement> breakpointTOs = new ArrayList<SyntaxElement>();
- private List<SyntaxElement> toBeRemovedTOs = new ArrayList<SyntaxElement>();
+ private final List<SyntaxElement> toBeRemovedTOs = new ArrayList<SyntaxElement>();
// -------------------------------------------------------------------------
@@ -51,7 +51,7 @@ public class BreakpointRuntimeHandler implements RuntimeHandler, ProcessHandler,
* @see org.openarchitectureware.debug.processing.IRuntimeHandler#init(org.openarchitectureware.debug.processing.DebugMonitor,
* org.openarchitectureware.debug.communication.Connection)
*/
- public void init(DebugMonitor monitor, Connection connection) {
+ public void init(final DebugMonitor monitor, final Connection connection) {
this.monitor = monitor;
this.connection = connection;
if (monitor != null) {
@@ -77,8 +77,9 @@ public class BreakpointRuntimeHandler implements RuntimeHandler, ProcessHandler,
*/
public void run() {
try {
- while (true)
+ while (true) {
listenAndDispatchCommand();
+ }
} catch (IOException e) {
}
}
@@ -87,7 +88,7 @@ public class BreakpointRuntimeHandler implements RuntimeHandler, ProcessHandler,
handle((BreakpointPacket) connection.listenForPacket(BreakpointPacket.class));
}
- private void handle(BreakpointPacket packet) {
+ private void handle(final BreakpointPacket packet) {
switch (packet.type) {
case SET:
doSet(packet.se, null, 0);
@@ -102,38 +103,44 @@ public class BreakpointRuntimeHandler implements RuntimeHandler, ProcessHandler,
// -------------------------------------------------------------------------
- private void doSet(SyntaxElement se, Object actual, int flag) {
+ private void doSet(final SyntaxElement se, final Object actual, final int flag) {
ElementAdapter adapter = monitor.getAdapter(se);
- if (adapter == null)
+ if (adapter == null) {
return;
+ }
Object element = adapter.findElement(se, actual, flag);
// breakpoints may be set before the syntax element structure is instantiated
// in this case we store the SyntaxElementTO and try it again during shallSuspend(...)
if (element == null){
breakpointTOs.add(se);
- for (SyntaxElement cand : toBeRemovedTOs)
+ for (SyntaxElement cand : toBeRemovedTOs) {
if(se.equalsBP(cand)){
toBeRemovedTOs.remove(cand);
break;
}
- }else
+ }
+ } else {
breakpoints.add(element);
+ }
}
- private void doRemove(SyntaxElement se, Object actual, int flag) {
+ private void doRemove(final SyntaxElement se, final Object actual, final int flag) {
ElementAdapter adapter = monitor.getAdapter(se);
- if (adapter == null)
+ if (adapter == null) {
return;
+ }
Object element = adapter.findElement(se, actual, flag);
if (element == null){
toBeRemovedTOs.add(se);
- for (SyntaxElement cand : breakpointTOs)
+ for (SyntaxElement cand : breakpointTOs) {
if(se.equalsBP(cand)){
breakpointTOs.remove(cand);
break;
}
- }else
+ }
+ } else {
breakpoints.remove(element);
+ }
}
// -------------------------------------------------------------------------
@@ -148,20 +155,22 @@ public class BreakpointRuntimeHandler implements RuntimeHandler, ProcessHandler,
*
* @see org.eclipse.emf.mwe.internal.core.debug.processing.ProcessHandler#shallSuspend(boolean, java.lang.Object, int)
*/
- public boolean shallSuspend(boolean lastState, Object element, int flag) {
+ public boolean shallSuspend(final boolean lastState, final Object element, final int flag) {
if (!toBeRemovedTOs.isEmpty()) {
List<SyntaxElement> temp = new ArrayList<SyntaxElement>();
temp.addAll(toBeRemovedTOs);
toBeRemovedTOs.clear();
- for (SyntaxElement se : temp)
+ for (SyntaxElement se : temp) {
doRemove(se, element, flag);
+ }
}
if (!breakpointTOs.isEmpty()) {
List<SyntaxElement> temp = new ArrayList<SyntaxElement>();
temp.addAll(breakpointTOs);
breakpointTOs.clear();
- for (SyntaxElement se : temp)
+ for (SyntaxElement se : temp) {
doSet(se, element, flag);
+ }
}
return lastState || breakpoints.contains(element);
}
@@ -171,7 +180,7 @@ public class BreakpointRuntimeHandler implements RuntimeHandler, ProcessHandler,
*
* @see org.eclipse.emf.mwe.internal.core.debug.processing.ProcessHandler#shallHandle(boolean, java.lang.Object, int)
*/
- public boolean shallHandle(boolean lastState, Object element, int flag) {
+ public boolean shallHandle(final boolean lastState, final Object element, final int flag) {
return lastState;
}
@@ -180,7 +189,7 @@ public class BreakpointRuntimeHandler implements RuntimeHandler, ProcessHandler,
*
* @see org.eclipse.emf.mwe.internal.core.debug.processing.ProcessHandler#shallInterrupt(boolean)
*/
- public boolean shallInterrupt(boolean lastState) {
+ public boolean shallInterrupt(final boolean lastState) {
return lastState;
}
diff --git a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/processing/handlers/CommandRuntimeHandler.java b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/processing/handlers/CommandRuntimeHandler.java
index b2e8f32..ea8d4dd 100644
--- a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/processing/handlers/CommandRuntimeHandler.java
+++ b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/processing/handlers/CommandRuntimeHandler.java
@@ -57,7 +57,7 @@ public class CommandRuntimeHandler implements RuntimeHandler, CommandListener, P
private boolean interrupt = false;
- private Stack<Boolean> stackFrames = new Stack<Boolean>();
+ private final Stack<Boolean> stackFrames = new Stack<Boolean>();
private int iterationLevel = 0;
@@ -65,7 +65,7 @@ public class CommandRuntimeHandler implements RuntimeHandler, CommandListener, P
private boolean continueOperation = false;
- private Object[] syncObject = new Object[0];
+ private final Object[] syncObject = new Object[0];
// -------------------------------------------------------------------------
@@ -75,7 +75,7 @@ public class CommandRuntimeHandler implements RuntimeHandler, CommandListener, P
* @see org.openarchitectureware.debug.processing.IRuntimeHandler#init(org.openarchitectureware.debug.processing.DebugMonitor,
* org.openarchitectureware.debug.communication.Connection)
*/
- public void init(DebugMonitor monitor, Connection connection) {
+ public void init(final DebugMonitor monitor, final Connection connection) {
this.monitor = monitor;
this.connection = connection;
if (monitor != null) {
@@ -115,7 +115,7 @@ public class CommandRuntimeHandler implements RuntimeHandler, CommandListener, P
dispatch(((CommandPacket) connection.listenForPacket(CommandPacket.class)).command);
}
- private void dispatch(int cmd) {
+ private void dispatch(final int cmd) {
switch (cmd) {
case STEP_INTO:
case STEP_OVER:
@@ -138,7 +138,7 @@ public class CommandRuntimeHandler implements RuntimeHandler, CommandListener, P
// -------------------------------------------------------------------------
- private void doStep(int cmd) {
+ private void doStep(final int cmd) {
stepping = true;
switch (cmd) {
case STEP_INTO:
@@ -186,14 +186,15 @@ public class CommandRuntimeHandler implements RuntimeHandler, CommandListener, P
*
* @see org.eclipse.emf.mwe.internal.core.debug.processing.ProcessHandler#shallHandle(boolean, java.lang.Object, int)
*/
- public boolean shallHandle(boolean lastState, Object element, int flag) {
+ public boolean shallHandle(final boolean lastState, final Object element, final int flag) {
boolean result;
if (flag == PUSH) {
result = monitor.getAdapter(element).shallHandle(element);
stackFrames.push(result);
- } else
+ } else {
// POP
result = stackFrames.pop();
+ }
return lastState || result;
}
@@ -202,8 +203,8 @@ public class CommandRuntimeHandler implements RuntimeHandler, CommandListener, P
*
* @see org.eclipse.emf.mwe.internal.core.debug.processing.ProcessHandler#shallSuspend(boolean, java.lang.Object, int)
*/
- public boolean shallSuspend(boolean lastState, Object element, int flag) {
- boolean shallSuspend = lastState || forceSuspend || stepping && (suspendBaseLevel - (flag == NORMAL_FRAME ? 0 : 1) >= iterationLevel);
+ public boolean shallSuspend(final boolean lastState, final Object element, final int flag) {
+ boolean shallSuspend = lastState || forceSuspend || (stepping && (suspendBaseLevel - (flag == NORMAL_FRAME ? 0 : 1) >= iterationLevel));
if (!monitor.getAdapter(element).shallSuspend(element, flag) && shallSuspend) {
suspendBaseLevel++;
return false;
@@ -216,7 +217,7 @@ public class CommandRuntimeHandler implements RuntimeHandler, CommandListener, P
*
* @see org.eclipse.emf.mwe.internal.core.debug.processing.ProcessHandler#shallInterrupt(boolean)
*/
- public boolean shallInterrupt(boolean lastState) {
+ public boolean shallInterrupt(final boolean lastState) {
return lastState || interrupt || !connection.isConnected();
}
@@ -236,7 +237,7 @@ public class CommandRuntimeHandler implements RuntimeHandler, CommandListener, P
*
* @see org.eclipse.emf.mwe.internal.core.debug.processing.EventHandler#preTask(java.lang.Object, int)
*/
- public void preTask(Object element, Object context, int state) {
+ public void preTask(final Object element, final Object context, final int state) {
iterationLevel++;
}
@@ -245,7 +246,7 @@ public class CommandRuntimeHandler implements RuntimeHandler, CommandListener, P
*
* @see org.eclipse.emf.mwe.internal.core.debug.processing.EventHandler#preTask(java.lang.Object, int)
*/
- public void postTask(Object context) {
+ public void postTask(final Object context) {
iterationLevel--;
}
@@ -283,7 +284,7 @@ public class CommandRuntimeHandler implements RuntimeHandler, CommandListener, P
* @see org.openarchitectureware.debug.processing.ICommandListener#listenCommand()
*/
public void listenCommand() {
- if (!continueOperation)
+ if (!continueOperation) {
synchronized (syncObject) {
try {
syncObject.wait();
@@ -291,6 +292,7 @@ public class CommandRuntimeHandler implements RuntimeHandler, CommandListener, P
//
}
}
+ }
continueOperation = false;
}
diff --git a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/processing/handlers/EventRuntimeHandler.java b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/processing/handlers/EventRuntimeHandler.java
index 3d337ed..548e1f3 100644
--- a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/processing/handlers/EventRuntimeHandler.java
+++ b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/processing/handlers/EventRuntimeHandler.java
@@ -40,7 +40,7 @@ public class EventRuntimeHandler implements RuntimeHandler, EventHandler {
private DebugMonitor monitor;
- private Stack<Frame> stackFrames = new Stack<Frame>();
+ private final Stack<Frame> stackFrames = new Stack<Frame>();
private int cleanStackLevel = 0;
@@ -52,7 +52,7 @@ public class EventRuntimeHandler implements RuntimeHandler, EventHandler {
* @see org.openarchitectureware.debug.processing.IRuntimeHandler#init(org.openarchitectureware.debug.processing.DebugMonitor,
* org.openarchitectureware.debug.communication.Connection)
*/
- public void init(DebugMonitor monitor, Connection connection) {
+ public void init(final DebugMonitor monitor, final Connection connection) {
this.monitor = monitor;
this.connection = connection;
monitor.addEventHandler(this);
@@ -82,7 +82,7 @@ public class EventRuntimeHandler implements RuntimeHandler, EventHandler {
*
* @see org.eclipse.emf.mwe.internal.core.debug.processing.EventHandler#preTask(java.lang.Object, int)
*/
- public void preTask(Object element, Object context, int state) {
+ public void preTask(final Object element, final Object context, final int state) {
stackFrames.push(new Frame(element, context, state));
}
@@ -91,9 +91,10 @@ public class EventRuntimeHandler implements RuntimeHandler, EventHandler {
*
* @see org.eclipse.emf.mwe.internal.core.debug.processing.EventHandler#postTask()
*/
- public void postTask(Object context) {
- if (cleanStackLevel >= stackFrames.size())
+ public void postTask(final Object context) {
+ if (cleanStackLevel >= stackFrames.size()) {
cleanStackLevel--;
+ }
stackFrames.pop();
}
@@ -113,10 +114,11 @@ public class EventRuntimeHandler implements RuntimeHandler, EventHandler {
SyntaxElement to;
ElementAdapter adapter = monitor.getAdapter(frame.element);
adapter.setContext(frame.context);
- if (frame.state == NORMAL_FRAME)
+ if (frame.state == NORMAL_FRAME) {
to = adapter.createElementTO(frame.element);
- else
+ } else {
to = adapter.createEndElementTO(frame.element);
+ }
to.type = adapter.getAdapterType();
to.frameId = i;
event.frames.add(to);
@@ -147,12 +149,12 @@ public class EventRuntimeHandler implements RuntimeHandler, EventHandler {
// -------------------------------------------------------------------------
- private void sendEvent(int type) throws IOException {
+ private void sendEvent(final int type) throws IOException {
EventPacket event = new EventPacket(type);
sendAndConfirm(event);
}
- private void sendAndConfirm(EventPacket event) throws IOException {
+ private void sendAndConfirm(final EventPacket event) throws IOException {
int refId = connection.sendPacket(event);
connection.listenForPacket(ConfirmationPacket.class, refId);
}
@@ -165,7 +167,7 @@ public class EventRuntimeHandler implements RuntimeHandler, EventHandler {
final Object context;
- private Frame(Object element, Object context, int state) {
+ private Frame(final Object element, final Object context, final int state) {
this.element = element;
this.context = context;
this.state = state;
diff --git a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/processing/handlers/VariablesRuntimeHandler.java b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/processing/handlers/VariablesRuntimeHandler.java
index c4acd04..0d9b05f 100644
--- a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/processing/handlers/VariablesRuntimeHandler.java
+++ b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/debug/processing/handlers/VariablesRuntimeHandler.java
@@ -38,11 +38,11 @@ public class VariablesRuntimeHandler implements RuntimeHandler, EventHandler, Ru
private DebugMonitor monitor;
- private Stack<Frame> stackFrames = new Stack<Frame>();
+ private final Stack<Frame> stackFrames = new Stack<Frame>();
- private List<VarValue> frameCache = new ArrayList<VarValue>();
+ private final List<VarValue> frameCache = new ArrayList<VarValue>();
- private List<VarValue> varCache = new ArrayList<VarValue>();
+ private final List<VarValue> varCache = new ArrayList<VarValue>();
private int nextId = 0;
@@ -54,11 +54,12 @@ public class VariablesRuntimeHandler implements RuntimeHandler, EventHandler, Ru
* @see org.openarchitectureware.debug.processing.IRuntimeHandler#init(org.openarchitectureware.debug.processing.DebugMonitor,
* org.openarchitectureware.debug.communication.Connection)
*/
- public void init(DebugMonitor monitor, Connection connection) {
+ public void init(final DebugMonitor monitor, final Connection connection) {
this.monitor = monitor;
this.connection = connection;
- if (monitor != null)
+ if (monitor != null) {
monitor.addEventHandler(this);
+ }
}
// -------------------------------------------------------------------------
@@ -81,21 +82,24 @@ public class VariablesRuntimeHandler implements RuntimeHandler, EventHandler, Ru
*/
public void run() {
try {
- while (true)
+ while (true) {
handle((RequireVarPacket) connection.listenForPacket(RequireVarPacket.class));
+ }
} catch (IOException e) {
}
}
- private void handle(RequireVarPacket packet) throws IOException {
+ private void handle(final RequireVarPacket packet) throws IOException {
List<VarValueTO> values;
- if (packet.varId == 0)
+ if (packet.varId == 0) {
values = getFrameVariables(packet.frameId);
- else
+ } else {
values = getSubVariables(packet.frameId, packet.varId);
+ }
VarDataPacket varPacket = new VarDataPacket();
- if (values != null)
+ if (values != null) {
varPacket.valueList = values;
+ }
varPacket.refId = packet.getId();
connection.sendPacket(varPacket);
}
@@ -104,7 +108,7 @@ public class VariablesRuntimeHandler implements RuntimeHandler, EventHandler, Ru
// It depends on the element adapter, which variables will be reported.
// The syntaxElement is also registered in the frameCache to find out later if variable values are still in
// use.
- private List<VarValueTO> getFrameVariables(int frameId) {
+ private List<VarValueTO> getFrameVariables(final int frameId) {
if (frameId >= stackFrames.size()) {
return null;
}
@@ -123,15 +127,17 @@ public class VariablesRuntimeHandler implements RuntimeHandler, EventHandler, Ru
// In case both frameId and varId are delivered the sub variables of to var with the varId will be collected.
// The adapter that suits for the element will be used. That means that there can be different variables
// delivered because of different adapters for two frames although the underlying java elements are the same.
- private List<VarValueTO> getSubVariables(int frameId, int varId) {
- if (stackFrames.size() <= frameId)
+ private List<VarValueTO> getSubVariables(final int frameId, final int varId) {
+ if (stackFrames.size() <= frameId) {
return null;
+ }
Frame frame = stackFrames.get(frameId);
ElementAdapter adapter = monitor.getAdapter(frame.element);
adapter.setContext(frame.context);
VarValue value = findVarValueById(varId);
- if (value == null)
+ if (value == null) {
return null;
+ }
return getVariableTOs(value.element, value, adapter);
}
@@ -143,7 +149,7 @@ public class VariablesRuntimeHandler implements RuntimeHandler, EventHandler, Ru
// If such a "removed" element is no longer used in any other element, it will be also removed from the
// cache and can be garbage collected.
//
- private List<VarValueTO> getVariableTOs(Object hostElement, VarValue hostValue, ElementAdapter adapter) {
+ private List<VarValueTO> getVariableTOs(final Object hostElement, final VarValue hostValue, final ElementAdapter adapter) {
List<VarValueTO> list = new ArrayList<VarValueTO>();
Set<VarValue> oldMembers = new HashSet<VarValue>();
@@ -184,7 +190,7 @@ public class VariablesRuntimeHandler implements RuntimeHandler, EventHandler, Ru
return list;
}
- private VarValue findOrCreateVarValue(Object element) {
+ private VarValue findOrCreateVarValue(final Object element) {
VarValue value = findVarValueByElement(element);
if (value == null) {
value = new VarValue(element, ++nextId);
@@ -193,17 +199,21 @@ public class VariablesRuntimeHandler implements RuntimeHandler, EventHandler, Ru
return value;
}
- private VarValue findVarValueByElement(Object element) {
- for (VarValue cacheEntry : varCache)
- if (element == cacheEntry.element)
+ private VarValue findVarValueByElement(final Object element) {
+ for (VarValue cacheEntry : varCache) {
+ if (element == cacheEntry.element) {
return cacheEntry;
+ }
+ }
return null;
}
- private VarValue findVarValueById(int id) {
- for (VarValue cacheEntry : varCache)
- if (id == cacheEntry.id)
+ private VarValue findVarValueById(final int id) {
+ for (VarValue cacheEntry : varCache) {
+ if (id == cacheEntry.id) {
return cacheEntry;
+ }
+ }
return null;
}
@@ -215,15 +225,17 @@ public class VariablesRuntimeHandler implements RuntimeHandler, EventHandler, Ru
Set<VarValue> oldFrameValues = new HashSet<VarValue>();
oldFrameValues.addAll(frameCache);
- for (VarValue value : oldFrameValues)
+ for (VarValue value : oldFrameValues) {
if (!stackFrames.contains(value.element)) {
frameCache.remove(value);
for (VarValue member : value.members) {
member.usedIn.remove(value);
- if (member.usedIn.isEmpty())
+ if (member.usedIn.isEmpty()) {
varCache.remove(member);
+ }
}
}
+ }
}
// -------------------------------------------------------------------------
@@ -234,7 +246,7 @@ public class VariablesRuntimeHandler implements RuntimeHandler, EventHandler, Ru
*
* @see org.eclipse.emf.mwe.internal.core.debug.processing.EventHandler#preTask(java.lang.Object, int)
*/
- public void preTask(Object element, Object context, int state) {
+ public void preTask(final Object element, final Object context, final int state) {
stackFrames.push(new Frame(element, context));
}
@@ -243,7 +255,7 @@ public class VariablesRuntimeHandler implements RuntimeHandler, EventHandler, Ru
*
* @see org.eclipse.emf.mwe.internal.core.debug.processing.EventHandler#postTask()
*/
- public void postTask(Object context) {
+ public void postTask(final Object context) {
stackFrames.pop();
}
@@ -285,7 +297,7 @@ public class VariablesRuntimeHandler implements RuntimeHandler, EventHandler, Ru
final Object context;
- private Frame(Object element, Object context) {
+ private Frame(final Object element, final Object context) {
this.element = element;
this.context = context;
}
diff --git a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/resources/ResourceLoaderDefaultImpl.java b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/resources/ResourceLoaderDefaultImpl.java
index 2b4fa6e..828adf0 100644
--- a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/resources/ResourceLoaderDefaultImpl.java
+++ b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/resources/ResourceLoaderDefaultImpl.java
@@ -61,9 +61,10 @@ public class ResourceLoaderDefaultImpl implements ResourceLoader {
try {
return internalLoadClass(clazzName);
} catch (final Exception e) {
- if (clazzName.startsWith("mwe"))
+ if (clazzName.startsWith("mwe")) {
return loadClass(clazzName.replaceFirst("mwe",
"org.eclipse.emf.mwe"));
+ }
return null;
}
}
@@ -82,8 +83,9 @@ public class ResourceLoaderDefaultImpl implements ResourceLoader {
path = FILE_PREFIX + path;
}
url = new URL(path);
- if (url.getContent() == null)
+ if (url.getContent() == null) {
return null;
+ }
} catch (final MalformedURLException e) {
return null;
} catch (final IOException e) {
@@ -97,7 +99,7 @@ public class ResourceLoaderDefaultImpl implements ResourceLoader {
return Thread.currentThread().getContextClassLoader().getResource(path);
}
- public Enumeration<URL> getResources(String uri) {
+ public Enumeration<URL> getResources(final String uri) {
try {
return Thread.currentThread().getContextClassLoader().getResources(
uri);
diff --git a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/resources/ResourceLoaderImpl.java b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/resources/ResourceLoaderImpl.java
index 3d82adc..795bb27 100644
--- a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/resources/ResourceLoaderImpl.java
+++ b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/resources/ResourceLoaderImpl.java
@@ -15,7 +15,7 @@ import java.net.URL;
public class ResourceLoaderImpl extends ResourceLoaderDefaultImpl {
- private ClassLoader loader;
+ private final ClassLoader loader;
public ResourceLoaderImpl(final ClassLoader l ) {
loader = l;
diff --git a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/util/ComponentPrinter.java b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/util/ComponentPrinter.java
index 6733a8f..8e2a18f 100644
--- a/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/util/ComponentPrinter.java
+++ b/plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/util/ComponentPrinter.java
@@ -20,19 +20,23 @@ public class ComponentPrinter {
if (comp instanceof CompositeComponent) {
final CompositeComponent cc = (CompositeComponent) comp;
String nameAndLocation = getShortName(cc)+": executing ";
- if (cc.getName() != null && !"".equals(cc.getName()))
+ if ((cc.getName() != null) && !"".equals(cc.getName())) {
nameAndLocation += cc.getName();
- if (cc.getResource() != null)
+ }
+ if (cc.getResource() != null) {
nameAndLocation += " " + cc.getResource();
- if (cc.getLocation() != null)
+ }
+ if (cc.getLocation() != null) {
nameAndLocation += " " + cc.getLocation();
- if (!"".equals(nameAndLocation))
+ }
+ if (!"".equals(nameAndLocation)) {
return nameAndLocation;
+ }
}
if (comp instanceof WorkflowComponentWithID) {
final WorkflowComponentWithID wid = (WorkflowComponentWithID) comp;
String logMessage = wid.getLogMessage();
- if (wid.getId() != null && !"".equals(wid.getId())) {
+ if ((wid.getId() != null) && !"".equals(wid.getId())) {
return getShortName(wid)+"("+wid.getId()+")" + ((logMessage == null) ? "" : ": "+logMessage);
}
return getShortName(wid) + ((logMessage == null) ? "" : ": "+logMessage) ;
@@ -40,36 +44,40 @@ public class ComponentPrinter {
return comp.getClass().getName();
}
- private static String getShortName(WorkflowComponentWithID wid) {
+ private static String getShortName(final WorkflowComponentWithID wid) {
return wid.getClass().getSimpleName();
}
public static String getShortString(final WorkflowComponent comp) {
- if(comp == null)
+ if(comp == null) {
return "no Name";
+ }
if (comp instanceof WorkflowComponentWithID) {
final WorkflowComponentWithID wid = (WorkflowComponentWithID) comp;
- if (wid.getId() != null && !"".equals(wid.getId()))
+ if ((wid.getId() != null) && !"".equals(wid.getId())) {
return wid.getId();
+ }
}
if (comp instanceof CompositeComponent) {
final CompositeComponent cc = (CompositeComponent) comp;
String nameAndLocation = "";
- if (cc.getName() != null && !"".equals(cc.getName()))
+ if ((cc.getName() != null) && !"".equals(cc.getName())) {
nameAndLocation += cc.getName();
+ }
if (cc.getResource() != null) {
int pos = cc.getResource().lastIndexOf("/");
nameAndLocation += " " + cc.getResource().substring(pos + 1);
}
- if (!"".equals(nameAndLocation))
+ if (!"".equals(nameAndLocation)) {
return nameAndLocation;
+ }
}
return comp.getClass().getName();
}
public static String getContainerName(final WorkflowComponent comp) {
final CompositeComponent cc = comp.getContainer();
- if(cc != null && cc.getResource() != null) {
+ if((cc != null) && (cc.getResource() != null)) {
int pos = cc.getResource().lastIndexOf("/");
return cc.getResource().substring(pos + 1);
}
@@ -79,8 +87,9 @@ public class ComponentPrinter {
public static String getElementName(final WorkflowComponent comp) {
if (comp instanceof WorkflowComponentWithID) {
final WorkflowComponentWithID wid = (WorkflowComponentWithID) comp;
- if (wid.getId() != null && !"".equals(wid.getId()))
+ if ((wid.getId() != null) && !"".equals(wid.getId())) {
return wid.getId();
+ }
}
if (comp instanceof CompositeComponent) {
final CompositeComponent cc = (CompositeComponent) comp;
diff --git a/plugins/org.eclipse.emf.mwe.ui.simpleEditor/src/org/eclipse/emf/mwe/ui/internal/simpleEditor/ColorManager.java b/plugins/org.eclipse.emf.mwe.ui.simpleEditor/src/org/eclipse/emf/mwe/ui/internal/simpleEditor/ColorManager.java
index 68227d8..299d7a1 100644
--- a/plugins/org.eclipse.emf.mwe.ui.simpleEditor/src/org/eclipse/emf/mwe/ui/internal/simpleEditor/ColorManager.java
+++ b/plugins/org.eclipse.emf.mwe.ui.simpleEditor/src/org/eclipse/emf/mwe/ui/internal/simpleEditor/ColorManager.java
@@ -28,8 +28,9 @@ public class ColorManager {
public void dispose() {
final Iterator<Color> e = fColorTable.values().iterator();
- while (e.hasNext())
- (e.next()).dispose();
+ while (e.hasNext()) {
+ (e.next()).dispose();
+ }
}
public Color getColor(final RGB rgb) {
diff --git a/plugins/org.eclipse.emf.mwe.ui.simpleEditor/src/org/eclipse/emf/mwe/ui/internal/simpleEditor/NonRuleBasedDamagerRepairer.java b/plugins/org.eclipse.emf.mwe.ui.simpleEditor/src/org/eclipse/emf/mwe/ui/internal/simpleEditor/NonRuleBasedDamagerRepairer.java
index 6885699..5afc885 100644
--- a/plugins/org.eclipse.emf.mwe.ui.simpleEditor/src/org/eclipse/emf/mwe/ui/internal/simpleEditor/NonRuleBasedDamagerRepairer.java
+++ b/plugins/org.eclipse.emf.mwe.ui.simpleEditor/src/org/eclipse/emf/mwe/ui/internal/simpleEditor/NonRuleBasedDamagerRepairer.java
@@ -68,8 +68,9 @@ public class NonRuleBasedDamagerRepairer implements IPresentationDamager, IPrese
protected int endOfLineOf(final int offset) throws BadLocationException {
IRegion info = fDocument.getLineInformationOfOffset(offset);
- if (offset <= info.getOffset() + info.getLength())
+ if (offset <= info.getOffset() + info.getLength()) {
return info.getOffset() + info.getLength();
+ }
final int line = fDocument.getLineOfOffset(offset);
try {
@@ -84,7 +85,7 @@ public class NonRuleBasedDamagerRepairer implements IPresentationDamager, IPrese
* @see IPresentationDamager#getDamageRegion(ITypedRegion, DocumentEvent,
* boolean)
*/
- public IRegion getDamageRegion(final ITypedRegion partition, final DocumentEvent event, boolean documentPartitioningChanged) {
+ public IRegion getDamageRegion(final ITypedRegion partition, final DocumentEvent event, final boolean documentPartitioningChanged) {
if (!documentPartitioningChanged) {
try {
@@ -93,11 +94,12 @@ public class NonRuleBasedDamagerRepairer implements IPresentationDamager, IPrese
int end = event.getOffset() + (event.getText() == null ? event.getLength() : event.getText().length());
- if (info.getOffset() <= end && end <= info.getOffset() + info.getLength()) {
+ if ((info.getOffset() <= end) && (end <= info.getOffset() + info.getLength())) {
// optimize the case of the same line
end = info.getOffset() + info.getLength();
- } else
+ } else {
end = endOfLineOf(end);
+ }
end = Math.min(partition.getOffset() + partition.getLength(), end);
return new Region(start, end - start);
@@ -130,7 +132,8 @@ public class NonRuleBasedDamagerRepairer implements IPresentationDamager, IPrese
* the attribute describing the style of the range to be styled
*/
protected void addRange(final TextPresentation presentation, final int offset, final int length, final TextAttribute attr) {
- if (attr != null)
+ if (attr != null) {
presentation.addStyleRange(new StyleRange(offset, length, attr.getForeground(), attr.getBackground(), attr.getStyle()));
+ }
}
} \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.mwe.ui.simpleEditor/src/org/eclipse/emf/mwe/ui/internal/simpleEditor/WorkflowEditor.java b/plugins/org.eclipse.emf.mwe.ui.simpleEditor/src/org/eclipse/emf/mwe/ui/internal/simpleEditor/WorkflowEditor.java
index a08cf0b..82d8d20 100644
--- a/plugins/org.eclipse.emf.mwe.ui.simpleEditor/src/org/eclipse/emf/mwe/ui/internal/simpleEditor/WorkflowEditor.java
+++ b/plugins/org.eclipse.emf.mwe.ui.simpleEditor/src/org/eclipse/emf/mwe/ui/internal/simpleEditor/WorkflowEditor.java
@@ -23,7 +23,7 @@ import org.eclipse.ui.editors.text.TextEditor;
public class WorkflowEditor extends TextEditor {
- private ColorManager colorManager;
+ private final ColorManager colorManager;
private BreakpointActionGroup actionGroup;
@@ -47,7 +47,7 @@ public class WorkflowEditor extends TextEditor {
}
@Override
- protected void editorContextMenuAboutToShow(IMenuManager menu) {
+ protected void editorContextMenuAboutToShow(final IMenuManager menu) {
menu.add(new Separator("mwe"));
super.editorContextMenuAboutToShow(menu);
@@ -55,7 +55,7 @@ public class WorkflowEditor extends TextEditor {
}
@Override
- protected void rulerContextMenuAboutToShow(IMenuManager menu) {
+ protected void rulerContextMenuAboutToShow(final IMenuManager menu) {
menu.add(new Separator("mwe")); //$NON-NLS-1$
super.rulerContextMenuAboutToShow(menu);
diff --git a/plugins/org.eclipse.emf.mwe.ui.simpleEditor/src/org/eclipse/emf/mwe/ui/internal/simpleEditor/XMLConfiguration.java b/plugins/org.eclipse.emf.mwe.ui.simpleEditor/src/org/eclipse/emf/mwe/ui/internal/simpleEditor/XMLConfiguration.java
index 7c6811b..fedd7d0 100644
--- a/plugins/org.eclipse.emf.mwe.ui.simpleEditor/src/org/eclipse/emf/mwe/ui/internal/simpleEditor/XMLConfiguration.java
+++ b/plugins/org.eclipse.emf.mwe.ui.simpleEditor/src/org/eclipse/emf/mwe/ui/internal/simpleEditor/XMLConfiguration.java
@@ -31,7 +31,7 @@ public class XMLConfiguration extends SourceViewerConfiguration {
private XMLScanner scanner;
- private ColorManager colorManager;
+ private final ColorManager colorManager;
public XMLConfiguration(final ColorManager colorManager) {
this.colorManager = colorManager;
@@ -45,8 +45,9 @@ public class XMLConfiguration extends SourceViewerConfiguration {
@Override
public ITextDoubleClickStrategy getDoubleClickStrategy(final ISourceViewer sourceViewer, final String contentType) {
- if (doubleClickStrategy == null)
- doubleClickStrategy = new XMLDoubleClickStrategy();
+ if (doubleClickStrategy == null) {
+ doubleClickStrategy = new XMLDoubleClickStrategy();
+ }
return doubleClickStrategy;
}
diff --git a/plugins/org.eclipse.emf.mwe.ui.simpleEditor/src/org/eclipse/emf/mwe/ui/internal/simpleEditor/XMLDoubleClickStrategy.java b/plugins/org.eclipse.emf.mwe.ui.simpleEditor/src/org/eclipse/emf/mwe/ui/internal/simpleEditor/XMLDoubleClickStrategy.java
index 0ef86eb..3958ed4 100644
--- a/plugins/org.eclipse.emf.mwe.ui.simpleEditor/src/org/eclipse/emf/mwe/ui/internal/simpleEditor/XMLDoubleClickStrategy.java
+++ b/plugins/org.eclipse.emf.mwe.ui.simpleEditor/src/org/eclipse/emf/mwe/ui/internal/simpleEditor/XMLDoubleClickStrategy.java
@@ -25,8 +25,9 @@ public class XMLDoubleClickStrategy implements ITextDoubleClickStrategy {
public void doubleClicked(final ITextViewer part) {
final int pos = part.getSelectedRange().x;
- if (pos < 0)
- return;
+ if (pos < 0) {
+ return;
+ }
fText = part;
@@ -49,13 +50,15 @@ public class XMLDoubleClickStrategy implements ITextDoubleClickStrategy {
pos -= 2;
continue;
}
- if (c == Character.LINE_SEPARATOR || c == '\"')
- break;
+ if ((c == Character.LINE_SEPARATOR) || (c == '\"')) {
+ break;
+ }
--pos;
}
- if (c != '\"')
- return false;
+ if (c != '\"') {
+ return false;
+ }
startPos = pos;
@@ -65,12 +68,14 @@ public class XMLDoubleClickStrategy implements ITextDoubleClickStrategy {
while (pos < length) {
c = doc.getChar(pos);
- if (c == Character.LINE_SEPARATOR || c == '\"')
- break;
+ if ((c == Character.LINE_SEPARATOR) || (c == '\"')) {
+ break;
+ }
++pos;
}
- if (c != '\"')
- return false;
+ if (c != '\"') {
+ return false;
+ }
endPos = pos;
@@ -96,8 +101,9 @@ public class XMLDoubleClickStrategy implements ITextDoubleClickStrategy {
while (pos >= 0) {
c = doc.getChar(pos);
- if (!Character.isJavaIdentifierPart(c))
- break;
+ if (!Character.isJavaIdentifierPart(c)) {
+ break;
+ }
--pos;
}
@@ -108,8 +114,9 @@ public class XMLDoubleClickStrategy implements ITextDoubleClickStrategy {
while (pos < length) {
c = doc.getChar(pos);
- if (!Character.isJavaIdentifierPart(c))
- break;
+ if (!Character.isJavaIdentifierPart(c)) {
+ break;
+ }
++pos;
}
diff --git a/plugins/org.eclipse.emf.mwe.ui.simpleEditor/src/org/eclipse/emf/mwe/ui/internal/simpleEditor/XMLWhitespaceDetector.java b/plugins/org.eclipse.emf.mwe.ui.simpleEditor/src/org/eclipse/emf/mwe/ui/internal/simpleEditor/XMLWhitespaceDetector.java
index 93530c8..3b1c223 100644
--- a/plugins/org.eclipse.emf.mwe.ui.simpleEditor/src/org/eclipse/emf/mwe/ui/internal/simpleEditor/XMLWhitespaceDetector.java
+++ b/plugins/org.eclipse.emf.mwe.ui.simpleEditor/src/org/eclipse/emf/mwe/ui/internal/simpleEditor/XMLWhitespaceDetector.java
@@ -19,6 +19,6 @@ import org.eclipse.jface.text.rules.IWhitespaceDetector;
public class XMLWhitespaceDetector implements IWhitespaceDetector {
public boolean isWhitespace(final char c) {
- return (c == ' ' || c == '\t' || c == '\n' || c == '\r');
+ return ((c == ' ') || (c == '\t') || (c == '\n') || (c == '\r'));
}
}
diff --git a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/breakpoint/actions/BreakpointActionGroup.java b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/breakpoint/actions/BreakpointActionGroup.java
index e71ebb5..c5f0489 100644
--- a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/breakpoint/actions/BreakpointActionGroup.java
+++ b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/breakpoint/actions/BreakpointActionGroup.java
@@ -52,13 +52,15 @@ public class BreakpointActionGroup extends ActionGroup {
// Note: We don't want to define a new "IOurOwnTextEditor" interface, so we do it via Reflection
Object obj = getterMethod("getSourceViewer", editor);
- if (obj == null)
+ if (obj == null) {
return;
+ }
textWidget = ((ISourceViewer) obj).getTextWidget();
obj = getterMethod("getVerticalRuler", editor);
- if (obj == null)
+ if (obj == null) {
return;
+ }
verticalRuler = (IVerticalRuler) obj;
enableAction = new EnableDisableBreakpointAction(editor, this);
@@ -67,9 +69,10 @@ public class BreakpointActionGroup extends ActionGroup {
// set lastSelectedLine if RightMouseClick on text
textWidget.addMouseListener(new MouseAdapter() {
@Override
- public void mouseDown(MouseEvent e) {
- if (e.button == 3)
+ public void mouseDown(final MouseEvent e) {
+ if (e.button == 3) {
updateLastSelectedOffset(e.x, e.y);
+ }
}
});
@@ -77,14 +80,15 @@ public class BreakpointActionGroup extends ActionGroup {
// set lastSelectedLine if RightMouseClick or DoubleClick on vertical ruler
verticalRuler.getControl().addMouseListener(new MouseAdapter() {
@Override
- public void mouseDown(MouseEvent e) {
- if (e.button == 3)
+ public void mouseDown(final MouseEvent e) {
+ if (e.button == 3) {
updateLastSelectedLine(e.y);
+ }
}
@Override
- public void mouseDoubleClick(MouseEvent e) {
+ public void mouseDoubleClick(final MouseEvent e) {
updateLastSelectedLine(e.y);
// see note below for why we call it here
toggleAction.run();
@@ -93,7 +97,7 @@ public class BreakpointActionGroup extends ActionGroup {
});
}
- private void updateLastSelectedLine(int y) {
+ private void updateLastSelectedLine(final int y) {
// Note: we use our own "lastSelectedLine mechanism" (not the ruler's one) because of sequencing problems
// our action mouseHandler would be called after the ruler mouseHandler, so for doubleClick the
// lastSelectedLine value may not be correct
@@ -103,7 +107,7 @@ public class BreakpointActionGroup extends ActionGroup {
lastSelectedOffset = textWidget.getOffsetAtLocation(new Point(0, y));
}
- private void updateLastSelectedOffset(int x, int y) {
+ private void updateLastSelectedOffset(final int x, final int y) {
rulerSelected = false;
lastSelectedLine = verticalRuler.toDocumentLineNumber(y);
lastSelectedOffset = textWidget.getOffsetAtLocation(new Point(x, y));
@@ -123,14 +127,14 @@ public class BreakpointActionGroup extends ActionGroup {
return lastSelectedOffset;
}
- public int getOffsetAtLine(int line) {
+ public int getOffsetAtLine(final int line) {
return textWidget.getOffsetAtLine(line);
}
// -------------------------------------------------------------------------
@Override
- public void fillContextMenu(IMenuManager manager) {
+ public void fillContextMenu(final IMenuManager manager) {
toggleAction.updateText();
manager.appendToGroup("mwe", toggleAction);
enableAction.updateText();
@@ -144,7 +148,7 @@ public class BreakpointActionGroup extends ActionGroup {
super.dispose();
}
- private Object getterMethod(String name, Object element) {
+ private Object getterMethod(final String name, final Object element) {
try {
Method m = findMethod(name, element.getClass());
if (m != null) {
@@ -157,12 +161,14 @@ public class BreakpointActionGroup extends ActionGroup {
return null;
}
- private Method findMethod(String name, Class<?> clazz) {
+ private Method findMethod(final String name, final Class<?> clazz) {
if (!Object.class.equals(clazz)) {
Method[] methods = clazz.getDeclaredMethods();
- for (Method method : methods)
- if (method.getName().equals(name))
+ for (Method method : methods) {
+ if (method.getName().equals(name)) {
return method;
+ }
+ }
return findMethod(name, clazz.getSuperclass());
}
return null;
diff --git a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/breakpoint/actions/EnableDisableBreakpointAction.java b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/breakpoint/actions/EnableDisableBreakpointAction.java
index ed9ad48..c4c9fb5 100644
--- a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/breakpoint/actions/EnableDisableBreakpointAction.java
+++ b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/breakpoint/actions/EnableDisableBreakpointAction.java
@@ -27,7 +27,7 @@ import org.eclipse.ui.texteditor.SimpleMarkerAnnotation;
public class EnableDisableBreakpointAction extends Action {
- private TextEditor editor;
+ private final TextEditor editor;
private final BreakpointActionGroup group;
@@ -35,7 +35,7 @@ public class EnableDisableBreakpointAction extends Action {
* Enable/Disable breakpoint action that can be used both at vertical ruler and editor context menu.
*
*/
- protected EnableDisableBreakpointAction(TextEditor editor, BreakpointActionGroup group) {
+ protected EnableDisableBreakpointAction(final TextEditor editor, final BreakpointActionGroup group) {
this.editor = editor;
this.group = group;
setToolTipText("enable or disable breakpoint");
@@ -89,13 +89,14 @@ public class EnableDisableBreakpointAction extends Action {
if (marker.isSubtypeOf(IBreakpoint.BREAKPOINT_MARKER)) {
Position position = annotationModel.getPosition(markerAnnotation);
int line = document.getLineOfOffset(position.offset);
- if (isRulerSelected && line == selectedLine || !isRulerSelected
- && selectedOffset >= position.offset
- && selectedOffset <= position.offset + position.length) {
+ if ((isRulerSelected && (line == selectedLine)) || (!isRulerSelected
+ && (selectedOffset >= position.offset)
+ && (selectedOffset <= position.offset + position.length))) {
IBreakpoint breakpoint = DebugPlugin.getDefault().getBreakpointManager()
.getBreakpoint(marker);
- if (breakpoint != null)
+ if (breakpoint != null) {
return breakpoint;
+ }
}
}
} catch (CoreException e) {
diff --git a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/breakpoint/actions/ToggleBreakpointAction.java b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/breakpoint/actions/ToggleBreakpointAction.java
index 69cd4a5..7141214 100644
--- a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/breakpoint/actions/ToggleBreakpointAction.java
+++ b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/breakpoint/actions/ToggleBreakpointAction.java
@@ -27,11 +27,11 @@ import org.eclipse.ui.editors.text.TextEditor;
*/
public class ToggleBreakpointAction extends Action {
- private TextEditor editor;
+ private final TextEditor editor;
private final BreakpointActionGroup group;
- public ToggleBreakpointAction(TextEditor editor, BreakpointActionGroup group) {
+ public ToggleBreakpointAction(final TextEditor editor, final BreakpointActionGroup group) {
this.editor = editor;
this.group = group;
setText("Toggle Breakpoint");
@@ -42,16 +42,18 @@ public class ToggleBreakpointAction extends Action {
IResource resource = (IResource) editor.getEditorInput().getAdapter(IResource.class);
PluginAdapter adapter = PluginExtensionManager.getDefault().getAdapterByResourceExtension(resource.getFileExtension());
- if (adapter == null)
+ if (adapter == null) {
return;
+ }
int line = group.getLastSelectedLine() + 1;
int start = group.getLastSelectedOffset();
int end = group.isRulerSelected() ? group.getOffsetAtLine(line) : start;
- if (group.isRulerSelected())
+ if (group.isRulerSelected()) {
setEnabled(true);
- else
+ } else {
setEnabled(adapter.isToggleBpEnabled(resource, start, end, line));
+ }
}
@Override
@@ -70,8 +72,9 @@ public class ToggleBreakpointAction extends Action {
int start = group.getLastSelectedOffset();
PluginAdapter adapter = PluginExtensionManager.getDefault().getAdapterByResourceExtension(resource.getFileExtension());
- if (adapter == null)
+ if (adapter == null) {
return;
+ }
// check if a BP already exists on that line and remove it
boolean isRulerSelected = group.isRulerSelected();
diff --git a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/launching/ui/MWELaunchConfigMainTab.java b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/launching/ui/MWELaunchConfigMainTab.java
index 3c3789d..b29396a 100644
--- a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/launching/ui/MWELaunchConfigMainTab.java
+++ b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/launching/ui/MWELaunchConfigMainTab.java
@@ -53,7 +53,7 @@ import org.eclipse.ui.dialogs.ResourceListSelectionDialog;
*/
public class MWELaunchConfigMainTab extends JavaLaunchTab {
- private WidgetListener fListener = new WidgetListener();
+ private final WidgetListener fListener = new WidgetListener();
private Text projText;
@@ -75,7 +75,7 @@ public class MWELaunchConfigMainTab extends JavaLaunchTab {
return "Main";
}
- public void createControl(Composite parent) {
+ public void createControl(final Composite parent) {
Font font = parent.getFont();
Composite comp = new Composite(parent, SWT.NONE);
@@ -99,7 +99,7 @@ public class MWELaunchConfigMainTab extends JavaLaunchTab {
javaDebugCheckbox });
}
- private Text createGroup(Composite comp, String title, Button searchButton, Button[] checkButtons) {
+ private Text createGroup(final Composite comp, final String title, final Button searchButton, final Button[] checkButtons) {
Font font = comp.getFont();
Group group = new Group(comp, SWT.NONE);
group.setText(title);
@@ -114,7 +114,7 @@ public class MWELaunchConfigMainTab extends JavaLaunchTab {
text.addModifyListener(fListener);
searchButton.setParent(group);
searchButton.addSelectionListener(fListener);
- if (checkButtons != null)
+ if (checkButtons != null) {
for (Button button : checkButtons) {
button.setParent(group);
GridData gd = new GridData();
@@ -122,18 +122,19 @@ public class MWELaunchConfigMainTab extends JavaLaunchTab {
button.setLayoutData(gd);
button.addSelectionListener(fListener);
}
+ }
return text;
}
// *********************************************************** data handling
- public void setDefaults(ILaunchConfigurationWorkingCopy config) {
+ public void setDefaults(final ILaunchConfigurationWorkingCopy config) {
// is called when a new LauchConfig is created
// nothing to do
}
@Override
- public void initializeFrom(ILaunchConfiguration config) {
+ public void initializeFrom(final ILaunchConfiguration config) {
super.initializeFrom(config);
try {
@@ -148,17 +149,18 @@ public class MWELaunchConfigMainTab extends JavaLaunchTab {
}
}
- private void setWfText(String fullName) {
+ private void setWfText(final String fullName) {
wfPath = new Path(fullName);
String projectName = projText.getText().trim();
int pos = fullName.indexOf(projectName);
- if (projectName.length() > 0 && pos >= 0) {
+ if ((projectName.length() > 0) && (pos >= 0)) {
wfText.setText(fullName.substring(pos + projectName.length() + 1));
- } else
+ } else {
wfText.setText(fullName);
+ }
}
- public void performApply(ILaunchConfigurationWorkingCopy config) {
+ public void performApply(final ILaunchConfigurationWorkingCopy config) {
config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, projText.getText().trim());
config.setAttribute(MWELaunchConfigurationConstants.ATTR_MWE_WORKFLOW_FILE, wfPath.toString());
config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_STOP_IN_MAIN, stopInMainCheckbox
@@ -168,7 +170,7 @@ public class MWELaunchConfigMainTab extends JavaLaunchTab {
}
@Override
- public boolean isValid(ILaunchConfiguration launchConfig) {
+ public boolean isValid(final ILaunchConfiguration launchConfig) {
String text = wfText.getText().trim();
if (text.length() > 0) {
if (getWorkspaceRoot().findMember(wfPath) == null) {
@@ -185,22 +187,23 @@ public class MWELaunchConfigMainTab extends JavaLaunchTab {
private class WidgetListener implements ModifyListener, SelectionListener {
- public void modifyText(ModifyEvent e) {
+ public void modifyText(final ModifyEvent e) {
updateLaunchConfigurationDialog();
}
- public void widgetDefaultSelected(SelectionEvent e) {
+ public void widgetDefaultSelected(final SelectionEvent e) {
// do nothing
}
- public void widgetSelected(SelectionEvent e) {
+ public void widgetSelected(final SelectionEvent e) {
Object source = e.getSource();
- if (source == projButton)
+ if (source == projButton) {
handleProjectButtonSelected();
- else if (source == wfButton)
+ } else if (source == wfButton) {
handleWfButtonSelected();
- else
+ } else {
updateLaunchConfigurationDialog();
+ }
}
}
@@ -218,8 +221,9 @@ public class MWELaunchConfigMainTab extends JavaLaunchTab {
private void handleProjectButtonSelected() {
IJavaProject project = chooseJavaProject();
- if (project == null)
+ if (project == null) {
return;
+ }
String projectName = project.getElementName();
projText.setText(projectName);
}
diff --git a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/launching/ui/MWELaunchConfigTabGroup.java b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/launching/ui/MWELaunchConfigTabGroup.java
index 63cb40e..3b3ae04 100644
--- a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/launching/ui/MWELaunchConfigTabGroup.java
+++ b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/launching/ui/MWELaunchConfigTabGroup.java
@@ -26,7 +26,7 @@ import org.eclipse.jdt.debug.ui.launchConfigurations.JavaClasspathTab;
*/
public class MWELaunchConfigTabGroup extends AbstractLaunchConfigurationTabGroup {
- public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
+ public void createTabs(final ILaunchConfigurationDialog dialog, final String mode) {
setTabs(new ILaunchConfigurationTab[] { new MWELaunchConfigMainTab(), new JavaArgumentsTab(), new JavaClasspathTab(), new CommonTab() });
}
diff --git a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/model/DebugElement.java b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/model/DebugElement.java
index 6de17a8..6eaef9a 100644
--- a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/model/DebugElement.java
+++ b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/model/DebugElement.java
@@ -25,7 +25,7 @@ import org.eclipse.emf.mwe.internal.ui.debug.processing.DebugModelManager;
public abstract class DebugElement extends PlatformObject implements IDebugElement {
protected DebugTarget target;
- public DebugElement(DebugTarget target) {
+ public DebugElement(final DebugTarget target) {
this.target = target;
}
@@ -47,7 +47,7 @@ public abstract class DebugElement extends PlatformObject implements IDebugEleme
@SuppressWarnings("unchecked")
@Override
- public Object getAdapter(Class adapter) {
+ public Object getAdapter(final Class adapter) {
if (adapter == IDebugElement.class) {
return this;
}
diff --git a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/model/DebugStackFrame.java b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/model/DebugStackFrame.java
index cb1101f..a32303c 100644
--- a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/model/DebugStackFrame.java
+++ b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/model/DebugStackFrame.java
@@ -32,17 +32,17 @@ import org.eclipse.emf.mwe.internal.ui.debug.model.ui.VariableSorter;
*/
public class DebugStackFrame extends DebugElement implements IStackFrame {
- private DebugThread thread;
+ private final DebugThread thread;
- private SyntaxElement frameValues;
+ private final SyntaxElement frameValues;
- private List<DebugVariable> variables = new ArrayList<DebugVariable>();
+ private final List<DebugVariable> variables = new ArrayList<DebugVariable>();
private boolean variablesChecked;
// -------------------------------------------------------------------------
- public DebugStackFrame(DebugThread thread, SyntaxElement to) {
+ public DebugStackFrame(final DebugThread thread, final SyntaxElement to) {
super(thread.getDebugTarget0());
this.thread = thread;
this.frameValues = to;
diff --git a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/model/DebugTarget.java b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/model/DebugTarget.java
index 26f8ced..3f4d0eb 100644
--- a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/model/DebugTarget.java
+++ b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/model/DebugTarget.java
@@ -43,15 +43,15 @@ import org.eclipse.emf.mwe.internal.ui.workflow.Activator;
*/
public class DebugTarget extends DebugElement implements IDebugTarget {
- private IProcess fProcess;
+ private final IProcess fProcess;
- private ILaunch fLaunch;
+ private final ILaunch fLaunch;
private DebugThread fThread;
- private DebugModelManager dmm;
+ private final DebugModelManager dmm;
- private Map<Integer, DebugValue> valueCache = new HashMap<Integer, DebugValue>();
+ private final Map<Integer, DebugValue> valueCache = new HashMap<Integer, DebugValue>();
protected boolean suspended;
@@ -75,7 +75,7 @@ public class DebugTarget extends DebugElement implements IDebugTarget {
return target[0];
}
- private DebugTarget(ILaunch launch, IProcess process, Connection conn) throws DebugException {
+ private DebugTarget(final ILaunch launch, final IProcess process, final Connection conn) throws DebugException {
super(null);
fLaunch = launch;
target = this;
@@ -128,14 +128,14 @@ public class DebugTarget extends DebugElement implements IDebugTarget {
return dmm;
}
- public DebugValue getDebugValue(VarValueTO varTO) {
+ public DebugValue getDebugValue(final VarValueTO varTO) {
DebugValue value = null;
int valueId = varTO.valueId;
- if (valueId == 0)
+ if (valueId == 0) {
// don't cache primitives
value = new DebugValue(this, varTO);
- else {
+ } else {
value = valueCache.get(valueId);
if (value == null) {
value = new DebugValue(this, varTO);
@@ -145,10 +145,10 @@ public class DebugTarget extends DebugElement implements IDebugTarget {
return value;
}
- public void updateDebugValues(List<VarValueTO> vars) {
+ public void updateDebugValues(final List<VarValueTO> vars) {
for (VarValueTO varTO : vars) {
DebugValue value = valueCache.get(varTO.valueId);
- if (value != null && value.isDirty()) {
+ if ((value != null) && value.isDirty()) {
value.setVarTO(varTO);
}
}
@@ -176,14 +176,16 @@ public class DebugTarget extends DebugElement implements IDebugTarget {
dmm.requireSuspend();
}
- public void setSuspended(boolean value) {
+ public void setSuspended(final boolean value) {
suspended = value;
}
public void setVariablesDirty() {
- for (DebugValue entry : valueCache.values())
- if (entry != null)
+ for (DebugValue entry : valueCache.values()) {
+ if (entry != null) {
entry.setDirty(true);
+ }
+ }
}
// ***************** Breakpoint handling, IBreakpointListener implementation
@@ -191,35 +193,38 @@ public class DebugTarget extends DebugElement implements IDebugTarget {
public void installDeferredBreakpoints() {
IBreakpoint[] breakpoints = DebugPlugin.getDefault().getBreakpointManager().getBreakpoints(
MWEBreakpoint.DEBUG_MODEL_ID);
- for (int i = 0; i < breakpoints.length; i++) {
- breakpointAdded(breakpoints[i]);
+ for (IBreakpoint element : breakpoints) {
+ breakpointAdded(element);
}
}
- public boolean supportsBreakpoint(IBreakpoint breakpoint) {
+ public boolean supportsBreakpoint(final IBreakpoint breakpoint) {
return breakpoint.getModelIdentifier().equals(MWEBreakpoint.DEBUG_MODEL_ID);
}
- public void breakpointAdded(IBreakpoint breakpoint) {
- if (supportsBreakpoint(breakpoint))
+ public void breakpointAdded(final IBreakpoint breakpoint) {
+ if (supportsBreakpoint(breakpoint)) {
try {
- if (breakpoint.isEnabled())
+ if (breakpoint.isEnabled()) {
dmm.requireSetBreakpoint((MWEBreakpoint) breakpoint);
+ }
} catch (CoreException e) {
// in case connection broke
}
+ }
}
- public void breakpointRemoved(IBreakpoint breakpoint, IMarkerDelta delta) {
- if (supportsBreakpoint(breakpoint))
+ public void breakpointRemoved(final IBreakpoint breakpoint, final IMarkerDelta delta) {
+ if (supportsBreakpoint(breakpoint)) {
try {
dmm.requireRemoveBreakpoint((MWEBreakpoint) breakpoint);
} catch (CoreException e) {
// in case connection broke
}
+ }
}
- public void breakpointChanged(IBreakpoint breakpoint, IMarkerDelta delta) {
+ public void breakpointChanged(final IBreakpoint breakpoint, final IMarkerDelta delta) {
if (supportsBreakpoint(breakpoint)) {
try {
if (breakpoint.isEnabled()) {
@@ -267,7 +272,7 @@ public class DebugTarget extends DebugElement implements IDebugTarget {
return false;
}
- public IMemoryBlock getMemoryBlock(long startAddress, long length) {
+ public IMemoryBlock getMemoryBlock(final long startAddress, final long length) {
return null;
}
diff --git a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/model/DebugThread.java b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/model/DebugThread.java
index 8689b45..9735e12 100644
--- a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/model/DebugThread.java
+++ b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/model/DebugThread.java
@@ -26,7 +26,7 @@ import org.eclipse.emf.mwe.core.debug.model.SyntaxElement;
*/
public class DebugThread extends DebugElement implements IThread {
- private Stack<DebugStackFrame> frames = new Stack<DebugStackFrame>();
+ private final Stack<DebugStackFrame> frames = new Stack<DebugStackFrame>();
private MWEBreakpoint bp;
@@ -35,7 +35,7 @@ public class DebugThread extends DebugElement implements IThread {
// id of last frame that was used to get variables from
private int varFrameId;
- public DebugThread(DebugTarget target) {
+ public DebugThread(final DebugTarget target) {
super(target);
}
@@ -51,8 +51,9 @@ public class DebugThread extends DebugElement implements IThread {
int size = frames.size();
for (int i = size - 1; i >= 0; i--) {
DebugStackFrame frame = frames.get(i);
- if (frame.isVisible())
+ if (frame.isVisible()) {
result.push(frame);
+ }
}
return result.toArray(new IStackFrame[0]);
}
@@ -70,7 +71,7 @@ public class DebugThread extends DebugElement implements IThread {
return frames.peek();
}
- public int getSetVarFrameId(DebugStackFrame frame) {
+ public int getSetVarFrameId(final DebugStackFrame frame) {
varFrameId = frame.getFrameId();
return varFrameId;
}
@@ -79,19 +80,22 @@ public class DebugThread extends DebugElement implements IThread {
return varFrameId;
}
- public void clearStack(int cleanStackLevel) {
- for (int i = frames.size(); i > cleanStackLevel; i--)
+ public void clearStack(final int cleanStackLevel) {
+ for (int i = frames.size(); i > cleanStackLevel; i--) {
frames.pop();
+ }
}
- public void pushStackFrames(List<SyntaxElement> list) {
- for (SyntaxElement se : list)
+ public void pushStackFrames(final List<SyntaxElement> list) {
+ for (SyntaxElement se : list) {
frames.push(new DebugStackFrame(this, se));
+ }
}
public void setVariablesDirty() {
- for (DebugStackFrame frame : frames)
+ for (DebugStackFrame frame : frames) {
frame.setVariablesDirty();
+ }
}
// ***************************************************** Breakpoint handling
@@ -105,7 +109,7 @@ public class DebugThread extends DebugElement implements IThread {
}
// a BP will be set by the DebugModelManager, when it is hit
- public void setBreakpoint(MWEBreakpoint bp) {
+ public void setBreakpoint(final MWEBreakpoint bp) {
this.bp = bp;
}
@@ -133,7 +137,7 @@ public class DebugThread extends DebugElement implements IThread {
return fStepping;
}
- public void setStepping(boolean stepping) {
+ public void setStepping(final boolean stepping) {
fStepping = stepping;
}
diff --git a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/model/DebugValue.java b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/model/DebugValue.java
index b9499af..ce89a7e 100644
--- a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/model/DebugValue.java
+++ b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/model/DebugValue.java
@@ -30,18 +30,18 @@ public class DebugValue extends DebugElement implements IValue {
private boolean dirty;
- private List<DebugVariable> variables = new ArrayList<DebugVariable>();
+ private final List<DebugVariable> variables = new ArrayList<DebugVariable>();
// -------------------------------------------------------------------------
- public DebugValue(DebugTarget target, VarValueTO varTO) {
+ public DebugValue(final DebugTarget target, final VarValueTO varTO) {
super(target);
this.varTO = varTO;
}
// -------------------------------------------------------------------------
- public void setVarTO(VarValueTO varTO) {
+ public void setVarTO(final VarValueTO varTO) {
this.varTO = varTO;
}
@@ -53,7 +53,7 @@ public class DebugValue extends DebugElement implements IValue {
return dirty;
}
- public void setDirty(boolean dirty) {
+ public void setDirty(final boolean dirty) {
this.dirty = dirty;
}
@@ -79,7 +79,7 @@ public class DebugValue extends DebugElement implements IValue {
}
public synchronized IVariable[] getVariables() throws DebugException {
- if (varTO.hasMembers && variables.isEmpty() || dirty) {
+ if ((varTO.hasMembers && variables.isEmpty()) || dirty) {
// require variable value information from runtime process for the first time and after one step
List<VarValueTO> vars = getDebugModelManager().requireSubVariables(varTO.valueId);
if (dirty) {
@@ -91,15 +91,16 @@ public class DebugValue extends DebugElement implements IValue {
for (DebugVariable var : variables) {
if (var.getName().equals(varTO.name)) {
varFound = true;
- if (varTO.valueId == 0)
+ if (varTO.valueId == 0) {
// update value for primitives
var.getValue0().setVarTO(varTO);
- else if (var.getValue0().getVarTOId() != varTO.valueId) {
+ } else if (var.getValue0().getVarTOId() != varTO.valueId) {
// update value information
var.setValue(varTO);
- } else
+ } else {
// still up2date
oldVars.remove(var);
+ }
break;
}
}
@@ -108,15 +109,17 @@ public class DebugValue extends DebugElement implements IValue {
variables.add(var);
}
}
- for (DebugVariable var : oldVars)
+ for (DebugVariable var : oldVars) {
// remove remaining obsolete vars
variables.remove(var);
- } else
+ }
+ } else {
// first time: create new variables
for (VarValueTO varTO : vars) {
DebugVariable var = new DebugVariable(getDebugTarget0(), varTO);
variables.add(var);
}
+ }
dirty = false;
VariableSorter.sort(variables);
diff --git a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/model/DebugVariable.java b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/model/DebugVariable.java
index 503ec7c..7fc54ef 100644
--- a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/model/DebugVariable.java
+++ b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/model/DebugVariable.java
@@ -21,11 +21,11 @@ import org.eclipse.emf.mwe.internal.core.debug.model.VarValueTO;
*/
public class DebugVariable extends DebugElement implements IVariable {
- private String name;
+ private final String name;
private DebugValue value;
- public DebugVariable(DebugTarget target, VarValueTO varTO) {
+ public DebugVariable(final DebugTarget target, final VarValueTO varTO) {
super(target);
name = varTO.name;
setValue(varTO);
@@ -43,18 +43,19 @@ public class DebugVariable extends DebugElement implements IVariable {
return value;
}
- public void setValue(VarValueTO varTO) {
+ public void setValue(final VarValueTO varTO) {
value = target.getDebugValue(varTO);
}
- public void setValue(String expression) {
+ public void setValue(final String expression) {
// not used (yet?)
// to be implemented if variable modification shall be established
}
- public void setValue(IValue value) {
- if (value instanceof DebugValue)
+ public void setValue(final IValue value) {
+ if (value instanceof DebugValue) {
this.value = (DebugValue) value;
+ }
}
public String getReferenceTypeName() {
@@ -71,11 +72,11 @@ public class DebugVariable extends DebugElement implements IVariable {
return false;
}
- public boolean verifyValue(String expression) {
+ public boolean verifyValue(final String expression) {
return true;
}
- public boolean verifyValue(IValue test) {
+ public boolean verifyValue(final IValue test) {
return true;
}
diff --git a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/model/MWEBreakpoint.java b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/model/MWEBreakpoint.java
index 452d1de..a336a1b 100644
--- a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/model/MWEBreakpoint.java
+++ b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/model/MWEBreakpoint.java
@@ -90,8 +90,8 @@ public class MWEBreakpoint extends LineBreakpoint {
return se;
}
- public boolean equals(int start, String resource) {
- return getOffset() == start && getResource().endsWith(resource);
+ public boolean equals(final int start, final String resource) {
+ return (getOffset() == start) && getResource().endsWith(resource);
}
private String getMarkerId() {
diff --git a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/model/ui/DebugModelPresentation.java b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/model/ui/DebugModelPresentation.java
index 609d412..666d65d 100644
--- a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/model/ui/DebugModelPresentation.java
+++ b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/model/ui/DebugModelPresentation.java
@@ -34,7 +34,7 @@ import org.eclipse.ui.part.FileEditorInput;
*/
public class DebugModelPresentation extends LabelProvider implements IDebugModelPresentation {
- public void setAttribute(String attribute, Object value) {
+ public void setAttribute(final String attribute, final Object value) {
// we don't set attributes in our debug model
}
@@ -42,12 +42,13 @@ public class DebugModelPresentation extends LabelProvider implements IDebugModel
// if we don't cover it here, the DefaultLabelProvider uses the default debug labels
// Hint: for ILaunch and IProcess the method is not called, so we don't have a chance to customize them
@Override
- public Image getImage(Object element) {
+ public Image getImage(final Object element) {
if (element instanceof DebugStackFrame) {
DebugStackFrame frame = (DebugStackFrame) element;
PluginAdapter adapter = PluginExtensionManager.getDefault().getAdapterByType(frame.getType());
- if (adapter != null)
+ if (adapter != null) {
return adapter.getIcon();
+ }
}
return null;
}
@@ -56,19 +57,20 @@ public class DebugModelPresentation extends LabelProvider implements IDebugModel
// Hint: we return null by intension, so that the DefaultLabelProvider calls getName() on the debug elements
// For breakpoints the default is too Java related, so we implement our own presentation.
@Override
- public String getText(Object element) {
- if (element instanceof MWEBreakpoint)
+ public String getText(final Object element) {
+ if (element instanceof MWEBreakpoint) {
return ((MWEBreakpoint) element).getName();
+ }
return null;
}
- public void computeDetail(IValue value, IValueDetailListener listener) {
+ public void computeDetail(final IValue value, final IValueDetailListener listener) {
String detail = ((DebugValue) value).getDetailRep();
listener.detailComputed(value, detail);
}
// called to get the right source editor input for a resource
- public IEditorInput getEditorInput(Object element) {
+ public IEditorInput getEditorInput(final Object element) {
if (element instanceof IFile) {
return new FileEditorInput((IFile) element);
}
@@ -83,16 +85,17 @@ public class DebugModelPresentation extends LabelProvider implements IDebugModel
}
// called at source editor display to show the source in the right editor type
- public String getEditorId(IEditorInput input, Object element) {
+ public String getEditorId(final IEditorInput input, final Object element) {
String ext = "";
- if ((element instanceof IFile || element instanceof ILineBreakpoint) && input instanceof IFileEditorInput) {
+ if (((element instanceof IFile) || (element instanceof ILineBreakpoint)) && (input instanceof IFileEditorInput)) {
ext = ((IFileEditorInput) input).getFile().getFileExtension();
- } else if (element instanceof IStorage && input instanceof JarEntryEditorInput) {
+ } else if ((element instanceof IStorage) && (input instanceof JarEntryEditorInput)) {
ext = ((JarEntryEditorInput) input).getContentType();
}
PluginAdapter adapter = PluginExtensionManager.getDefault().getAdapterByResourceExtension(ext);
- if (adapter != null)
+ if (adapter != null) {
return adapter.getEditorId();
+ }
return "org.eclipse.ui.DefaultTextEditor";
}
}
diff --git a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/model/ui/JarEntryEditorInput.java b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/model/ui/JarEntryEditorInput.java
index 8ebd8d2..12bea42 100644
--- a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/model/ui/JarEntryEditorInput.java
+++ b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/model/ui/JarEntryEditorInput.java
@@ -14,7 +14,7 @@ public class JarEntryEditorInput extends org.eclipse.jdt.internal.ui.javaeditor.
private IStorage fJarEntryFile;
- public JarEntryEditorInput(IStorage jarEntryFile) {
+ public JarEntryEditorInput(final IStorage jarEntryFile) {
super(jarEntryFile);
}
@@ -23,6 +23,7 @@ public class JarEntryEditorInput extends org.eclipse.jdt.internal.ui.javaeditor.
}
+ @Override
public String getToolTipText() {
//TODO: ER: add corresponding plugin to the text
// as it is for Files; This would be new, since it is also
@@ -30,6 +31,7 @@ public class JarEntryEditorInput extends org.eclipse.jdt.internal.ui.javaeditor.
return fJarEntryFile.getFullPath().makeRelative().toString();
}
+ @Override
public ImageDescriptor getImageDescriptor() {
IEditorRegistry registry = PlatformUI.getWorkbench()
.getEditorRegistry();
@@ -37,8 +39,9 @@ public class JarEntryEditorInput extends org.eclipse.jdt.internal.ui.javaeditor.
.getFileExtension());
}
+ @Override
@SuppressWarnings("unchecked")
- public Object getAdapter(Class adapter) {
+ public Object getAdapter(final Class adapter) {
if (adapter == IStorage.class) {
return fJarEntryFile;
}
diff --git a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/model/ui/VariableSorter.java b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/model/ui/VariableSorter.java
index 2dc3a54..dc27039 100644
--- a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/model/ui/VariableSorter.java
+++ b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/model/ui/VariableSorter.java
@@ -23,16 +23,17 @@ public class VariableSorter {
static VarComparator inst;
- public static void sort(List<DebugVariable> variables) {
- if (inst == null)
+ public static void sort(final List<DebugVariable> variables) {
+ if (inst == null) {
inst = new VariableSorter().new VarComparator();
+ }
Collections.sort(variables, inst);
}
class VarComparator implements java.util.Comparator<DebugVariable> {
// we assume names exist and are not empty, -> is not checked here (Problem?)
- public int compare(DebugVariable o1, DebugVariable o2) {
+ public int compare(final DebugVariable o1, final DebugVariable o2) {
return o1.getName().compareTo(o2.getName());
}
}
diff --git a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/processing/DebugModelManager.java b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/processing/DebugModelManager.java
index 078dc79..efc6798 100644
--- a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/processing/DebugModelManager.java
+++ b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/processing/DebugModelManager.java
@@ -33,7 +33,7 @@ import org.eclipse.emf.mwe.internal.ui.workflow.Activator;
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
public class DebugModelManager implements IDebugEventSetListener {
- private DebugTarget target;
+ private final DebugTarget target;
private PluginExtensionManager extensionManager;
@@ -43,7 +43,7 @@ public class DebugModelManager implements IDebugEventSetListener {
private BreakpointPluginHandler bpHandler;
- public static DebugModelManager newDebugModelManager(DebugTarget target, Connection connection)
+ public static DebugModelManager newDebugModelManager(final DebugTarget target, final Connection connection)
throws DebugException {
DebugModelManager dmm = new DebugModelManager(target);
dmm.extensionManager = PluginExtensionManager.getDefault();
@@ -51,27 +51,27 @@ public class DebugModelManager implements IDebugEventSetListener {
return dmm;
}
- private DebugModelManager(DebugTarget target) {
+ private DebugModelManager(final DebugTarget target) {
this.target = target;
DebugPlugin.getDefault().addDebugEventListener(this);
}
// -------------------------------------------------------------------------
- public void setCmdHandler(CommandPluginHandler cmdHandler) {
+ public void setCmdHandler(final CommandPluginHandler cmdHandler) {
this.cmdHandler = cmdHandler;
}
- public void setVariablesHandler(VariablesPluginHandler varHandler) {
+ public void setVariablesHandler(final VariablesPluginHandler varHandler) {
this.varHandler = varHandler;
}
- public void setBreakpointHandler(BreakpointPluginHandler bpHandler) {
+ public void setBreakpointHandler(final BreakpointPluginHandler bpHandler) {
this.bpHandler = bpHandler;
}
public boolean hasRequiredHandlers() {
- return cmdHandler != null && varHandler != null && bpHandler != null;
+ return (cmdHandler != null) && (varHandler != null) && (bpHandler != null);
}
// -------------------------------------------------------------------------
@@ -87,14 +87,15 @@ public class DebugModelManager implements IDebugEventSetListener {
// ********************************************************** event handling
public void debuggerStarted() throws DebugException {
- if (shallStopInMain())
+ if (shallStopInMain()) {
cmdHandler.sendSuspendCommand();
+ }
target.setSuspended(false);
target.installDeferredBreakpoints();
fireCreationEvent();
}
- public void adaptStackFrames(int cleanStackLevel, List<SyntaxElement> frames) {
+ public void adaptStackFrames(final int cleanStackLevel, final List<SyntaxElement> frames) {
getThread().clearStack(cleanStackLevel);
getThread().pushStackFrames(frames);
target.setVariablesDirty();
@@ -139,9 +140,8 @@ public class DebugModelManager implements IDebugEventSetListener {
*
* @see org.eclipse.debug.core.IDebugEventSetListener#handleDebugEvents(org.eclipse.debug.core.DebugEvent[])
*/
- public void handleDebugEvents(DebugEvent[] events) {
- for (int i = 0; i < events.length; i++) {
- DebugEvent event = events[i];
+ public void handleDebugEvents(final DebugEvent[] events) {
+ for (DebugEvent event : events) {
if (event.getKind() == DebugEvent.TERMINATE) {
DebugPlugin.getDefault().removeDebugEventListener(this);
DebugPlugin.getDefault().getBreakpointManager().removeBreakpointListener(target);
@@ -206,7 +206,7 @@ public class DebugModelManager implements IDebugEventSetListener {
// -------------------------------------------------------------------------
- public List<VarValueTO> requireVariables(int frameId) throws DebugException {
+ public List<VarValueTO> requireVariables(final int frameId) throws DebugException {
try {
List<VarValueTO> vars = varHandler.sendRequireVariables(frameId);
target.updateDebugValues(vars);
@@ -220,7 +220,7 @@ public class DebugModelManager implements IDebugEventSetListener {
// we send the frame id and the var id; the frame id is used to get the correct adapter
// example: an object could occur in a workflow slot (which is handled by the workflow adapter
// later in the execution context the string representation may be rendered differently by another adapter
- public List<VarValueTO> requireSubVariables(int varId) throws DebugException {
+ public List<VarValueTO> requireSubVariables(final int varId) throws DebugException {
int frameId = target.getThread().getVarFrameId();
try {
List<VarValueTO> vars = varHandler.sendRequireSubVariables(frameId, varId);
@@ -232,7 +232,7 @@ public class DebugModelManager implements IDebugEventSetListener {
}
}
- public void requireSetBreakpoint(MWEBreakpoint bp) throws DebugException {
+ public void requireSetBreakpoint(final MWEBreakpoint bp) throws DebugException {
try {
bpHandler.sendSetBreakpoint(bp);
} catch (IOException e) {
@@ -240,7 +240,7 @@ public class DebugModelManager implements IDebugEventSetListener {
}
}
- public void requireRemoveBreakpoint(MWEBreakpoint bp) throws DebugException {
+ public void requireRemoveBreakpoint(final MWEBreakpoint bp) throws DebugException {
try {
bpHandler.sendRemoveBreakpoint(bp);
} catch (IOException e) {
@@ -248,7 +248,7 @@ public class DebugModelManager implements IDebugEventSetListener {
}
}
- public void handleIOProblem(Exception e) throws DebugException {
+ public void handleIOProblem(final Exception e) throws DebugException {
throw new DebugException(Activator.createErrorStatus(
"lost connection to debugger runtime process --> aborting", e));
}
@@ -259,11 +259,11 @@ public class DebugModelManager implements IDebugEventSetListener {
fireEvent(new DebugEvent(target, DebugEvent.CREATE));
}
- private void fireResumeEvent(int detail) {
+ private void fireResumeEvent(final int detail) {
fireEvent(new DebugEvent(getThread(), DebugEvent.RESUME, detail));
}
- private void fireSuspendEvent(int detail) {
+ private void fireSuspendEvent(final int detail) {
fireEvent(new DebugEvent(getThread(), DebugEvent.SUSPEND, detail));
}
@@ -271,7 +271,7 @@ public class DebugModelManager implements IDebugEventSetListener {
fireEvent(new DebugEvent(target, DebugEvent.TERMINATE));
}
- private void fireEvent(DebugEvent event) {
+ private void fireEvent(final DebugEvent event) {
DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] { event });
}
diff --git a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/processing/PluginExtensionManager.java b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/processing/PluginExtensionManager.java
index d5b1319..14de55b 100644
--- a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/processing/PluginExtensionManager.java
+++ b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/processing/PluginExtensionManager.java
@@ -42,7 +42,7 @@ public class PluginExtensionManager {
private static PluginExtensionManager singleton;
- private Set<PluginAdapter> pluginAdapters = new HashSet<PluginAdapter>();
+ private final Set<PluginAdapter> pluginAdapters = new HashSet<PluginAdapter>();
private boolean missingAdapterReported;
@@ -53,8 +53,9 @@ public class PluginExtensionManager {
// -------------------------------------------------------------------------
public static PluginExtensionManager getDefault() {
- if (singleton == null)
+ if (singleton == null) {
singleton = new PluginExtensionManager();
+ }
return singleton;
}
@@ -64,7 +65,7 @@ public class PluginExtensionManager {
// -------------------------------------------------------------------------
- public void init(DebugModelManager dmm, Connection connection) throws DebugException {
+ public void init(final DebugModelManager dmm, final Connection connection) throws DebugException {
this.dmm = dmm;
this.connection = connection;
try {
@@ -78,10 +79,12 @@ public class PluginExtensionManager {
// -------------------------------------------------------------------------
- public PluginAdapter getAdapterByResourceExtension(String ext) {
- for (PluginAdapter adapter : pluginAdapters)
- if (adapter.canHandleResourceExtension(ext))
+ public PluginAdapter getAdapterByResourceExtension(final String ext) {
+ for (PluginAdapter adapter : pluginAdapters) {
+ if (adapter.canHandleResourceExtension(ext)) {
return adapter;
+ }
+ }
if (!missingAdapterReported) {
String msg = "Warning: Debug system initialization problem.\nDidn't find a plugin adapter for the file extension: '"
+ ext + "'";
@@ -92,10 +95,12 @@ public class PluginExtensionManager {
return null;
}
- public PluginAdapter getAdapterByType(String type) {
- for (PluginAdapter adapter : pluginAdapters)
- if (adapter.canHandleType(type))
+ public PluginAdapter getAdapterByType(final String type) {
+ for (PluginAdapter adapter : pluginAdapters) {
+ if (adapter.canHandleType(type)) {
return adapter;
+ }
+ }
if (!missingAdapterReported) {
String msg = "Warning: Debug system initialization problem.\nDidn't find a plugin adapter for type: '"
+ type + "'";
@@ -136,26 +141,29 @@ public class PluginExtensionManager {
if (elem.getName().equals("handler")) {
String className = elem.getAttribute("runtimeClass");
- if (className != null)
+ if (className != null) {
packet.classNames.add(className);
+ }
PluginHandler handler = null;
className = elem.getAttribute("pluginClass");
- if (className != null)
+ if (className != null) {
try {
handler = (PluginHandler) elem.createExecutableExtension("pluginClass");
} catch (CoreException e) {
Activator.logError("Internal configuration error.\nCouldn't instantiate "
+ elem.getAttribute("pluginClass"), e);
}
+ }
if (handler != null) {
handler.setConnection(connection);
- if ("variablesHandler".equals(elem.getAttribute("type")))
+ if ("variablesHandler".equals(elem.getAttribute("type"))) {
dmm.setVariablesHandler((VariablesPluginHandler) handler);
- else if ("breakpointHandler".equals(elem.getAttribute("type")))
+ } else if ("breakpointHandler".equals(elem.getAttribute("type"))) {
dmm.setBreakpointHandler((BreakpointPluginHandler) handler);
- else
+ } else {
handler.setDebugModelManager(dmm);
+ }
}
}
}
@@ -175,12 +183,14 @@ public class PluginExtensionManager {
IExtensionRegistry reg = Platform.getExtensionRegistry();
IConfigurationElement[] elems = reg
.getConfigurationElementsFor("org.eclipse.emf.mwe.ui.debugAdapters");
- for (IConfigurationElement elem : elems)
+ for (IConfigurationElement elem : elems) {
if (elem.getName().equals("adapter")) {
String className = elem.getAttribute("runtimeClass");
- if (className != null)
+ if (className != null) {
packet.classNames.add(className);
+ }
}
+ }
connection.sendPacket(packet);
}
@@ -193,15 +203,17 @@ public class PluginExtensionManager {
if (elem.getName().equals("adapter")) {
PluginAdapter adapter = null;
String className = elem.getAttribute("pluginClass");
- if (className != null)
+ if (className != null) {
try {
adapter = (PluginAdapter) elem.createExecutableExtension("pluginClass");
} catch (CoreException e) {
Activator.logError("Internal configuration error.\nCouldn't instantiate "
+ elem.getAttribute("pluginClass"), e);
}
- if (adapter != null)
+ }
+ if (adapter != null) {
pluginAdapters.add(adapter);
+ }
}
}
}
diff --git a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/processing/handlers/BreakpointPluginHandler.java b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/processing/handlers/BreakpointPluginHandler.java
index d389ff5..b21750c 100644
--- a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/processing/handlers/BreakpointPluginHandler.java
+++ b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/processing/handlers/BreakpointPluginHandler.java
@@ -30,21 +30,21 @@ public class BreakpointPluginHandler implements PluginHandler {
// -------------------------------------------------------------------------
- public void setConnection(Connection connection) {
+ public void setConnection(final Connection connection) {
this.connection = connection;
}
- public void setDebugModelManager(DebugModelManager dmm) {
+ public void setDebugModelManager(final DebugModelManager dmm) {
// don't need it
}
// -------------------------------------------------------------------------
- public void sendSetBreakpoint(MWEBreakpoint bp) throws IOException {
+ public void sendSetBreakpoint(final MWEBreakpoint bp) throws IOException {
connection.sendPacket(new BreakpointPacket(SET, bp.createTO()));
}
- public void sendRemoveBreakpoint(MWEBreakpoint bp) throws IOException {
+ public void sendRemoveBreakpoint(final MWEBreakpoint bp) throws IOException {
connection.sendPacket(new BreakpointPacket(REMOVE, bp.createTO()));
}
diff --git a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/processing/handlers/CommandPluginHandler.java b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/processing/handlers/CommandPluginHandler.java
index 5bf904f..ff59826 100644
--- a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/processing/handlers/CommandPluginHandler.java
+++ b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/processing/handlers/CommandPluginHandler.java
@@ -33,7 +33,7 @@ public class CommandPluginHandler {
// -------------------------------------------------------------------------
- public void setConnection(Connection connection) {
+ public void setConnection(final Connection connection) {
this.connection = connection;
}
@@ -65,7 +65,7 @@ public class CommandPluginHandler {
// -------------------------------------------------------------------------
- private void sendCommand(int type) throws DebugException {
+ private void sendCommand(final int type) throws DebugException {
try {
connection.sendPacket(new CommandPacket(type));
} catch (IOException e) {
diff --git a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/processing/handlers/EventPluginHandler.java b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/processing/handlers/EventPluginHandler.java
index c733090..c1099a4 100644
--- a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/processing/handlers/EventPluginHandler.java
+++ b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/processing/handlers/EventPluginHandler.java
@@ -37,7 +37,7 @@ public class EventPluginHandler implements Runnable {
private DebugModelManager dmm;
- private Class<? extends AbstractPacket> typeToListen = EventPacket.class;
+ private final Class<? extends AbstractPacket> typeToListen = EventPacket.class;
// -------------------------------------------------------------------------
@@ -46,7 +46,7 @@ public class EventPluginHandler implements Runnable {
// -------------------------------------------------------------------------
- public void setDmm(DebugModelManager dmm) {
+ public void setDmm(final DebugModelManager dmm) {
this.dmm = dmm;
}
@@ -54,7 +54,7 @@ public class EventPluginHandler implements Runnable {
return typeToListen;
}
- public void setConnection(Connection connection) {
+ public void setConnection(final Connection connection) {
this.connection = connection;
}
@@ -68,14 +68,15 @@ public class EventPluginHandler implements Runnable {
public void run() {
try {
- while (true)
+ while (true) {
dispatch((EventPacket) connection.listenForPacket(typeToListen));
+ }
} catch (Exception e) {
connection.close();
}
}
- private void dispatch(EventPacket packet) throws DebugException {
+ private void dispatch(final EventPacket packet) throws DebugException {
dmm.getThread().setBreakpoint(null);
switch (packet.event) {
@@ -106,7 +107,7 @@ public class EventPluginHandler implements Runnable {
}
}
- private void adaptStackFrames(EventPacket sp) {
+ private void adaptStackFrames(final EventPacket sp) {
EventPacketWithFrames packet = (EventPacketWithFrames) sp;
dmm.adaptStackFrames(packet.cleanStackLevel, packet.frames);
}
diff --git a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/processing/handlers/VariablesPluginHandler.java b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/processing/handlers/VariablesPluginHandler.java
index 8a14f13..818140b 100644
--- a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/processing/handlers/VariablesPluginHandler.java
+++ b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/processing/handlers/VariablesPluginHandler.java
@@ -29,23 +29,23 @@ public class VariablesPluginHandler implements PluginHandler {
// -------------------------------------------------------------------------
- public void setConnection(Connection connection) {
+ public void setConnection(final Connection connection) {
this.connection = connection;
}
- public void setDebugModelManager(DebugModelManager dmm) {
+ public void setDebugModelManager(final DebugModelManager dmm) {
// don't need it
}
// -------------------------------------------------------------------------
- public List<VarValueTO> sendRequireVariables(int frameId) throws IOException {
+ public List<VarValueTO> sendRequireVariables(final int frameId) throws IOException {
RequireVarPacket packet = new RequireVarPacket(frameId, 0);
int refId = connection.sendPacket(packet);
return ((VarDataPacket) connection.listenForPacket(VarDataPacket.class, refId)).valueList;
}
- public List<VarValueTO> sendRequireSubVariables(int frameId, int varId) throws IOException {
+ public List<VarValueTO> sendRequireSubVariables(final int frameId, final int varId) throws IOException {
RequireVarPacket packet = new RequireVarPacket(frameId, varId);
int refId = connection.sendPacket(packet);
return ((VarDataPacket) connection.listenForPacket(VarDataPacket.class, refId)).valueList;
diff --git a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/sourcelookup/MWESourceLookupParticipant.java b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/sourcelookup/MWESourceLookupParticipant.java
index 50c4d99..fd78c67 100644
--- a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/sourcelookup/MWESourceLookupParticipant.java
+++ b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/sourcelookup/MWESourceLookupParticipant.java
@@ -19,7 +19,7 @@ import org.eclipse.emf.mwe.internal.ui.debug.model.DebugStackFrame;
*/
public class MWESourceLookupParticipant extends AbstractSourceLookupParticipant {
- public String getSourceName(Object object) throws CoreException {
+ public String getSourceName(final Object object) throws CoreException {
if (object instanceof DebugStackFrame) {
return ((DebugStackFrame) object).getResource();
}
diff --git a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/sourcelookup/MWESourcePathComputerDelegate.java b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/sourcelookup/MWESourcePathComputerDelegate.java
index be0e397..9a30d2e 100644
--- a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/sourcelookup/MWESourcePathComputerDelegate.java
+++ b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/sourcelookup/MWESourcePathComputerDelegate.java
@@ -23,7 +23,7 @@ public class MWESourcePathComputerDelegate implements ISourcePathComputerDelegat
* returns all SourceContainer corresponding to the entries as defined in the base project of the launch
* configuration. The classpath resolving process is used from JavaRuntime, but we use our own container creator
*/
- public ISourceContainer[] computeSourceContainers(ILaunchConfiguration configuration, IProgressMonitor monitor)
+ public ISourceContainer[] computeSourceContainers(final ILaunchConfiguration configuration, final IProgressMonitor monitor)
throws CoreException {
IRuntimeClasspathEntry[] entries = JavaRuntime.computeUnresolvedSourceLookupPath(configuration);
IRuntimeClasspathEntry[] resolved = JavaRuntime.resolveSourceLookupPath(entries, configuration);
diff --git a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/sourcelookup/PackageFragmentRootContainer.java b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/sourcelookup/PackageFragmentRootContainer.java
index 5e48841..6664b3c 100644
--- a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/sourcelookup/PackageFragmentRootContainer.java
+++ b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/sourcelookup/PackageFragmentRootContainer.java
@@ -26,15 +26,15 @@ import org.eclipse.jdt.core.IPackageFragmentRoot;
*/
public class PackageFragmentRootContainer extends AbstractSourceContainer {
- private IPackageFragmentRoot fRoot;
+ private final IPackageFragmentRoot fRoot;
public static final String TYPE_ID = Activator.PLUGIN_ID + ".packageFragmentRootContainer";
- public PackageFragmentRootContainer(IPackageFragmentRoot root) {
+ public PackageFragmentRootContainer(final IPackageFragmentRoot root) {
fRoot = root;
}
- public Object[] findSourceElements(String name) throws CoreException {
+ public Object[] findSourceElements(final String name) throws CoreException {
int index = name.lastIndexOf('.');
String typeName = name;
String suffix = "";
@@ -58,8 +58,9 @@ public class PackageFragmentRootContainer extends AbstractSourceContainer {
for (Object resource : resources) {
if (resource instanceof IStorage) {
IStorage storage = (IStorage) resource;
- if (elementName.equals(storage.getName()))
+ if (elementName.equals(storage.getName())) {
return new Object[] { resource };
+ }
}
}
}
@@ -76,7 +77,7 @@ public class PackageFragmentRootContainer extends AbstractSourceContainer {
@Override
public boolean equals(final Object obj) {
- return obj instanceof PackageFragmentRootContainer
+ return (obj instanceof PackageFragmentRootContainer)
&& ((PackageFragmentRootContainer) obj)
.getPackageFragmentRoot().equals(
getPackageFragmentRoot());
diff --git a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/sourcelookup/SourceFolderSourceContainer.java b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/sourcelookup/SourceFolderSourceContainer.java
index 81a5215..2f98eb7 100644
--- a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/sourcelookup/SourceFolderSourceContainer.java
+++ b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/sourcelookup/SourceFolderSourceContainer.java
@@ -36,16 +36,17 @@ import org.eclipse.jdt.launching.sourcelookup.containers.JavaProjectSourceContai
public class SourceFolderSourceContainer extends CompositeSourceContainer {
// Java project
- private IJavaProject fProject;
+ private final IJavaProject fProject;
// Source folders
private ISourceContainer[] fSourceFolders;
public static final String TYPE_ID = Activator.PLUGIN_ID + ".sourceFolderSourceContainer";
- public SourceFolderSourceContainer(IJavaProject project) {
- if (project == null)
+ public SourceFolderSourceContainer(final IJavaProject project) {
+ if (project == null) {
throw new IllegalArgumentException();
+ }
fProject = project;
}
@@ -67,8 +68,7 @@ public class SourceFolderSourceContainer extends CompositeSourceContainer {
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
if (fProject.getProject().isOpen()) {
IClasspathEntry[] entries = fProject.getRawClasspath();
- for (int i = 0; i < entries.length; i++) {
- IClasspathEntry entry = entries[i];
+ for (IClasspathEntry entry : entries) {
switch (entry.getEntryKind()) {
case IClasspathEntry.CPE_SOURCE:
IPath path = entry.getPath();
@@ -99,7 +99,7 @@ public class SourceFolderSourceContainer extends CompositeSourceContainer {
}
@Override
- public Object[] findSourceElements(String name) throws CoreException {
+ public Object[] findSourceElements(final String name) throws CoreException {
// force container initialization
getSourceContainers();
return findSourceElements(name, fSourceFolders);
diff --git a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/sourcelookup/SourceLookupUtil.java b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/sourcelookup/SourceLookupUtil.java
index 671f8ac..0f0c6ad 100644
--- a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/sourcelookup/SourceLookupUtil.java
+++ b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/debug/sourcelookup/SourceLookupUtil.java
@@ -45,7 +45,7 @@ public class SourceLookupUtil {
/**
* Translates the given runtime classpath entries into associated source containers.
*/
- public static ISourceContainer[] translate(IRuntimeClasspathEntry[] entries) {
+ public static ISourceContainer[] translate(final IRuntimeClasspathEntry[] entries) {
List<ISourceContainer> containers = new ArrayList<ISourceContainer>(entries.length);
for (IRuntimeClasspathEntry entry : entries) {
ISourceContainer container = null;
@@ -57,38 +57,41 @@ public class SourceLookupUtil {
File file = new File(path);
if (file.isDirectory()) {
IResource resource = entry.getResource();
- if (resource instanceof IContainer)
+ if (resource instanceof IContainer) {
container = new FolderSourceContainer((IContainer) resource, false);
- else
+ } else {
container = new DirectorySourceContainer(file, false);
- } else
+ }
+ } else {
container = new ExternalArchiveSourceContainer(path, true);
+ }
} else {
container = new PackageFragmentRootContainer(root);
}
break;
case IRuntimeClasspathEntry.PROJECT:
IResource resource = entry.getResource();
- if (resource != null && resource.getType() == IResource.PROJECT) {
+ if ((resource != null) && (resource.getType() == IResource.PROJECT)) {
IJavaProject javaProject = JavaCore.create((IProject) resource);
- if (javaProject.exists())
+ if (javaProject.exists()) {
container = new SourceFolderSourceContainer(javaProject);
- else if (resource.exists())
+ } else if (resource.exists()) {
container = new ProjectSourceContainer((IProject) resource, false);
+ }
}
break;
default:
// no other classpath types are valid in a resolved path
break;
}
- if (container != null && !containers.contains(container)) {
+ if ((container != null) && !containers.contains(container)) {
containers.add(container);
}
}
return containers.toArray(new ISourceContainer[containers.size()]);
}
- private static IPackageFragmentRoot getPackageFragmentRoot(IRuntimeClasspathEntry entry) {
+ private static IPackageFragmentRoot getPackageFragmentRoot(final IRuntimeClasspathEntry entry) {
IResource resource = entry.getResource();
if (resource != null) {
@@ -101,17 +104,21 @@ public class SourceLookupUtil {
}
}
- if (model == null)
+ if (model == null) {
model = JavaCore.create(ResourcesPlugin.getWorkspace().getRoot());
+ }
// ... or external jars, that are registered in one of the open projects at runtime
IPath reqPath = (resource == null ? new Path(entry.getLocation()) : entry.getPath());
try {
for (IJavaProject jp : model.getJavaProjects()) {
- if (jp.getProject().isOpen())
- for (IPackageFragmentRoot root : jp.getPackageFragmentRoots())
- if (root.isExternal() && root.getPath().equals(reqPath))
+ if (jp.getProject().isOpen()) {
+ for (IPackageFragmentRoot root : jp.getPackageFragmentRoots()) {
+ if (root.isExternal() && root.getPath().equals(reqPath)) {
return root;
+ }
+ }
+ }
}
} catch (JavaModelException e) {
Activator.logError(e); // should not occur
diff --git a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/eclipse/launch/MWEDebuggerLauncher.java b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/eclipse/launch/MWEDebuggerLauncher.java
index 5702b6e..902c402 100644
--- a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/eclipse/launch/MWEDebuggerLauncher.java
+++ b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/eclipse/launch/MWEDebuggerLauncher.java
@@ -39,9 +39,9 @@ import org.eclipse.jdt.launching.VMRunnerConfiguration;
*
*/
public class MWEDebuggerLauncher extends AbstractVMRunner {
- private IVMInstall vm;
+ private final IVMInstall vm;
- public MWEDebuggerLauncher(IVMInstall vmInstance) {
+ public MWEDebuggerLauncher(final IVMInstall vmInstance) {
vm = vmInstance;
}
@@ -51,7 +51,7 @@ public class MWEDebuggerLauncher extends AbstractVMRunner {
}
@SuppressWarnings("null")
- public void run(VMRunnerConfiguration config, ILaunch launch, IProgressMonitor monitor) throws CoreException {
+ public void run(final VMRunnerConfiguration config, final ILaunch launch, final IProgressMonitor monitor) throws CoreException {
// port for communication between runtime VM and Eclipse
int commPort = SocketUtil.findFreePort();
@@ -97,8 +97,9 @@ public class MWEDebuggerLauncher extends AbstractVMRunner {
runnable.cancel();
}
try {
- if (p.exitValue() != 0)
+ if (p.exitValue() != 0) {
runnable.cancel();
+ }
} catch (IllegalThreadStateException e) {
// occurs in normal process (p is still running)
}
@@ -108,31 +109,35 @@ public class MWEDebuggerLauncher extends AbstractVMRunner {
}
}
Exception e = runnable.getException();
- if (e != null || process.isTerminated()) {
- if (runnable.isRunning())
+ if ((e != null) || process.isTerminated()) {
+ if (runnable.isRunning()) {
runnable.cancel();
+ }
throw new DebugException(Activator.createErrorStatus(
"Debugger runtime process didn't respond properly --> aborting", null));
}
DebugTarget.newDebugTarget(launch, process, connection);
} catch (CoreException e) {
- if (p != null)
+ if (p != null) {
p.destroy();
+ }
connection.close();
throw e;
}
}
- private String[] renderCommandLine(VMRunnerConfiguration config, int commPort) throws CoreException {
+ private String[] renderCommandLine(final VMRunnerConfiguration config, final int commPort) throws CoreException {
// program string
List<String> arguments = new ArrayList<String>();
arguments.add(findJavaExecutable());
// VM arguments
String[] vmArgs = config.getVMArguments();
- if (vmArgs != null)
- for (int i = 0; i < vmArgs.length; i++)
- arguments.add(vmArgs[i]);
+ if (vmArgs != null) {
+ for (String element : vmArgs) {
+ arguments.add(element);
+ }
+ }
// classpath
String[] cp = config.getClassPath();
@@ -152,8 +157,9 @@ public class MWEDebuggerLauncher extends AbstractVMRunner {
// programArgs
String[] progArgs = config.getProgramArguments();
- for (int i = 0; i < progArgs.length; i++)
- arguments.add(progArgs[i]);
+ for (String element : progArgs) {
+ arguments.add(element);
+ }
arguments.add("" + commPort);
@@ -171,8 +177,8 @@ public class MWEDebuggerLauncher extends AbstractVMRunner {
"bin" + fgSeparator + "java.exe", "jre" + fgSeparator + "bin" + fgSeparator + "java",
"jre" + fgSeparator + "bin" + fgSeparator + "java.exe" };
File vmInstallLocation = vm.getInstallLocation();
- for (int i = 0; i < fgCandidateJavaLocations.length; i++) {
- File javaFile = new File(vmInstallLocation, fgCandidateJavaLocations[i]);
+ for (String element : fgCandidateJavaLocations) {
+ File javaFile = new File(vmInstallLocation, element);
if (javaFile.isFile()) {
return javaFile.getAbsolutePath();
}
@@ -181,7 +187,7 @@ public class MWEDebuggerLauncher extends AbstractVMRunner {
+ " --> aborting", null));
}
- private static String renderProcessLabel(String command) {
+ private static String renderProcessLabel(final String command) {
String timestamp = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM).format(
new Date(System.currentTimeMillis()));
return command + " (" + timestamp + ")";
@@ -189,7 +195,7 @@ public class MWEDebuggerLauncher extends AbstractVMRunner {
/** ************************************************************************* */
- private ConnectRunnable startListeningThread(Connection connector) {
+ private ConnectRunnable startListeningThread(final Connection connector) {
ConnectRunnable runnable = new ConnectRunnable(connector);
Thread connectThread = new Thread(runnable, "Listening Connector");
runnable.setThread(connectThread);
@@ -205,7 +211,7 @@ public class MWEDebuggerLauncher extends AbstractVMRunner {
private Thread thread = null;
- public ConnectRunnable(Connection connector) {
+ public ConnectRunnable(final Connection connector) {
fConnector = connector;
}
@@ -226,7 +232,7 @@ public class MWEDebuggerLauncher extends AbstractVMRunner {
return fException;
}
- public void setThread(Thread thread) {
+ public void setThread(final Thread thread) {
this.thread = thread;
}
diff --git a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/eclipse/launch/MWELaunchDelegate.java b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/eclipse/launch/MWELaunchDelegate.java
index d72794a..ab614d8 100644
--- a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/eclipse/launch/MWELaunchDelegate.java
+++ b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/eclipse/launch/MWELaunchDelegate.java
@@ -50,11 +50,12 @@ public class MWELaunchDelegate extends AbstractJavaLaunchConfigurationDelegate {
private String wfFileName;
- public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor)
+ public void launch(final ILaunchConfiguration configuration, final String mode, final ILaunch launch, final IProgressMonitor monitor)
throws CoreException {
- if (monitor.isCanceled())
+ if (monitor.isCanceled()) {
return;
+ }
monitor.beginTask("Launching VM...", 3);
monitor.worked(1);
@@ -71,8 +72,9 @@ public class MWELaunchDelegate extends AbstractJavaLaunchConfigurationDelegate {
// add abs. path because ResourceListSelectionDialog creates it relative
// to the WS-root
- if (wfFileName.startsWith("/"))
+ if (wfFileName.startsWith("/")) {
wfFileName = file.getLocation().toString();
+ }
// check if file exist
if (!file.exists()) {
@@ -113,7 +115,7 @@ public class MWELaunchDelegate extends AbstractJavaLaunchConfigurationDelegate {
do {
autoBuildJobs = Job.getJobManager().find(ResourcesPlugin.FAMILY_AUTO_BUILD);
manBuildJobs = Job.getJobManager().find(ResourcesPlugin.FAMILY_MANUAL_BUILD);
- } while (autoBuildJobs.length > 0 || manBuildJobs.length > 0);
+ } while ((autoBuildJobs.length > 0) || (manBuildJobs.length > 0));
getLaunchManager().removeLaunch(launch);
@@ -165,13 +167,12 @@ public class MWELaunchDelegate extends AbstractJavaLaunchConfigurationDelegate {
* @see org.eclipse.jdt.launching.AbstractJavaLaunchConfigurationDelegate#handleDebugEvents(org.eclipse.debug.core.DebugEvent[])
*/
@Override
- public void handleDebugEvents(DebugEvent[] events) {
- for (int i = 0; i < events.length; i++) {
- DebugEvent event = events[i];
+ public void handleDebugEvents(final DebugEvent[] events) {
+ for (DebugEvent event : events) {
if (event.getKind() == DebugEvent.TERMINATE) {
new Job("refresh resources") {
@Override
- protected IStatus run(IProgressMonitor monitor) {
+ protected IStatus run(final IProgressMonitor monitor) {
try {
ResourcesPlugin.getWorkspace().getRoot().refreshLocal(IResource.DEPTH_INFINITE,
monitor);
diff --git a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/eclipse/launch/MWELaunchShortcut.java b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/eclipse/launch/MWELaunchShortcut.java
index 84a11c7..5cca5f3 100644
--- a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/eclipse/launch/MWELaunchShortcut.java
+++ b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/eclipse/launch/MWELaunchShortcut.java
@@ -52,7 +52,7 @@ public class MWELaunchShortcut implements ILaunchShortcut {
private IFile currFile;
- private ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
+ private final ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
public void launch(final ISelection selection, final String mode) {
if (selection instanceof IStructuredSelection) {
@@ -85,13 +85,15 @@ public class MWELaunchShortcut implements ILaunchShortcut {
ILaunchConfiguration config = null;
try {
configs = launchManager.getLaunchConfigurations();
- for (ILaunchConfiguration configuration : configs)
+ for (ILaunchConfiguration configuration : configs) {
if (info.configEquals(configuration)) {
config = configuration;
break;
}
- if (config == null)
+ }
+ if (config == null) {
config = createConfiguration(info);
+ }
DebugUITools.launch(config, mode);
currFile.getProject().refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
} catch (CoreException e) {
@@ -102,13 +104,14 @@ public class MWELaunchShortcut implements ILaunchShortcut {
}
private void locateWfRunner(final IResource resource) throws CoreException {
- if (!checkClasspathEntries(resource, WorkflowRunner.class.getName()))
+ if (!checkClasspathEntries(resource, WorkflowRunner.class.getName())) {
throw new DebugException(Activator.createErrorStatus(
"Can't execute.\n MWE release jars are required in the project's classpath! --> aborting",
null));
+ }
}
- private boolean checkClasspathEntries(final IResource resource, String classNameToFind) throws CoreException {
+ private boolean checkClasspathEntries(final IResource resource, final String classNameToFind) throws CoreException {
// TODO: ER: put required MWE packages always to the classpath
final IJavaProject project = JavaCore.create(resource.getProject());
final SearchPattern pattern = SearchPattern
@@ -161,13 +164,13 @@ public class MWELaunchShortcut implements ILaunchShortcut {
}
private class LaunchConfigurationInfo {
- private String name;
+ private final String name;
- private String project;
+ private final String project;
- private String wfFile;
+ private final String wfFile;
- private LaunchConfigurationInfo(IFile file) {
+ private LaunchConfigurationInfo(final IFile file) {
name = file.getName();
project = file.getProject().getName();
wfFile = file.getFullPath().toString();
diff --git a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/wizard/NewWorkflowFileWizard.java b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/wizard/NewWorkflowFileWizard.java
index 836bc9c..5ad103d 100644
--- a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/wizard/NewWorkflowFileWizard.java
+++ b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/wizard/NewWorkflowFileWizard.java
@@ -29,7 +29,7 @@ import org.eclipse.ui.wizards.newresource.BasicNewResourceWizard;
public class NewWorkflowFileWizard extends BasicNewResourceWizard {
private Page mainPage;
- private String extension = "mwe";
+ private final String extension = "mwe";
String initialContents = "";
/*
@@ -38,7 +38,7 @@ public class NewWorkflowFileWizard extends BasicNewResourceWizard {
@Override
public void addPages() {
super.addPages();
- mainPage = new Page(getSelection());//$NON-NLS-1$
+ mainPage = new Page(getSelection());
addPage(mainPage);
}
@@ -47,7 +47,7 @@ public class NewWorkflowFileWizard extends BasicNewResourceWizard {
*/
@Override
- public void init(IWorkbench workbench, IStructuredSelection currentSelection) {
+ public void init(final IWorkbench workbench, final IStructuredSelection currentSelection) {
super.init(workbench, currentSelection);
setWindowTitle("New File");
setNeedsProgressMonitor(true);
@@ -95,7 +95,7 @@ public class NewWorkflowFileWizard extends BasicNewResourceWizard {
class Page extends WizardNewFileCreationPage {
- public Page(IStructuredSelection selection) {
+ public Page(final IStructuredSelection selection) {
super("newFilePage1", selection);
setFileName("newWorkflowFile." + extension);
setTitle("New Workflow File");
@@ -104,8 +104,9 @@ public class NewWorkflowFileWizard extends BasicNewResourceWizard {
@Override
public String getErrorMessage() {
- if (!getFileName().endsWith("." + extension))
+ if (!getFileName().endsWith("." + extension)) {
return "file extension must be ." + extension;
+ }
return null;
}
diff --git a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/workflow/Activator.java b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/workflow/Activator.java
index d1a02f8..abb6d7b 100644
--- a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/workflow/Activator.java
+++ b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/workflow/Activator.java
@@ -28,7 +28,7 @@ public class Activator extends AbstractUIPlugin {
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
*/
@Override
- public void start(BundleContext context) throws Exception {
+ public void start(final BundleContext context) throws Exception {
super.start(context);
}
@@ -38,7 +38,7 @@ public class Activator extends AbstractUIPlugin {
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
*/
@Override
- public void stop(BundleContext context) throws Exception {
+ public void stop(final BundleContext context) throws Exception {
plugin = null;
super.stop(context);
}
@@ -52,19 +52,19 @@ public class Activator extends AbstractUIPlugin {
return plugin;
}
- public static void logError(Exception e) {
+ public static void logError(final Exception e) {
logError(e.getMessage(), e);
}
- public static void logError(String msg, Exception e) {
+ public static void logError(final String msg, final Exception e) {
logError(createErrorStatus(msg, e));
}
- public static void logError(IStatus status) {
+ public static void logError(final IStatus status) {
getDefault().getLog().log(status);
}
- public static IStatus createErrorStatus(String msg, Exception e) {
+ public static IStatus createErrorStatus(final String msg, final Exception e) {
return new Status(IStatus.ERROR, PLUGIN_ID, IStatus.OK, msg, e);
}
diff --git a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/workflow/debug/MWEPluginAdapter.java b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/workflow/debug/MWEPluginAdapter.java
index 0e18584..8c0fc9a 100644
--- a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/workflow/debug/MWEPluginAdapter.java
+++ b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/workflow/debug/MWEPluginAdapter.java
@@ -51,7 +51,7 @@ import org.eclipse.swt.widgets.Display;
*/
public class MWEPluginAdapter implements PluginAdapter {
- private XmlLocationAnalyser locationAnalyser;
+ private final XmlLocationAnalyser locationAnalyser;
private static Set<String> extensions = new HashSet<String>();
static {
@@ -65,11 +65,11 @@ public class MWEPluginAdapter implements PluginAdapter {
this.locationAnalyser = new XmlLocationAnalyser();
}
- public boolean canHandleResourceExtension(String ext) {
+ public boolean canHandleResourceExtension(final String ext) {
return getRequiredExtension().contains(ext);
}
- public boolean canHandleType(String type) {
+ public boolean canHandleType(final String type) {
return TYPE.equals(type);
}
@@ -87,36 +87,39 @@ public class MWEPluginAdapter implements PluginAdapter {
return configElements.length != 0?configElements[0].getAttribute("id"):null;
}
- public boolean isToggleBpEnabled(IResource resource, int start, int end, int line) {
+ public boolean isToggleBpEnabled(final IResource resource, final int start, final int end, final int line) {
return getComponentAstAtLine(resource, line) != null;
}
- public MWEBreakpoint createBreakpoint(IResource resource, int start, int end, int line) throws CoreException {
+ public MWEBreakpoint createBreakpoint(final IResource resource, final int start, final int end, final int line) throws CoreException {
// TODO: ER: allow BP on file's end tag (e.g. </workflow> )
ComponentAST comp = getComponentAstAtLine(resource, line);
- if (comp == null)
+ if (comp == null) {
return null;
+ }
// get the correct start and end of the tag
return new MWEBreakpoint(resource, getElementName(comp), comp.getLineNumber(), comp.getOffset(), comp.getLength());
}
- public IBreakpoint checkBreakpoints(IBreakpoint[] bps, IResource resource, int start, int end, int line) throws CoreException {
+ public IBreakpoint checkBreakpoints(final IBreakpoint[] bps, final IResource resource, final int start, final int end, final int line) throws CoreException {
ComponentAST comp = getComponentAstAtLine(resource, line);
- if (comp == null)
+ if (comp == null) {
return null;
+ }
Location loc = locationAnalyser.adapt(comp.getLocation());
for (IBreakpoint bp1 : bps) {
MWEBreakpoint bp = (MWEBreakpoint) bp1;
- if (bp.getResource().equals(resource.getFullPath().toString()) && bp.getLine() == loc.getLineNumber()
- && bp.getCharStart() == loc.getNameStart() && bp.getCharEnd() == loc.getNameEnd())
+ if (bp.getResource().equals(resource.getFullPath().toString()) && (bp.getLine() == loc.getLineNumber())
+ && (bp.getCharStart() == loc.getNameStart()) && (bp.getCharEnd() == loc.getNameEnd())) {
return bp;
+ }
}
return null;
}
// get the closest ComponentAst that surrounds the lineNumber
- private ComponentAST getComponentAstAtLine(IResource resource, int lineNumber) {
+ private ComponentAST getComponentAstAtLine(final IResource resource, final int lineNumber) {
IPath path = resource.getFullPath();
IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
String wfFileName = file.getLocation().toString();
@@ -126,7 +129,7 @@ public class MWEPluginAdapter implements PluginAdapter {
final Map<String, String> params = new HashMap<String, String>();
AbstractASTBase wfAST = factory.parseAndInitialize(wfFileName, issues, params);
- if (wfAST != null && wfAST instanceof ComponentAST) {
+ if ((wfAST != null) && (wfAST instanceof ComponentAST)) {
List<AbstractASTBase> candidates = ((ComponentAST) wfAST).getChildren();
AbstractASTBase candidate = null;
@@ -135,33 +138,39 @@ public class MWEPluginAdapter implements PluginAdapter {
loc = locationAnalyser.adapt(next.getLocation());
next.setLocation(loc);
if (loc.getLineNumber() > lineNumber) {
- if (candidate instanceof ComponentAST)
+ if (candidate instanceof ComponentAST) {
return (ComponentAST) candidate;
+ }
}
candidate = next;
}
- if (candidate instanceof ComponentAST)
+ if (candidate instanceof ComponentAST) {
return (ComponentAST) candidate;
+ }
}
return null;
}
- private String getElementName(ComponentAST ast) {
- if (ast.getId() != null)
+ private String getElementName(final ComponentAST ast) {
+ if (ast.getId() != null) {
return ast.getId();
- if (ast instanceof InclusionAST)
+ }
+ if (ast instanceof InclusionAST) {
return ((InclusionAST) ast).getFile();
+ }
String clazz = new Path(ast.getClazz()).getFileExtension();
- if (clazz != null)
+ if (clazz != null) {
return clazz;
+ }
return ast.getClazz();
}
private Image icon = null;
public Image getIcon() {
- if (icon != null)
+ if (icon != null) {
return icon;
+ }
IPath path = new Path("/icons/workflowfile.gif");
InputStream is = null;
try {
diff --git a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/workflow/util/PluginConfigurationElementUtil.java b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/workflow/util/PluginConfigurationElementUtil.java
index 421e9e2..38c66ef 100644
--- a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/workflow/util/PluginConfigurationElementUtil.java
+++ b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/workflow/util/PluginConfigurationElementUtil.java
@@ -11,18 +11,19 @@ import org.eclipse.core.runtime.Platform;
public class PluginConfigurationElementUtil {
- public static String getConfigAttribute(String path) {
+ public static String getConfigAttribute(final String path) {
// "aaa/bbb[xx=yy]/ccc" or "aaa/bbb/ccc";
Pattern p = Pattern.compile("(.+)/(.+?)(\\[(.+)=(.+)\\])?/(.+)");
Matcher m = p.matcher(path);
- if (!m.find())
+ if (!m.find()) {
return null;
+ }
String attribute = null;
IExtensionRegistry reg = Platform.getExtensionRegistry();
IConfigurationElement[] elems = reg.getConfigurationElementsFor(m.group(1));
for (IConfigurationElement elem : elems) {
- if (elem.getName().equals(m.group(2)) && (m.group(3) == null || m.group(5).equals(elem.getAttribute(m.group(4))))) {
+ if (elem.getName().equals(m.group(2)) && ((m.group(3) == null) || m.group(5).equals(elem.getAttribute(m.group(4))))) {
attribute = elem.getAttribute(m.group(6));
break;
}
@@ -30,17 +31,18 @@ public class PluginConfigurationElementUtil {
return attribute;
}
- public static IConfigurationElement[] getConfigElements(String path) {
+ public static IConfigurationElement[] getConfigElements(final String path) {
Pattern p = Pattern.compile("(.+)/(.+?)(\\[(.+)=(.+)\\])?/(.+)");
Matcher m = p.matcher(path);
- if (!m.find())
+ if (!m.find()) {
return null;
+ }
List<IConfigurationElement> elements = new ArrayList<IConfigurationElement>();
IExtensionRegistry reg = Platform.getExtensionRegistry();
IConfigurationElement[] elems = reg.getConfigurationElementsFor(m.group(1));
for (IConfigurationElement elem : elems) {
- if (elem.getName().equals(m.group(2)) && (m.group(3) == null || m.group(5).equals(elem.getAttribute(m.group(4))))) {
+ if (elem.getName().equals(m.group(2)) && ((m.group(3) == null) || m.group(5).equals(elem.getAttribute(m.group(4))))) {
elements.add(elem);
}
}
diff --git a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/workflow/util/ProjectIncludingResourceLoader.java b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/workflow/util/ProjectIncludingResourceLoader.java
index 58715ba..9db8915 100644
--- a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/workflow/util/ProjectIncludingResourceLoader.java
+++ b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/workflow/util/ProjectIncludingResourceLoader.java
@@ -20,9 +20,9 @@ import org.eclipse.jdt.core.JavaCore;
*
*/
public class ProjectIncludingResourceLoader extends ResourceLoaderDefaultImpl {
- private ClassLoader projectCL;
+ private final ClassLoader projectCL;
- public ProjectIncludingResourceLoader(IProject project) throws CoreException {
+ public ProjectIncludingResourceLoader(final IProject project) throws CoreException {
super();
projectCL = createClassLoader(project);
}
@@ -32,23 +32,24 @@ public class ProjectIncludingResourceLoader extends ResourceLoaderDefaultImpl {
* @param project An Eclipse project
* @throws CoreException
*/
- public ClassLoader createClassLoader (IProject project) throws CoreException {
+ public ClassLoader createClassLoader (final IProject project) throws CoreException {
IJavaProject jp = JavaCore.create(project);
IClasspathEntry[] javacp = jp.getResolvedClasspath(true);
URL[] url = new URL[javacp.length];
- for (int i=0; i<javacp.length; i++)
+ for (int i=0; i<javacp.length; i++) {
try {
url[i] = javacp[i].getPath().toFile().toURL();
} catch (MalformedURLException e) {
Activator.logError(e);
}
+ }
return new URLClassLoader(url);
}
@Override
- protected URL internalGetResource(String path) {
+ protected URL internalGetResource(final String path) {
URL resource = projectCL.getResource(path);
if ( resource == null ) {
resource = super.internalGetResource(path);
@@ -57,7 +58,7 @@ public class ProjectIncludingResourceLoader extends ResourceLoaderDefaultImpl {
}
@Override
- protected InputStream internalGetResourceAsStream(String path) {
+ protected InputStream internalGetResourceAsStream(final String path) {
URL url = internalGetResource(path);
try {
return url != null ? url.openStream() : null;
diff --git a/plugins/org.eclipse.emf.mwe.utils/src/org/eclipse/emf/mwe/utils/AbstractEMFWorkflowComponent.java b/plugins/org.eclipse.emf.mwe.utils/src/org/eclipse/emf/mwe/utils/AbstractEMFWorkflowComponent.java
index 71bab18..0030029 100644
--- a/plugins/org.eclipse.emf.mwe.utils/src/org/eclipse/emf/mwe/utils/AbstractEMFWorkflowComponent.java
+++ b/plugins/org.eclipse.emf.mwe.utils/src/org/eclipse/emf/mwe/utils/AbstractEMFWorkflowComponent.java
@@ -13,20 +13,21 @@ public abstract class AbstractEMFWorkflowComponent extends
new StandaloneSetup();
}
- public void setUseSingleGlobalResourceSet( boolean b ) {
- if (b)
+ public void setUseSingleGlobalResourceSet( final boolean b ) {
+ if (b) {
resourceSet = SingleGlobalResourceSet.get();
+ }
}
protected ResourceSet resourceSet = new ResourceSetImpl();
protected String uri;
- public void setResourceSet(ResourceSet resourceSet) {
+ public void setResourceSet(final ResourceSet resourceSet) {
this.resourceSet = resourceSet;
}
- public void setUri(String uri) {
+ public void setUri(final String uri) {
this.uri = uri;
}
diff --git a/plugins/org.eclipse.emf.mwe.utils/src/org/eclipse/emf/mwe/utils/DirectoryCleaner.java b/plugins/org.eclipse.emf.mwe.utils/src/org/eclipse/emf/mwe/utils/DirectoryCleaner.java
index 77a933e..7d00ddb 100644
--- a/plugins/org.eclipse.emf.mwe.utils/src/org/eclipse/emf/mwe/utils/DirectoryCleaner.java
+++ b/plugins/org.eclipse.emf.mwe.utils/src/org/eclipse/emf/mwe/utils/DirectoryCleaner.java
@@ -34,7 +34,8 @@ public class DirectoryCleaner extends AbstractWorkflowComponent {
this.directories = directories;
}
- public String getLogMessage() {
+ @Override
+ public String getLogMessage() {
return "cleaning directory '"+directories+"'";
}
@@ -48,8 +49,7 @@ public class DirectoryCleaner extends AbstractWorkflowComponent {
if (f.exists() && f.isDirectory()) {
logger.info("Cleaning " + f.getAbsolutePath());
final File[] contents = f.listFiles();
- for (int j = 0; j < contents.length; j++) {
- final File file = contents[j];
+ for (final File file : contents) {
if (!delete(file)) {
logger.error("Couldn't delete " + file.getAbsolutePath());
}
@@ -72,10 +72,11 @@ public class DirectoryCleaner extends AbstractWorkflowComponent {
public boolean delete(final File file) {
if (file.isDirectory()) {
final String[] children = file.list();
- for (int i = 0; i < children.length; i++) {
- boolean success = delete(new File(file, children[i]));
- if (!success)
- return false;
+ for (String element : children) {
+ boolean success = delete(new File(file, element));
+ if (!success) {
+ return false;
+ }
}
}
@@ -87,6 +88,9 @@ public class DirectoryCleaner extends AbstractWorkflowComponent {
/*******************************************************************************
* $Log: DirectoryCleaner.java,v $
+ * Revision 1.2 2007/09/26 13:26:57 bkolb
+ * cleanUP
+ *
* Revision 1.1 2007/09/25 18:09:24 bkolb
* initial check-in
* * restructured projects
diff --git a/plugins/org.eclipse.emf.mwe.utils/src/org/eclipse/emf/mwe/utils/Reader.java b/plugins/org.eclipse.emf.mwe.utils/src/org/eclipse/emf/mwe/utils/Reader.java
index 98c7310..a7c5e34 100644
--- a/plugins/org.eclipse.emf.mwe.utils/src/org/eclipse/emf/mwe/utils/Reader.java
+++ b/plugins/org.eclipse.emf.mwe.utils/src/org/eclipse/emf/mwe/utils/Reader.java
@@ -20,34 +20,38 @@ public class Reader extends AbstractEMFWorkflowComponent {
private boolean firstElementOnly = true;
- public void invokeInternal(WorkflowContext ctx, ProgressMonitor monitor,
- Issues issues) {
+ @Override
+ public void invokeInternal(final WorkflowContext ctx, final ProgressMonitor monitor,
+ final Issues issues) {
ctx.set(this.getModelSlot(), load(resourceSet, uri, firstElementOnly));
if (makeEPackagesGlobal) {
for (String k : resourceSet.getPackageRegistry()
- .keySet())
+ .keySet()) {
EPackage.Registry.INSTANCE.put(k, resourceSet
.getPackageRegistry().get(k));
+ }
}
}
@Override
- public void checkConfiguration(Issues issues) {
+ public void checkConfiguration(final Issues issues) {
super.checkConfiguration(issues);
if (uri == null) {
issues.addError("URI not set");
}
}
- public static Object load(ResourceSet resourceSet, String uri,
- boolean firstElementOnly) {
+ public static Object load(final ResourceSet resourceSet, final String uri,
+ final boolean firstElementOnly) {
Resource res = resourceSet.getResource(URI.createURI(uri), true);
- if (res == null)
+ if (res == null) {
throw new WorkflowInterruptedException(
"Couldn't find resource under " + uri);
+ }
try {
- if (!res.isLoaded())
+ if (!res.isLoaded()) {
res.load(Collections.EMPTY_MAP);
+ }
} catch (IOException e) {
throw new WorkflowInterruptedException(
"Couldn't find resource under " + uri + " : "
@@ -55,18 +59,19 @@ public class Reader extends AbstractEMFWorkflowComponent {
}
EList result = res.getContents();
if (firstElementOnly) {
- if (result.isEmpty())
+ if (result.isEmpty()) {
return null;
+ }
return result.iterator().next();
}
return result;
}
- public void setFirstElementOnly(boolean firstElementOnly) {
+ public void setFirstElementOnly(final boolean firstElementOnly) {
this.firstElementOnly = firstElementOnly;
}
- public void setMakeEPackagesGlobal(boolean makeEPackagesGlobal) {
+ public void setMakeEPackagesGlobal(final boolean makeEPackagesGlobal) {
this.makeEPackagesGlobal = makeEPackagesGlobal;
}
diff --git a/plugins/org.eclipse.emf.mwe.utils/src/org/eclipse/emf/mwe/utils/StandaloneSetup.java b/plugins/org.eclipse.emf.mwe.utils/src/org/eclipse/emf/mwe/utils/StandaloneSetup.java
index 95065cd..94866f5 100644
--- a/plugins/org.eclipse.emf.mwe.utils/src/org/eclipse/emf/mwe/utils/StandaloneSetup.java
+++ b/plugins/org.eclipse.emf.mwe.utils/src/org/eclipse/emf/mwe/utils/StandaloneSetup.java
@@ -59,26 +59,28 @@ public class StandaloneSetup {
* @param pathToPlatform
*/
@SuppressWarnings("unchecked")
- public void setPlatformUri(String pathToPlatform) {
+ public void setPlatformUri(final String pathToPlatform) {
File f = new File(pathToPlatform);
- if (!f.exists())
+ if (!f.exists()) {
throw new ConfigurationException("The platformUri location '"
+ pathToPlatform + "' does not exist");
- if (!f.isDirectory())
+ }
+ if (!f.isDirectory()) {
throw new ConfigurationException(
"The platformUri location must point to a directory");
+ }
String path = f.getAbsolutePath();
try {
path = f.getCanonicalPath();
} catch (IOException e) {
log.error("Error when registering platform location", e);
}
- if (platformRootPath == null || !platformRootPath.equals(path)) {
+ if ((platformRootPath == null) || !platformRootPath.equals(path)) {
platformRootPath = path;
log.info("Registering platform uri '" + path + "'");
if (f.exists()) {
for (File subdir : f.listFiles(new FileFilter() {
- public boolean accept(File arg0) {
+ public boolean accept(final File arg0) {
return arg0.exists() && arg0.isDirectory()
&& !arg0.getName().startsWith(".");
}
@@ -137,23 +139,25 @@ public class StandaloneSetup {
// locate the factory class of the extension
Class factoryClass = ResourceLoaderFactory.createResourceLoader()
.loadClass(m.getTo());
- if (factoryClass == null)
+ if (factoryClass == null) {
throw new ConfigurationException("cannot find class "
+ m.getTo() + " for extension " + m.getFrom());
+ }
Object factoryInstance = null;
if (factoryClass.isInterface()) {
final Class[] innerClasses = factoryClass.getDeclaredClasses();
factoryClass = null;
- for (int j = 0; j < innerClasses.length; j++) {
+ for (Class element : innerClasses) {
if (Resource.Factory.class
- .isAssignableFrom(innerClasses[j])) {
- factoryClass = innerClasses[j];
+ .isAssignableFrom(element)) {
+ factoryClass = element;
}
}
- if (factoryClass == null)
+ if (factoryClass == null) {
throw new ConfigurationException(
"cannot find inner factory class " + m.getTo()
+ " for extension " + m.getFrom());
+ }
final Field instanceField = factoryClass.getField("INSTANCE");
factoryInstance = instanceField.get(null);
} else {
@@ -166,7 +170,7 @@ public class StandaloneSetup {
}
}
- public void addRegisterGeneratedEPackage(String interfacename) {
+ public void addRegisterGeneratedEPackage(final String interfacename) {
Class clazz = ResourceLoaderFactory.createResourceLoader().loadClass(
interfacename);
if (clazz == null) {
@@ -190,24 +194,25 @@ public class StandaloneSetup {
protected ResourceSet resourceSet = new ResourceSetImpl();
protected Registry registry = EPackage.Registry.INSTANCE;
- public void setResourceSet(ResourceSet resourceSet) {
+ public void setResourceSet(final ResourceSet resourceSet) {
log
.info("Using resourceSet registry. The registered Packages will not be registered in the global EPackage.Registry.INSTANCE!");
this.resourceSet = resourceSet;
this.registry = resourceSet.getPackageRegistry();
}
- public void setResourceSetImpl(ResourceSetImpl resourceSet) {
+ public void setResourceSetImpl(final ResourceSetImpl resourceSet) {
this.setResourceSet(resourceSet);
}
- public void addRegisterEcoreFile(String fileName)
+ public void addRegisterEcoreFile(final String fileName)
throws IllegalArgumentException, SecurityException,
IllegalAccessException, NoSuchFieldException {
Resource res = resourceSet.getResource(URI.createURI(fileName), true);
- if (res == null)
+ if (res == null) {
throw new ConfigurationException("Couldn't find resource under "
+ fileName);
+ }
if (!res.isLoaded()) {
try {
res.load(null);
@@ -233,7 +238,7 @@ public class StandaloneSetup {
}
}
- public EPackage getPackage(String nsUri) {
+ public EPackage getPackage(final String nsUri) {
return (EPackage) registry.get(nsUri);
}
diff --git a/plugins/org.eclipse.emf.mwe.utils/src/org/eclipse/emf/mwe/utils/Writer.java b/plugins/org.eclipse.emf.mwe.utils/src/org/eclipse/emf/mwe/utils/Writer.java
index 764e1ca..e7cb967 100644
--- a/plugins/org.eclipse.emf.mwe.utils/src/org/eclipse/emf/mwe/utils/Writer.java
+++ b/plugins/org.eclipse.emf.mwe.utils/src/org/eclipse/emf/mwe/utils/Writer.java
@@ -10,7 +10,7 @@ import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.emf.ecore.xmi.XMIResource;
+import org.eclipse.emf.ecore.xmi.XMLResource;
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
import org.eclipse.emf.mwe.core.WorkflowContext;
import org.eclipse.emf.mwe.core.WorkflowInterruptedException;
@@ -21,7 +21,7 @@ public class Writer extends AbstractEMFWorkflowComponent {
private boolean OPTION_SCHEMA_LOCATION = true;
- public void setOPTION_SCHEMA_LOCATION(boolean option_schema_location) {
+ public void setOPTION_SCHEMA_LOCATION(final boolean option_schema_location) {
OPTION_SCHEMA_LOCATION = option_schema_location;
}
@@ -31,29 +31,30 @@ public class Writer extends AbstractEMFWorkflowComponent {
private boolean cloneSlotContents = false;
- public void setMultipleResourcesInCaseOfList( boolean b ) {
+ public void setMultipleResourcesInCaseOfList( final boolean b ) {
multipleResourcesInCaseOfList = b;
}
- public void setCloneSlotContents( boolean b ) {
+ public void setCloneSlotContents( final boolean b ) {
this.cloneSlotContents = b;
}
public void setOPTION_SCHEMA_LOCATION_IMPLEMENTATION(
- boolean option_schema_location_implementation) {
+ final boolean option_schema_location_implementation) {
OPTION_SCHEMA_LOCATION_IMPLEMENTATION = option_schema_location_implementation;
}
+ @Override
@SuppressWarnings("unchecked")
- public void invokeInternal(WorkflowContext ctx, ProgressMonitor monitor,
- Issues issues) {
+ public void invokeInternal(final WorkflowContext ctx, final ProgressMonitor monitor,
+ final Issues issues) {
Object slotContent = ctx.get(getModelSlot());
if (slotContent == null) {
issues.addError(this, "slot '" + getModelSlot() + "' is empty.");
return;
}
- if (!(slotContent instanceof Collection<?> || slotContent instanceof EObject)) {
+ if (!((slotContent instanceof Collection<?>) || (slotContent instanceof EObject))) {
issues
.addError(this, "slot '" + getModelSlot()
+ "' neither contains an EList nor an EObject",
@@ -112,22 +113,24 @@ public class Writer extends AbstractEMFWorkflowComponent {
}
}
- private String createResourceName(EObject eo) {
+ private String createResourceName(final EObject eo) {
return getUri()+(getUri().endsWith("/")? "": "/")+getName(eo)+".ecore";
}
- private String getName(EObject model) {
+ private String getName(final EObject model) {
return (String) model.eGet(model.eClass().getEStructuralFeature("name"));
}
- private void write(Resource r) {
+ private void write(final Resource r) {
try {
Map<String, Object> options = new HashMap<String, Object>();
- if (OPTION_SCHEMA_LOCATION)
- options.put(XMIResource.OPTION_SCHEMA_LOCATION, Boolean.TRUE);
- if (OPTION_SCHEMA_LOCATION_IMPLEMENTATION)
- options.put(XMIResource.OPTION_SCHEMA_LOCATION_IMPLEMENTATION,
+ if (OPTION_SCHEMA_LOCATION) {
+ options.put(XMLResource.OPTION_SCHEMA_LOCATION, Boolean.TRUE);
+ }
+ if (OPTION_SCHEMA_LOCATION_IMPLEMENTATION) {
+ options.put(XMLResource.OPTION_SCHEMA_LOCATION_IMPLEMENTATION,
Boolean.TRUE);
+ }
r.save(options);
} catch (final IOException e) {
throw new WorkflowInterruptedException(