Example usage for org.eclipse.jdt.internal.codeassist.select SelectionNodeFound SelectionNodeFound

List of usage examples for org.eclipse.jdt.internal.codeassist.select SelectionNodeFound SelectionNodeFound

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.codeassist.select SelectionNodeFound SelectionNodeFound.

Prototype

public SelectionNodeFound() 

Source Link

Usage

From source file:org.eclipse.objectteams.otdt.internal.codeassist.SelectionOnBaseCallMessageSend.java

License:Open Source License

public TypeBinding resolveType(BlockScope scope) {
    try {//from  ww  w.  j  av a 2  s .  com
        super.resolveType(scope);
    } catch (SelectionNodeFound snf) {
        if ((snf.binding instanceof MethodBinding) && MethodModel.isFakedMethod((MethodBinding) snf.binding)) {
            // fake method (e.g. basecall surrogate) is not valid, continue below
        } else {
            throw snf;
        }
    }

    MessageSend wrappee = this._sendOrig; // _wrappee might have been replaced with an Assignment.

    // tolerate some error cases
    if (wrappee.binding == null
            || !(wrappee.binding.isValidBinding() || wrappee.binding.problemId() == ProblemReasons.NotVisible
                    || wrappee.binding.problemId() == ProblemReasons.InheritedNameHidesEnclosingName
                    || wrappee.binding.problemId() == ProblemReasons.NonStaticReferenceInConstructorInvocation
                    || wrappee.binding.problemId() == ProblemReasons.NonStaticReferenceInStaticContext)) {
        throw new SelectionNodeFound();
    } else {
        // wrappee.binding is the base call surrogate, find the proper enclosing method instead:
        MethodBinding callinMethod = null;
        MethodScope methodScope = scope.methodScope();
        if (methodScope == null)
            throw new SelectionNodeFound();

        MemberTypeBinding role = null;
        SourceTypeBinding site = scope.enclosingSourceType();

        if (site.isLocalType()) {
            MethodDeclaration callinDecl = getOuterCallinMethod(methodScope);
            if (callinDecl == null)
                throw new SelectionNodeFound();
            callinMethod = callinDecl.binding;
            role = (MemberTypeBinding) callinMethod.declaringClass;
        } else {
            callinMethod = methodScope.referenceMethod().binding;
            role = (MemberTypeBinding) site;
        }

        // find base methods bound in callin mappings which have callinMethod as their role method:
        MethodBinding[] baseBindings = findBaseMethodBindings(role, callinMethod);
        if (baseBindings == null || baseBindings.length == 0) {
            throw new SelectionNodeFound();
        } else {
            throw new SelectionNodesFound(baseBindings);
        }
    }
}

From source file:org.eclipse.objectteams.otdt.internal.codeassist.SelectionOnBaseReference.java

License:Open Source License

public TypeBinding resolveType(BlockScope scope) {
    ReferenceBinding binding = (ReferenceBinding) super.resolveType(scope);

    //        ReferenceBinding superclass = (SourceTypeBinding)((MemberTypeBinding)this.resolvedType).enclosingType.superclass;
    //        String roleName = new String(this.resolvedType.sourceName());
    //        ReferenceBinding base = scope.findDirectMemberType((IOTConstants.OT_DELIM + roleName).toCharArray(), (ReferenceBinding) this.resolvedType);
    //        ReferenceBinding base = scope.findDirectMemberType((IOTConstants.OT_DELIM + roleName).toCharArray(), (ReferenceBinding) this.resolvedType);
    if (binding == null || !binding.isValidBinding() || binding.baseclass() == null) {
        throw new SelectionNodeFound();
    } else {/*from  w w  w  .  j  av  a2  s . com*/
        throw new SelectionNodeFound(binding.baseclass());
    }
}

From source file:org.eclipse.objectteams.otdt.internal.codeassist.SelectionOnFieldAccessSpec.java

License:Open Source License

@Override
public void resolveFinished() {
    // cf. SelectionOnMethodSpec:
    FieldBinding binding = this.resolvedField;
    // tolerate some error cases
    if (binding == null || !(binding.isValidBinding() || binding.problemId() == ProblemReasons.NotVisible
            || binding.problemId() == ProblemReasons.InheritedNameHidesEnclosingName
            || binding.problemId() == ProblemReasons.NonStaticReferenceInConstructorInvocation
            || binding.problemId() == ProblemReasons.NonStaticReferenceInStaticContext)) {
        throw new SelectionNodeFound();
    } else {/* ww  w .ja va2 s.  c o m*/
        //field is part of a role
        if (binding.declaringClass.isRole()) {
            // field is copy inherited: use the original binding:
            if (binding.copyInheritanceSrc != null)
                throw new SelectionNodeFound(binding.copyInheritanceSrc);

            //have to generate a new binding here!
            ReferenceBinding roleClass = binding.declaringClass.roleModel.getClassPartBinding();
            FieldBinding newBinding = roleClass.getField(binding.name, true);
            throw new SelectionNodeFound(newBinding);
        }
    }
    throw new SelectionNodeFound(this.resolvedField);
}

From source file:org.eclipse.objectteams.otdt.internal.codeassist.SelectionOnMethodSpec.java

License:Open Source License

@Override
public void resolveFinished() {
    MethodBinding binding = this.resolvedMethod;
    // tolerate some error cases
    if (binding == null || !(binding.isValidBinding() || binding.problemId() == ProblemReasons.NotVisible
            || binding.problemId() == ProblemReasons.InheritedNameHidesEnclosingName
            || binding.problemId() == ProblemReasons.NonStaticReferenceInConstructorInvocation
            || binding.problemId() == ProblemReasons.NonStaticReferenceInStaticContext)) {
        throw new SelectionNodeFound();
    } else {//  ww  w.j av a 2 s .com
        //{ObjectTeams:
        //method is part of a role
        if (binding.declaringClass.isRole()) {
            // method is copy inherited: use the original binding:
            if (binding.copyInheritanceSrc != null)
                throw new SelectionNodeFound(binding.copyInheritanceSrc);
        }
        //haebor}
    }
    throw new SelectionNodeFound(this.resolvedMethod);
}

From source file:org.eclipse.objectteams.otdt.internal.codeassist.SelectionOnTSuperReference.java

License:Open Source License

public TypeBinding resolveType(BlockScope scope) {
    TypeBinding tSuperRole = super.resolveType(scope);

    if (tSuperRole == null || !tSuperRole.isValidBinding())
        throw new SelectionNodeFound();
    else {//ww w  .j a va  2s.  co  m
        throw new SelectionNodeFound(tSuperRole);
    }
}