protected void initChildren(IProgressMonitor monitor) {
CompilationUnit astNode = getASTNode();
List<?> types = astNode.types();
for (int i = 0; i < types.size(); i++) {
AbstractTypeDeclaration declaration = (AbstractTypeDeclaration) types
.get(i);
if (declaration instanceof TypeDeclaration) {
TypeDeclaration typeDeclaration = (TypeDeclaration) declaration;
IType type = ((ICompilationUnit) getJavaElement())
.getType(typeDeclaration.getName().getIdentifier());
AbstractMetricElement next = new TypeMetric(type
.getHandleIdentifier(), typeDeclaration, analyzer);
if (next != null)
addChild(next);
else
logger.warning("Get null TypeMetric when initializing.");
addInnerClasses(typeDeclaration, type);
} else if (declaration instanceof EnumDeclaration) {
EnumDeclaration enumDeclaration = (EnumDeclaration) declaration;
IType type = ((ICompilationUnit) getJavaElement())
.getType(enumDeclaration.getName().getIdentifier());
AbstractMetricElement next = new EnumMetric(type
.getHandleIdentifier(), enumDeclaration, analyzer);
if (next != null)
addChild(next);
else
logger.warning("Get null EnumMetric when initializing.");
} else if (declaration instanceof AnnotationTypeDeclaration) {
AnnotationTypeDeclaration annotationDeclaration = (AnnotationTypeDeclaration) declaration;
IType type = ((ICompilationUnit) getJavaElement())
.getType(annotationDeclaration.getName()
.getIdentifier());
AbstractMetricElement next = new AnnotationTypeMetric(type
.getHandleIdentifier(), annotationDeclaration, analyzer);
if (next != null)
addChild(next);
else
logger
.warning("Get null AnnotationTypeMetric when initializing.");
} else
logger.warning("Unknown type : "
+ declaration.getClass().getName());
}
}