use of org.eclipse.n4js.xpect.common.N4JSOffsetAdapter.EObjectCoveringRegion in project n4js by eclipse.
the class FlowgraphsXpectMethod method performBranchAnalysis.
private AllBranchPrintVisitor performBranchAnalysis(IEObjectCoveringRegion offset, String directionName, IEObjectCoveringRegion referenceOffset) {
EObjectCoveringRegion offsetImpl = (EObjectCoveringRegion) offset;
EObjectCoveringRegion referenceOffsetImpl = (EObjectCoveringRegion) referenceOffset;
ControlFlowElement startCFE = getCFEWithReference(offsetImpl, referenceOffsetImpl);
ControlFlowElement referenceCFE = getCFE(referenceOffset);
TraverseDirection direction = getDirection(directionName);
ControlFlowElement container = FGUtils.getCFContainer(referenceCFE);
AllBranchPrintVisitor appw = new AllBranchPrintVisitor(container, startCFE, direction);
getFlowAnalyzer(referenceCFE).accept(appw);
return appw;
}
use of org.eclipse.n4js.xpect.common.N4JSOffsetAdapter.EObjectCoveringRegion in project n4js by eclipse.
the class FlowgraphsXpectMethod method path.
/**
* This xpect method can evaluate if the tested element is a transitive predecessor of the given element.
*/
@ParameterParser(syntax = "'from' arg0=OFFSET ('to' arg1=OFFSET)? ('notTo' arg2=OFFSET)? ('via' arg3=OFFSET)? ('notVia' arg4=OFFSET)? ('pleaseNeverUseThisParameterSinceItExistsOnlyToGetAReferenceOffset' arg5=OFFSET)?")
@Xpect
public void path(IEObjectCoveringRegion fromOffset, IEObjectCoveringRegion toOffset, IEObjectCoveringRegion notToOffset, IEObjectCoveringRegion viaOffset, IEObjectCoveringRegion notViaOffset, IEObjectCoveringRegion referenceOffset) {
EObjectCoveringRegion toOffsetImpl = (EObjectCoveringRegion) toOffset;
EObjectCoveringRegion notToOffsetImpl = (EObjectCoveringRegion) notToOffset;
EObjectCoveringRegion viaOffsetImpl = (EObjectCoveringRegion) viaOffset;
EObjectCoveringRegion notViaOffsetImpl = (EObjectCoveringRegion) notViaOffset;
EObjectCoveringRegion referenceOffsetImpl = (EObjectCoveringRegion) referenceOffset;
ControlFlowElement fromCFE = getCFE(fromOffset);
ControlFlowElement toCFE = getCFEWithReference(toOffsetImpl, referenceOffsetImpl);
ControlFlowElement notToCFE = getCFEWithReference(notToOffsetImpl, referenceOffsetImpl);
ControlFlowElement viaCFE = getCFEWithReference(viaOffsetImpl, referenceOffsetImpl);
ControlFlowElement notViaCFE = getCFEWithReference(notViaOffsetImpl, referenceOffsetImpl);
ControlFlowElement targetCFE = (toCFE != null) ? toCFE : notToCFE;
boolean expectPathExists = toCFE != null;
if (fromCFE == null) {
fail("Element 'from' could not be found");
}
if (targetCFE == null) {
fail("Element 'to' or 'notTo' could not be found or before 'from'");
}
boolean actualPathExists;
if (viaCFE != null) {
actualPathExists = getFlowAnalyzer(fromCFE).isTransitiveSuccessor(fromCFE, viaCFE, notViaCFE);
actualPathExists &= getFlowAnalyzer(fromCFE).isTransitiveSuccessor(viaCFE, targetCFE, notViaCFE);
} else {
actualPathExists = getFlowAnalyzer(fromCFE).isTransitiveSuccessor(fromCFE, targetCFE, notViaCFE);
}
if (expectPathExists && !actualPathExists) {
fail("Path not found");
}
if (!expectPathExists && actualPathExists) {
fail("A path was found");
}
}
Aggregations