Example usage for org.eclipse.jdt.core.dom Modifier isStatic

List of usage examples for org.eclipse.jdt.core.dom Modifier isStatic

Introduction

In this page you can find the example usage for org.eclipse.jdt.core.dom Modifier isStatic.

Prototype

public static boolean isStatic(int flags) 

Source Link

Document

Returns whether the given flags includes the "static" modifier.

Usage

From source file:at.bestsolution.fxide.jdt.corext.util.JdtFlags.java

License:Open Source License

public static boolean isDefaultMethod(IMethodBinding method) {
    int modifiers = method.getModifiers();
    // https://bugs.eclipse.org/bugs/show_bug.cgi?id=405517#c7
    ITypeBinding declaringClass = method.getDeclaringClass();
    if (declaringClass.isInterface()) {
        return !Modifier.isAbstract(modifiers) && !Modifier.isStatic(modifiers);
    }//from   www.  j  a va  2 s. c o  m
    return false;
}

From source file:at.bestsolution.fxide.jdt.corext.util.JdtFlags.java

License:Open Source License

public static boolean isStatic(BodyDeclaration bodyDeclaration) {
    if (isNestedInterfaceOrAnnotation(bodyDeclaration))
        return true;
    int nodeType = bodyDeclaration.getNodeType();
    if (!(nodeType == ASTNode.METHOD_DECLARATION || nodeType == ASTNode.ANNOTATION_TYPE_MEMBER_DECLARATION)
            && isInterfaceOrAnnotationMember(bodyDeclaration))
        return true;
    if (bodyDeclaration instanceof EnumConstantDeclaration)
        return true;
    if (bodyDeclaration instanceof EnumDeclaration
            && bodyDeclaration.getParent() instanceof AbstractTypeDeclaration)
        return true;
    return Modifier.isStatic(bodyDeclaration.getModifiers());
}

From source file:at.bestsolution.fxide.jdt.corext.util.JdtFlags.java

License:Open Source License

public static boolean isStatic(IMethodBinding methodBinding) {
    return Modifier.isStatic(methodBinding.getModifiers());
}

From source file:at.bestsolution.fxide.jdt.corext.util.JdtFlags.java

License:Open Source License

public static boolean isStatic(IVariableBinding variableBinding) {
    if (isInterfaceOrAnnotationMember(variableBinding))
        return true;
    return Modifier.isStatic(variableBinding.getModifiers());
}

From source file:ca.ecliptical.pde.internal.ds.AnnotationProcessor.java

License:Open Source License

private boolean isNestedPublicStatic(TypeDeclaration type) {
    if (Modifier.isStatic(type.getModifiers())) {
        ASTNode parent = type.getParent();
        if (parent != null && parent.getNodeType() == ASTNode.TYPE_DECLARATION) {
            TypeDeclaration parentType = (TypeDeclaration) parent;
            if (Modifier.isPublic(parentType.getModifiers()))
                return parentType.isPackageMemberTypeDeclaration() || isNestedPublicStatic(parentType);
        }//from   w  ww . j ava  2s  . co m
    }

    return false;
}

From source file:ca.mcgill.cs.swevo.jayfx.ASTCrawler.java

License:Open Source License

@Override
public boolean visit(final FieldDeclaration pNode) {
    @SuppressWarnings("rawtypes")
    final List fragments = pNode.fragments();
    IElement lField;//  w  ww.jav  a2 s .  c  o m

    this.aCurrMethodReminder.push(this.aCurrMethod);

    if (Modifier.isStatic(pNode.getModifiers())) {
        this.aCurrMethod = (MethodElement) FlyweightElementFactory.getElement(Category.METHOD,
                this.aCurrType.getId() + "." + ASTCrawler.aCLINIT_METHOD_NAME);
        if (!this.aDB.contains(this.aCurrMethod))
            // This <clinit>() method will be in any class that has a static
            // field with initialization
            // But the DECLARES relation will be linked only if this method
            // has at least one sub relations
            // The linkage is done at the end of traversing each
            // compilations unit while end visiting type Declaration
            this.aDB.addElement(this.aCurrMethod, pNode.getModifiers());
    } else
        this.aCurrMethod = this.aTempMethod;

    // Consider multiple declaration in one statment
    for (@SuppressWarnings("rawtypes")
    final Iterator itr = fragments.iterator(); itr.hasNext();) {
        final VariableDeclarationFragment fragment = (VariableDeclarationFragment) itr.next();
        final String lSimpleName = fragment.getName().getIdentifier();
        final Expression lInit = fragment.getInitializer();

        if (lSimpleName != null) {
            lField = FlyweightElementFactory.getElement(Category.FIELD,
                    this.aCurrType.getId() + "." + lSimpleName);
            this.aDB.addElement(lField, pNode.getModifiers());

            this.aDB.addRelation(this.aCurrType, Relation.DECLARES_FIELD, lField);

            // If there is any initialization to this field then we write
            // them as an access by <init> or <clinit>
            if (lInit != null) {
                this.aDB.addRelationAndTranspose(this.aCurrMethod, Relation.ACCESSES, lField);
                this.aDB.addRelationAndTranspose(this.aCurrMethod, Relation.SETS, lField);

                // Want to go into the right side of assignment operator
                lInit.accept(this);
            }
        }
    }

    // Because we have covered everything we need about field declaration,
    // we dont' have to go deeper into this node.
    // return false;
    return true;
}

From source file:ca.mcgill.cs.swevo.jayfx.ASTCrawler.java

License:Open Source License

@Override
public boolean visit(final MethodInvocation pNode) {
    final SimpleName lName = pNode.getName();
    final IBinding lBinding = lName.resolveBinding();

    if (ASTCrawler.checkForNull(lBinding))
        return false;

    final IMethodBinding lMethod = (IMethodBinding) lBinding;
    this.addCallRelation(pNode, lMethod, Modifier.isStatic(lMethod.getModifiers()));
    return true;// w w w . j a  v  a 2 s . co m
}

From source file:ca.mcgill.cs.swevo.jayfx.JayFX.java

License:Open Source License

/**
 * Returns a non-static, non-constructor method that matches pMethod but
 * that is declared in pClass. null if none are found. Small concession to
 * correctness here for sake of efficiency: methods are matched only if they
 * parameter types match exactly.//from w  w w  .  j a  v a  2  s .  com
 * 
 * @param pMethod
 * @param pClass
 * @return
 */
private Set<IElement> matchMethod(final MethodElement pMethod, final IElement pClass) {
    final Set<IElement> lReturn = new HashSet<IElement>();
    final String lThisName = pMethod.getName();

    final Set<IElement> lElements = this.getRange(pClass, Relation.DECLARES_METHOD);
    for (final IElement lMethodElement : lElements)
        if (lMethodElement.getCategory() == Category.METHOD)
            if (!((MethodElement) lMethodElement).getName().startsWith("<init>")
                    && !((MethodElement) lMethodElement).getName().startsWith("<clinit>"))
                if (!Modifier.isStatic(this.aDB.getModifiers(lMethodElement)))
                    if (lThisName.equals(((MethodElement) lMethodElement).getName())) {
                        pMethod.getParameters().equals(((MethodElement) lMethodElement).getParameters());
                        lReturn.add(lMethodElement);
                        break;
                    }

    /*
     * for( Iterator i = lElements.iterator(); i.hasNext(); ) { IElement
     * lNext = (IElement)i.next(); if( lNext.getCategory() ==
     * Category.METHOD ) { if(
     * !((MethodElement)lNext).getName().startsWith("<init>") &&
     * !((MethodElement)lNext).getName().startsWith("<clinit>")) { if(
     * !Modifier.isStatic( aDB.getModifiers( lNext ))) { if(
     * lThisName.equals( ((MethodElement)lNext).getName() )) {
     * pMethod.getParameters().equals(
     * ((MethodElement)lNext).getParameters() ); lReturn.add( lNext );
     * break; } } } } }
     */
    return lReturn;
}

From source file:cc.kave.eclipse.namefactory.NodeFactory.java

License:Apache License

private static String modifierHelper(IBinding binding) {
    int modifier = binding.getModifiers();

    if (Modifier.isStatic(modifier))
        return "static ";
    else {/*from   w w w.j a va2s.  c o  m*/
        return "";
    }
}

From source file:coloredide.utils.CopiedNaiveASTFlattener.java

License:Open Source License

/**
 * Appends the text representation of the given modifier flags, followed by
 * a single space. Used for JLS2 modifiers.
 * /*www .  jav a  2  s  . c  om*/
 * @param modifiers
 *            the modifier flags
 */
void printModifiers(int modifiers) {
    if (Modifier.isPublic(modifiers)) {
        this.buffer.append("public ");//$NON-NLS-1$
    }
    if (Modifier.isProtected(modifiers)) {
        this.buffer.append("protected ");//$NON-NLS-1$
    }
    if (Modifier.isPrivate(modifiers)) {
        this.buffer.append("private ");//$NON-NLS-1$
    }
    if (Modifier.isStatic(modifiers)) {
        this.buffer.append("static ");//$NON-NLS-1$
    }
    if (Modifier.isAbstract(modifiers)) {
        this.buffer.append("abstract ");//$NON-NLS-1$
    }
    if (Modifier.isFinal(modifiers)) {
        this.buffer.append("final ");//$NON-NLS-1$
    }
    if (Modifier.isSynchronized(modifiers)) {
        this.buffer.append("synchronized ");//$NON-NLS-1$
    }
    if (Modifier.isVolatile(modifiers)) {
        this.buffer.append("volatile ");//$NON-NLS-1$
    }
    if (Modifier.isNative(modifiers)) {
        this.buffer.append("native ");//$NON-NLS-1$
    }
    if (Modifier.isStrictfp(modifiers)) {
        this.buffer.append("strictfp ");//$NON-NLS-1$
    }
    if (Modifier.isTransient(modifiers)) {
        this.buffer.append("transient ");//$NON-NLS-1$
    }
}