Example usage for org.eclipse.jdt.internal.compiler.classfmt ClassFileConstants AccProtected

List of usage examples for org.eclipse.jdt.internal.compiler.classfmt ClassFileConstants AccProtected

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.compiler.classfmt ClassFileConstants AccProtected.

Prototype

int AccProtected

To view the source code for org.eclipse.jdt.internal.compiler.classfmt ClassFileConstants AccProtected.

Click Source Link

Usage

From source file:ch.uzh.ifi.seal.changedistiller.ast.java.JavaASTHelper.java

License:Apache License

private boolean isProtected(int ecjModifier) {
    return (ecjModifier & ClassFileConstants.AccProtected) != 0;
}

From source file:com.android.tools.lint.psi.EcjPsiBuilder.java

License:Apache License

private EcjPsiModifierList toModifierList(@NonNull EcjPsiSourceElement parent, int modifiers,
        Annotation[] annotations) {
    int flags = 0;
    if ((modifiers & ClassFileConstants.AccStatic) != 0) {
        flags |= Modifier.STATIC;
    }//w  w w .ja v  a2s. com
    if ((modifiers & ClassFileConstants.AccFinal) != 0) {
        flags |= Modifier.FINAL;
    }
    if ((modifiers & ClassFileConstants.AccAbstract) != 0) {
        flags |= Modifier.ABSTRACT;
    }
    if ((modifiers & ClassFileConstants.AccPrivate) != 0) {
        flags |= Modifier.PRIVATE;
    }
    if ((modifiers & ClassFileConstants.AccProtected) != 0) {
        flags |= Modifier.PROTECTED;
    }
    if ((modifiers & ClassFileConstants.AccPublic) != 0) {
        flags |= Modifier.PUBLIC;
    }
    if ((modifiers & ClassFileConstants.AccSynchronized) != 0) {
        flags |= Modifier.SYNCHRONIZED;
    }
    if ((modifiers & ClassFileConstants.AccVolatile) != 0) {
        flags |= Modifier.VOLATILE;
    }
    if ((modifiers & ExtraCompilerModifiers.AccDefaultMethod) != 0) {
        flags |= EcjPsiModifierList.DEFAULT_MASK;
    }

    EcjPsiModifierList modifierList = new EcjPsiModifierList(mManager, flags);
    parent.adoptChild(modifierList);
    EcjPsiAnnotation[] psiAnnotations = toAnnotations(modifierList, annotations);
    modifierList.setAnnotations(psiAnnotations);
    return modifierList;
}

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

License:Open Source License

/**
 * Turns an {@code AccessLevel} instance into the flag bit used by eclipse.
 *//* w  w w  .jav  a 2 s  .  co m*/
public static int toEclipseModifier(AccessLevel value) {
    switch (value) {
    case MODULE:
    case PACKAGE:
        return 0;
    default:
    case PUBLIC:
        return ClassFileConstants.AccPublic;
    case PROTECTED:
        return ClassFileConstants.AccProtected;
    case NONE:
    case PRIVATE:
        return ClassFileConstants.AccPrivate;
    }
}

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

License:Open Source License

public void setFieldDefaultsForField(EclipseNode fieldNode, ASTNode pos, AccessLevel level, boolean makeFinal) {
    FieldDeclaration field = (FieldDeclaration) fieldNode.get();
    if (level != null && level != AccessLevel.NONE) {
        if ((field.modifiers & (ClassFileConstants.AccPublic | ClassFileConstants.AccPrivate
                | ClassFileConstants.AccProtected)) == 0) {
            if (!hasAnnotation(PackagePrivate.class, fieldNode)) {
                field.modifiers |= EclipseHandlerUtil.toEclipseModifier(level);
            }/*from   w  w w  .  j ava  2  s  .  co m*/
        }
    }

    if (makeFinal && (field.modifiers & ClassFileConstants.AccFinal) == 0) {
        if (!hasAnnotation(NonFinal.class, fieldNode)) {
            if ((field.modifiers & ClassFileConstants.AccStatic) == 0 || field.initialization != null) {
                field.modifiers |= ClassFileConstants.AccFinal;
            }
        }
    }

    fieldNode.rebuild();
}

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

License:Open Source License

/**
 * Generates a <code>$fillValuesFrom()</code> method in the abstract builder class that looks
 * like this:// w  w w.  j  av  a  2s .c o m
 * <pre>
 * protected B $fillValuesFrom(final C instance) {
 *     super.$fillValuesFrom(instance);
 *     FoobarBuilderImpl.$fillValuesFromInstanceIntoBuilder(instance, this);
 *     return self();
 * }
 * </pre>
 */
private MethodDeclaration generateFillValuesMethod(EclipseNode tdParent, boolean inherited,
        String builderGenericName, String classGenericName, String builderClassName,
        TypeParameter[] typeParams) {
    MethodDeclaration out = new MethodDeclaration(
            ((CompilationUnitDeclaration) tdParent.top().get()).compilationResult);
    out.selector = FILL_VALUES_METHOD_NAME;
    out.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG;
    out.modifiers = ClassFileConstants.AccProtected;
    if (inherited)
        out.annotations = new Annotation[] {
                makeMarkerAnnotation(TypeConstants.JAVA_LANG_OVERRIDE, tdParent.get()) };
    out.returnType = new SingleTypeReference(builderGenericName.toCharArray(), 0);

    TypeReference builderType = new SingleTypeReference(classGenericName.toCharArray(), 0);
    out.arguments = new Argument[] { new Argument(INSTANCE_VARIABLE_NAME, 0, builderType, Modifier.FINAL) };

    List<Statement> body = new ArrayList<Statement>();

    if (inherited) {
        // Call super.
        MessageSend callToSuper = new MessageSend();
        callToSuper.receiver = new SuperReference(0, 0);
        callToSuper.selector = FILL_VALUES_METHOD_NAME;
        callToSuper.arguments = new Expression[] { new SingleNameReference(INSTANCE_VARIABLE_NAME, 0) };
        body.add(callToSuper);
    }

    // Call the builder implemention's helper method that actually fills the values from the instance.
    MessageSend callStaticFillValuesMethod = new MessageSend();
    callStaticFillValuesMethod.receiver = new SingleNameReference(builderClassName.toCharArray(), 0);
    callStaticFillValuesMethod.selector = FILL_VALUES_STATIC_METHOD_NAME;
    callStaticFillValuesMethod.arguments = new Expression[] {
            new SingleNameReference(INSTANCE_VARIABLE_NAME, 0), new ThisReference(0, 0) };
    body.add(callStaticFillValuesMethod);

    // Return self().
    MessageSend returnCall = new MessageSend();
    returnCall.receiver = ThisReference.implicitThis();
    returnCall.selector = SELF_METHOD_NAME;
    body.add(new ReturnStatement(returnCall, 0, 0));

    out.statements = body.isEmpty() ? null : body.toArray(new Statement[0]);

    return out;
}

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

License:Open Source License

private MethodDeclaration generateAbstractSelfMethod(EclipseNode tdParent, boolean override,
        String builderGenericName) {
    MethodDeclaration out = new MethodDeclaration(
            ((CompilationUnitDeclaration) tdParent.top().get()).compilationResult);
    out.selector = SELF_METHOD_NAME;/*from  w ww .jav a  2 s. c  o m*/
    out.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG;
    out.modifiers = ClassFileConstants.AccAbstract | ClassFileConstants.AccProtected
            | ExtraCompilerModifiers.AccSemicolonBody;
    if (override)
        out.annotations = new Annotation[] {
                makeMarkerAnnotation(TypeConstants.JAVA_LANG_OVERRIDE, tdParent.get()) };
    out.returnType = new SingleTypeReference(builderGenericName.toCharArray(), 0);
    return out;
}

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

License:Open Source License

private MethodDeclaration generateSelfMethod(EclipseNode builderImplType, TypeParameter[] typeParams, long p) {
    MethodDeclaration out = new MethodDeclaration(
            ((CompilationUnitDeclaration) builderImplType.top().get()).compilationResult);
    out.selector = SELF_METHOD_NAME;// w  w  w.j ava  2s . c o  m
    out.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG;
    out.modifiers = ClassFileConstants.AccProtected;
    out.annotations = new Annotation[] {
            makeMarkerAnnotation(TypeConstants.JAVA_LANG_OVERRIDE, builderImplType.get()) };
    out.returnType = namePlusTypeParamsToTypeReference(builderImplType.getName().toCharArray(), typeParams, p);
    out.statements = new Statement[] { new ReturnStatement(new ThisReference(0, 0), 0, 0) };
    return out;
}

From source file:org.eclipse.ajdt.core.javaelements.CompilationUnitTools.java

License:Open Source License

public static int getModifierCode(IProgramElement elem) {
    IProgramElement.Accessibility acc = elem.getAccessibility();
    List<Modifiers> others = elem.getModifiers();
    int modifiers = 0;
    if (acc == IProgramElement.Accessibility.PUBLIC) {
        modifiers |= ClassFileConstants.AccPublic;
    } else if (acc == IProgramElement.Accessibility.PROTECTED) {
        modifiers |= ClassFileConstants.AccProtected;
    } else if (acc == IProgramElement.Accessibility.PRIVATE) {
        modifiers |= ClassFileConstants.AccPrivate;
    }/*from   w  ww.j  a  va2  s  . c  om*/

    if (others != null) {
        if (others.contains(IProgramElement.Modifiers.ABSTRACT)) {
            modifiers |= ClassFileConstants.AccAbstract;
        }
        if (others.contains(IProgramElement.Modifiers.FINAL)) {
            modifiers |= ClassFileConstants.AccFinal;
        }
        if (others.contains(IProgramElement.Modifiers.NATIVE)) {
            modifiers |= ClassFileConstants.AccNative;
        }
        if (others.contains(IProgramElement.Modifiers.STATIC)) {
            modifiers |= ClassFileConstants.AccStatic;
        }
        if (others.contains(IProgramElement.Modifiers.SYNCHRONIZED)) {
            modifiers |= ClassFileConstants.AccSynchronized;
        }
        if (others.contains(IProgramElement.Modifiers.TRANSIENT)) {
            modifiers |= ClassFileConstants.AccTransient;
        }
        if (others.contains(IProgramElement.Modifiers.VOLATILE)) {
            modifiers |= ClassFileConstants.AccVolatile;
        }
    }
    return modifiers;
}

From source file:org.eclipse.ajdt.core.javaelements.CompilationUnitTools.java

License:Open Source License

public static IProgramElement.Accessibility getAccessibilityFromModifierCode(int code) {
    IProgramElement.Accessibility acc = null;
    if ((code & ClassFileConstants.AccPublic) != 0) {
        acc = IProgramElement.Accessibility.PUBLIC;
    } else if ((code & ClassFileConstants.AccProtected) != 0) {
        acc = IProgramElement.Accessibility.PROTECTED;
    } else if ((code & ClassFileConstants.AccPrivate) != 0) {
        acc = IProgramElement.Accessibility.PRIVATE;
    } else {//  www. j a  va 2  s .  c o  m
        acc = IProgramElement.Accessibility.PACKAGE;
    }
    return acc;
}

From source file:org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding.java

License:Open Source License

/**
 * Answer true if the receiver has default visibility
 *//*from   ww w.j a v a 2 s  .co  m*/
public final boolean isDefault() {
    return (this.modifiers & (ClassFileConstants.AccPublic | ClassFileConstants.AccProtected
            | ClassFileConstants.AccPrivate)) == 0;
}