((ClassObjectType) objectType).getClassType() ) );
if ( analysis == null ) {
// something bad happened
if ( reportError ) {
context.getErrors().add( new DescrBuildError( context.getParentDescr(),
descr,
null,
"Unable to analyze expression '" + fieldName + "'" ) );
}
return null;
}
final BoundIdentifiers usedIdentifiers = analysis.getBoundIdentifiers();
if ( !usedIdentifiers.getDeclrClasses().isEmpty() ) {
if ( reportError ) {
context.getErrors().add( new DescrBuildError( context.getParentDescr(),
descr,
null,
"Variables can not be used inside bindings. Variable " + usedIdentifiers.getDeclrClasses().keySet() + " is being used in binding '" + fieldName + "'" ) );
}
return null;
}
// final List<Declaration> tupleDeclarations = new ArrayList<Declaration>();
// final List<Declaration> factDeclarations = new ArrayList<Declaration>();
// for ( String id : usedIdentifiers.getDeclrClasses().keySet() ) {
// final Declaration decl = context.getDeclarationResolver().getDeclaration( context.getRule(),
// id );
// if ( decl.getPattern() == pattern ) {
// factDeclarations.add( decl );
// } else {
// tupleDeclarations.add( decl );
// }
// }
//
// final Declaration[] previousDeclarations = (Declaration[]) tupleDeclarations.toArray( new Declaration[tupleDeclarations.size()] );
// final Declaration[] localDeclarations = (Declaration[]) factDeclarations.toArray( new Declaration[factDeclarations.size()] );
// final String[] requiredGlobals = usedIdentifiers.getGlobals().keySet().toArray( new String[usedIdentifiers.getGlobals().size()] );
// final String[] requiredOperators = usedIdentifiers.getOperators().keySet().toArray( new String[usedIdentifiers.getOperators().size()] );
//
// Arrays.sort( previousDeclarations,
// SortDeclarations.instance );
// Arrays.sort( localDeclarations,
// SortDeclarations.instance );
reader = context.getPkg().getClassFieldAccessorStore().getMVELReader( context.getPkg().getName(),
((ClassObjectType) objectType).getClassName(),
fieldName,
context.isTypesafe() );
MVELDialectRuntimeData data = (MVELDialectRuntimeData) context.getPkg().getDialectRuntimeRegistry().getDialectData( "mvel" );
((MVELCompileable) reader).compile( data );
data.addCompileable( (MVELCompileable) reader );
} catch ( final Exception e ) {
if ( reportError ) {
copyErrorLocation( e,
descr );
context.getErrors().add( new DescrBuildError( context.getParentDescr(),
descr,
e,
"Unable to create reader for '" + fieldName + "':" + e.getMessage() ) );
}
// if there was an error, set the reader back to null
reader = null;
}
} else {
try {
reader = context.getPkg().getClassFieldAccessorStore().getReader( ((ClassObjectType) objectType).getClassName(),
fieldName,
target );
} catch ( final Exception e ) {
if ( reportError ) {
copyErrorLocation( e,
descr );
context.getErrors().add( new DescrBuildError( context.getParentDescr(),
descr,
e,
"Unable to create Field Extractor for '" + fieldName + "'" + e.getMessage() ) );
}
// if there was an error, set the reader back to null