Example usage for org.eclipse.jdt.internal.compiler.lookup NestedTypeBinding syntheticEnclosingInstances

List of usage examples for org.eclipse.jdt.internal.compiler.lookup NestedTypeBinding syntheticEnclosingInstances

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.compiler.lookup NestedTypeBinding syntheticEnclosingInstances.

Prototype

public SyntheticArgumentBinding[] syntheticEnclosingInstances() 

Source Link

Usage

From source file:org.eclipse.objectteams.otdt.internal.core.compiler.bytecode.ConstantPoolObjectReader.java

License:Open Source License

public FieldBinding findFieldByName(ReferenceBinding clazz, char[] name) {
    char[] prefix = TypeConstants.SYNTHETIC_ENCLOSING_INSTANCE_PREFIX;
    if (CharOperation.prefixEquals(prefix, name)) {
        TypeBinding original = clazz.original();
        if (original instanceof NestedTypeBinding) {
            if (original.isMemberType() || original.isLocalType()) {
                NestedTypeBinding ntb = (NestedTypeBinding) original;
                SyntheticArgumentBinding[] sab = ntb.syntheticEnclosingInstances();
                for (int i = 0; i < sab.length; i++) {
                    if (CharOperation.equals(name, sab[i].name))
                        return sab[i].matchingField;
                }//from  w ww .  j  a va2s  . c o  m
            }
        }
        // no name adjustment or synthetics needed at the reading (source) side.
    }
    // either regular field or synthetic in a BinaryTypeBinding:
    return clazz.getField(name, true);
}