public ParserContext getParserContext(final Dialect.AnalysisResult analysis,
final Map outerDeclarations,
final Map otherInputDeclarations,
final RuleBuildContext context) {
final ParserContext parserContext = new ParserContext( this.imports,
null,
context.getPkg().getName() + "." + context.getRuleDescr().getClassName() );
for ( Iterator it = this.packageImports.values().iterator(); it.hasNext(); ) {
String packageImport = (String) it.next();
parserContext.addPackageImport( packageImport );
}
parserContext.setStrictTypeEnforcement( strictMode );
if ( interceptors != null ) {
parserContext.setInterceptors( interceptors );
}
//FIXME: analysis can be null, throws an NPE
List list[] = analysis.getBoundIdentifiers();
DeclarationScopeResolver resolver = context.getDeclarationResolver();
for ( Iterator it = list[0].iterator(); it.hasNext(); ) {
String identifier = (String) it.next();
Class cls = resolver.getDeclaration( identifier ).getExtractor().getExtractToClass();
parserContext.addInput( identifier,
cls );
}
Map globalTypes = context.getPkg().getGlobals();
for ( Iterator it = list[1].iterator(); it.hasNext(); ) {
String identifier = (String) it.next();
parserContext.addInput( identifier,
(Class) globalTypes.get( identifier ) );
}
if ( otherInputDeclarations != null ) {
for ( Iterator it = otherInputDeclarations.entrySet().iterator(); it.hasNext(); ) {
Entry entry = (Entry) it.next();
parserContext.addInput( (String) entry.getKey(),
(Class) entry.getValue() );
}
}
if ( outerDeclarations != null ) {
for ( Iterator it = outerDeclarations.entrySet().iterator(); it.hasNext(); ) {
Entry entry = (Entry) it.next();
parserContext.addInput( (String) entry.getKey(),
((Declaration) entry.getValue()).getExtractor().getExtractToClass() );
}
}
parserContext.addInput( "drools",
KnowledgeHelper.class );
return parserContext;
}