Example usage for org.eclipse.jdt.internal.compiler.lookup Binding NO_FIELDS

List of usage examples for org.eclipse.jdt.internal.compiler.lookup Binding NO_FIELDS

Introduction

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

Prototype

FieldBinding[] NO_FIELDS

To view the source code for org.eclipse.jdt.internal.compiler.lookup Binding NO_FIELDS.

Click Source Link

Usage

From source file:org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding.java

License:Open Source License

public FieldBinding[] fields() {
    return Binding.NO_FIELDS;
}

From source file:org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding.java

License:Open Source License

public FieldBinding[] unResolvedFields() {
    return Binding.NO_FIELDS;
}

From source file:org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.java

License:Open Source License

public FieldBinding[] fields() {
    if ((this.tagBits & TagBits.AreFieldsComplete) != 0)
        return this.fields;

    int failed = 0;
    FieldBinding[] resolvedFields = this.fields;
    try {//w  ww. j av  a2 s.co m
        // lazily sort fields
        if ((this.tagBits & TagBits.AreFieldsSorted) == 0) {
            int length = this.fields.length;
            if (length > 1)
                ReferenceBinding.sortFields(this.fields, 0, length);
            this.tagBits |= TagBits.AreFieldsSorted;
        }
        for (int i = 0, length = this.fields.length; i < length; i++) {
            if (resolveTypeFor(this.fields[i]) == null) {
                // do not alter original field array until resolution is over, due to reentrance (143259)
                if (resolvedFields == this.fields) {
                    System.arraycopy(this.fields, 0, resolvedFields = new FieldBinding[length], 0, length);
                }
                resolvedFields[i] = null;
                failed++;
            }
        }
    } finally {
        if (failed > 0) {
            // ensure fields are consistent reqardless of the error
            int newSize = resolvedFields.length - failed;
            if (newSize == 0)
                return this.fields = Binding.NO_FIELDS;

            FieldBinding[] newFields = new FieldBinding[newSize];
            for (int i = 0, j = 0, length = resolvedFields.length; i < length; i++) {
                if (resolvedFields[i] != null)
                    newFields[j++] = resolvedFields[i];
            }
            this.fields = newFields;
        }
    }
    this.tagBits |= TagBits.AreFieldsComplete;
    return this.fields;
}

From source file:org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.java

License:Open Source License

public FieldBinding getField(char[] fieldName, boolean needResolve) {

    if ((this.tagBits & TagBits.AreFieldsComplete) != 0)
        return ReferenceBinding.binarySearch(fieldName, this.fields);

    // lazily sort fields
    if ((this.tagBits & TagBits.AreFieldsSorted) == 0) {
        int length = this.fields.length;
        if (length > 1)
            ReferenceBinding.sortFields(this.fields, 0, length);
        this.tagBits |= TagBits.AreFieldsSorted;
    }/*from w w  w.  ja  va2  s.c om*/
    // always resolve anyway on source types
    FieldBinding field = ReferenceBinding.binarySearch(fieldName, this.fields);
    if (field != null) {
        FieldBinding result = null;
        try {
            result = resolveTypeFor(field);
            return result;
        } finally {
            if (result == null) {
                // ensure fields are consistent reqardless of the error
                int newSize = this.fields.length - 1;
                if (newSize == 0) {
                    this.fields = Binding.NO_FIELDS;
                } else {
                    FieldBinding[] newFields = new FieldBinding[newSize];
                    int index = 0;
                    for (int i = 0, length = this.fields.length; i < length; i++) {
                        FieldBinding f = this.fields[i];
                        if (f == field)
                            continue;
                        newFields[index++] = f;
                    }
                    this.fields = newFields;
                }
            }
        }
    }
    return null;
}

From source file:org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.java

License:Open Source License

public String toString() {
    StringBuffer buffer = new StringBuffer(30);
    buffer.append("(id="); //$NON-NLS-1$
    if (this.id == TypeIds.NoId)
        buffer.append("NoId"); //$NON-NLS-1$
    else//from  www  . ja v  a  2 s  . c o  m
        buffer.append(this.id);
    buffer.append(")\n"); //$NON-NLS-1$
    if (isDeprecated())
        buffer.append("deprecated "); //$NON-NLS-1$
    if (isPublic())
        buffer.append("public "); //$NON-NLS-1$
    if (isProtected())
        buffer.append("protected "); //$NON-NLS-1$
    if (isPrivate())
        buffer.append("private "); //$NON-NLS-1$
    if (isAbstract() && isClass())
        buffer.append("abstract "); //$NON-NLS-1$
    if (isStatic() && isNestedType())
        buffer.append("static "); //$NON-NLS-1$
    if (isFinal())
        buffer.append("final "); //$NON-NLS-1$

    if (isEnum())
        buffer.append("enum "); //$NON-NLS-1$
    else if (isAnnotationType())
        buffer.append("@interface "); //$NON-NLS-1$
    else if (isClass())
        buffer.append("class "); //$NON-NLS-1$
    else
        buffer.append("interface "); //$NON-NLS-1$
    buffer.append((this.compoundName != null) ? CharOperation.toString(this.compoundName) : "UNNAMED TYPE"); //$NON-NLS-1$

    if (this.typeVariables == null) {
        buffer.append("<NULL TYPE VARIABLES>"); //$NON-NLS-1$
    } else if (this.typeVariables != Binding.NO_TYPE_VARIABLES) {
        buffer.append("<"); //$NON-NLS-1$
        for (int i = 0, length = this.typeVariables.length; i < length; i++) {
            if (i > 0)
                buffer.append(", "); //$NON-NLS-1$
            if (this.typeVariables[i] == null) {
                buffer.append("NULL TYPE VARIABLE"); //$NON-NLS-1$
                continue;
            }
            char[] varChars = this.typeVariables[i].toString().toCharArray();
            buffer.append(varChars, 1, varChars.length - 2);
        }
        buffer.append(">"); //$NON-NLS-1$
    }
    buffer.append("\n\textends "); //$NON-NLS-1$
    buffer.append((this.superclass != null) ? this.superclass.debugName() : "NULL TYPE"); //$NON-NLS-1$

    if (this.superInterfaces != null) {
        if (this.superInterfaces != Binding.NO_SUPERINTERFACES) {
            buffer.append("\n\timplements : "); //$NON-NLS-1$
            for (int i = 0, length = this.superInterfaces.length; i < length; i++) {
                if (i > 0)
                    buffer.append(", "); //$NON-NLS-1$
                buffer.append(
                        (this.superInterfaces[i] != null) ? this.superInterfaces[i].debugName() : "NULL TYPE"); //$NON-NLS-1$
            }
        }
    } else {
        buffer.append("NULL SUPERINTERFACES"); //$NON-NLS-1$
    }

    if (enclosingType() != null) {
        buffer.append("\n\tenclosing type : "); //$NON-NLS-1$
        buffer.append(enclosingType().debugName());
    }

    if (this.fields != null) {
        if (this.fields != Binding.NO_FIELDS) {
            buffer.append("\n/*   fields   */"); //$NON-NLS-1$
            for (int i = 0, length = this.fields.length; i < length; i++)
                buffer.append('\n').append((this.fields[i] != null) ? this.fields[i].toString() : "NULL FIELD"); //$NON-NLS-1$
        }
    } else {
        buffer.append("NULL FIELDS"); //$NON-NLS-1$
    }

    if (this.methods != null) {
        if (this.methods != Binding.NO_METHODS) {
            buffer.append("\n/*   methods   */"); //$NON-NLS-1$
            for (int i = 0, length = this.methods.length; i < length; i++)
                buffer.append('\n')
                        .append((this.methods[i] != null) ? this.methods[i].toString() : "NULL METHOD"); //$NON-NLS-1$
        }
    } else {
        buffer.append("NULL METHODS"); //$NON-NLS-1$
    }

    if (this.memberTypes != null) {
        if (this.memberTypes != Binding.NO_MEMBER_TYPES) {
            buffer.append("\n/*   members   */"); //$NON-NLS-1$
            for (int i = 0, length = this.memberTypes.length; i < length; i++)
                buffer.append('\n')
                        .append((this.memberTypes[i] != null) ? this.memberTypes[i].toString() : "NULL TYPE"); //$NON-NLS-1$
        }
    } else {
        buffer.append("NULL MEMBER TYPES"); //$NON-NLS-1$
    }

    buffer.append("\n\n"); //$NON-NLS-1$
    return buffer.toString();
}

From source file:org.eclipse.objectteams.otdt.internal.core.compiler.lookup.RoleTypeBinding.java

License:Open Source License

public FieldBinding[] availableFields() {
    if (this._staticallyKnownRoleClass == null)
        return Binding.NO_FIELDS;
    return this._staticallyKnownRoleClass.availableFields();
}

From source file:org.eclipse.objectteams.otdt.internal.core.compiler.lookup.RoleTypeBinding.java

License:Open Source License

public FieldBinding[] fields() {
    if (this._staticallyKnownRoleClass == null)
        return Binding.NO_FIELDS;
    return this._staticallyKnownRoleClass.fields();
}

From source file:org.eclipse.objectteams.otdt.internal.core.compiler.statemachine.copyinheritance.CopyInheritance.java

License:Open Source License

/**
 * If a tsuper role is not overriden in the current team,
 * create a fresh new role type declaration.
 * Always copy all inheritance information to the tsub role
 * (extends, implements, playedBy).//w w  w.j a  va 2  s  . c  om
 * No difference, whether we are looking at a role class or interface.
 *
 * @param superRole
 * @param subTeamDecl this declaration is being edited.
 * @return the new or modified type declaration
 */
private static TypeDeclaration copyRole(ReferenceBinding superRole, boolean isNestedType,
        TypeDeclaration subTeamDecl, boolean isTsuperTeam) {
    subTeamDecl.getTeamModel()._isCopyingLateRole = true;
    try {
        if (superRole instanceof MissingTypeBinding)
            return null; // don't copy missing type!
        if (superRole.sourceName == null)
            return null; // local types have null name
        String name = new String(superRole.sourceName);
        if ((name.startsWith(TSUPER_OT) || CharOperation.equals(superRole.sourceName, ROFI_CACHE)))
            return null; // don't copy these special roles

        if (subTeamDecl.isRole() && superRole.roleModel.equals(subTeamDecl.getRoleModel()))
            return null; // can happen in case of a role extending its enclosing

        TypeDeclaration subRoleDecl = findMemberType(subTeamDecl, superRole.sourceName);

        ReferenceBinding subRoleBinding = subTeamDecl.binding.getMemberType(superRole.internalName());
        if (subRoleBinding != null) {
            // don't copy binary tsuper, if a binary exists already here.
            if (shouldPreserveBinaryRole(subRoleBinding, subTeamDecl.compilationResult)) {
                if (isNestedType)
                    subRoleBinding.roleModel.maybeAddLocalToEnclosing();
                // no further processing needed except for connecting tsuper and copyInheritanceSrc:
                connectBinaryNested(superRole, subTeamDecl, subRoleBinding);
                return null;
            }
            // try again, memberType lookup might have introduced a role file to subTeamDecl:
            if (subRoleDecl == null)
                subRoleDecl = findMemberType(subTeamDecl, superRole.sourceName);
            if (subRoleDecl != null && (subRoleDecl.binding.tagBits & TagBits.BeginHierarchyCheck) == 0)
                subRoleDecl.scope.connectTypeHierarchyWithoutMembers();
            if (subRoleDecl == null) // still?
                return null; // assume recompile has been scheduled
        }

        // If type doesn't exist, create now
        if (subRoleDecl == null) {
            char[] superRoleName = superRole.internalName();
            if (superRole.isLocalType()) {
                if (!superRole.isBinaryBinding())
                    ((LocalTypeBinding) superRole).computeConstantPoolName();
                int lastDollar = CharOperation.lastIndexOf('$', superRole.sourceName);
                if (lastDollar >= 0) {
                    superRoleName = CharOperation.subarray(superRole.sourceName, lastDollar + 1, -1);
                } else {
                    char[] superConstantPoolName = superRole.constantPoolName();
                    lastDollar = CharOperation.lastIndexOf('$', superConstantPoolName);
                    if (lastDollar >= 0)
                        superRoleName = CharOperation.subarray(superConstantPoolName, lastDollar + 1, -1);
                }
            }
            subRoleDecl = AstConverter.createNestedType(superRoleName, superRole.modifiers, isNestedType, true, // purely copied
                    subTeamDecl, superRole);
            if (subRoleDecl.isInterface()) {
                // purely copied interface now copies superinterfaces (not handled in connectRolesFromTeam()):
                ReferenceBinding[] tsuperSupers = superRole.superInterfaces();
                subRoleDecl.binding.superInterfaces = new ReferenceBinding[tsuperSupers.length];
                int j = 0;
                for (int i = 0; i < tsuperSupers.length; i++) {
                    char[] tsuperSuperName = tsuperSupers[i].internalName();
                    if (!CharOperation.equals(tsuperSuperName, superRoleName)) {
                        ReferenceBinding tsubRole = subTeamDecl.binding.getMemberType(tsuperSuperName);
                        if (tsubRole != null)
                            subRoleDecl.binding.superInterfaces[j++] = tsubRole;
                    }
                }
                if (j < tsuperSupers.length)
                    System.arraycopy(subRoleDecl.binding.superInterfaces, 0,
                            subRoleDecl.binding.superInterfaces = new ReferenceBinding[j], 0, j);
            }
        } else {
            if (subRoleDecl.isRegularInterface() != superRole.isRegularInterface()) {
                subRoleDecl.scope.problemReporter().roleClassIfcConflict(subRoleDecl);
                // overwrite existing type with tsuper copy:
                subRoleDecl.isGenerated = true;
                subRoleDecl.isPurelyCopied = true;
                subRoleDecl.modifiers = superRole.modifiers;
                subRoleDecl.fields = null;
                subRoleDecl.methods = null;
                subRoleDecl.superclass = null;
                subRoleDecl.superInterfaces = null;
                SourceTypeBinding roleBinding = subRoleDecl.binding;
                roleBinding.modifiers = superRole.modifiers;
                roleBinding.setFields(Binding.NO_FIELDS);
                roleBinding.setMethods(Binding.NO_METHODS);
                roleBinding.baseclass = null;
                roleBinding.superclass = subTeamDecl.scope.getJavaLangObject();
                roleBinding.superInterfaces = Binding.NO_SUPERINTERFACES;
                return subRoleDecl;
            }
            if (superRole.isTeam() && !subRoleDecl.isTeam()) {
                if (!Protections.hasClassKindProblem(subRoleDecl.binding))
                    subRoleDecl.scope.problemReporter().regularOverridesTeam(subRoleDecl, superRole);
                subRoleDecl.modifiers |= ClassFileConstants.AccTeam;
                if (subRoleBinding != null)
                    subRoleBinding.modifiers |= ClassFileConstants.AccTeam;
            }
            if (!isTsuperTeam) {
                if (CharOperation.equals(subRoleDecl.name, OTCONFINED)) {
                    subRoleDecl.scope.problemReporter().overridingConfined(subRoleDecl, "Confined"); //$NON-NLS-1$
                    return null;
                }
                if (CharOperation.equals(subRoleDecl.name, ICONFINED)) {
                    subRoleDecl.scope.problemReporter().overridingConfined(subRoleDecl, "IConfined"); //$NON-NLS-1$
                    return null;
                }
                if (superRole.isFinal()) {
                    subRoleDecl.scope.problemReporter().overridingFinalRole(subRoleDecl, superRole);
                    return null;
                }
            }
        }

        superRole.roleModel.hasBaseclassProblem(); // just trigger propagation from super-role to current
        //      if (subRoleBinding != null && subRoleBinding.isBinaryBinding())
        //         subRoleDecl.scope.problemReporter().mismatchingRoleParts(subRoleBinding, subRoleDecl);
        return subRoleDecl;
    } finally {
        subTeamDecl.getTeamModel()._isCopyingLateRole = false;
    }
}