// continue to fault in the model.
if (!sourceFileNode.getKind().equals(IProgramElement.Kind.FILE_JAVA)) {
return;
}
ResolvedType aspect = munger.getDeclaringType();
// create the class file node
IProgramElement classFileNode = new ProgramElement(asm, sourceFileNode.getName(), IProgramElement.Kind.FILE,
munger.getBinarySourceLocation(aspect.getSourceLocation()), 0, null, null);
// create package ipe if one exists....
IProgramElement root = asm.getHierarchy().getRoot();
IProgramElement binaries = asm.getHierarchy().findElementForLabel(root, IProgramElement.Kind.SOURCE_FOLDER, "binaries");
if (binaries == null) {
binaries = new ProgramElement(asm, "binaries", IProgramElement.Kind.SOURCE_FOLDER, new ArrayList());
root.addChild(binaries);
}
// if (aspect.getPackageName() != null) {
String packagename = aspect.getPackageName() == null ? "" : aspect.getPackageName();
// check that there doesn't already exist a node with this name
IProgramElement pkgNode = asm.getHierarchy().findElementForLabel(binaries, IProgramElement.Kind.PACKAGE, packagename);
// note packages themselves have no source location
if (pkgNode == null) {
pkgNode = new ProgramElement(asm, packagename, IProgramElement.Kind.PACKAGE, new ArrayList());
binaries.addChild(pkgNode);
pkgNode.addChild(classFileNode);
} else {
// need to add it first otherwise the handle for classFileNode
// may not be generated correctly if it uses information from
// it's parent node
pkgNode.addChild(classFileNode);
for (Iterator iter = pkgNode.getChildren().iterator(); iter.hasNext();) {
IProgramElement element = (IProgramElement) iter.next();
if (!element.equals(classFileNode) && element.getHandleIdentifier().equals(classFileNode.getHandleIdentifier())) {
// already added the classfile so have already
// added the structure for this aspect
pkgNode.removeChild(classFileNode);
return;
}
}
}
// } else {
// // need to add it first otherwise the handle for classFileNode
// // may not be generated correctly if it uses information from
// // it's parent node
// root.addChild(classFileNode);
// for (Iterator iter = root.getChildren().iterator(); iter.hasNext();)
// {
// IProgramElement element = (IProgramElement) iter.next();
// if (!element.equals(classFileNode) &&
// element.getHandleIdentifier().equals
// (classFileNode.getHandleIdentifier())) {
// // already added the sourcefile so have already
// // added the structure for this aspect
// root.removeChild(classFileNode);
// return;
// }
// }
// }
// add and create empty import declaration ipe
// classFileNode.addChild(new ProgramElement(asm, "import declarations", IProgramElement.Kind.IMPORT_REFERENCE, null, 0,
// null,
// null));
// add and create aspect ipe
IProgramElement aspectNode = new ProgramElement(asm, aspect.getSimpleName(), IProgramElement.Kind.ASPECT,
munger.getBinarySourceLocation(aspect.getSourceLocation()), aspect.getModifiers(), null, null);
classFileNode.addChild(aspectNode);
String sourcefilename = getSourceFileName(aspect);
addPointcuts(asm, sourcefilename, aspect, aspectNode, aspect.getDeclaredPointcuts());
addChildNodes(asm, aspect, aspectNode, aspect.getDeclaredAdvice());
addChildNodes(asm, aspect, aspectNode, aspect.getDeclares());
addChildNodes(asm, aspect, aspectNode, aspect.getTypeMungers());
}