}
final FromDescr fromDescr = (FromDescr) descr;
final MVELExprDescr expr = (MVELExprDescr) fromDescr.getDataSource();
From from = null;
try {
Map<String, Declaration> decls = context.getDeclarationResolver().getDeclarations(context.getRule());
String text = (String) expr.getText();
AnalysisResult analysis = dialect.analyzeExpression( context,
descr,
text,
new BoundIdentifiers(context.getDeclarationResolver().getDeclarationClasses( decls ),
context.getPackageBuilder().getGlobals() ) );
if ( analysis == null ) {
// something bad happened
return null;
}
final BoundIdentifiers usedIdentifiers = analysis.getBoundIdentifiers();
final Declaration[] declarations = new Declaration[usedIdentifiers.getDeclrClasses().size()];
String[] declrStr = new String[declarations.length];
int j = 0;
for (String str : usedIdentifiers.getDeclrClasses().keySet() ) {
declrStr[j] = str;
declarations[j++] = decls.get( str );
}
Arrays.sort( declarations, SortDeclarations.instance );
MVELCompilationUnit unit = dialect.getMVELCompilationUnit( text,
analysis,
declarations,
null,
null,
context,
"drools",
KnowledgeHelper.class,
false );
MVELDataProvider dataProvider = new MVELDataProvider( unit,
context.getDialect().getId() );
from = new From( dataProvider );
MVELDialectRuntimeData data = (MVELDialectRuntimeData) context.getPkg().getDialectRuntimeRegistry().getDialectData( "mvel" );
data.addCompileable( from,
dataProvider );