Here you can find the source of getPackagesInModel(AsmManager modl)
public static List getPackagesInModel(AsmManager modl)
//package com.java2s; /* ******************************************************************* * Copyright (c) 1999-2001 Xerox Corporation, * 2002 Palo Alto Research Center, Incorporated (PARC). * All rights reserved. // www. j a va2 s.c om * This program and the accompanying materials are made available * under the terms of the Eclipse Public License v1.0 * which accompanies this distribution and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Xerox/PARC initial implementation * ******************************************************************/ import java.util.ArrayList; import java.util.Iterator; import java.util.List; import org.aspectj.asm.AsmManager; import org.aspectj.asm.IHierarchy; import org.aspectj.asm.IProgramElement; public class Main { public static List getPackagesInModel(AsmManager modl) { List packages = new ArrayList(); IHierarchy model = modl.getHierarchy(); if (model.getRoot().equals(IHierarchy.NO_STRUCTURE)) { return null; } else { return getPackagesHelper(model.getRoot(), IProgramElement.Kind.PACKAGE, null, packages); } } private static List getPackagesHelper(IProgramElement node, IProgramElement.Kind kind, String prename, List matches) { if (kind == null || node.getKind().equals(kind)) { if (prename == null) { prename = new String(node.toString()); } else { prename = new String(prename + "." + node); } Object[] o = new Object[2]; o[0] = node; o[1] = prename; matches.add(o); } for (Iterator it = node.getChildren().iterator(); it.hasNext();) { IProgramElement nextNode = (IProgramElement) it.next(); getPackagesHelper(nextNode, kind, prename, matches); } return matches; } }