From 5c1cfd9219168e79f77c779e9c0fb8d47feee790 Mon Sep 17 00:00:00 2001 From: Henrik Rentz-Reichert Date: Fri, 15 Jun 2012 10:49:26 +0200 Subject: [abstractexec.behavior] prepared for reachability check --- .../behavior/AbstractExecutionValidator.java | 67 ++++++++++++++++------ 1 file changed, 50 insertions(+), 17 deletions(-) (limited to 'plugins/org.eclipse.etrice.abstractexec.behavior') 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 9891e116e..73c24b539 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 @@ -14,13 +14,17 @@ package org.eclipse.etrice.abstractexec.behavior; import java.util.List; +import org.eclipse.emf.common.util.TreeIterator; 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.GeneralProtocolClass; import org.eclipse.etrice.core.room.InterfaceItem; +import org.eclipse.etrice.core.room.ProtocolClass; +import org.eclipse.etrice.core.room.StateGraphItem; import org.eclipse.etrice.core.room.util.RoomHelpers; import org.eclipse.etrice.core.validation.IRoomValidator; import org.eclipse.xtext.validation.ValidationMessageAcceptor; @@ -39,26 +43,55 @@ public class AbstractExecutionValidator implements IRoomValidator { 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 ifItems = RoomHelpers.getAllInterfaceItems(ac); - for (InterfaceItem item : ifItems) { - if (item.getProtocol().getSemantics()==null) { - allProtocolsWithSemantics = false; - break; - } + + boolean allProtocolsWithSemantics = true; + List ifItems = RoomHelpers.getAllInterfaceItems(ac); + for (InterfaceItem item : ifItems) { + GeneralProtocolClass pc = item.getGeneralProtocol(); + if (!(pc instanceof ProtocolClass)) + continue; + + if (((ProtocolClass) pc).getSemantics() == null) { + allProtocolsWithSemantics = false; + break; } + } + + if (allProtocolsWithSemantics) { + // begin abstract execution on state machine of expanded actor class + + NullDiagnostician diagnostician = new NullDiagnostician(); + GeneratorModelBuilder builder = new GeneratorModelBuilder(new NullLogger(), diagnostician); + ExpandedActorClass xpac = builder.createExpandedActorClass(ac); - if (allProtocolsWithSemantics) { - // begin abstract execution on state machine of expanded actor class - - ActionCodeAnalyzer analyzer = new ActionCodeAnalyzer(ac); + if (xpac != null && !diagnostician.isFailed()) { + // ActionCodeAnalyzer analyzer = new ActionCodeAnalyzer(ac); +// ReachabilityCheck checker = new ReachabilityCheck(xpac); +// checker.computeReachability(); + + TreeIterator it = xpac.getStateMachine().eAllContents(); + while (it.hasNext()) { + EObject item = it.next(); + if (item instanceof StateGraphItem) + { + StateGraphItem toCheck = (StateGraphItem) item; + if (false/*!checker.isReachable(toCheck)*/) { + System.out.println("Unreachable "+ toCheck.getName()); + + EObject orig = xpac.getOrig(toCheck); + EObject container = orig.eContainer(); + @SuppressWarnings("unchecked") + int idx = ((List)container.eGet(orig.eContainingFeature())).indexOf(orig); + + messageAcceptor.acceptWarning( + "Unreachable state/point of graph", + container, toCheck.eContainingFeature(), idx, + "UNREACHABLE", toCheck.getName()); + } + } + } } } } -- cgit v1.2.3