List of usage examples for org.aspectj.asm IHierarchy getRoot
public IProgramElement getRoot();
From source file:org.caesarj.ui.marker.AdviceMarkerGenerator.java
License:Open Source License
public void generateMarkers(IProject project, IHierarchy hierarchy) { this.project = project; this.process(hierarchy.getRoot()); }
From source file:org.eclipse.ajdt.core.model.AJProjectModelFacade.java
License:Open Source License
/** * useful for testing//ww w . j a v a 2 s . c om */ public static String printHierarchy(IHierarchy h) { final StringBuffer sb = new StringBuffer(); HierarchyWalker walker = new HierarchyWalker() { int depth = 0; protected void preProcess(IProgramElement node) { sb.append(spaces(depth)); sb.append(node.getHandleIdentifier()); sb.append("\n"); depth += 2; } protected void postProcess(IProgramElement node) { depth -= 2; } String spaces(int depth) { StringBuffer sb = new StringBuffer(); for (int i = 0; i < depth; i++) { sb.append(" "); } return sb.toString(); } }; h.getRoot().walk(walker); return sb.toString(); }
From source file:org.eclipse.ajdt.core.tests.model.AbstractModelTest.java
License:Open Source License
protected void checkHandles(IJavaProject jProject) throws Exception { final AJProjectModelFacade model = AJProjectModelFactory.getInstance().getModelForJavaElement(jProject); final List<String> accumulatedErrors = new ArrayList<String>(); // check all the java handles IPackageFragment[] frags = jProject.getPackageFragments(); for (int i = 0; i < frags.length; i++) { ICompilationUnit[] units = frags[i].getCompilationUnits(); for (int j = 0; j < units.length; j++) { accumulatedErrors.addAll(walk(units[j], model)); }//from ww w. ja v a2 s .c om } // now check all the aj handles AsmManager asm = AspectJPlugin.getDefault().getCompilerFactory() .getCompilerForProject(jProject.getProject()).getModel(); IHierarchy hierarchy = asm.getHierarchy(); hierarchy.getRoot().walk(new HierarchyWalker() { protected void preProcess(IProgramElement node) { try { HandleTestUtils.checkAJHandle(node.getHandleIdentifier(), model); } catch (JavaModelException e) { throw new RuntimeException(e); } } }); if (accumulatedErrors.size() > 0) { StringBuffer sb = new StringBuffer(); sb.append("Found errors in comparing elements:\n"); for (String msg : accumulatedErrors) { sb.append(msg + "\n"); } fail(sb.toString()); } }