Search in sources :

Example 56 with JavacNode

use of lombok.javac.JavacNode in project lombok by rzwitserloot.

the class HandleConstructor method findAllFields.

public static List<JavacNode> findAllFields(JavacNode typeNode, boolean evenFinalInitialized) {
    ListBuffer<JavacNode> fields = new ListBuffer<JavacNode>();
    for (JavacNode child : typeNode.down()) {
        if (child.getKind() != Kind.FIELD)
            continue;
        JCVariableDecl fieldDecl = (JCVariableDecl) child.get();
        // Skip fields that start with $
        if (fieldDecl.name.toString().startsWith("$"))
            continue;
        long fieldFlags = fieldDecl.mods.flags;
        // Skip static fields.
        if ((fieldFlags & Flags.STATIC) != 0)
            continue;
        // Skip initialized final fields
        boolean isFinal = (fieldFlags & Flags.FINAL) != 0;
        if (evenFinalInitialized || !isFinal || fieldDecl.init == null)
            fields.append(child);
    }
    return fields.toList();
}
Also used : JavacNode(lombok.javac.JavacNode) ListBuffer(com.sun.tools.javac.util.ListBuffer) JCVariableDecl(com.sun.tools.javac.tree.JCTree.JCVariableDecl)

Aggregations

JavacNode (lombok.javac.JavacNode)56 JCVariableDecl (com.sun.tools.javac.tree.JCTree.JCVariableDecl)30 JCClassDecl (com.sun.tools.javac.tree.JCTree.JCClassDecl)24 ListBuffer (com.sun.tools.javac.util.ListBuffer)18 JavacTreeMaker (lombok.javac.JavacTreeMaker)16 JCExpression (com.sun.tools.javac.tree.JCTree.JCExpression)15 JCMethodDecl (com.sun.tools.javac.tree.JCTree.JCMethodDecl)15 JCAnnotation (com.sun.tools.javac.tree.JCTree.JCAnnotation)13 Name (com.sun.tools.javac.util.Name)12 JCTypeParameter (com.sun.tools.javac.tree.JCTree.JCTypeParameter)9 JCStatement (com.sun.tools.javac.tree.JCTree.JCStatement)8 JCModifiers (com.sun.tools.javac.tree.JCTree.JCModifiers)7 JCBlock (com.sun.tools.javac.tree.JCTree.JCBlock)6 ArrayList (java.util.ArrayList)6 JCTree (com.sun.tools.javac.tree.JCTree)4 JCArrayTypeTree (com.sun.tools.javac.tree.JCTree.JCArrayTypeTree)4 JCFieldAccess (com.sun.tools.javac.tree.JCTree.JCFieldAccess)4 JCMethodInvocation (com.sun.tools.javac.tree.JCTree.JCMethodInvocation)4 JCPrimitiveTypeTree (com.sun.tools.javac.tree.JCTree.JCPrimitiveTypeTree)4 AccessLevel (lombok.AccessLevel)4