Example usage for org.eclipse.jdt.internal.compiler.lookup TagBits IsArgument

List of usage examples for org.eclipse.jdt.internal.compiler.lookup TagBits IsArgument

Introduction

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

Prototype

long IsArgument

To view the source code for org.eclipse.jdt.internal.compiler.lookup TagBits IsArgument.

Click Source Link

Usage

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

License:Open Source License

private void initializeFromType(ReferenceBinding givenType) {
    this.model = givenType.model; // shared model from type.
    this.modifiers = givenType.modifiers;
    this.tagBits = givenType.tagBits;
    this.tagBits &= ~(TagBits.AreMethodsSorted | TagBits.AreMethodsComplete); // in case the generic type was already processed

    this.compoundName = givenType.compoundName;
    this.sourceName = givenType.sourceName;
    this.constantPoolName = givenType.constantPoolName;
    this.callinCallouts = givenType.callinCallouts;
    this.precedences = givenType.precedences;
    this.fileName = givenType.fileName;
    this.fPackage = givenType.fPackage;
    this.teamPackage = givenType.teamPackage;

    if (givenType.isTypeVariable()) { // concrete type unknown ...
        ITeamAnchor[] anchors = ((TypeVariableBinding) givenType).anchors;
        if (anchors != null && anchors[0] instanceof LocalVariableBinding) {
            final LocalVariableBinding anchor = (LocalVariableBinding) anchors[0];
            if ((anchor.tagBits & TagBits.IsArgument) != 0) { // ... but known to be anchored to an argument
                this._argumentPosition = anchor.resolvedPosition;
                this._declaringMethod = new IMethodProvider() {
                    public MethodBinding getMethod() {
                        return ((MethodScope) anchor.declaringScope).referenceMethodBinding();
                    }/* w  ww.  j  a v a2  s  .c  om*/
                };
            }
        }
    }
    // registerAnchor();
}

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

License:Open Source License

private void initialize(ReferenceBinding roleType, ITeamAnchor teamAnchor) {
    // FIXME(SH): is it OK to strip ParameterizedFields?
    if (teamAnchor instanceof ParameterizedFieldBinding)
        teamAnchor = ((ParameterizedFieldBinding) teamAnchor).original();

    initializeDependentType(teamAnchor, -1); // role type bindings have no explicit value parameters

    // infer argument position.
    ITeamAnchor firstAnchorSegment = teamAnchor.getBestNamePath()[0];
    if (firstAnchorSegment instanceof LocalVariableBinding
            && (((LocalVariableBinding) firstAnchorSegment).tagBits & TagBits.IsArgument) != 0) {
        LocalVariableBinding argumentBinding = (LocalVariableBinding) firstAnchorSegment;
        this._argumentPosition = argumentBinding.resolvedPosition;
        final MethodScope methodScope = argumentBinding.declaringScope.methodScope();
        if (methodScope != null)
            // if scope is a callout, role method may not yet be resolved, defer:
            this._declaringMethod = new IMethodProvider() {
                private MethodBinding binding;

                public MethodBinding getMethod() {
                    if (this.binding == null)
                        this.binding = methodScope.referenceMethodBinding();
                    return this.binding;
                }//from www .  j  ava  2  s  .co m
            };
    }

    // compute the team:
    if (CharOperation.equals(roleType.compoundName, IOTConstants.ORG_OBJECTTEAMS_TEAM_OTCONFINED))
        // the following is needed in order to break the circularity
        // of roles extending the predefined Team.__OT__Confined (see class comment)
        this._staticallyKnownTeam = roleType.enclosingType();
    else if (teamAnchor == NoAnchor)
        this._staticallyKnownTeam = roleType.enclosingType();
    else
        teamAnchor.setStaticallyKnownTeam(this);

    assert (this._staticallyKnownTeam.isTeam());

    // compute role class and role interface (by name manipulation):
    if (RoleSplitter.isClassPartName(roleType.sourceName)) {
        this._staticallyKnownRoleClass = roleType.getRealClass();
        char[] typeName = RoleSplitter.getInterfacePartName(roleType.sourceName);
        this._staticallyKnownRoleType = this._staticallyKnownTeam.getMemberType(typeName);
    } else {
        this._staticallyKnownRoleType = roleType.getRealType();
        char[] className = CharOperation.concat(OT_DELIM_NAME, this._staticallyKnownRoleType.sourceName);
        this._staticallyKnownRoleClass = this._staticallyKnownTeam.getMemberType(className);
        this._staticallyKnownRoleClass = transferTypeArguments(this._staticallyKnownRoleClass);
    }
    this._staticallyKnownRoleType = transferTypeArguments(this._staticallyKnownRoleType);

    this._declaredRoleType = this._staticallyKnownRoleType;
    // keep these consistent with _declaredRoleType:
    this.roleModel = this._declaredRoleType.roleModel;
    this._teamModel = this._declaredRoleType.getTeamModel();

    assert TypeBinding.equalsEquals(this._staticallyKnownTeam.getRealClass(),
            roleType.enclosingType()) : "weakening not using WeakenedTypeBinding"; //$NON-NLS-1$
    // some adjustments after all fields are known:
    if (TypeBinding.notEquals(this._staticallyKnownTeam, roleType.enclosingType()))
        this._staticallyKnownRoleType = this._staticallyKnownTeam.getMemberType(roleType.sourceName);
    if (this._staticallyKnownRoleClass != null)
        this.modifiers = this._staticallyKnownRoleClass.modifiers;
    // after we might have overwritten the modifiers restore some bits in the vein of ParameterizedTypeBinding:
    if (this.arguments != null) {
        this.modifiers |= ExtraCompilerModifiers.AccGenericSignature;
    } else if (this.enclosingType() != null) {
        this.modifiers |= (this.enclosingType().modifiers & ExtraCompilerModifiers.AccGenericSignature);
        this.tagBits |= this.enclosingType().tagBits & (TagBits.HasTypeVariable | TagBits.HasMissingType);
    }

    // record as known role type at teamAnchor and in our own cache
    registerAnchor();
}

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

License:Open Source License

/**
 * Check whether the given expression determines a proper bestName for this binding.
 * @param rhs expression being assigned to this variable (Expression or Argument)
 *///from  w w  w.  ja  v  a  2  s.co  m
public void setBestNameFromStat(Statement rhs) {
    if (isFinal() && (this.type instanceof ReferenceBinding)) {
        ITeamAnchor[] path = getBestNameFromStat(rhs);
        if (path != null) {
            ITeamAnchor lastBinding = path[path.length - 1];
            if (this instanceof FieldBinding) {
                if (lastBinding instanceof LocalVariableBinding) {
                    LocalVariableBinding localVar = ((LocalVariableBinding) lastBinding);
                    Scope scope = localVar.declaringScope;
                    if (scope.referenceContext() instanceof ConstructorDeclaration) {
                        // don't record the initial field assignment within a constructor,
                        // but reverse this: pretend the local was initialized from the field,
                        // to make both equivalent within this ctor.
                        if (lastBinding.isFinal()) {
                            if ((localVar.tagBits & TagBits.IsArgument) != 0 && !localVar.pathIsAbsolute()) {
                                // localVar is really an argument not anchored to a field
                                lastBinding.shareBestName(this);
                            }
                        }
                    }
                    return; // all others: ignore
                } else if (lastBinding instanceof TThisBinding) {
                    return; // field may already have better anchor
                }
            }
            this.bestNamePath = path;
        }
    }
}

From source file:org.eclipse.objectteams.otdt.internal.core.compiler.util.RoleTypeCreator.java

License:Open Source License

private static boolean isConvertedArgument(ITeamAnchor anchor, Scope scope) {
    if (!(anchor instanceof VariableBinding))
        return false; // impossible/defensive
    if ((((VariableBinding) anchor).tagBits & TagBits.IsArgument) == 0)
        return false;
    return scope.classScope().referenceContext.isConverted;
}