Example usage for org.eclipse.jdt.internal.compiler.ast AbstractMethodDeclaration isStatic

List of usage examples for org.eclipse.jdt.internal.compiler.ast AbstractMethodDeclaration isStatic

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.compiler.ast AbstractMethodDeclaration isStatic.

Prototype

public boolean isStatic() 

Source Link

Usage

From source file:org.eclipse.objectteams.otdt.internal.core.compiler.lifting.DeclaredLifting.java

License:Open Source License

public static void transformMethodWithDeclaredLifting(AbstractMethodDeclaration method,
        TypeDeclaration teamDecl, boolean needMethodBody) {
    if (method.arguments == null)
        return; // No Declared Lifting

    // gather and count DeclaredLifting Arguments
    List<Argument> liftingTypeArguments = new LinkedList<Argument>();

    for (int idx = 0; idx < method.arguments.length; idx++) {
        Argument argument = method.arguments[idx];
        if (argument.type != null && argument.type.isDeclaredLifting()) {
            liftingTypeArguments.add(argument);
        }/* w  ww  . j  a v a  2s.  c  o m*/
    }
    if (liftingTypeArguments.isEmpty())
        return; //No DeclaredLifting found in Arguments

    if (method.isStatic()) {
        method.scope.problemReporter().declaredLiftingInStaticMethod(method, liftingTypeArguments.get(0));
        return;
    }
    // generate lift_dynamic method if <T base B> type parameter is declared
    if (hasBaseBoundedTypeParameters(method))
        for (Argument arg : liftingTypeArguments) {
            TypeBinding roleType = teamDecl.binding.getMemberType(((LiftingTypeReference) arg.type).roleToken);
            if (roleType != null)
                genLiftDynamicMethod(teamDecl, arg.type, roleType, needMethodBody);
        }

    if (!needMethodBody)
        return; // no more details needed

    //create modified Statements
    Statement[] statements = new Statement[liftingTypeArguments.size()];
    int position = 0;
    for (Iterator<Argument> iter = liftingTypeArguments.iterator(); iter.hasNext();) {
        Argument argument = iter.next();
        char[] oldArgumentName = argument.name; // save before renaming argument
        LocalDeclaration declaration = createLiftingStatement(method.scope, argument);
        if (method instanceof ConstructorDeclaration) {
            // replace references in self-call:
            ConstructorDeclaration ctor = (ConstructorDeclaration) method;
            if (ctor.constructorCall != null) {
                // replace argn with _OT$argn in ctor call:
                ReplaceSingleNameVisitor.performReplacement(ctor.constructorCall, ctor.scope, oldArgumentName,
                        argument.name);
            }
            ctor.needsLifting = true;
        }

        // collect:
        statements[position++] = declaration;
    }

    // add local variable declarations to the front of statements:
    Statement[] originalStatements = method.statements;
    if (originalStatements == null) {
        method.setStatements(statements);
    } else {
        Statement[] newStatements = new Statement[statements.length + method.statements.length];
        System.arraycopy(statements, 0, newStatements, 0, statements.length);
        System.arraycopy(originalStatements, 0, newStatements, statements.length, originalStatements.length);
        method.setStatements(newStatements);
    }
}

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

License:Open Source License

/** After inserting a method into a role interface create an attribute to store its source modifiers. */
public static boolean checkCreateModifiersAttribute(TypeDeclaration type, AbstractMethodDeclaration method) {
    if ((type.modifiers & IOTConstants.AccSynthIfc) != 0) {
        if ((method.modifiers & ClassFileConstants.AccPublic) == 0 || method.isStatic()) // also static methods must be disguised
        {/*  w  w  w  .  j  ava 2 s  . c  om*/
            MethodModel model = getModel(method);
            model.addAttribute(WordValueAttribute.modifiersAttribute(method.modifiers));
            // if no binding is present yet remember this bit for transfer in MethodScope.createMethod().
            model._clearPrivateModifier = true;
            return true;
        }
    }
    return false;
}