public Declaration getDeclaration(final RuleImpl rule,
final String identifier) {
// it may be a local bound variable
for ( int i = this.buildStack.size() - 1; i >= 0; i-- ) {
final Declaration declaration = buildStack.get( i ).getInnerDeclarations().get( identifier );
if ( declaration != null ) {
return declaration;
}
}
// look at parent rules
if ( rule != null && rule.getParent() != null ) {
// recursive algorithm for each parent
// -> lhs.getInnerDeclarations()
Declaration parentDeclaration = getExtendedDeclaration( rule.getParent(),
identifier );
if ( null != parentDeclaration ) {
return parentDeclaration;
}
}
// it may be a global or something
if ( this.map.containsKey( (identifier) ) ) {
Class<?> cls = this.map.get( identifier );
ClassObjectType classObjectType = new ClassObjectType( cls );
Declaration declaration;
final Pattern dummy = new Pattern( 0,
classObjectType );
InternalReadAccessor globalExtractor = getReadAcessor( identifier,
classObjectType );
declaration = new Declaration( identifier,
globalExtractor,
dummy );
if ( pkg != null ) {
// make sure dummy and globalExtractor are wired up to correct ClassObjectType