Search in sources :

Example 1 with CexExtractorRegistry

use of com.rockwellcollins.atc.agree.analysis.extentions.CexExtractorRegistry in project AGREE by loonwerks.

the class AgreeMenuListener method addViewCounterexampleMenu.

private void addViewCounterexampleMenu(IMenuManager manager, AnalysisResult original) {
    AnalysisResult result = transformResult(original);
    final List<Counterexample> cexs = getCounterexamples(result);
    final Property property = getProperty(result);
    CexExtractorRegistry cexReg = (CexExtractorRegistry) ExtensionRegistry.getRegistry(ExtensionRegistry.CEX_EXTRACTOR_EXT_ID);
    List<CexExtractor> extractors = cexReg.getCexExtractors();
    if (cexs != null) {
        for (Counterexample cex : cexs) {
            final String cexType = getCounterexampleType(result);
            Map<String, EObject> tempRefMap = linker.getReferenceMap(result.getParent());
            if (tempRefMap == null) {
                tempRefMap = linker.getReferenceMap(result);
            }
            Layout tempLayout = linker.getLayout(result.getParent());
            if (tempLayout == null) {
                tempLayout = linker.getLayout(result);
            }
            Renaming tempRenaming = linker.getRenaming(result.getParent());
            if (tempRenaming == null) {
                tempRenaming = linker.getRenaming(result);
            }
            final Layout layout = tempLayout;
            final Map<String, EObject> refMap = tempRefMap;
            final AgreeRenaming renaming = (AgreeRenaming) tempRenaming;
            final Counterexample translatedCex = translateCounterexampleArrayIndices(cex);
            MenuManager sub = new MenuManager("View " + cexType + "Counterexample in");
            manager.add(sub);
            sub.add(new Action("Console") {

                @Override
                public void run() {
                    viewCexConsole(translatedCex, layout, refMap, 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);
                }
            });
            InvalidProperty invalid = findInvalidProperty(original);
            if (invalid != null) {
                String report = invalid.getReport();
                if (report != null) {
                    sub.add(new Action("Web Browser") {

                        @Override
                        public void run() {
                            viewCexBrowser(report);
                        }
                    });
                }
            }
            // send counterexamples to external plugins
            EObject agreeProperty = refMap.get(result.getName());
            ComponentImplementation compImpl = linker.getComponent(result.getParent());
            for (CexExtractor ex : extractors) {
                sub.add(new Action(ex.getDisplayText()) {

                    @Override
                    public void run() {
                        ex.receiveCex(compImpl, property, agreeProperty, cex, refMap);
                    }
                });
            }
        }
    }
}
Also used : ComponentImplementation(org.osate.aadl2.ComponentImplementation) IAction(org.eclipse.jface.action.IAction) Action(org.eclipse.jface.action.Action) AgreeRenaming(com.rockwellcollins.atc.agree.analysis.AgreeRenaming) CexExtractorRegistry(com.rockwellcollins.atc.agree.analysis.extentions.CexExtractorRegistry) CexExtractor(com.rockwellcollins.atc.agree.analysis.extentions.CexExtractor) Counterexample(jkind.results.Counterexample) AnalysisResult(jkind.api.results.AnalysisResult) AgreeRenaming(com.rockwellcollins.atc.agree.analysis.AgreeRenaming) Renaming(jkind.api.results.Renaming) Layout(jkind.results.layout.Layout) EObject(org.eclipse.emf.ecore.EObject) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) ValidProperty(jkind.results.ValidProperty) Property(jkind.results.Property) InvalidProperty(jkind.results.InvalidProperty) UnknownProperty(jkind.results.UnknownProperty) InvalidProperty(jkind.results.InvalidProperty)

Aggregations

AgreeRenaming (com.rockwellcollins.atc.agree.analysis.AgreeRenaming)1 CexExtractor (com.rockwellcollins.atc.agree.analysis.extentions.CexExtractor)1 CexExtractorRegistry (com.rockwellcollins.atc.agree.analysis.extentions.CexExtractorRegistry)1 AnalysisResult (jkind.api.results.AnalysisResult)1 Renaming (jkind.api.results.Renaming)1 Counterexample (jkind.results.Counterexample)1 InvalidProperty (jkind.results.InvalidProperty)1 Property (jkind.results.Property)1 UnknownProperty (jkind.results.UnknownProperty)1 ValidProperty (jkind.results.ValidProperty)1 Layout (jkind.results.layout.Layout)1 EObject (org.eclipse.emf.ecore.EObject)1 Action (org.eclipse.jface.action.Action)1 IAction (org.eclipse.jface.action.IAction)1 IMenuManager (org.eclipse.jface.action.IMenuManager)1 MenuManager (org.eclipse.jface.action.MenuManager)1 ComponentImplementation (org.osate.aadl2.ComponentImplementation)1