// Check if already defined in the model
// IProgramElement filenode =
// model.getHierarchy().findElementForType(aspect.getPackageName(),
// aspect.getClassName());
// SourceLine(typeTransformer.getSourceLocation());
IProgramElement filenode = model.getHierarchy().findElementForSourceLine(typeTransformer.getSourceLocation());
if (filenode == null) {
if (typeTransformer.getKind() == ResolvedTypeMunger.MethodDelegate2
|| typeTransformer.getKind() == ResolvedTypeMunger.FieldHost) {
// not yet faulting these in
return;
}
}
// the call to findElementForSourceLine(ISourceLocation) returns a file
// node
// if it can't find a node in the hierarchy for the given
// sourcelocation.
// Therefore, if this is returned, we know we can't find one and have to
// // continue to fault in the model.
// if (filenode != null) { //
if (!filenode.getKind().equals(IProgramElement.Kind.FILE_JAVA)) {
return;
}
// create the class file node
ISourceLocation binLocation = getBinarySourceLocation(aspect, aspect.getSourceLocation());
String f = getBinaryFile(aspect).getName();
IProgramElement classFileNode = new ProgramElement(model, f, IProgramElement.Kind.FILE, binLocation, 0, null, null);
// create package ipe if one exists....
IProgramElement root = model.getHierarchy().getRoot();
IProgramElement binaries = model.getHierarchy().findElementForLabel(root, IProgramElement.Kind.SOURCE_FOLDER, "binaries");
if (binaries == null) {
binaries = new ProgramElement(model, "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 = model.getHierarchy().findElementForLabel(binaries, IProgramElement.Kind.PACKAGE, packagename);
// note packages themselves have no source location
if (pkgNode == null) {
pkgNode = new ProgramElement(model, 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
// no import container for binary type - 265693
// classFileNode.addChild(new ProgramElement(model, "import declarations", IProgramElement.Kind.IMPORT_REFERENCE, null, 0,
// null, null));
// add and create aspect ipe
IProgramElement aspectNode = new ProgramElement(model, aspect.getSimpleName(), IProgramElement.Kind.ASPECT,
getBinarySourceLocation(aspect, aspect.getSourceLocation()), aspect.getModifiers(), null, null);
classFileNode.addChild(aspectNode);
addChildNodes(model, aspect, aspectNode, aspect.getDeclaredPointcuts());