Tabnine Logo
CompilationUnit.getPackage
Code IndexAdd Tabnine to your IDE (free)

How to use
getPackage
method
in
japa.parser.ast.CompilationUnit

Best Java code snippets using japa.parser.ast.CompilationUnit.getPackage (Showing top 20 results out of 315)

origin: org.mule.tools/mule-cloud-connector-generator

  private String packageNameFromCompilationUnit()
  {
    PackageDeclaration packageDeclaration = compilationUnit.getPackage();
    if (packageDeclaration == null)
    {
      throw new IllegalArgumentException("Source file does not declare a package. Default package is unsupported.");
    }
    return packageDeclaration.getName().toString();
  }
}
origin: com.google.code.javaparser/javaparser

@Override public Node visit(final CompilationUnit n, final A arg) {
  if (n.getPackage() != null) {
    n.setPackage((PackageDeclaration) n.getPackage().accept(this, arg));
  }
  final List<ImportDeclaration> imports = n.getImports();
  if (imports != null) {
    for (int i = 0; i < imports.size(); i++) {
      imports.set(i, (ImportDeclaration) imports.get(i).accept(this, arg));
    }
    removeNulls(imports);
  }
  final List<TypeDeclaration> types = n.getTypes();
  if (types != null) {
    for (int i = 0; i < types.size(); i++) {
      types.set(i, (TypeDeclaration) types.get(i).accept(this, arg));
    }
    removeNulls(types);
  }
  return n;
}
origin: org.juzu/juzu-core

public PackageDeclaration assertPackage() {
 return assertCompilationUnit().getPackage();
}
origin: org.kuali.rice/rice-development-tools

final String enclosingName = n.getPackage().getName() + "." + n.getTypes().get(0).getName();
origin: juzu/juzu

public PackageDeclaration assertPackage() {
 return assertCompilationUnit().getPackage();
}
origin: org.chromattic/chromattic.testgenerator

public void build() {
 UnitChromatticVisitor unitChromatticVisitor = new UnitChromatticVisitor();
 compilationUnit.getPackage().getName().setName(compilationUnit.getPackage().getName().getName() + ".groovy");
 unitChromatticVisitor.visit(compilationUnit, null);
 sb.append(compilationUnit.toString(new GroovyCompatibilityFactory()));
}
origin: com.google.code.javaparser/javaparser

/**
 * Comments are attributed to the thing the comment and are removed from
 * allComments.
 */
private static void insertCommentsInCu(CompilationUnit cu, CommentsCollection commentsCollection){
  if (commentsCollection.size()==0) return;
  // I should sort all the direct children and the comments, if a comment is the first thing then it
  // a comment to the CompilationUnit
  // FIXME if there is no package it could be also a comment to the following class...
  // so I could use some heuristics in these cases to distinguish the two cases
  List<Comment> comments = commentsCollection.getAll();
  sortByBeginPosition(comments);
  List<Node> children = cu.getChildrenNodes();
  sortByBeginPosition(children);
  if (cu.getPackage()!=null && (children.size()==0 || areInOrder(comments.get(0), children.get(0)))){
    cu.setComment(comments.get(0));
    comments.remove(0);
  }
  insertCommentsInNode(cu,comments);
}
origin: org.chromattic/chromattic.testgenerator

public void visit(CompilationUnit n, Object arg) {
  if (n.getPackage() != null) {
    n.getPackage().accept(this, arg);
  }
  if (n.getImports() != null) {
    for (ImportDeclaration i : n.getImports()) {
      i.accept(this, arg);
    }
    printer.printLn();
  }
  if (n.getTypes() != null) {
    for (Iterator<TypeDeclaration> i = n.getTypes().iterator(); i.hasNext();) {
      i.next().accept(this, arg);
      printer.printLn();
      if (i.hasNext()) {
        printer.printLn();
      }
    }
  }
}
origin: com.google.code.javaparser/javaparser

@Override public void visit(final CompilationUnit n, final Object arg) {
  printJavaComment(n.getComment(), arg);
  if (n.getPackage() != null) {
    n.getPackage().accept(this, arg);
  }
  if (n.getImports() != null) {
    for (final ImportDeclaration i : n.getImports()) {
      i.accept(this, arg);
    }
    printer.printLn();
  }
  if (n.getTypes() != null) {
    for (final Iterator<TypeDeclaration> i = n.getTypes().iterator(); i.hasNext();) {
      i.next().accept(this, arg);
      printer.printLn();
      if (i.hasNext()) {
        printer.printLn();
      }
    }
  }
  printOrphanCommentsEnding(n);
}
origin: com.google.code.javaparser/javaparser

@Override public void visit(final CompilationUnit n, final A arg) {
  visitComment(n.getComment(), arg);
  if (n.getPackage() != null) {
    n.getPackage().accept(this, arg);
  }
  if (n.getImports() != null) {
    for (final ImportDeclaration i : n.getImports()) {
      i.accept(this, arg);
    }
  }
  if (n.getTypes() != null) {
    for (final TypeDeclaration typeDeclaration : n.getTypes()) {
      typeDeclaration.accept(this, arg);
    }
  }
}
origin: com.google.code.javaparser/javaparser

@Override
public R visit(final CompilationUnit n, final A arg) {
  if (n.getPackage() != null) {
      R result = n.getPackage().accept(this, arg);
      if (result != null) {
        return result;
origin: com.google.code.javaparser/javaparser

@Override public Boolean visit(final CompilationUnit n1, final Node arg) {
  final CompilationUnit n2 = (CompilationUnit) arg;
  if (!nodeEquals(n1.getPackage(), n2.getPackage())) {
    return Boolean.FALSE;
  }
  if (!nodesEquals(n1.getImports(), n2.getImports())) {
    return Boolean.FALSE;
  }
  if (!nodesEquals(n1.getTypes(), n2.getTypes())) {
    return Boolean.FALSE;
  }
  if (!nodesEquals(n1.getComments(), n2.getComments())) {
    return Boolean.FALSE;
  }
  return Boolean.TRUE;
}
origin: org.kuali.rice/rice-development-tools

@Override
public final NodeData resolve(Node node, String mappedClass) {
  if (!(node instanceof FieldDeclaration)) {
    throw new IllegalArgumentException("this annotation belongs only on FieldDeclaration");
  }
  final FieldDeclaration field = (FieldDeclaration) node;
  if (ResolverUtil.canFieldBeAnnotated(field)) {
    final TypeDeclaration dclr = (TypeDeclaration) node.getParentNode();
    final String name = dclr.getName();
    final String pckg = ((CompilationUnit) dclr.getParentNode()).getPackage().getName().toString();
    final String fullyQualifiedClass = pckg + "." + name;
    final boolean mappedColumn = OjbUtil.isMappedColumn(mappedClass, ParserUtil.getFieldName(field),
        descriptorRepositories);
    if (mappedColumn) {
      return getAnnotationNodes(fullyQualifiedClass, ParserUtil.getFieldName(field), mappedClass);
    }
  }
  return null;
}
origin: com.google.code.javaparser/javaparser

@Override
public Node visit(CompilationUnit _n, Object _arg) {
  PackageDeclaration package_ = cloneNodes(_n.getPackage(), _arg);
  List<ImportDeclaration> imports = visit(_n.getImports(), _arg);
  List<TypeDeclaration> types = visit(_n.getTypes(), _arg);
  return new CompilationUnit(
      _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(),
      package_, imports, types
  );
}
origin: org.kuali.rice/rice-development-tools

@Override
public NodeData resolve(Node node, String mappedClass) {
  if (!(node instanceof ClassOrInterfaceDeclaration)) {
    throw new IllegalArgumentException("this annotation belongs only on ClassOrInterfaceDeclaration");
  }
  final TypeDeclaration dclr = (TypeDeclaration) node;
  if (!(dclr.getParentNode() instanceof CompilationUnit)) {
    //handling nested classes
    return null;
  }
  final String name = dclr.getName();
  final String pckg = ((CompilationUnit) dclr.getParentNode()).getPackage().getName().toString();
  final String enclosingClass = pckg + "." + name;
  final Collection<String> customizedFieldsOnNode = getFieldsOnNode(dclr, getCustomizedFields(mappedClass));
  if (customizedFieldsOnNode == null || customizedFieldsOnNode.isEmpty()) {
    LOG.info(ResolverUtil.logMsgForClass(enclosingClass, mappedClass) + " has no customized fields");
    return null;
  }
  return new NodeData(new SingleMemberAnnotationExpr(new NameExpr(SIMPLE_NAME), new NameExpr("CreateCustomizerFor" + customizedFieldsOnNode.toString())),
      new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), SIMPLE_NAME), false, false));
}
origin: org.kuali.rice/rice-development-tools

  @Override
  public NodeData resolve(Node node, String mappedClass) {
    if (!(node instanceof ClassOrInterfaceDeclaration)) {
      throw new IllegalArgumentException("this annotation belongs only on ClassOrInterfaceDeclaration");
    }

    final TypeDeclaration dclr = (TypeDeclaration) node;
    if (!(dclr.getParentNode() instanceof CompilationUnit)) {
      //handling nested classes
      return null;
    }

    final String name = dclr.getName();
    final String pckg = ((CompilationUnit) dclr.getParentNode()).getPackage().getName().toString();
    final String enclosingClass = pckg + "." + name;
    if (!enclosingClass.equals(mappedClass)) {
      return new NodeData(new MarkerAnnotationExpr(new NameExpr(SIMPLE_NAME)),
        new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), SIMPLE_NAME), false, false));
    }
    return null;
  }
}
origin: org.kuali.rice/rice-development-tools

@Override
public NodeData resolve(Node node, String mappedClass) {
  if (!(node instanceof ClassOrInterfaceDeclaration)) {
    throw new IllegalArgumentException("this annotation belongs only on ClassOrInterfaceDeclaration");
  }
  final TypeDeclaration dclr = (TypeDeclaration) node;
  if (!(dclr.getParentNode() instanceof CompilationUnit)) {
    //handling nested classes
    return null;
  }
  final String name = dclr.getName();
  final String pckg = ((CompilationUnit) dclr.getParentNode()).getPackage().getName().toString();
  final String enclosingClass = pckg + "." + name;
  final ClassDescriptor cd = OjbUtil.findClassDescriptor(enclosingClass, descriptorRepositories);
  if (cd != null) {
    final String tableName = getMappedTable(enclosingClass);
    if (tableName == null) {
      LOG.error(ResolverUtil.logMsgForClass(enclosingClass, mappedClass) + " table could not be found");
      return null;
    }
    return new NodeData(new NormalAnnotationExpr(new NameExpr(SIMPLE_NAME), Collections.singletonList(new MemberValuePair("name", new StringLiteralExpr(upperCaseTableName ? tableName.toUpperCase() : tableName)))),
        new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), SIMPLE_NAME), false, false));
  }
  return null;
}
origin: org.kuali.rice/rice-development-tools

  @Override
  public NodeData resolve(Node node, String mappedClass) {
    if (!(node instanceof ClassOrInterfaceDeclaration)) {
      throw new IllegalArgumentException("this annotation belongs only on ClassOrInterfaceDeclaration");
    }

    final TypeDeclaration dclr = (TypeDeclaration) node;
    if (!(dclr.getParentNode() instanceof CompilationUnit)) {
      //handling nested classes
      return null;
    }

    final String name = dclr.getName();
    final String pckg = ((CompilationUnit) dclr.getParentNode()).getPackage().getName().toString();
    final String enclosingClass = pckg + "." + name;

    final ClassDescriptor cd = OjbUtil.findClassDescriptor(enclosingClass, descriptorRepositories);
    if (cd != null) {
      return new NodeData(new MarkerAnnotationExpr(new NameExpr(SIMPLE_NAME)),
          new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), SIMPLE_NAME), false, false));
    }

    return null;
  }
}
origin: org.juzu/juzu-core

assertTrue(file.renameTo(tmp));
JavaFile javaFile = helper.assertJavaSource("metamodel.controller.sub.A");
javaFile.assertCompilationUnit().getPackage().setName(ASTHelper.createNameExpr("metamodel.controller.sub"));
javaFile.assertSave();
origin: juzu/juzu

assertTrue(file.renameTo(tmp));
JavaFile javaFile = helper.assertJavaSource("metamodel.controller.sub.A");
javaFile.assertCompilationUnit().getPackage().setName(ASTHelper.createNameExpr("metamodel.controller.sub"));
javaFile.assertSave();
japa.parser.astCompilationUnitgetPackage

Javadoc

Retrieves the package declaration of this compilation unit.
If this compilation unit has no package declaration (default package), null is returned.

Popular methods of CompilationUnit

  • getTypes
    Return the list of types declared in this compilation unit. If there is no types declared, null is r
  • getImports
    Retrieves the list of imports declared in this compilation unit ornull if there is no import.
  • setImports
    Sets the list of imports of this compilation unit. The list is initiallynull.
  • toString
  • <init>
  • accept
  • equals
  • getAllContainedComments
  • getBeginColumn
  • getBeginLine
  • getChildrenNodes
  • getComment
  • getChildrenNodes,
  • getComment,
  • getComments,
  • getEndColumn,
  • getEndLine,
  • setAsParentNodeOf,
  • setComment,
  • setPackage,
  • setTypes

Popular in Java

  • Making http requests using okhttp
  • onRequestPermissionsResult (Fragment)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • getExternalFilesDir (Context)
  • SimpleDateFormat (java.text)
    Formats and parses dates in a locale-sensitive manner. Formatting turns a Date into a String, and pa
  • ArrayList (java.util)
    ArrayList is an implementation of List, backed by an array. All optional operations including adding
  • HashMap (java.util)
    HashMap is an implementation of Map. All optional operations are supported.All elements are permitte
  • StringTokenizer (java.util)
    Breaks a string into tokens; new code should probably use String#split.> // Legacy code: StringTo
  • Semaphore (java.util.concurrent)
    A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each #acquire blocks if
  • ServletException (javax.servlet)
    Defines a general exception a servlet can throw when it encounters difficulty.
  • Top PhpStorm plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now