Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rentz-Reichert2012-05-25 18:53:52 -0400
committerHenrik Rentz-Reichert2012-05-25 18:53:52 -0400
commit177965c4f54f156684783f313acb1ab2ca99d321 (patch)
tree30c84d7f52bcac87ec68c7beb50654d9af367cc0 /plugins/org.eclipse.etrice.abstractexec.behavior
parent51ef62bc6f1d1d61e4ed2af2e14d81edcbf3274d (diff)
downloadorg.eclipse.etrice-177965c4f54f156684783f313acb1ab2ca99d321.tar.gz
org.eclipse.etrice-177965c4f54f156684783f313acb1ab2ca99d321.tar.xz
org.eclipse.etrice-177965c4f54f156684783f313acb1ab2ca99d321.zip
[core.room, core.room.ui, genmodel, abstractexec.behavior] validator and quickfix extension points and extension examples
preparations for abstract state machine execution
Diffstat (limited to 'plugins/org.eclipse.etrice.abstractexec.behavior')
-rw-r--r--plugins/org.eclipse.etrice.abstractexec.behavior/.classpath7
-rw-r--r--plugins/org.eclipse.etrice.abstractexec.behavior/.gitignore2
-rw-r--r--plugins/org.eclipse.etrice.abstractexec.behavior/.project28
-rw-r--r--plugins/org.eclipse.etrice.abstractexec.behavior/.settings/org.eclipse.jdt.core.prefs8
-rw-r--r--plugins/org.eclipse.etrice.abstractexec.behavior/META-INF/MANIFEST.MF14
-rw-r--r--plugins/org.eclipse.etrice.abstractexec.behavior/build.properties5
-rw-r--r--plugins/org.eclipse.etrice.abstractexec.behavior/plugin.xml25
-rw-r--r--plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/AbstractExecutionValidator.java66
-rw-r--r--plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/ActionCodeAnalyzer.java83
-rw-r--r--plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/DemoQuickfix.java40
-rw-r--r--plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/DemoValidator.java44
11 files changed, 322 insertions, 0 deletions
diff --git a/plugins/org.eclipse.etrice.abstractexec.behavior/.classpath b/plugins/org.eclipse.etrice.abstractexec.behavior/.classpath
new file mode 100644
index 000000000..8a8f1668c
--- /dev/null
+++ b/plugins/org.eclipse.etrice.abstractexec.behavior/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/org.eclipse.etrice.abstractexec.behavior/.gitignore b/plugins/org.eclipse.etrice.abstractexec.behavior/.gitignore
new file mode 100644
index 000000000..a25460a14
--- /dev/null
+++ b/plugins/org.eclipse.etrice.abstractexec.behavior/.gitignore
@@ -0,0 +1,2 @@
+bin
+.antlr-generator-3.2.0.jar \ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.abstractexec.behavior/.project b/plugins/org.eclipse.etrice.abstractexec.behavior/.project
new file mode 100644
index 000000000..bc5cf1d2c
--- /dev/null
+++ b/plugins/org.eclipse.etrice.abstractexec.behavior/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.etrice.abstractexec.behavior</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/plugins/org.eclipse.etrice.abstractexec.behavior/.settings/org.eclipse.jdt.core.prefs b/plugins/org.eclipse.etrice.abstractexec.behavior/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 000000000..08fa054b3
--- /dev/null
+++ b/plugins/org.eclipse.etrice.abstractexec.behavior/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,8 @@
+#Wed May 23 19:11:47 CEST 2012
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/plugins/org.eclipse.etrice.abstractexec.behavior/META-INF/MANIFEST.MF b/plugins/org.eclipse.etrice.abstractexec.behavior/META-INF/MANIFEST.MF
new file mode 100644
index 000000000..06bec0601
--- /dev/null
+++ b/plugins/org.eclipse.etrice.abstractexec.behavior/META-INF/MANIFEST.MF
@@ -0,0 +1,14 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Abstract Execution for State Machines
+Bundle-SymbolicName: org.eclipse.etrice.abstractexec.behavior;singleton:=true
+Bundle-Version: 0.2.0.qualifier
+Bundle-Vendor: eTrice (Incubation)
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Require-Bundle: org.eclipse.etrice.core.room;bundle-version="0.2.0",
+ org.eclipse.etrice.core.room.ui;bundle-version="0.2.0",
+ org.eclipse.etrice.core.genmodel;bundle-version="0.2.0",
+ org.eclipse.etrice.generator;bundle-version="0.2.0",
+ org.eclipse.emf.ecore;bundle-version="2.7.0",
+ org.eclipse.xtext;bundle-version="2.1.1",
+ org.eclipse.xtext.ui;bundle-version="2.1.1"
diff --git a/plugins/org.eclipse.etrice.abstractexec.behavior/build.properties b/plugins/org.eclipse.etrice.abstractexec.behavior/build.properties
new file mode 100644
index 000000000..6f20375d6
--- /dev/null
+++ b/plugins/org.eclipse.etrice.abstractexec.behavior/build.properties
@@ -0,0 +1,5 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml
diff --git a/plugins/org.eclipse.etrice.abstractexec.behavior/plugin.xml b/plugins/org.eclipse.etrice.abstractexec.behavior/plugin.xml
new file mode 100644
index 000000000..07d46d86e
--- /dev/null
+++ b/plugins/org.eclipse.etrice.abstractexec.behavior/plugin.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.eclipse.etrice.core.room.validation">
+ <validator
+ class="org.eclipse.etrice.abstractexec.behavior.DemoValidator"
+ classToCheck="org.eclipse.etrice.core.room.ActorClass"
+ mode="FAST">
+ </validator>
+ <validator
+ class="org.eclipse.etrice.abstractexec.behavior.AbstractExecutionValidator"
+ classToCheck="org.eclipse.etrice.core.room.ActorClass"
+ mode="FAST">
+ </validator>
+ </extension>
+ <extension
+ point="org.eclipse.etrice.core.room.ui.quickfix">
+ <quickfixProvider
+ class="org.eclipse.etrice.abstractexec.behavior.DemoQuickfix"
+ code="demo_issue">
+ </quickfixProvider>
+ </extension>
+
+</plugin>
diff --git a/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/AbstractExecutionValidator.java b/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/AbstractExecutionValidator.java
new file mode 100644
index 000000000..9891e116e
--- /dev/null
+++ b/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/AbstractExecutionValidator.java
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2012 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.abstractexec.behavior;
+
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.etrice.core.genmodel.base.NullDiagnostician;
+import org.eclipse.etrice.core.genmodel.base.NullLogger;
+import org.eclipse.etrice.core.genmodel.builder.GeneratorModelBuilder;
+import org.eclipse.etrice.core.genmodel.etricegen.ExpandedActorClass;
+import org.eclipse.etrice.core.room.ActorClass;
+import org.eclipse.etrice.core.room.InterfaceItem;
+import org.eclipse.etrice.core.room.util.RoomHelpers;
+import org.eclipse.etrice.core.validation.IRoomValidator;
+import org.eclipse.xtext.validation.ValidationMessageAcceptor;
+
+/**
+ * @author rentzhnr
+ *
+ */
+public class AbstractExecutionValidator implements IRoomValidator {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.etrice.core.validation.IRoomValidator#validate(org.eclipse.emf.ecore.EObject, org.eclipse.xtext.validation.ValidationMessageAcceptor)
+ */
+ @Override
+ public void validate(EObject object, ValidationMessageAcceptor messageAcceptor) {
+
+ if (!(object instanceof ActorClass))
+ return;
+
+ ActorClass ac = (ActorClass) object;
+
+ NullDiagnostician diagnostician = new NullDiagnostician();
+ GeneratorModelBuilder builder = new GeneratorModelBuilder(new NullLogger(), diagnostician);
+ ExpandedActorClass xpac = builder.createExpandedActorClass(ac);
+ if (xpac!=null && !diagnostician.isFailed()) {
+ boolean allProtocolsWithSemantics = true;
+ List<InterfaceItem> ifItems = RoomHelpers.getAllInterfaceItems(ac);
+ for (InterfaceItem item : ifItems) {
+ if (item.getProtocol().getSemantics()==null) {
+ allProtocolsWithSemantics = false;
+ break;
+ }
+ }
+
+ if (allProtocolsWithSemantics) {
+ // begin abstract execution on state machine of expanded actor class
+
+ ActionCodeAnalyzer analyzer = new ActionCodeAnalyzer(ac);
+ }
+ }
+ }
+
+}
diff --git a/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/ActionCodeAnalyzer.java b/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/ActionCodeAnalyzer.java
new file mode 100644
index 000000000..ac47532a7
--- /dev/null
+++ b/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/ActionCodeAnalyzer.java
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * Copyright (c) 2012 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.abstractexec.behavior;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.etrice.core.room.ActorClass;
+import org.eclipse.etrice.core.room.DetailCode;
+import org.eclipse.etrice.core.room.InterfaceItem;
+import org.eclipse.etrice.core.room.Message;
+import org.eclipse.etrice.core.room.MessageFromIf;
+import org.eclipse.etrice.core.room.RoomFactory;
+import org.eclipse.etrice.generator.base.DefaultTranslationProvider;
+import org.eclipse.etrice.generator.base.DetailCodeTranslator;
+
+/**
+ * @author Henrik Rentz-Reichert
+ *
+ */
+public class ActionCodeAnalyzer {
+
+ private class Collector extends DefaultTranslationProvider {
+
+ private ArrayList<MessageFromIf> mifs = new ArrayList<MessageFromIf>();
+
+ public ArrayList<MessageFromIf> getMifs() {
+ return mifs;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.etrice.generator.base.DefaultTranslationProvider#getInterfaceItemMessageText(org.eclipse.etrice.core.room.InterfaceItem, org.eclipse.etrice.core.room.Message, java.util.ArrayList, java.lang.String, java.lang.String)
+ */
+ @Override
+ public String getInterfaceItemMessageText(InterfaceItem item,
+ Message msg, ArrayList<String> args, String index, String orig) {
+
+ MessageFromIf mif = RoomFactory.eINSTANCE.createMessageFromIf();
+ mif.setFrom(item);
+ mif.setMessage(msg);
+ mifs.add(mif);
+
+ return orig;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.etrice.generator.base.DefaultTranslationProvider#translateMembers()
+ */
+ @Override
+ public boolean translateMembers() {
+ return true;
+ }
+
+ // create a new list and leave previous unchanged
+ public void begin() {
+ mifs = new ArrayList<MessageFromIf>();
+ }
+ }
+
+ private Collector collector;
+ private DetailCodeTranslator translator;
+
+ public ActionCodeAnalyzer(ActorClass ac) {
+ collector = new Collector();
+ translator = new DetailCodeTranslator(ac, collector);
+ }
+
+ public List<MessageFromIf> analyze(DetailCode dc) {
+ collector.begin();
+ translator.translateDetailCode(dc);
+ return collector.getMifs();
+ }
+}
diff --git a/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/DemoQuickfix.java b/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/DemoQuickfix.java
new file mode 100644
index 000000000..900343e68
--- /dev/null
+++ b/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/DemoQuickfix.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2012 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.abstractexec.behavior;
+
+import org.eclipse.etrice.core.ui.quickfix.IRoomQuickfixProvider;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.xtext.ui.editor.model.IXtextDocument;
+import org.eclipse.xtext.ui.editor.model.edit.IModification;
+import org.eclipse.xtext.ui.editor.model.edit.IModificationContext;
+import org.eclipse.xtext.ui.editor.quickfix.IssueResolutionAcceptor;
+import org.eclipse.xtext.validation.Issue;
+
+public class DemoQuickfix implements IRoomQuickfixProvider {
+
+ public DemoQuickfix() {
+ }
+
+ @Override
+ public void getResolution(final Issue issue, IssueResolutionAcceptor acceptor) {
+ // 3rd arg is image, check ImageHelper how this could work
+ acceptor.accept(issue, issue.getData()[0]+"_ac", "change actor class name to "+issue.getData()[0]+"_ac", null, new IModification() {
+ public void apply(IModificationContext context) throws BadLocationException {
+ IXtextDocument xtextDocument = context.getXtextDocument();
+// String firstLetter = xtextDocument.get(issue.getOffset(), 1);
+ xtextDocument.replace(issue.getOffset()+issue.getData()[0].length(), 0, "_ac");
+ }
+ });
+ }
+
+}
diff --git a/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/DemoValidator.java b/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/DemoValidator.java
new file mode 100644
index 000000000..ade8ace17
--- /dev/null
+++ b/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/DemoValidator.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2012 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.abstractexec.behavior;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.etrice.core.room.ActorClass;
+import org.eclipse.etrice.core.room.RoomPackage;
+import org.eclipse.etrice.core.validation.IRoomValidator;
+import org.eclipse.xtext.validation.ValidationMessageAcceptor;
+
+/**
+ * @author Henrik Rentz-Reichert
+ *
+ */
+public class DemoValidator implements IRoomValidator {
+
+ public static final String DEMO_ISSUE_CODE = "demo_issue";
+
+ // HOWTO: if validator is running in check mode NORMAL there are issues with marker updates
+ // the marker appears grayed and quick fixes aren't available
+
+ @Override
+ public void validate(EObject object,
+ ValidationMessageAcceptor messageAcceptor) {
+
+ if (!(object instanceof ActorClass))
+ return;
+
+ ActorClass ac = (ActorClass) object;
+ if (!ac.getName().endsWith("_ac"))
+ messageAcceptor.acceptWarning("ActorClass name must end with _ac", ac, RoomPackage.Literals.ROOM_CLASS__NAME, -1, DEMO_ISSUE_CODE, ac.getName());
+ }
+
+}

Back to the top