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

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

Introduction

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

Prototype

public final char[] constantPoolName() 

Source Link

Usage

From source file:com.google.gwt.dev.jjs.impl.TypeMap.java

License:Apache License

private boolean equals(MethodBinding binding, JMethod method) {
    if (!(method instanceof JConstructor && binding.isConstructor())
            && !method.getName().equals(String.valueOf(binding.constantPoolName()))) {
        return false;
    }//w  w  w  .  java 2s. c om

    List<JType> paramTypes = method.getOriginalParamTypes();
    TypeBinding[] bindingParams = binding.parameters;

    if (paramTypes.size() != bindingParams.length) {
        return false;
    }

    for (int i = 0; i < bindingParams.length; ++i) {
        TypeBinding bindingParam = bindingParams[i];
        if (paramTypes.get(i) != get(bindingParam)) {
            return false;
        }
    }

    return method.getType() == get(binding.returnType);
}

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

License:Open Source License

private boolean isOverloadingInType(ReferenceBinding superClass, MethodBinding method) {
    MethodVerifier methodVerifier = superClass.getPackage().environment.methodVerifier();
    for (MethodBinding inheritedMethod : superClass.methods()) {
        if (inheritedMethod.isPrivate() || inheritedMethod.isStatic() || inheritedMethod.isConstructor()
                || inheritedMethod.isBridge() || inheritedMethod.isSynthetic()
                || !Arrays.equals(inheritedMethod.constantPoolName(), method.selector))
            continue;

        // skip ignored methods
        if (ignoreMethodInAncestorSearch(inheritedMethod)) {
            continue;
        }//from  ww w  . j av a 2 s .  c  o  m

        // if it does not override it and has the same name, it's overloading
        if (!methodVerifier.doesMethodOverride(method, inheritedMethod)) {
            return true;
        }
    }
    return false;
}

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

License:Open Source License

void writeElementValue(int i) {
    CallinCalloutBinding mapping = this._mappings[i];
    writeName(mapping._roleMethodBinding.constantPoolName());
    writeName(mapping._roleMethodBinding.signature());
    byte flags = 0;
    switch (mapping.calloutModifier) {
    case TerminalTokens.TokenNameget:
        flags = CALLOUT_GET;/* w  w w. j  a v  a 2  s  .  com*/
        break;
    case TerminalTokens.TokenNameset:
        flags = CALLOUT_SET;
        break;
    }
    switch (mapping.declaredModifiers) {
    case ClassFileConstants.AccPublic:
        flags |= CALLOUT_PUBLIC;
        break;
    case ClassFileConstants.AccProtected:
        flags |= CALLOUT_PROTECTED;
        break;
    case ClassFileConstants.AccPrivate:
        flags |= CALLOUT_PRIVATE;
        break;
    }
    writeByte(flags);
    MethodBinding baseMethod = mapping._baseMethods[0];
    writeName(baseMethod.declaringClass.attributeName());
    writeName(baseMethod.constantPoolName());
    writeName(baseMethod.signature());
}

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

License:Open Source License

@Override
public boolean visit(LambdaExpression lambdaExpression, BlockScope blockScope) {
    CtLambda<?> lambda = factory.Core().createLambda();

    final MethodBinding methodBinding = lambdaExpression.getMethodBinding();
    if (methodBinding != null) {
        lambda.setSimpleName(String.valueOf(methodBinding.constantPoolName()));
    }/*from   w  ww  . j av  a2 s . c om*/

    context.enter(lambda, lambdaExpression);

    final Argument[] arguments = lambdaExpression.arguments();
    if (arguments != null && arguments.length > 0) {
        for (Argument e : arguments) {
            e.traverse(this, blockScope);
        }
    }

    if (lambdaExpression.body() != null) {
        lambdaExpression.body().traverse(this, blockScope);
    }

    return false;
}

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

License:Open Source License

@SuppressWarnings("unchecked")
<T> CtExecutableReference<T> getExecutableReference(MethodBinding exec) {
    if (exec == null) {
        return null;
    }/*from w  w w .j av a 2  s .com*/
    final CtExecutableReference ref = this.jdtTreeBuilder.getFactory().Core().createExecutableReference();
    if (exec.isConstructor()) {
        ref.setSimpleName(CtExecutableReference.CONSTRUCTOR_NAME);

        // in case of constructor of an array, it's the return type that we want
        if (exec.returnType instanceof VoidTypeBinding) {
            ref.setType(getTypeReference(exec.declaringClass, true));
        } else {
            ref.setType(getTypeReference(exec.returnType, true));
        }
    } else {
        ref.setSimpleName(new String(exec.selector));
        ref.setType(getTypeReference(exec.returnType, true));
    }
    if (exec instanceof ProblemMethodBinding) {
        if (exec.declaringClass != null && Arrays.asList(exec.declaringClass.methods()).contains(exec)) {
            ref.setDeclaringType(getTypeReference(exec.declaringClass));
        } else {
            final CtReference declaringType = getDeclaringReferenceFromImports(exec.constantPoolName());
            if (declaringType instanceof CtTypeReference) {
                ref.setDeclaringType((CtTypeReference<?>) declaringType);
            }
        }
        if (exec.isConstructor()) {
            // super() invocation have a good declaring class.
            ref.setDeclaringType(getTypeReference(exec.declaringClass));
        }
        ref.setStatic(true);
    } else {
        if (exec.isConstructor() && !(exec.returnType instanceof VoidTypeBinding)) {
            ref.setDeclaringType(getTypeReference(exec.returnType));
        } else {
            ref.setDeclaringType(getTypeReference(exec.declaringClass));
        }
        ref.setStatic(exec.isStatic());
    }

    if (exec.declaringClass instanceof ParameterizedTypeBinding) {
        ref.setDeclaringType(getTypeReference(exec.declaringClass.actualType()));
    }

    // original() method returns a result not null when the current method is generic.
    if (exec.original() != null) {
        final List<CtTypeReference<?>> parameters = new ArrayList<>(exec.original().parameters.length);
        for (TypeBinding b : exec.original().parameters) {
            parameters.add(getTypeReference(b, true));
        }
        ref.setParameters(parameters);
    } else if (exec.parameters != null) {
        // This is a method without a generic argument.
        final List<CtTypeReference<?>> parameters = new ArrayList<>();
        for (TypeBinding b : exec.parameters) {
            parameters.add(getTypeReference(b, true));
        }
        ref.setParameters(parameters);
    }

    return ref;
}