Example usage for org.eclipse.jdt.internal.compiler.lookup MethodBinding readableName

List of usage examples for org.eclipse.jdt.internal.compiler.lookup MethodBinding readableName

Introduction

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

Prototype

@Override
    public char[] readableName()  

Source Link

Usage

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

License:Open Source License

public JDTMethod(JDTClass enclosingClass, MethodBinding method) {
    this.enclosingClass = enclosingClass;
    bindingRef = new WeakReference<MethodBinding>(method);
    name = new String(method.selector);
    readableName = new String(method.readableName());
    isStatic = method.isStatic();//from w  w  w  . ja  va 2s.com
    isPublic = method.isPublic();
    isConstructor = method.isConstructor();
    isStaticInit = method.selector == TypeConstants.CLINIT; // TODO : check if it is right
    isAbstract = method.isAbstract();
    isFinal = method.isFinal();
    isProtected = method.isProtected();
    isDefaultAccess = method.isDefault();
    isDeclaredVoid = method.returnType.id == TypeIds.T_void;
    isVariadic = method.isVarargs();
    isDefault = method.getDefaultValue() != null;
    bindingKey = method.computeUniqueKey();
    if (method instanceof ProblemMethodBinding) {
        annotations = new HashMap<>();
        parameters = Collections.emptyList();
        returnType = JDTType.UNKNOWN_TYPE;
        typeParameters = Collections.emptyList();
        isOverriding = false;
        isOverloading = false;
    }
}

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

License:Open Source License

private void getInterfaceMethods(final TypeBinding binding, final List<MethodBinding> methods,
        final Set<String> banList) {
    if (binding == null)
        return;/* w  w  w  .  j a  v  a  2 s.c om*/
    ensureAllClassScopeMethodWereBuild(binding);
    if (binding instanceof ReferenceBinding) {
        ReferenceBinding rb = (ReferenceBinding) binding;
        MethodBinding[] availableMethods = rb.availableMethods();
        for (MethodBinding mb : Each.elementIn(availableMethods)) {
            String sig = As.string(mb.readableName());
            if (!banList.add(sig))
                continue;
            methods.add(mb);
        }
        ReferenceBinding[] interfaces = rb.superInterfaces();
        for (ReferenceBinding iface : Each.elementIn(interfaces)) {
            getInterfaceMethods(iface, methods, banList);
        }
    }
}

From source file:org.conqat.engine.java.ecj.EcjUtils.java

License:Apache License

/**
 * Constructs a String representation of the given MethodBinding. The
 * notation is <declaringClassFQN>#<method signature>.
 *///w  w w.  j a  va2 s. c  o m
public static String methodBindingToString(MethodBinding methodBinding) {
    MethodBinding original = methodBinding.original();
    ReferenceBinding declaringClass = original.declaringClass;
    return getFullQualifiedClassName(declaringClass) + "#" + new String(original.readableName());
}

From source file:org.eclipse.objectteams.otdt.internal.core.compiler.mappings.CallinImplementor.java

License:Open Source License

/**
 *   gen:  if (result == null) throw new ResultNotProvidedException(..);
 *
 * @param roleName/*from  w w  w  . j  a v  a  2  s .  com*/
 * @param roleMethodBinding
 * @param baseTypeBinding
 * @param baseMethodSpec
 * @param gen
 * @return the assembled iff statement
 */
public static Statement genResultNotProvidedCheck(char[] teamName, char[] roleName,
        MethodBinding roleMethodBinding, TypeBinding baseTypeBinding, MethodSpec baseMethodSpec,
        AstGenerator gen) {

    String errMsg = Messages.bind("(team: {0}, role: {1}, method {2})\n" + //$NON-NLS-1$
            "Base call to {3}.{4} is missing", //$NON-NLS-1$
            new Object[] { new String(teamName), new String(roleName),
                    new String(roleMethodBinding.readableName()), new String(baseTypeBinding.readableName()),
                    new String(baseMethodSpec.resolvedMethod.readableName()) });

    return gen.ifStatement(
            new EqualExpression(gen.singleNameReference(IOTConstants.OT_RESULT), gen.nullLiteral(),
                    OperatorIds.EQUAL_EQUAL),
            gen.block(new Statement[] { gen.throwStatement(
                    gen.allocation(gen.qualifiedTypeReference(IOTConstants.ORG_OBJECTTEAMS_RESULT_NOT_PROVIDED),
                            new Expression[] { gen.stringLiteral(errMsg.toCharArray()) })) }));
}

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

License:Open Source License

/**
 * Ensure we have bytes and constantPoolOffsets ready to use.
 *//*  w w  w  .j av  a2s. c  o m*/
private void setupByteCode(boolean bytesRequired) {
    if (this._bytes == null || this._constantPoolOffsets == null) {
        try {
            MethodBinding binding = (this._binding == null) ? this._decl.binding : this._binding;
            assert binding.declaringClass.isTeam();

            ClassFileReader reader = null;
            if (this._bytes == null) {
                if (this._classFile == null && this._decl != null) {
                    char[] className = binding.declaringClass.constantPoolName();
                    this._classFile = (ClassFile) this._decl.compilationResult.compiledTypes.get(className);
                    if (this._classFile != null && !this._classFile.isForType(binding.declaringClass)) {
                        this._classFile = null; // has been reset thus cannot be used for this type any more.
                    }
                }
                // here we made the best attempt to obtain a classfile, use it if possible:
                if (this._classFile != null && this._classFile.isForType(this._binding.declaringClass)) {
                    this._bytes = this._classFile.getBytes();
                    this._structOffset += this._classFile.headerOffset; // structOffset did not yet include the headerOffset
                    int olen = this._classFile.constantPool.currentIndex;
                    System.arraycopy(this._classFile.constantPool.offsets, 0,
                            this._constantPoolOffsets = new int[olen], 0, olen);
                    this._classFile = null; // don't use any more
                    return;
                }
            }
            if (this._bytes != null) {
                // create a reader for in-memory bytes in order to recalculate constant pool offsets
                reader = new ClassFileReader(this._bytes, RoleModel.NO_SOURCE_FILE); // STATE_BYTECODE_PREPARED
            } else {
                // Currently only team-ctors use a MethodModel for byte code retrieval.
                // Use the stored file name for reading the byte code from disc:
                if (binding.declaringClass.isTeam())
                    reader = binding.declaringClass.getTeamModel().read();
                if (reader == null) {
                    if (bytesRequired)
                        throw new InternalCompilerError(
                                "No byte code available for " + new String(binding.readableName())); //$NON-NLS-1$
                    return;
                }
                this._bytes = reader.getBytes();
            }
            this._classFile = null; // don't use any more
            // now we have both a reader and bytes
            this._constantPoolOffsets = reader.getConstantPoolOffsets();
            // find bytecode offset of this method:
            char[] mySignature = this._binding.signature();
            for (IBinaryMethod m : reader.getMethods()) {
                if (CharOperation.equals(m.getSelector(), this._binding.selector)
                        && CharOperation.equals(m.getMethodDescriptor(), mySignature)) {
                    this._structOffset = ((MethodInfo) m).getStructOffset();
                    return;
                }
            }
            if (bytesRequired)
                throw new InternalCompilerError("Method " + String.valueOf(this._binding.readableName()) //$NON-NLS-1$
                        + "not found in class file " + String.valueOf(reader.getFileName())); //$NON-NLS-1$
        } catch (ClassFormatException ex) {
            throw new InternalCompilerError(ex.getMessage());
        } catch (IOException ex) {
            throw new InternalCompilerError(ex.getMessage());
        }
    }

}

From source file:org.eclipse.recommenders.internal.chain.rcp.CompletionTemplateBuilder.java

License:Open Source License

private static String createChainCode(final Chain chain, final boolean createAsTitle,
        final int expectedDimension) {
    final HashMultiset<String> varNames = HashMultiset.create();
    final StringBuilder sb = new StringBuilder(64);
    for (final ChainElement edge : chain.getElements()) {
        switch (edge.getElementType()) {
        case FIELD:
        case LOCAL_VARIABLE:
            appendVariableString(edge, sb);
            break;
        case METHOD:
            final MethodBinding method = edge.getElementBinding();
            if (createAsTitle) {
                sb.append(method.readableName());
            } else {
                sb.append(method.selector);
                appendParameters(sb, method, varNames);
            }/*from  w  ww .  j  av a2  s.  c om*/
            break;
        default:
            log(WARNING_CANNOT_HANDLE_ELEMENT_TYPE, edge);
        }
        final boolean appendVariables = !createAsTitle;
        appendArrayDimensions(sb, edge.getReturnTypeDimension(), expectedDimension, appendVariables, varNames);
        sb.append("."); //$NON-NLS-1$
    }
    deleteLastChar(sb);
    return sb.toString();
}

From source file:org.eclipse.recommenders.internal.chain.rcp.TypeBindingAnalyzer.java

License:Open Source License

private static String createMethodKey(final MethodBinding method) {
    final String signature = String.valueOf(method.signature());
    final String signatureWithoutReturnType = StringUtils.substringBeforeLast(signature, ")"); //$NON-NLS-1$
    return new StringBuilder().append(method.readableName()).append(signatureWithoutReturnType).toString();
}