summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRohit Agrawal2012-08-16 06:21:12 (EDT)
committerRohit Agrawal2012-08-16 06:21:12 (EDT)
commitc58122321c34dc11466ef74e3db491e8e2d47b91 (patch)
treef59f4bf117fef447e852669813d73d8e31c12265
parentccec3ae50f026dc23d755e340305361c918b114b (diff)
downloadorg.eclipse.etrice-c58122321c34dc11466ef74e3db491e8e2d47b91.zip
org.eclipse.etrice-c58122321c34dc11466ef74e3db491e8e2d47b91.tar.gz
org.eclipse.etrice-c58122321c34dc11466ef74e3db491e8e2d47b91.tar.bz2
[CQ6589] : Working version with warning markers refs/changes/53/7253/1
1. I authored 100% of the content I contributed 2. I have the rights to donate the content to Eclipse 3. I contribute the content under the EPL Change-Id: Iccff8ec4178015c40101653edc7d97801c7febaf
-rw-r--r--plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/AbstractExecutionValidator.java78
-rw-r--r--plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/ProposalGenerator.java7
-rw-r--r--plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/SemanticsCheck.java36
3 files changed, 56 insertions, 65 deletions
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
index b35551a..3901c75 100644
--- 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
@@ -26,9 +26,12 @@ import org.eclipse.etrice.core.room.ActorClass;
import org.eclipse.etrice.core.room.DetailCode;
import org.eclipse.etrice.core.room.GeneralProtocolClass;
import org.eclipse.etrice.core.room.InterfaceItem;
+import org.eclipse.etrice.core.room.MessageFromIf;
import org.eclipse.etrice.core.room.ProtocolClass;
import org.eclipse.etrice.core.room.State;
import org.eclipse.etrice.core.room.StateGraphItem;
+import org.eclipse.etrice.core.room.Trigger;
+import org.eclipse.etrice.core.room.TriggeredTransition;
import org.eclipse.etrice.core.room.util.RoomHelpers;
import org.eclipse.etrice.core.validation.IRoomValidator;
import org.eclipse.xtext.validation.ValidationMessageAcceptor;
@@ -132,43 +135,46 @@ public class AbstractExecutionValidator implements IRoomValidator {
StateGraphItem item = (StateGraphItem) obj;
List<HandledMessage> warningList = checker
.getWarningMsg(item);
- if (traceExec) {
- System.out
- .println("Messages in the warning list for item "
- + item.getName() );
- if(warningList != null)
- for (HandledMessage msg : warningList) {
- System.out.println(msg.getMsg().getName());
- }
+ if (traceExec && warningList != null) {
+ System.out.println("Messages in the warning list for item "+ item.getName() );
}
- /*
- * for(HandledMessage msg : warningList) { EObject
- * origin = msg.getOrigin(); if(origin instanceof
- * ActiveTrigger) { ActiveTrigger trigger =
- * (ActiveTrigger) origin; //TODO : issue a warning
- * marker EObject orig = xpac.getOrig(trigger); EObject
- * container = orig.eContainer();
- *
- * @SuppressWarnings("unchecked") int idx = ((List<?
- * extends
- * EObject>)container.eGet(orig.eContainingFeature
- * ())).indexOf(orig); messageAcceptor.acceptWarning(
- * "The message violates the semantic rule", container,
- * orig.eContainingFeature(), idx, "VIOLATION",
- * trigger.getMsg().getName()); } else if (origin
- * instanceof DetailCode) { DetailCode dc = (DetailCode)
- * origin; EObject orig = xpac.getOrig(dc); EObject
- * container = orig.eContainer();
- *
- * @SuppressWarnings("unchecked") int idx = ((List<?
- * extends
- * EObject>)container.eGet(orig.eContainingFeature
- * ())).indexOf(orig); messageAcceptor.acceptWarning(
- * "The message violates the semantic rule", container,
- * orig.eContainingFeature(), idx, "VIOLATION" );
- *
- * } }
- */
+ if (warningList!=null)
+ for (HandledMessage msg : warningList) {
+ EObject origin = msg.getOrigin();
+ if (origin instanceof ActiveTrigger) {
+ ActiveTrigger trigger = (ActiveTrigger) origin;
+ for (TriggeredTransition trans : trigger.getTransitions()) {
+ // have to translate back the transition to our original model
+ TriggeredTransition orig = (TriggeredTransition) xpac.getOrig(trans);
+ for (Trigger trig : orig.getTriggers()) {
+ for (MessageFromIf mif : trig.getMsgFromIfPairs()) {
+ // messages haven't been copied, so all point to the same objects and we can just compare pointers
+ if (mif.getMessage()==msg.getMsg() && mif.getFrom()==msg.getIfitem()) {
+ messageAcceptor
+ .acceptWarning(
+ "The message violates the semantic rule",
+ trig, mif.eContainingFeature(),
+ trig.getMsgFromIfPairs().indexOf(trig), "VIOLATION", trigger.getMsg().getName());
+ }
+ }
+ }
+ }
+ } else if (origin instanceof DetailCode) {
+ DetailCode dc = (DetailCode) origin;
+ EObject orig = xpac.getOrig(dc);
+ messageAcceptor
+ .acceptWarning(
+ "The message violates the semantic rule",
+ orig.eContainer(),
+ orig.eContainingFeature(), ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
+ "VIOLATION");
+
+ }
+ }
+
+
+
+
}
}
if (traceExec)
diff --git a/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/ProposalGenerator.java b/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/ProposalGenerator.java
index 1d577be..e853b36 100644
--- a/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/ProposalGenerator.java
+++ b/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/ProposalGenerator.java
@@ -71,7 +71,7 @@ public class ProposalGenerator {
incomingProposal.clear();
Set<SemanticsRule> rulesToIgnore = new HashSet<SemanticsRule>();
- if (xpac.getActiveTriggers(st) != null)
+
for (ActiveTrigger trigger : xpac.getActiveTriggers(st)) {
SemanticsRule match = null;
Port port = (Port) trigger.getIfitem();
@@ -88,10 +88,7 @@ public class ProposalGenerator {
// mark this rule for ignoring while generating proposals
// as they have already been taken care of
rulesToIgnore.add(match);
- } else {
- // according to the rules this trigger isn't necessary
- warningTrigger.add(trigger);
- }
+ }
}
// now start generating proposals by listing all the rules and ignoring
diff --git a/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/SemanticsCheck.java b/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/SemanticsCheck.java
index efa6d40..06a399f 100644
--- a/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/SemanticsCheck.java
+++ b/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/SemanticsCheck.java
@@ -90,14 +90,7 @@ public class SemanticsCheck {
msgList.addAll(codeAnalyzer.analyze(((State) cur).getEntryCode()));
}
List<HandledMessage> wrongMsgList = localRules.consumeMessages(msgList);
- if(mapToWarnings.containsKey(trans))
- {
- mapToWarnings.get(trans).addAll(wrongMsgList);
- }
- else
- {
- mapToWarnings.put(trans, wrongMsgList);
- }
+ addToWarning(trans, wrongMsgList);
boolean rulesChanged = false;
if (mapToRules.containsKey(cur)) {
rulesChanged = mapToRules.get(cur).merge(localRules);
@@ -164,15 +157,9 @@ public class SemanticsCheck {
printRules();
}
List<HandledMessage> wrongMsgList = tempRule.consumeMessages(msgList);
+ addToWarning(node, wrongMsgList);
if(mapToWarnings.containsKey(node))
- {
- mapToWarnings.get(node).addAll(wrongMsgList);
- }
- else
- {
- mapToWarnings.put(node, wrongMsgList);
- }
-
+
if (traceChecks && traceLevel>=TRACE_DETAILS)
System.out.println(" Messages consumed");
@@ -205,19 +192,20 @@ public class SemanticsCheck {
msgList.addAll(codeAnalyzer.analyze(((State) target).getEntryCode()));
}
List<HandledMessage> wrongMsgList = tempRule.consumeMessages(msgList);
- if(mapToWarnings.containsKey(node))
- {
- mapToWarnings.get(node).addAll(wrongMsgList);
- }
- else
- {
- mapToWarnings.put(node, wrongMsgList);
- }
+ addToWarning(node, wrongMsgList);
addAndMergeRules(target, tempRule);
}
}
}
+ private void addToWarning(StateGraphItem item,
+ List<HandledMessage> wrongMsgList) {
+ if (mapToWarnings.containsKey(item)) {
+ mapToWarnings.get(item).addAll(wrongMsgList);
+ } else {
+ mapToWarnings.put(item, wrongMsgList);
+ }
+ }
private void addAndMergeRules(StateGraphNode target, ActiveRules tempRule) {
boolean rulesChanged = false;
if (mapToRules.containsKey(target)) {