type.setResource(typeDescr.getResource());
return type;
}
protected TypeDeclaration getParentDeclaration( AbstractClassTypeDeclarationDescr typeDescr, List<TypeDefinition> unresolvedTypes ) {
TypeDeclaration parent = null;
if ( ! typeDescr.getSuperTypes().isEmpty() ) {
// parent might have inheritable properties
PackageRegistry sup = kbuilder.getPackageRegistry( typeDescr.getSuperTypeNamespace() );
if ( sup != null ) {
parent = sup.getPackage().getTypeDeclaration( typeDescr.getSuperTypeName() );
if ( parent == null ) {
/*
for ( TypeDefinition tdef : unresolvedTypes ) {
if ( tdef.getTypeClassName().equals( typeDescr.getSuperTypes().get( 0 ).getFullName() ) ) {
parent = tdef.type;
}
}
*/
}
if (parent == null) {
// FIXME Does this behavior still make sense? The need to redeclare an existing (java) class in order to be able to extend it...
// kbuilder.addBuilderResult(new TypeDeclarationError(typeDescr, "Declared class " + typeDescr.getTypeName() + " can't extend class " + typeDescr.getSuperTypeName() + ", it should be declared"));
} else {
if (parent.getNature() == TypeDeclaration.Nature.DECLARATION && kbuilder.getKnowledgeBase() != null) {
// trying to find a definition
parent = kbuilder.getKnowledgeBase().getPackagesMap().get(typeDescr.getSuperTypeNamespace()).getTypeDeclaration(typeDescr.getSuperTypeName());
}
}
}