Search in sources :

Example 6 with QualifiedName

use of org.drools.compiler.lang.descr.QualifiedName in project drools by kiegroup.

the class TypeDeclarationBuilder method mergeTypeDescriptors.

private boolean mergeTypeDescriptors(AbstractClassTypeDeclarationDescr prev, AbstractClassTypeDeclarationDescr descr) {
    boolean isDef1 = isDefinition(prev);
    boolean isDef2 = isDefinition(descr);
    if (isDef1 && isDef2) {
        return false;
    }
    if (!prev.getSuperTypes().isEmpty() && !descr.getSuperTypes().isEmpty() && prev.getSuperTypes().size() != descr.getSuperTypes().size()) {
        return false;
    }
    if (prev.getSuperTypes().isEmpty()) {
        for (QualifiedName qn : descr.getSuperTypes()) {
            ((TypeDeclarationDescr) prev).addSuperType(qn);
        }
    }
    if (prev.getFields().isEmpty()) {
        for (String fieldName : descr.getFields().keySet()) {
            prev.addField(descr.getFields().get(fieldName));
        }
    }
    for (AnnotationDescr ad : descr.getAnnotations()) {
        prev.addQualifiedAnnotation(ad);
    }
    for (AnnotationDescr ad : prev.getAnnotations()) {
        if (!descr.getAnnotations().contains(ad)) {
            descr.addQualifiedAnnotation(ad);
        }
    }
    return true;
}
Also used : AbstractClassTypeDeclarationDescr(org.drools.compiler.lang.descr.AbstractClassTypeDeclarationDescr) TypeDeclarationDescr(org.drools.compiler.lang.descr.TypeDeclarationDescr) QualifiedName(org.drools.compiler.lang.descr.QualifiedName) AnnotationDescr(org.drools.compiler.lang.descr.AnnotationDescr)

Example 7 with QualifiedName

use of org.drools.compiler.lang.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.compiler.lang.descr.QualifiedName)

Aggregations

QualifiedName (org.drools.compiler.lang.descr.QualifiedName)7 AbstractClassTypeDeclarationDescr (org.drools.compiler.lang.descr.AbstractClassTypeDeclarationDescr)4 TypeDeclarationError (org.drools.compiler.compiler.TypeDeclarationError)3 TypeDeclarationDescr (org.drools.compiler.lang.descr.TypeDeclarationDescr)3 ArrayList (java.util.ArrayList)2 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 PackageRegistry (org.drools.compiler.compiler.PackageRegistry)1 AnnotationDescr (org.drools.compiler.lang.descr.AnnotationDescr)1 TypeFieldDescr (org.drools.compiler.lang.descr.TypeFieldDescr)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