@Override public Object execute(ExecutionEvent event) throws ExecutionException { // TODO: this wrapping try is for debug only. Remove later. final int TIMES = 10; List<Long> runsTimer = new ArrayList<Long>(TIMES); for (int i = 0; i < TIMES; i++) { long startTimer = System.currentTimeMillis(); try { ISelection selection = HandlerUtil.getCurrentSelectionChecked(event); Shell shell = HandlerUtil.getActiveShellChecked(event); if (!(selection instanceof ITextSelection)) throw new ExecutionException("Not a text selection"); IFile textSelectionFile = (IFile) HandlerUtil.getActiveEditorChecked(event).getEditorInput().getAdapter(IFile.class); ITextSelection textSelection = (ITextSelection) selection; SelectionNodesVisitor selectionNodesVisitor = new SelectionNodesVisitor(textSelection); ICompilationUnit compilationUnit = JavaCore.createCompilationUnitFrom(textSelectionFile); ASTParser parser = ASTParser.newParser(AST.JLS3); parser.setSource(compilationUnit); parser.setKind(ASTParser.K_COMPILATION_UNIT); parser.setResolveBindings(true); CompilationUnit jdtCompilationUnit = (CompilationUnit) parser.createAST(null); jdtCompilationUnit.accept(selectionNodesVisitor); Set<ASTNode> selectionNodes = selectionNodesVisitor.getNodes(); System.out.println("Selection" + selectionNodes); IFeatureExtracter extracter = CIDEFeatureExtracterFactory.getInstance().newExtracter(); String correspondentClasspath = MethodDeclarationSootMethodBridge.getCorrespondentClasspath(textSelectionFile); SootManager.configure(correspondentClasspath); MethodDeclaration methodDeclaration = MethodDeclarationSootMethodBridge.getParentMethod(selectionNodes.iterator().next()); String declaringMethodClass = methodDeclaration.resolveBinding().getDeclaringClass().getQualifiedName(); MethodDeclarationSootMethodBridge mdsm = new MethodDeclarationSootMethodBridge(methodDeclaration); SootMethod sootMethod = SootManager.getMethodBySignature( declaringMethodClass, mdsm.getSootMethodSubSignature()); Body body = sootMethod.retrieveActiveBody(); Collection<Unit> unitsInSelection = ASTNodeUnitBridge.getUnitsFromLines( ASTNodeUnitBridge.getLinesFromASTNodes(selectionNodes, jdtCompilationUnit), body); if (unitsInSelection.isEmpty()) { System.out.println("the selection doesn't map to any Soot Unit"); return null; } FeatureModelInstrumentorTransformer instrumentorTransformer = new FeatureModelInstrumentorTransformer(extracter, correspondentClasspath); instrumentorTransformer.transform2(body, correspondentClasspath); FeatureTag<Set<String>> bodyFeatureTag = (FeatureTag<Set<String>>) body.getTag("FeatureTag"); BriefUnitGraph bodyGraph = new BriefUnitGraph(body); LiftedReachingDefinitions reachingDefinitions = new LiftedReachingDefinitions(bodyGraph, bodyFeatureTag.getFeatures()); reachingDefinitions.execute(); Map<Pair<Unit, Set<String>>, Set<Unit>> createProvidesConfigMap = createProvidesConfigMap(unitsInSelection, reachingDefinitions, body); System.out.println(createProvidesConfigMap); String message = createMessage(createProvidesConfigMap); // EmergentPopup.pop(shell, message); } catch (Exception ex) { ex.printStackTrace(); } finally { G.v().reset(); } long estimatedTime = System.currentTimeMillis() - startTimer; runsTimer.add(estimatedTime); } System.out.println(runsTimer); return null; }