&& javaProject.isOnClasspath(resource)) {
IFile file = (IFile) resource;
if ("drl".equals(resource.getFileExtension())
|| "dslr".equals(resource.getFileExtension())) {
try {
DRLInfo drlInfo = DroolsEclipsePlugin.getDefault().parseResource(resource, false);
String packageName = drlInfo.getPackageName();
Package pkg = ruleSet.getPackage(packageName);
if (pkg == null) {
pkg = DroolsModelBuilder.addPackage(ruleSet, packageName, 0, 0);
}
if (drlInfo.getBuilderErrors().length > 0 || drlInfo.getPackageDescr() == null) {
return false;
}
// add rules
List rules = drlInfo.getPackageDescr().getRules();
for (Iterator iterator = rules.iterator(); iterator.hasNext();) {
RuleDescr ruleDescr = (RuleDescr) iterator.next();
boolean isQuery = ruleDescr instanceof QueryDescr;
String ruleName = ruleDescr.getName();
if (!isQuery) {
Rule rule = DroolsModelBuilder.addRule(
pkg, ruleName, file, ruleDescr.getStartCharacter(),
ruleDescr.getEndCharacter() - ruleDescr.getStartCharacter() + 1, null);
// create link between resource and created rule nodes
List droolsElements = (List) resourcesMap.get(file);
if (droolsElements == null) {
droolsElements = new ArrayList();
resourcesMap.put(file, droolsElements);
}
droolsElements.add(rule);
} else {
Query query = DroolsModelBuilder.addQuery(
pkg, ruleName, file, ruleDescr.getStartCharacter(),
ruleDescr.getEndCharacter() - ruleDescr.getStartCharacter() + 1);
// create link between resource and created rule nodes
List droolsElements = (List) resourcesMap.get(file);
if (droolsElements == null) {
droolsElements = new ArrayList();
resourcesMap.put(file, droolsElements);
}
droolsElements.add(query);
}
}
// add globals
List globals = drlInfo.getPackageDescr().getGlobals();
for (Iterator iterator = globals.iterator(); iterator.hasNext();) {
GlobalDescr globalDescr = (GlobalDescr) iterator.next();
Global global = DroolsModelBuilder.addGlobal(
pkg, globalDescr.getIdentifier(), file, globalDescr.getStartCharacter(),
globalDescr.getEndCharacter() - globalDescr.getStartCharacter() + 1);
// create link between resource and created rule nodes
List droolsElements = (List) resourcesMap.get(file);
if (droolsElements == null) {
droolsElements = new ArrayList();
resourcesMap.put(file, droolsElements);
}
droolsElements.add(global);
}
// add functions
List functions = drlInfo.getPackageDescr().getFunctions();
for (Iterator iterator = functions.iterator(); iterator.hasNext();) {
FunctionDescr functionDescr = (FunctionDescr) iterator.next();
String functionName = functionDescr.getName();
Function function = DroolsModelBuilder.addFunction(
pkg, functionName, file, functionDescr.getStartCharacter(),