((ClassObjectType) objectType).getClassType() ) );
if ( analysis == null ) {
// something bad happened
if ( reportError ) {
context.addError(new DescrBuildError(context.getParentDescr(),
descr,
null,
"Unable to analyze expression '" + fieldName + "'"));
}
return null;
}
final BoundIdentifiers usedIdentifiers = analysis.getBoundIdentifiers();
if ( !usedIdentifiers.getDeclrClasses().isEmpty() ) {
if ( reportError && descr instanceof BindingDescr ) {
context.addError(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;
}
reader = context.getPkg().getClassFieldAccessorStore().getMVELReader( context.getPkg().getName(),
((ClassObjectType) objectType).getClassName(),
fieldName,
context.isTypesafe(),
((MVELAnalysisResult)analysis).getReturnType() );
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.addError(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;
} finally {
context.setDialect( dialect );
}
} else {
boolean alternatives = false;
try {
Map<String, Class< ? >> declarations = getDeclarationsMap( descr, context, false );
Map<String, Class< ? >> globals = context.getPackageBuilder().getGlobals();
alternatives = declarations.containsKey( fieldName ) || globals.containsKey( fieldName );
reader = context.getPkg().getClassFieldAccessorStore().getReader( ((ClassObjectType) objectType).getClassName(),
fieldName,
target );
} catch ( final Exception e ) {
if ( reportError && ! alternatives && context.isTypesafe() ) {
copyErrorLocation( e,
descr );
context.addError(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