Package lombok.ast

Examples of lombok.ast.VariableDefinition


            }
        }

        if (node instanceof VariableDeclaration) {
            VariableDeclaration declaration = (VariableDeclaration) node;
            VariableDefinition definition = declaration.astDefinition();
            if (definition != null) {
                lombok.ast.TypeReference typeReference = definition.astTypeReference();
                if (typeReference != null) {
                    return typeReference.getNativeNode();
                }
            }
        }
View Full Code Here


            Class<? extends Node> type = scope.getClass();
            // The Lombok AST uses a flat hierarchy of node type implementation classes
            // so no need to do instanceof stuff here.
            if (type == VariableDefinition.class) {
                // Variable
                VariableDefinition declaration = (VariableDefinition) scope;
                if (isSuppressed(issue, declaration.astModifiers())) {
                    return true;
                }
            } else if (type == MethodDeclaration.class) {
                // Method
                // Look for annotations on the method
                MethodDeclaration declaration = (MethodDeclaration) scope;
                if (isSuppressed(issue, declaration.astModifiers())) {
                    return true;
                }
            } else if (type == ConstructorDeclaration.class) {
                // Constructor
                // Look for annotations on the method
                ConstructorDeclaration declaration = (ConstructorDeclaration) scope;
                if (isSuppressed(issue, declaration.astModifiers())) {
                    return true;
                }
            } else if (type == ClassDeclaration.class) {
                // Class
                ClassDeclaration declaration = (ClassDeclaration) scope;
                if (isSuppressed(issue, declaration.astModifiers())) {
                    return true;
                }
            }

            scope = scope.getParent();
View Full Code Here

            Class<? extends Node> type = scope.getClass();
            // The Lombok AST uses a flat hierarchy of node type implementation classes
            // so no need to do instanceof stuff here.
            if (type == VariableDefinition.class) {
                // Variable
                VariableDefinition declaration = (VariableDefinition) scope;
                if (isSuppressed(issue, declaration.astModifiers())) {
                    return true;
                }
            } else if (type == MethodDeclaration.class) {
                // Method
                // Look for annotations on the method
                MethodDeclaration declaration = (MethodDeclaration) scope;
                if (isSuppressed(issue, declaration.astModifiers())) {
                    return true;
                }
            } else if (type == ConstructorDeclaration.class) {
                // Constructor
                // Look for annotations on the method
                ConstructorDeclaration declaration = (ConstructorDeclaration) scope;
                if (isSuppressed(issue, declaration.astModifiers())) {
                    return true;
                }
            } else if (type == ClassDeclaration.class) {
                // Class
                ClassDeclaration declaration = (ClassDeclaration) scope;
                if (isSuppressed(issue, declaration.astModifiers())) {
                    return true;
                }
            }

            scope = scope.getParent();
View Full Code Here

 
  public Node createEnhancedFor(
      org.parboiled.Node<Node> modifiers, Node type,
      org.parboiled.Node<Node> varDefEntry, Node iterable, Node statement) {
   
    VariableDefinition decl = new VariableDefinition().rawTypeReference(type).rawVariables()
        .addToEnd(varDefEntry.getValue());
    positionSpan(decl, modifiers, varDefEntry);
    decl.astModifiers(createModifiersIfNeeded(modifiers.getValue(), decl.getPosition().getStart()));
    return posify(new ForEach().rawVariable(decl).rawIterable(iterable).rawStatement(statement));
  }
View Full Code Here

  }
 
  public Node createCatch(Node modifiers, Node type, Node varName, Node body) {
    VariableDefinitionEntry varNameEntry = new VariableDefinitionEntry().astName(createIdentifierIfNeeded(varName, currentPos()));
    if (varName != null) varNameEntry.setPosition(varName.getPosition());
    VariableDefinition decl = new VariableDefinition().rawTypeReference(type).rawVariables().addToEnd(
        varNameEntry);
    if (type != null && varName != null) decl.setPosition(new Position(type.getPosition().getStart(), varName.getPosition().getEnd()));
    if (modifiers != null) decl.astModifiers(createModifiersIfNeeded(modifiers, currentPos()));
    return posify(new Catch().rawExceptionDeclaration(decl).rawBody(body));
  }
View Full Code Here

    return posify(new VariableDefinitionEntry().astName(createIdentifierIfNeeded(varName, currentPos()))
        .rawInitializer(initializer).astArrayDimensions(dims == null ? 0 : dims.size()));
  }
 
  public Node createVariableDefinition(Node type, Node head, List<Node> tail) {
    VariableDefinition result = new VariableDefinition().rawTypeReference(type);
    if (head != null) result.rawVariables().addToEnd(head);
    if (tail != null) for (Node n : tail) if (n != null) result.rawVariables().addToEnd(n);
    return posify(result);
  }
View Full Code Here

  }
 
  public void fieldModifiersCheck(VariableDeclaration vd) {
    TypeDeclaration td = vd.upUpToTypeDeclaration();
    if (td == null) return//not a field.
    VariableDefinition def = vd.astDefinition();
    if (def != null) {
      Modifiers m = def.astModifiers();
      modifiersCheck(m, FIELD_MODIFIERS_EXCLUSIVITY, FIELD_MODIFIERS_LEGAL, "field declarations");
      boolean allFieldsHaveInitializers = true;
      for (VariableDefinitionEntry entry : def.astVariables()) {
        if (entry.rawInitializer() == null) {
          allFieldsHaveInitializers = false;
          break;
        }
      }
View Full Code Here

      node.addMessage(error(VARIABLEDEFINITION_VARARGS_NOT_LEGAL_HERE, "Varargs are only legal on the last parameter of a constructor or method."));
    }
  }
 
  public void varargsAndExtendedDimsDontMix(VariableDefinitionEntry node) {
    VariableDefinition vd = node.upToVariableDefinition();
    if (vd == null) return;
    if (node.astArrayDimensions() > 0 && vd.astVarargs()) {
      node.addMessage(error(VARIABLEDEFINITIONENTRY_EXTENDED_DIMENSIONS_NOT_LEGAL, "Extended dimensions are not legal on a varargs declaration."));
    }
  }
View Full Code Here

    }
    if (dimClosed != null) for (org.parboiled.Node<Node> pNode : dimClosed) {
      source.registerStructure(e, pNode);
    }
    if (name != null) e.setPosition(new Position(name.getPosition().getStart(), currentPos()));
    VariableDefinition decl = new VariableDefinition().rawTypeReference(type);
    if (modifiers != null) decl.astModifiers(createModifiersIfNeeded(modifiers, currentPos()));
    if (varargs != null && !varargs.trim().isEmpty()) decl.astVarargs(true);
    decl.rawVariables().addToEnd(e);
    return posify(decl);
  }
View Full Code Here

            }
        }

        if (node instanceof VariableDeclaration) {
            VariableDeclaration declaration = (VariableDeclaration) node;
            VariableDefinition definition = declaration.astDefinition();
            if (definition != null) {
                lombok.ast.TypeReference typeReference = definition.astTypeReference();
                if (typeReference != null) {
                    return typeReference.getNativeNode();
                }
            }
        }
View Full Code Here

TOP

Related Classes of lombok.ast.VariableDefinition

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.