}
protected void loadImportsAndFunctions() {
try {
DRLInfo drlInfo = DroolsEclipsePlugin.getDefault().parseResource(this, true, false);
PackageDescr descr = drlInfo.getPackageDescr();
// package
this.packageName = drlInfo.getPackageName();
// imports
List<ImportDescr> allImports = descr.getImports();
this.imports = new ArrayList<String>();
if (packageName != null) {
imports.addAll(getAllClassesInPackage(packageName));
}
Iterator<ImportDescr> iterator = allImports.iterator();
while (iterator.hasNext()) {
String importName = iterator.next().getTarget();
if (importName.endsWith(".*")) {
String packageName = importName.substring(0, importName.length() - 2);
imports.addAll(getAllClassesInPackage(packageName));
} else {
imports.add(importName);
}
}
// functions
List<FunctionDescr> functionDescrs = descr.getFunctions();
List<FunctionImportDescr> functionImports = descr.getFunctionImports();
functions = new ArrayList<String>(functionDescrs.size());
Iterator<FunctionDescr> iterator2 = functionDescrs.iterator();
while (iterator2.hasNext()) {
functions.add(iterator2.next().getName());
}
Iterator<FunctionImportDescr> iterator3 = functionImports.iterator();
while (iterator3.hasNext()) {
String functionImport = iterator3.next().getTarget();
if (functionImport.endsWith(".*")) {
String className = functionImport.substring(0, functionImport.length() - 2);
functions.addAll(getAllStaticMethodsInClass(className));
} else {
int index = functionImport.lastIndexOf('.');
if (index != -1) {
functions.add(functionImport.substring(index + 1));
}
}
}
// globals
List<GlobalDescr> globalDescrs = descr.getGlobals();
globals = new ArrayList<GlobalDescr>();
Iterator<GlobalDescr> iterator5 = globalDescrs.iterator();
while (iterator5.hasNext()) {
globals.add(iterator5.next());
}
//attributes
this.attributes = new HashMap<String, String>();
for (Iterator<AttributeDescr> attrIter = descr.getAttributes().iterator(); attrIter.hasNext();) {
AttributeDescr attribute = attrIter.next();
if (attribute != null && attribute.getName() != null) {
attributes.put(attribute.getName(), attribute.getValue());
}
}