int length = 0;
ASTNode[] nodes = null;
if (isInRange) {
requestor.enterCompilationUnit();
}
ImportReference currentPackage = parsedUnit.currentPackage;
ImportReference[] imports = parsedUnit.imports;
TypeDeclaration[] types = parsedUnit.types;
length =
(currentPackage == null ? 0 : 1)
+ (imports == null ? 0 : imports.length)
+ (types == null ? 0 : types.length);
nodes = new ASTNode[length];
int index = 0;
if (currentPackage != null) {
nodes[index++] = currentPackage;
}
if (imports != null) {
for (int i = 0, max = imports.length; i < max; i++) {
nodes[index++] = imports[i];
}
}
if (types != null) {
for (int i = 0, max = types.length; i < max; i++) {
nodes[index++] = types[i];
}
}
// notify the nodes in the syntactical order
if (length > 0) {
quickSort(nodes, 0, length-1);
for (int i=0;i<length;i++) {
ASTNode node = nodes[i];
if (node instanceof ImportReference) {
ImportReference importRef = (ImportReference)node;
if (node == parsedUnit.currentPackage) {
notifySourceElementRequestor(importRef, true);
} else {
notifySourceElementRequestor(importRef, false);
}