use of jkind.api.results.Renaming in project AGREE by loonwerks.
the class TestCaseGeneratorMenuListener method addViewTestCaseMenu.
private void addViewTestCaseMenu(IMenuManager manager, AnalysisResult result) {
final Counterexample cex = getCounterexample(result);
TcgExtractorRegistry tcgReg = (TcgExtractorRegistry) ExtensionRegistry.getRegistry(ExtensionRegistry.TCG_EXTRACTOR_EXT_ID);
List<TcgExtractor> extractors = tcgReg.getTcgExtractors();
if (cex != null) {
final String cexType = getCounterexampleType(result);
final Layout layout = linker.getLayout(result.getParent());
final Renaming renaming = linker.getRenaming(result.getParent());
final Map<String, EObject> refMap = ((TcgRenaming) renaming).getTcgRefMap();
final Counterexample translatedCex = AgreeMenuListener.translateCounterexampleArrayIndices(cex);
MenuManager sub = new MenuManager("View " + cexType + "Test Case in");
manager.add(sub);
sub.add(new Action("Console") {
@Override
public void run() {
viewCexConsole(translatedCex, layout, refMap, (TcgRenaming) renaming);
}
});
sub.add(new Action("Eclipse") {
@Override
public void run() {
viewCexEclipse(translatedCex, layout, refMap);
}
});
sub.add(new Action("Spreadsheet") {
@Override
public void run() {
viewCexSpreadsheet(translatedCex, layout);
}
});
// send counterexamples to external plugins
PropertyResult pr = (PropertyResult) result;
EObject property = refMap.get(pr.getName());
ComponentImplementation compImpl = linker.getComponent(result.getParent());
for (TcgExtractor ex : extractors) {
sub.add(new Action(ex.getDisplayText()) {
@Override
public void run() {
ex.receiveCex(compImpl, property, translatedCex, refMap);
}
});
}
}
}
use of jkind.api.results.Renaming in project AGREE by loonwerks.
the class TestSuiteMenuListener method addViewTestCaseMenu.
private void addViewTestCaseMenu(IMenuManager manager, TestCase testCase) {
final Counterexample cex = testCase.getCex();
TcgExtractorRegistry tcgReg = (TcgExtractorRegistry) ExtensionRegistry.getRegistry(ExtensionRegistry.TCG_EXTRACTOR_EXT_ID);
List<TcgExtractor> extractors = tcgReg.getTcgExtractors();
if (cex != null) {
/*
* TODO: getCounterexampleType?
*/
// final String cexType = getCounterexampleType(result);
final String cexType = "";
final Layout layout = linker.getLayout(result);
final Renaming renaming = linker.getRenaming(result);
final Map<String, EObject> refMap = ((TcgRenaming) linker.getRenaming(result)).getTcgRefMap();
final Counterexample translatedCex = AgreeMenuListener.translateCounterexampleArrayIndices(cex);
MenuManager sub = new MenuManager("View " + cexType + "Test Case in");
manager.add(sub);
sub.add(new Action("Console") {
@Override
public void run() {
viewCexConsole(translatedCex, layout, refMap, (TcgRenaming) renaming);
}
});
sub.add(new Action("Eclipse") {
@Override
public void run() {
viewCexEclipse(translatedCex, layout, refMap);
}
});
sub.add(new Action("Spreadsheet") {
@Override
public void run() {
viewCexSpreadsheet(translatedCex, layout);
}
});
// send counterexamples to external plugins
EObject property = refMap.get(testCase.getName());
ComponentImplementation compImpl = linker.getComponent(result);
for (TcgExtractor ex : extractors) {
sub.add(new Action(ex.getDisplayText()) {
@Override
public void run() {
ex.receiveCex(compImpl, property, translatedCex, refMap);
}
});
}
}
}
use of jkind.api.results.Renaming in project AGREE by loonwerks.
the class ExportAction method buildExportArguments.
private ExportArguments buildExportArguments() {
final SimulationUIService simUiService = (SimulationUIService) Objects.requireNonNull(PlatformUI.getWorkbench().getService(SimulationUIService.class), "Unable to retrieve Simulation UI Service");
final SimulatorState simulatorState = simUiService.getCurrentState();
if (!(simulatorState.getEngineState() instanceof AGREESimulationState)) {
throw new RuntimeException("Simulation engine state must be an AGREESimulationState");
}
if (!(simulatorState.getSimulationEngine() instanceof AGREESimulationEngine)) {
throw new RuntimeException("Simulation engine must be an AGREESimulationEngine");
}
final AGREESimulationState agreeSimState = (AGREESimulationState) simulatorState.getEngineState();
final AGREESimulationEngine engine = (AGREESimulationEngine) simulatorState.getSimulationEngine();
final ComponentImplementation componentImplementation = engine.getSystemInstance().getComponentImplementation();
final Counterexample cex = buildCounterexample(agreeSimState);
final Renaming renaming = engine.getSimulationProgram().getAgreeRenaming();
return new ExportArguments() {
@Override
public ComponentImplementation getComponentImplementation() {
return componentImplementation;
}
@Override
public Counterexample getCounterexample() {
return cex;
}
@Override
public Renaming getAgreeRenaming() {
return renaming;
}
};
}
use of jkind.api.results.Renaming in project AGREE by loonwerks.
the class AgreeMenuListener method addViewSupportConsole.
private IAction addViewSupportConsole(String text, IMenuManager manager, AnalysisResult result) {
return new Action(text) {
@Override
public void run() {
Map<String, EObject> tempRefMap = linker.getReferenceMap(result.getParent());
if (tempRefMap == null) {
tempRefMap = linker.getReferenceMap(result);
}
final Map<String, EObject> refMap = tempRefMap;
final MessageConsole console = findConsole("Support");
Renaming tempRenaming = linker.getRenaming(result);
while (tempRenaming == null) {
AnalysisResult parent = result.getParent();
if (parent == null) {
throw new AgreeException("Problem finding renaming");
}
tempRenaming = linker.getRenaming(parent);
}
final Renaming renaming = tempRenaming;
showConsole(console);
console.clearConsole();
if (patternListener != null) {
console.removePatternMatchListener(patternListener);
}
patternListener = new AgreePatternListener(refMap);
console.addPatternMatchListener(patternListener);
new Thread(() -> {
if (renaming instanceof AgreeRenaming) {
writeIvcResult(result, console, (AgreeRenaming) renaming);
}
}).start();
}
};
}
use of jkind.api.results.Renaming in project AGREE by loonwerks.
the class AgreeMenuListener method addViewTraceabilityConsole.
private IAction addViewTraceabilityConsole(String text, IMenuManager manager, AnalysisResult result) {
return new Action(text) {
@Override
public void run() {
Map<String, EObject> tempRefMap = linker.getReferenceMap(result.getParent());
if (tempRefMap == null) {
tempRefMap = linker.getReferenceMap(result);
}
final Map<String, EObject> refMap = tempRefMap;
final MessageConsole console = findConsole("Traceability");
final Renaming renaming = linker.getRenaming(result);
showConsole(console);
console.clearConsole();
console.addPatternMatchListener(new AgreePatternListener(refMap));
new Thread(() -> {
try {
MessageConsoleStream out = console.newMessageStream();
printHLine(out, 2);
out.println("Traceability for Valid Contract Guarantees");
printHLine(out, 2);
out.println("");
List<PropertyResult> allProperties = new ArrayList<PropertyResult>(((JKindResult) result).getPropertyResults());
if (!allProperties.isEmpty()) {
for (PropertyResult prop : allProperties) {
if (prop.getStatus().equals(jkind.api.results.Status.VALID)) {
if (renaming instanceof AgreeRenaming) {
writeIvcResult(prop, console, (AgreeRenaming) renaming);
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}).start();
}
};
}
Aggregations