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

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

Introduction

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

Prototype

public final int getAccessFlags() 

Source Link

Usage

From source file:com.codenvy.ide.ext.java.server.TypeBindingConvector.java

License:Open Source License

private static JsonElement toJsonMethod(MethodBinding method) {
    JsonObject object = new JsonObject();
    object.addProperty("modifiers", method.getAccessFlags());
    object.addProperty("constructor", method.isConstructor());
    object.add("argumentNames", toJsonParametersName(method.sourceMethod()));
    object.add("annotations", toJsonAnnotations(method.getAnnotations()));
    object.add("defaultValue", toJsonDefaultValue(method.getDefaultValue()));
    object.add("exceptionTypeNames", toJsonExceptionTypeNames(method.thrownExceptions));
    object.add("genericSignature", method.genericSignature() == null ? JsonNull.INSTANCE
            : new JsonPrimitive(new String(method.genericSignature())));
    object.add("methodDescriptor",
            method.signature() == null ? JsonNull.INSTANCE : new JsonPrimitive(new String(method.signature())));
    object.add("parameterAnnotations", toJsonParameterAnnotations(method));
    object.add("selector",
            method.selector == null ? JsonNull.INSTANCE : new JsonPrimitive(new String(method.selector)));
    object.addProperty("tagBits", String.valueOf(method.getAnnotationTagBits()));
    object.addProperty("clinit", false);
    return object;
}

From source file:lombok.eclipse.handlers.ast.EclipseASTMaker.java

License:Open Source License

@Override
public ASTNode visitWrappedMethodDecl(final lombok.ast.WrappedMethodDecl node, final Void p) {
    MethodDeclaration methodDeclaration = new MethodDeclaration(
            ((CompilationUnitDeclaration) sourceNode.top().get()).compilationResult);
    setGeneratedByAndCopyPos(methodDeclaration, source, posHintOf(node));
    MethodBinding abstractMethod = (MethodBinding) node.getWrappedObject();

    if (node.getReturnType() == null) {
        node.withReturnType(Type(abstractMethod.returnType));
    }// www.  j  a  v a  2s . c  o m
    if (node.getThrownExceptions().isEmpty())
        for (ReferenceBinding thrownException : Each.elementIn(abstractMethod.thrownExceptions)) {
            node.withThrownException(Type(thrownException));
        }
    if (node.getArguments().isEmpty() && Is.notEmpty(abstractMethod.parameters))
        for (int i = 0; i < abstractMethod.parameters.length; i++) {
            node.withArgument(Arg(Type(abstractMethod.parameters[i]), "arg" + i));
        }
    if (node.getTypeParameters().isEmpty())
        for (TypeVariableBinding binding : Each.elementIn(abstractMethod.typeVariables)) {
            ReferenceBinding super1 = binding.superclass;
            ReferenceBinding[] super2 = binding.superInterfaces;
            lombok.ast.TypeParam typeParameter = TypeParam(As.string(binding.sourceName));
            if (super2 == null)
                super2 = new ReferenceBinding[0];
            if (super1 != null || super2.length > 0) {
                if (super1 != null)
                    typeParameter.withBound(Type(super1));
                for (ReferenceBinding bound : super2) {
                    typeParameter.withBound(Type(bound).makeSuperType());
                }
            }
            node.withTypeParameter(typeParameter);
        }

    methodDeclaration.modifiers = (abstractMethod.getAccessFlags() & (~AccAbstract));
    methodDeclaration.returnType = build(node.getReturnType(), TypeReference.class);
    methodDeclaration.annotations = toArray(build(node.getAnnotations()), new Annotation[0]);
    methodDeclaration.selector = abstractMethod.selector;
    methodDeclaration.thrownExceptions = toArray(build(node.getThrownExceptions()), new TypeReference[0]);
    methodDeclaration.typeParameters = toArray(build(node.getTypeParameters()), new TypeParameter[0]);
    methodDeclaration.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG;
    methodDeclaration.arguments = toArray(build(node.getArguments()), new Argument[0]);
    if (node.isImplementing())
        methodDeclaration.modifiers |= AccImplementing;
    if (node.noBody()) {
        methodDeclaration.modifiers |= AccSemicolonBody;
    } else {
        methodDeclaration.statements = toArray(build(node.getStatements()), new Statement[0]);
    }
    return methodDeclaration;
}