Example usage for org.eclipse.jdt.internal.compiler.lookup ReferenceBinding memberTypes

List of usage examples for org.eclipse.jdt.internal.compiler.lookup ReferenceBinding memberTypes

Introduction

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

Prototype

public ReferenceBinding[] memberTypes() 

Source Link

Document

Returns the member types of this type sorted by simple name.

Usage

From source file:com.codenvy.ide.ext.java.server.internal.codeassist.SelectionEngine.java

License:Open Source License

private void selectMemberTypeFromImport(CompilationUnitDeclaration parsedUnit, char[] lastToken,
        ReferenceBinding ref, boolean staticOnly) {
    int fieldLength = lastToken.length;
    ReferenceBinding[] memberTypes = ref.memberTypes();
    next: for (int j = 0; j < memberTypes.length; j++) {
        ReferenceBinding memberType = memberTypes[j];

        if (fieldLength > memberType.sourceName.length)
            continue next;

        if (staticOnly && !memberType.isStatic())
            continue next;

        if (!CharOperation.equals(lastToken, memberType.sourceName, true))
            continue next;

        selectFrom(memberType, parsedUnit, false);
    }//from ww w  . ja  v  a  2 s  .com
}

From source file:com.redhat.ceylon.eclipse.core.model.mirror.UnknownClassMirror.java

License:Open Source License

@Override
public List<ClassMirror> getDirectInnerClasses() {
    if (innerClasses == null) {
        doWithBindings(new ActionOnClassBinding() {
            @Override//from  w w  w . java 2  s .  co  m
            public void doWithBinding(IType classModel, ReferenceBinding klass) {
                ReferenceBinding[] memberTypeBindings = klass.memberTypes();
                innerClasses = new ArrayList<ClassMirror>(memberTypeBindings.length);
                for (ReferenceBinding memberTypeBinding : memberTypeBindings) {
                    ReferenceBinding classBinding = memberTypeBinding;
                    IType classTypeModel = JDTModelLoader.toType(classBinding);
                    innerClasses.add(new JDTClass(classBinding, classTypeModel));
                }
            }
        });
    }
    return innerClasses;
}

From source file:lombok.eclipse.handlers.HandleActionFunctionAndPredicate.java

License:Open Source License

private List<TemplateData> findTemplatesFor(final AbstractMethodDeclaration methodDecl,
        final ReferenceBinding template, final String forcedReturnType) {
    final List<TemplateData> foundTemplates = new ArrayList<TemplateData>();
    final TemplateData templateData = templateDataFor(methodDecl, template, forcedReturnType);
    if (templateData != null)
        foundTemplates.add(templateData);
    for (ReferenceBinding memberType : Each.elementIn(template.memberTypes())) {
        if (!template.isInterface() && !memberType.isStatic())
            continue;
        foundTemplates.addAll(findTemplatesFor(methodDecl, memberType, forcedReturnType));
    }/*ww  w . ja v  a2 s  .c o  m*/
    return foundTemplates;
}

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

License:Open Source License

/**
 * Implementation of the above./*from   w ww  . ja  v a  2 s  .c o m*/
 *
 * TODO (SH): searching by simple name is not exact for nested teams!
 *
 * @return null ProblemReferenceBinding or a valid type in the context of 'site'
 */
private static ReferenceBinding searchRoleClass(char[] roleName, ReferenceBinding srcTeam,
        ReferenceBinding site) {
    // check the site type
    if (site.isLocalType() && CharOperation.equals(site.constantPoolName(), roleName))
        return site;
    // check its member types
    ReferenceBinding[] members = site.memberTypes();
    // TODO(SH): We observe binary and source of the same type.
    //           As a workaround prefer source over binary here:
    ReferenceBinding candidate = null;
    for (int i = 0; i < members.length; i++) {
        if (CharOperation.equals(members[i].internalName(), roleName))
            if (members[i].isBinaryBinding() && candidate == null)
                candidate = members[i];
            else
                return members[i];
    }
    if (candidate != null)
        return candidate;
    for (int i = 0; i < members.length; i++) {
        ReferenceBinding result = searchRoleClass(roleName, srcTeam, members[i]);
        if (result != null && result.isValidBinding())
            return result;
    }
    // delegate to role model, which can handle local types, too.
    if (site.isRole())
        return site.roleModel.findTypeRelative(TypeAnalyzer.constantPoolNameRelativeToTeam(srcTeam, roleName));
    return null; // caller in recursion may still find the type.
}

From source file:org.eclipse.objectteams.otdt.internal.core.compiler.model.TeamModel.java

License:Open Source License

/**
 * Perform static adjustment according to OTJLD 2.3.3(a).
 *//* w  w  w. jav  a2s.com*/
private static ReferenceBinding adjustRoleToLiftTo(Scope scope, TypeBinding provided, ReferenceBinding required,
        ASTNode location) {
    ReferenceBinding mostGeneralFound = null;
    ReferenceBinding mostSpecificFound = null;

    ReferenceBinding enclosingTeam = required.enclosingType();
    ReferenceBinding[] roleTypes = enclosingTeam.memberTypes();
    ReferenceBinding requiredLeaf = (ReferenceBinding) required.leafComponentType();
    requiredLeaf = requiredLeaf.getRealType();
    for (int i = 0; i < roleTypes.length; i++) {
        if (TSuperHelper.isMarkerInterface(roleTypes[i]))
            continue;
        RoleModel currentRole = roleTypes[i].roleModel;
        ReferenceBinding currentRoleIfc = currentRole.getInterfacePartBinding();
        ReferenceBinding currentBase = currentRole.getBaseTypeBinding();

        if (TypeBinding.equalsEquals(mostGeneralFound, currentRoleIfc))
            continue; // already seen (happens because class/ifc part show the same role)

        if (currentBase != null && provided.leafComponentType().isCompatibleWith(currentBase)
                && currentRoleIfc.isCompatibleWith(requiredLeaf)) {
            if (mostGeneralFound == null) {
                mostGeneralFound = currentRoleIfc;
                mostSpecificFound = currentRoleIfc;
            } else {
                if (mostGeneralFound.isCompatibleWith(currentRoleIfc)) {
                    mostGeneralFound = currentRoleIfc; // new type is more general
                } else if (currentRoleIfc.isCompatibleWith(mostSpecificFound)) {
                    mostSpecificFound = currentRoleIfc;// new type is more specific
                } else { // non-linear relation between different candidates.
                    return required; // revert to non-specific required type (additionally LFE is declared by the lift method)
                }
            }
        }
    }
    return mostGeneralFound;
}

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

License:Open Source License

/**
 * Copy role from one (t)super team to the target team.
 * @param sourceTeam either super or tsuper team of the target team
 * @param targetTeamModel/*from w  w w .ja  v  a 2 s . co  m*/
 * @param isTsuperTeam is the source team a tsuper team of the target (regular super otherwise)?
 */
private static void copyRolesFromTeam(ReferenceBinding sourceTeam, TeamModel targetTeamModel,
        boolean isTsuperTeam) {
    if (!sourceTeam.isTeam())
        return; // error which is detected elsewhere (see ProblemReporter.regularOverridesTeam())
    loadRoleFiles(sourceTeam, targetTeamModel.getBinding().memberTypes());
    loadRoleFiles(targetTeamModel.getBinding(), sourceTeam.memberTypes());

    // 1. copy all roles (NO recursion for nested teams).
    doCopyRoles(sourceTeam, targetTeamModel, isTsuperTeam);
    connectRolesFromTeam(sourceTeam, targetTeamModel.getAst(), isTsuperTeam);
}

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

License:Open Source License

/** A binary team need not copy roles from super, but must connect roles to the
 *  teamModel and to their tsupers./*w w w .ja  v a 2  s .  c om*/
 */
public static void connectBinaryTSupers(TeamModel subTeamModel) {
    ReferenceBinding subTeam = subTeamModel.getBinding();
    ReferenceBinding superTeam = subTeam.superclass();
    if (superTeam != null && superTeam.isTeam()) {
        Dependencies.ensureBindingState(superTeam, STATE_LENV_CONNECT_TYPE_HIERARCHY);
        for (ReferenceBinding tsuperRole : superTeam.memberTypes()) {
            connectToTSuperRole(subTeamModel, subTeam, tsuperRole);
        }
    }
}

From source file:spoon.support.compiler.jdt.JDTTreeBuilderQuery.java

License:Open Source License

/**
 * Searches a type from an entry-point according to a simple name.
 *
 * @param type/*from w  w w  .ja v a2  s .c  o m*/
 *       Entry-point to search.
 * @param simpleName
 *       Expected type name.
 * @return type binding.
 */
static TypeBinding searchTypeBinding(ReferenceBinding type, String simpleName) {
    if (simpleName == null || type == null) {
        return null;
    }

    if (type.memberTypes() != null) {
        for (ReferenceBinding memberType : type.memberTypes()) {
            if (simpleName.equals(CharOperation.charToString(memberType.sourceName()))) {
                return memberType;
            }
        }
    }

    return searchTypeBinding(type.superclass(), simpleName);
}