DroolsEclipsePlugin.getDefault().setForceFullBuild();
return changes;
}
private TextFileChange createChangesForFile(IFile drlFile) throws CoreException {
DRLInfo drlInfo = null;
try {
drlInfo = DroolsEclipsePlugin.getDefault().parseResource( drlFile, false );
} catch (DroolsParserException e) { }
if ( drlInfo == null ) {
return null;
}
String content = FileUtil.readFile(drlFile);
if ( content == null ) {
return null;
}
TextFileChange change = new TextFileChange(drlFile.getName(), drlFile);
MultiTextEdit mte = new MultiTextEdit();
change.setEdit(mte);
boolean isImported = false;
for (ImportDescr importDescr : drlInfo.getPackageDescr().getImports()) {
isImported |= importDescr.getTarget().equals(className) || importDescr.getTarget().equals(packageName + ".*");
addReplace(mte, importDescr.getTarget(), content, importDescr.getStartCharacter(), importDescr.getEndCharacter());
}
if (!isImported) {
return change;
}
for (DRLInfo.RuleInfo ruleInfo : drlInfo.getRuleInfos()) {
List<PatternInfo> patternInfos = ruleInfo.getPatternInfos();
if (patternInfos != null) {
for (DRLInfo.PatternInfo patternInfo : patternInfos) {
addReplace(mte, patternInfo.getPatternTypeName(), content, patternInfo.getStart(), patternInfo.getEnd());
}
addReplace(mte, className, content, ruleInfo.getConsequenceStart(), ruleInfo.getConsequenceEnd());
} else {
addReplace(mte, className, content, ruleInfo.getRuleStart(), ruleInfo.getRuleEnd());
}
}
for (DRLInfo.FunctionInfo functionInfo : drlInfo.getFunctionInfos()) {
addReplace(mte, className, content, functionInfo.getFunctionStart(), functionInfo.getFunctionEnd());
}
return change;
}