Package lombok.ast

Examples of lombok.ast.CompilationUnit


  private ImportList getImportList(Node n) {
    ImportList il = new ImportList();
   
    while (n != null) {
      if (n instanceof CompilationUnit) {
        CompilationUnit cu = (CompilationUnit) n;
        PackageDeclaration pkg = cu.astPackageDeclaration();
        if (pkg != null) il.stars.add(pkg.getPackageName());
        for (ImportDeclaration imp : cu.astImportDeclarations()) {
          if (imp.astStaticImport()) continue;
          if (imp.astStarImport()) {
            String i = imp.asFullyQualifiedName();
            i = i.substring(0, i.length() - 2);
            il.stars.add(i);
View Full Code Here


    }
   
    //name is definitely a simple name, and it might match. Walk up type tree and if it doesn't match any of those, delve into import statements.
    Node n = typeReference.getParent();
    Node prevN = null;
    CompilationUnit cu = null;
    while (n != null) {
      RawListAccessor<?, ?> list;
      boolean stopAtSelf;
     
      if (n instanceof Block) {
        list = ((Block) n).rawContents();
        stopAtSelf = true;
      } else if (n instanceof TypeBody) {
        list = ((TypeBody) n).rawMembers();
        stopAtSelf = false;
      } else if (n instanceof CompilationUnit) {
        list = ((CompilationUnit) n).rawTypeDeclarations();
        cu = (CompilationUnit) n;
        stopAtSelf = false;
      } else {
        list = null;
        stopAtSelf = false;
      }
     
      if (list != null) {
        for (Node c : list) {
          if (c instanceof TypeDeclaration && namesMatch(name, ((TypeDeclaration) c).astName())) return false;
          if (stopAtSelf && c == prevN) break;
        }
      }
     
      prevN = n;
      n = n.getParent();
    }
   
    //A locally defined type is definitely not what's targeted so it could still be our wanted type reference. Let's check imports.
    if (wantedPkg.isEmpty()) return cu == null || cu.rawPackageDeclaration() == null;
   
    return true;
  }
View Full Code Here

    if (dotStar != null && dotStar.length() > 0) decl.astStarImport(true);
    return posify(decl);
  }
 
  public Node createCompilationUnit(Node packageDeclaration, List<Node> importDeclarations, List<Node> typeDeclarations) {
    CompilationUnit unit = new CompilationUnit().rawPackageDeclaration(packageDeclaration);
    if (importDeclarations != null) for (Node n : importDeclarations) if (n != null) unit.rawImportDeclarations().addToEnd(n);
    if (typeDeclarations != null) for (Node n : typeDeclarations) if (n != null) unit.rawTypeDeclarations().addToEnd(n);
    return posify(unit);
  }
View Full Code Here

    @Override public void visitTree(JCTree node) {
      throw new UnsupportedOperationException("visit" + node.getClass().getSimpleName() + " not implemented");
    }
   
    @Override public void visitTopLevel(JCCompilationUnit node) {
      CompilationUnit unit = new CompilationUnit();
      if (node.pid != null) {
        PackageDeclaration pkg = new PackageDeclaration();
        fillWithIdentifiers(node.pid, pkg.astParts());
        unit.astPackageDeclaration(setPos(node.pid, pkg));
        fillList(node.packageAnnotations, pkg.rawAnnotations());
      }
     
      for (JCTree def : node.defs) {
        if (def instanceof JCImport) {
          unit.rawImportDeclarations().addToEnd(toTree(def));
        } else {
          unit.rawTypeDeclarations().addToEnd(toTree(def, FlagKey.SKIP_IS_DECL));
        }
      }
     
      setConversionStructureInfo(unit, "converted");
      set(node, unit);
View Full Code Here

TOP

Related Classes of lombok.ast.CompilationUnit

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.