Skip to content

Commit 2cee22e

Browse files
committed
eclipse-archived#190 TqCL added javadoc
1 parent 1117bba commit 2cee22e

File tree

15 files changed

+153
-16
lines changed

15 files changed

+153
-16
lines changed

org.eclipse.triquetrum.commands.xtext.ide/src/main/java/org/eclipse/triquetrum/commands/xtext/ide/TqCLLaunchShortcut.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package org.eclipse.triquetrum.commands.xtext.ide;
22

3-
import java.util.Arrays;
4-
53
import org.eclipse.core.resources.IFile;
64
import org.eclipse.core.runtime.CoreException;
75
import org.eclipse.debug.ui.ILaunchShortcut;
@@ -10,13 +8,14 @@
108
import org.eclipse.triquetrum.commands.interpreter.TqclInterpreter;
119
import org.eclipse.ui.IEditorInput;
1210
import org.eclipse.ui.IEditorPart;
13-
import org.eclipse.ui.PlatformUI;
1411
import org.eclipse.ui.console.ConsolePlugin;
1512
import org.eclipse.ui.console.IConsole;
1613
import org.eclipse.ui.console.IConsoleManager;
1714
import org.eclipse.ui.console.MessageConsole;
1815
import org.eclipse.ui.console.MessageConsoleStream;
1916

17+
18+
//TODO: TqCL Macro launcher
2019
public class TqCLLaunchShortcut implements ILaunchShortcut {
2120

2221
@Override

org.eclipse.triquetrum.commands.xtext.ide/src/main/java/org/eclipse/triquetrum/commands/xtext/ide/TqCLPtolemyLaunchShortcut.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,20 @@
1515
import org.eclipse.ui.console.IConsole;
1616
import org.eclipse.ui.console.IConsoleManager;
1717
import org.eclipse.ui.console.MessageConsole;
18-
import org.eclipse.ui.console.MessageConsoleStream;
1918

2019
import ptolemy.actor.CompositeActor;
2120

21+
/**
22+
* Launcher to create and start a ptolemy model
23+
*
24+
* @author rtotaro
25+
*
26+
*/
2227
public class TqCLPtolemyLaunchShortcut implements ILaunchShortcut {
2328

29+
/* (non-Javadoc)
30+
* @see org.eclipse.debug.ui.ILaunchShortcut#launch(org.eclipse.jface.viewers.ISelection, java.lang.String)
31+
*/
2432
@SuppressWarnings({ "rawtypes", "unchecked" })
2533
@Override
2634
public void launch(ISelection selection, String mode) {
@@ -32,16 +40,11 @@ public void launch(ISelection selection, String mode) {
3240
IConsoleManager consoleManager = ConsolePlugin.getDefault().getConsoleManager();
3341
MessageConsole messageConsole = new MessageConsole(file.getName(), "TqCL", null, false);
3442
consoleManager.addConsoles(new IConsole[] { messageConsole });
35-
// MessageConsoleStream newMessageStream = messageConsole.newMessageStream();
36-
// newMessageStream
3743

3844
TqclInterpreter interpreter = new TqclInterpreter();
3945
CompositeActor model = (CompositeActor) interpreter.interpret(file.getName(), file.getContents(),
4046
file.getParent().getLocationURI(), CompositeActor.class);
4147

42-
// String moml = model.exportMoML();
43-
//
44-
// System.out.println(moml);
4548

4649
//workflow service could be exposed by a different plugin; not workflow editor
4750
WorkflowExecutionService executionService = TriqEditorPlugin.getDefault().getWorkflowExecutionService();
@@ -54,6 +57,9 @@ public void launch(ISelection selection, String mode) {
5457
}
5558
}
5659

60+
/* (non-Javadoc)
61+
* @see org.eclipse.debug.ui.ILaunchShortcut#launch(org.eclipse.ui.IEditorPart, java.lang.String)
62+
*/
5763
@Override
5864
public void launch(IEditorPart editor, String mode) {
5965
// TODO Auto-generated method stub

org.eclipse.triquetrum.commands.xtext.ui/src/main/java/org/eclipse/triquetrum/commands/ui/contentassist/TqclProposalProvider.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,6 @@ public void completeInsert_Name(EObject model, Assignment assignment, ContentAss
166166
@Override
167167
public void completeConnectionPort_Port(EObject model, Assignment assignment, ContentAssistContext context,
168168
ICompletionProposalAcceptor acceptor) {
169-
// TODO Auto-generated method stub
170169
super.completeConnectionPort_Port(model, assignment, context, acceptor);
171170
if (model instanceof ConnectionPort) {
172171
ConnectionPort connectionPort = (ConnectionPort) model;

org.eclipse.triquetrum.commands.xtext.ui/src/main/java/org/eclipse/triquetrum/commands/ui/editor/TriquetrumCommandEditor.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
*******************************************************************************/
1111
package org.eclipse.triquetrum.commands.ui.editor;
1212

13-
import org.eclipse.jface.text.ITextSelection;
14-
import org.eclipse.jface.viewers.ISelection;
1513
import org.eclipse.swt.SWT;
1614
import org.eclipse.swt.events.KeyAdapter;
1715
import org.eclipse.swt.events.KeyEvent;

org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/interpreter/CompositeCommandInterpreterComponent.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,16 @@
1010
import org.eclipse.triquetrum.commands.tqcl.Go;
1111
import org.eclipse.triquetrum.commands.tqcl.TqclPackage;
1212

13+
/**
14+
* Interpreter component for {@link CompositeCommand}
15+
* @author rtotaro
16+
*/
1317
public class CompositeCommandInterpreterComponent implements TqclInterpreterComponent {
1418

19+
/* (non-Javadoc)
20+
* @see org.eclipse.triquetrum.commands.interpreter.TqclInterpreterComponent#interpret(org.eclipse.emf.ecore.EObject, org.eclipse.triquetrum.commands.interpreter.InterpretContext)
21+
*/
22+
@SuppressWarnings({ "rawtypes", "unchecked" })
1523
@Override
1624
public void interpret(EObject element, InterpretContext context) {
1725
if (element instanceof CompositeCommand) {
@@ -29,6 +37,9 @@ public void interpret(EObject element, InterpretContext context) {
2937

3038
}
3139

40+
/* (non-Javadoc)
41+
* @see org.eclipse.triquetrum.commands.interpreter.TqclInterpreterComponent#intepretedEClasses()
42+
*/
3243
@Override
3344
public List<EClass> intepretedEClasses() {
3445
return Arrays.asList(TqclPackage.Literals.COMPOSITE_COMMAND);

org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/interpreter/ConnectInterpreterComponent.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,20 @@
66
import org.eclipse.emf.common.util.EList;
77
import org.eclipse.emf.ecore.EClass;
88
import org.eclipse.emf.ecore.EObject;
9+
import org.eclipse.triquetrum.commands.tqcl.CompositeCommand;
910
import org.eclipse.triquetrum.commands.tqcl.Connect;
1011
import org.eclipse.triquetrum.commands.tqcl.ConnectionPort;
1112
import org.eclipse.triquetrum.commands.tqcl.TqclPackage;
1213

14+
/**
15+
* Interpreter component for {@link Connect}
16+
* @author rtotaro
17+
*/
1318
public class ConnectInterpreterComponent implements TqclInterpreterComponent {
1419

20+
/* (non-Javadoc)
21+
* @see org.eclipse.triquetrum.commands.interpreter.TqclInterpreterComponent#interpret(org.eclipse.emf.ecore.EObject, org.eclipse.triquetrum.commands.interpreter.InterpretContext)
22+
*/
1523
@Override
1624
public void interpret(EObject element, InterpretContext context) {
1725
if (element instanceof Connect) {
@@ -28,10 +36,17 @@ public void interpret(EObject element, InterpretContext context) {
2836

2937
}
3038

39+
/**
40+
* @param port
41+
* @return
42+
*/
3143
private String createPortPath(ConnectionPort port) {
3244
return port.getActor().getName()+"."+port.getPort();
3345
}
3446

47+
/* (non-Javadoc)
48+
* @see org.eclipse.triquetrum.commands.interpreter.TqclInterpreterComponent#intepretedEClasses()
49+
*/
3550
@Override
3651
public List<EClass> intepretedEClasses() {
3752
return Arrays.asList(TqclPackage.Literals.CONNECT);

org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/interpreter/GoInterpreterComponent.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,20 @@
55

66
import org.eclipse.emf.ecore.EClass;
77
import org.eclipse.emf.ecore.EObject;
8+
import org.eclipse.triquetrum.commands.tqcl.CompositeCommand;
89
import org.eclipse.triquetrum.commands.tqcl.Go;
910
import org.eclipse.triquetrum.commands.tqcl.Insert;
1011
import org.eclipse.triquetrum.commands.tqcl.TqclPackage;
1112

13+
/**
14+
* Interpreter component for {@link Go}
15+
* @author rtotaro
16+
*/
1217
public class GoInterpreterComponent implements TqclInterpreterComponent {
1318

19+
/* (non-Javadoc)
20+
* @see org.eclipse.triquetrum.commands.interpreter.TqclInterpreterComponent#interpret(org.eclipse.emf.ecore.EObject, org.eclipse.triquetrum.commands.interpreter.InterpretContext)
21+
*/
1422
@SuppressWarnings({ "unchecked", "rawtypes" })
1523
@Override
1624
public void interpret(EObject element, InterpretContext context) {
@@ -34,6 +42,9 @@ public void interpret(EObject element, InterpretContext context) {
3442
}
3543
}
3644

45+
/* (non-Javadoc)
46+
* @see org.eclipse.triquetrum.commands.interpreter.TqclInterpreterComponent#intepretedEClasses()
47+
*/
3748
@Override
3849
public List<EClass> intepretedEClasses() {
3950
return Arrays.asList(TqclPackage.Literals.GO);

org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/interpreter/InsertInterpreterComponent.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,21 @@
99
import org.eclipse.emf.ecore.EObject;
1010
import org.eclipse.triquetrum.commands.api.services.TcQLException;
1111
import org.eclipse.triquetrum.commands.tqcl.Category;
12+
import org.eclipse.triquetrum.commands.tqcl.CompositeCommand;
1213
import org.eclipse.triquetrum.commands.tqcl.Insert;
1314
import org.eclipse.triquetrum.commands.tqcl.Parameter;
1415
import org.eclipse.triquetrum.commands.tqcl.TqclPackage;
1516
import org.eclipse.triquetrum.commands.validation.TqCLUtils;
1617

18+
/**
19+
* Interpreter component for {@link Insert}
20+
* @author rtotaro
21+
*/
1722
public class InsertInterpreterComponent implements TqclInterpreterComponent {
1823

24+
/* (non-Javadoc)
25+
* @see org.eclipse.triquetrum.commands.interpreter.TqclInterpreterComponent#interpret(org.eclipse.emf.ecore.EObject, org.eclipse.triquetrum.commands.interpreter.InterpretContext)
26+
*/
1927
@SuppressWarnings({ "unchecked", "rawtypes" })
2028
@Override
2129
public void interpret(EObject element, InterpretContext context) {
@@ -51,6 +59,9 @@ private Map<String, String> extractParameterMap(Insert insert) {
5159
return params;
5260
}
5361

62+
/* (non-Javadoc)
63+
* @see org.eclipse.triquetrum.commands.interpreter.TqclInterpreterComponent#intepretedEClasses()
64+
*/
5465
@Override
5566
public List<EClass> intepretedEClasses() {
5667
return Arrays.asList(TqclPackage.Literals.INSERT);

org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/interpreter/InterpretContext.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
import org.eclipse.triquetrum.commands.api.services.ModelBuilderService;
44

5+
6+
/**
7+
* Object that contains the result of interpretation
8+
*
9+
* @author rtotaro
10+
*
11+
* @param <CompositeActor> class used to represent the composite actor
12+
* @param <Actor> class used to represent the simple actor
13+
*/
514
public class InterpretContext<CompositeActor,Actor> {
615

716
private ModelBuilderService<CompositeActor,Actor> modelBuilderService;
@@ -12,6 +21,11 @@ public class InterpretContext<CompositeActor,Actor> {
1221

1322
private Actor currentActor;
1423

24+
/**
25+
* @param interpreter is used by interpreter component
26+
* @param model root of the model to interpret
27+
* @param modelBuilderService is used to build the model
28+
*/
1529
public InterpretContext(TqclInterpreter<CompositeActor,Actor> interpreter,CompositeActor model,ModelBuilderService<CompositeActor,Actor> modelBuilderService) {
1630
super();
1731
this.interpreter = interpreter;
@@ -35,6 +49,11 @@ public Actor getCurrentActor() {
3549
return currentActor;
3650
}
3751

52+
/**
53+
* Is used to set the current level in the actor hierarchy
54+
* Could be also a simple actor for adding ports or parameters
55+
* @param currentActor
56+
*/
3857
public void setCurrentActor(Actor currentActor) {
3958
this.currentActor = currentActor;
4059
}

org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/interpreter/TqclInterpreter.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@
2929

3030
import ptolemy.util.StringUtilities;
3131

32+
/**
33+
* The TqCL interpreter, the type of the result is related to the {@link ModelBuilderService} set in the {@link InterpretContext}
34+
* @author rtotaro
35+
*
36+
* @param <CompositeActor> class used to represent the composite actor
37+
* @param <Actor> class used to represent the simple acto
38+
*/
3239
public class TqclInterpreter<CompositeActor,Actor> {
3340

3441
private static Map<EClass, TqclInterpreterComponent> components = new HashMap<>();
@@ -51,6 +58,15 @@ private static void addComponent(TqclInterpreterComponent component){
5158
}
5259
}
5360

61+
/**
62+
* Interpreter the TqCL script
63+
*
64+
* @param modelName the name of the result model
65+
* @param script to interpret
66+
* @param uri parent directory of the script
67+
* @param modelClass result class, is used to select the right {@link ModelBuilderService}
68+
* @return
69+
*/
5470
public CompositeActor interpret(String modelName,InputStream script, java.net.URI uri,Class<?> modelClass) {
5571
try {
5672
Injector injector = new TqclStandaloneSetup().createInjectorAndDoEMFRegistration();

0 commit comments

Comments
 (0)