Search in sources :

Example 6 with QualifiedName

use of org.drools.drl.ast.descr.QualifiedName in project drools by kiegroup.

the class TypeDeclarationNameResolver method ensureQualifiedSuperType.

private void ensureQualifiedSuperType(AbstractClassTypeDeclarationDescr typeDescr, PackageDescr packageDescr, TypeResolver typeResolver, List<TypeDefinition> unresolvedTypes) {
    for (QualifiedName qname : typeDescr.getSuperTypes()) {
        String declaredSuperType = qname.getFullName();
        String resolved = resolveName(declaredSuperType, typeDescr, packageDescr, typeResolver, unresolvedTypes, true);
        if (resolved != null) {
            qname.setName(resolved);
        } else {
            kbuilder.addBuilderResult(new TypeDeclarationError(typeDescr, "Cannot resolve supertype '" + declaredSuperType + " for declared type " + typeDescr.getTypeName()));
        }
    }
}
Also used : TypeDeclarationError(org.drools.compiler.compiler.TypeDeclarationError) QualifiedName(org.drools.drl.ast.descr.QualifiedName)

Example 7 with QualifiedName

use of org.drools.drl.ast.descr.QualifiedName in project drools by kiegroup.

the class DescrTypeDefinition method processSuperTypes.

private void processSuperTypes() {
    for (QualifiedName superType : typeDeclarationDescr.getSuperTypes()) {
        Optional<Class<?>> optResolvedSuper = typeResolver.resolveType(superType.getName());
        optResolvedSuper.ifPresent(resolvedSuper -> {
            if (resolvedSuper.isInterface()) {
                interfaceNames.add(superType.getName());
            } else {
                superTypeName = of(superType.getName());
                abstractClass = of(resolvedSuper);
            }
        });
        // We're extending a class using the Declared Type mechanism, so the super class doesn't exist in the classloader
        if (!optResolvedSuper.isPresent()) {
            superTypeName = of(superType.getName());
            declaredAbstractClass = of(superType.getName());
        }
    }
}
Also used : QualifiedName(org.drools.drl.ast.descr.QualifiedName)

Aggregations

QualifiedName (org.drools.drl.ast.descr.QualifiedName)7 TypeDeclarationError (org.drools.compiler.compiler.TypeDeclarationError)3 AbstractClassTypeDeclarationDescr (org.drools.drl.ast.descr.AbstractClassTypeDeclarationDescr)3 ArrayList (java.util.ArrayList)2 TypeDeclarationDescr (org.drools.drl.ast.descr.TypeDeclarationDescr)2 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 PackageRegistry (org.drools.compiler.compiler.PackageRegistry)1 ClassDefinition (org.drools.core.factmodel.ClassDefinition)1 EnumClassDefinition (org.drools.core.factmodel.EnumClassDefinition)1 Thing (org.drools.core.factmodel.traits.Thing)1 Traitable (org.drools.core.factmodel.traits.Traitable)1 TraitableBean (org.drools.core.factmodel.traits.TraitableBean)1 TypeDeclaration (org.drools.core.rule.TypeDeclaration)1 AnnotationDescr (org.drools.drl.ast.descr.AnnotationDescr)1 TypeFieldDescr (org.drools.drl.ast.descr.TypeFieldDescr)1