Package lombok.ast

Examples of lombok.ast.Modifiers


    return i;
  }
 
  Modifiers createModifiersIfNeeded(Node modifiers, int pos) {
    if (modifiers instanceof Modifiers) return (Modifiers)modifiers;
    Modifiers m = new Modifiers();
    m.setPosition(new Position(pos, pos));
    DanglingNodes.addDanglingNode(m, modifiers);
    return m;
  }
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;
        }
      }
     
      if (m.isStatic() && !m.isFinal() && !allFieldsHaveInitializers) {
        // Initialized static final fields, assuming the initializer expression is a compile time constant, are 'special' and
        // do not need to adhere to the static chain rule. However, we can't determine CTC nature without resolution.
        checkStaticChain(m);
      }
    }
View Full Code Here

   
    Node p = modifiers.getParent();
    while (p != null) {
      if (p instanceof CompilationUnit) return;
      if (p instanceof TypeDeclaration) {
        Modifiers pMods = ((TypeDeclaration)p).astModifiers();
        if (!pMods.isStatic()) {
          modifiers.getParent().addMessage(error(MODIFIERS_STATIC_CHAIN,
              "This declaration is (effectively) static; static declarations or only legal in top-level and static declarations."));
        }
      }
      p = p.getParent();
View Full Code Here

   
    return false;
  }
 
  public void emptyDeclarationMustHaveNoModifiers(EmptyDeclaration node) {
    Modifiers modifiers = node.astModifiers();
   
    if (!modifiers.astKeywords().isEmpty() || !modifiers.astAnnotations().isEmpty()) {
      node.addMessage(error(MODIFIERS_MODIFIER_NOT_ALLOWED, "Empty Declarations cannot have modifiers."));
    }
  }
View Full Code Here

import lombok.ast.template.SyntaxCheck;

@SyntaxCheck
public class StructuralChecks {
  public void checkAbstractMembersOnlyInAbstractTypes(MethodDeclaration md) {
    Modifiers modifiers = md.astModifiers();
    if (modifiers == null) return;
    if (!modifiers.isAbstract()) return;
    TypeDeclaration parent = md.upUpToTypeDeclaration();
    if (parent != null) {
      Modifiers modifiersOfParent = parent.astModifiers();
      if (modifiersOfParent != null && modifiersOfParent.isAbstract()) return;
      md.addMessage(error(MODIFIERS_ABSTRACT_NOT_ALLOWED, "Abstract methods are only allowed in interfaces and abstract classes"));
    }
  }
View Full Code Here

    if (throwsTail != null) for (Node n : throwsTail) if (n != null) decl.rawThrownTypeReferences().addToEnd(n);
    return posify(decl);
  }
 
  public Node createModifiers(List<Node> values) {
    Modifiers result = new Modifiers();
    if (values != null) for (Node n : values) {
      if (n instanceof Annotation) result.rawAnnotations().addToEnd(n);
      if (n instanceof KeywordModifier) result.rawKeywords().addToEnd(n);
    }
    return posify(result);
  }
View Full Code Here

      addJavadoc(typeDecl, node.mods);
      set(node, typeDecl);
    }
   
    @Override public void visitModifiers(JCModifiers node) {
      Modifiers m = new Modifiers();
      fillList(node.annotations, m.rawAnnotations());
      for (KeywordModifier mod : KeywordModifier.fromReflectModifiers((int) node.flags)) m.astKeywords().addToEnd(mod);
      setConversionStructureInfo(m, "converted");
      set(node, m);
    }
View Full Code Here

TOP

Related Classes of lombok.ast.Modifiers

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.