use of org.drools.compiler.lang.descr.EnumDeclarationDescr in project drools by kiegroup.
the class KnowledgeBuilderImpl method buildTypeDeclarations.
protected void buildTypeDeclarations(Collection<CompositePackageDescr> packages) {
Map<String, AbstractClassTypeDeclarationDescr> unprocesseableDescrs = new HashMap<String, AbstractClassTypeDeclarationDescr>();
List<TypeDefinition> unresolvedTypes = new ArrayList<TypeDefinition>();
List<AbstractClassTypeDeclarationDescr> unsortedDescrs = new ArrayList<AbstractClassTypeDeclarationDescr>();
for (CompositePackageDescr packageDescr : packages) {
for (TypeDeclarationDescr typeDeclarationDescr : packageDescr.getTypeDeclarations()) {
unsortedDescrs.add(typeDeclarationDescr);
}
for (EnumDeclarationDescr enumDeclarationDescr : packageDescr.getEnumDeclarations()) {
unsortedDescrs.add(enumDeclarationDescr);
}
}
getTypeBuilder().processTypeDeclarations(packages, unsortedDescrs, unresolvedTypes, unprocesseableDescrs);
for (CompositePackageDescr packageDescr : packages) {
for (ImportDescr importDescr : packageDescr.getImports()) {
getPackageRegistry(packageDescr.getNamespace()).addImport(importDescr);
}
}
}
use of org.drools.compiler.lang.descr.EnumDeclarationDescr in project drools by kiegroup.
the class TypeDeclarationBuilder method normalizeForeignPackages.
protected void normalizeForeignPackages(PackageDescr packageDescr) {
Map<String, PackageDescr> foreignPackages = null;
for (AbstractClassTypeDeclarationDescr typeDescr : packageDescr.getClassAndEnumDeclarationDescrs()) {
if (kbuilder.filterAccepts(ResourceChange.Type.DECLARATION, typeDescr.getNamespace(), typeDescr.getTypeName())) {
if (!typeDescr.getNamespace().equals(packageDescr.getNamespace())) {
// If the type declaration is for a different namespace, process that separately.
PackageDescr altDescr;
if (foreignPackages == null) {
foreignPackages = new HashMap<String, PackageDescr>();
}
if (foreignPackages.containsKey(typeDescr.getNamespace())) {
altDescr = foreignPackages.get(typeDescr.getNamespace());
} else {
altDescr = new PackageDescr(typeDescr.getNamespace());
altDescr.setResource(packageDescr.getResource());
foreignPackages.put(typeDescr.getNamespace(), altDescr);
}
if (typeDescr instanceof TypeDeclarationDescr) {
altDescr.addTypeDeclaration((TypeDeclarationDescr) typeDescr);
} else if (typeDescr instanceof EnumDeclarationDescr) {
altDescr.addEnumDeclaration((EnumDeclarationDescr) typeDescr);
}
for (ImportDescr imp : packageDescr.getImports()) {
altDescr.addImport(imp);
}
kbuilder.getOrCreatePackageRegistry(altDescr);
}
}
}
}
use of org.drools.compiler.lang.descr.EnumDeclarationDescr in project drools by kiegroup.
the class TypeDeclarationNameResolver method qualifyNames.
private void qualifyNames(List<TypeDefinition> unresolvedTypes, PackageDescr packageDescr, TypeResolver typeResolver) {
for (TypeDeclarationDescr declarationDescr : packageDescr.getTypeDeclarations()) {
qualifyNames(declarationDescr, packageDescr, unresolvedTypes, typeResolver);
discoverHierarchyForRedeclarations(declarationDescr, packageDescr, typeResolver);
}
for (EnumDeclarationDescr enumDeclarationDescr : packageDescr.getEnumDeclarations()) {
qualifyNames(enumDeclarationDescr, packageDescr, unresolvedTypes, typeResolver);
}
}
use of org.drools.compiler.lang.descr.EnumDeclarationDescr in project drools by kiegroup.
the class TypeDeclarationFactory method processAnnotations.
public static void processAnnotations(AbstractClassTypeDeclarationDescr typeDescr, TypeDeclaration type) {
Role role = typeDescr.getTypedAnnotation(Role.class);
if (role != null) {
type.setRole(role.value());
}
TypeSafe typeSafe = typeDescr.getTypedAnnotation(TypeSafe.class);
if (typeSafe != null) {
type.setTypesafe(typeSafe.value());
}
if (typeDescr instanceof EnumDeclarationDescr) {
type.setKind(TypeDeclaration.Kind.ENUM);
} else if (typeDescr instanceof TypeDeclarationDescr && ((TypeDeclarationDescr) typeDescr).isTrait()) {
type.setKind(TypeDeclaration.Kind.TRAIT);
}
type.setDynamic(typeDescr.hasAnnotation(PropertyChangeSupport.class));
}
Aggregations