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

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

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

origin: paypal/SeLion

private void initialize() throws IOException, ParseException {
  CompilationUnit cu = JavaParser.parse(file);
  if (cu.getImports() != null) {
    imports = cu.getImports();
  }
  initializeFieldDetails(cu);
  initializeMethodDetails(cu);
}
origin: paypal/SeLion

/**
 * This method will add methods, fields and import statement to existing java file
 * 
 * @throws IOException
 * @throws ParseException
 */
public void insertCode() throws IOException, ParseException {
  CompilationUnit cuResult = JavaParser.parse(baseFile);
  if (cuResult.getImports() != null) {
    List<ImportDeclaration> importsFromBaseFile = cuResult.getImports();
    for (ImportDeclaration eachImport : importsFromExtendedFile) {
      if (!importAlreadyPresent(importsFromBaseFile, eachImport)) {
        importsFromBaseFile.add(eachImport);
      }
    }
    cuResult.setImports(importsFromBaseFile);
  }
  String code = cuResult.toString();
  BufferedWriter b = new BufferedWriter(new FileWriter(baseFile));
  b.write(code);
  b.close();
}
origin: org.kuali.rice/rice-development-tools

@Override
public void visit(final CompilationUnit n, final String mappedClass) {
  if (StringUtils.isBlank(mappedClass)) {
    throw new IllegalArgumentException("mappedClass cannot be blank");
  }
  super.visit(n, mappedClass);
  ParserUtil.sortImports(n.getImports());
  processedCache(n, mappedClass, PROCESSED_CACHE);
}
origin: org.chromattic/chromattic.testgenerator

public void build(DumpVisitorFactory factory, List<String> excludedMethods) {
 UnitTestVisitor unitTestVisitor = new UnitTestVisitor(name);
 //
 Iterator<ImportDeclaration> itImports = compilationUnit.getImports().iterator();
 while (itImports.hasNext()) {
  if (GroovyTestGeneration.class.getName().equals(itImports.next().getName().toString())) {
   itImports.remove();
  }
 }
 //
 for (String dep : deps)
 {
  int i = dep.lastIndexOf(".");
  String depPackage = dep.substring(0, i) + ".groovy";
  String depImport = depPackage + dep.substring(i);
  compilationUnit.getImports().add(new ImportDeclaration(new NameExpr(depImport), false, false));
 }
 //
 unitTestVisitor.visit(compilationUnit, excludedMethods);
 sb.append(compilationUnit.toString(factory));
}
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.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

if (n.getImports() != null) {
  for (final ImportDeclaration i : n.getImports()) {
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

final List<ImportDeclaration> imports = unit.getImports() != null ? unit.getImports() : new ArrayList<ImportDeclaration>();
final boolean foundAnnImport = imported(imports, fullyQualifiedName);
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
  );
}
japa.parser.astCompilationUnitgetImports

Javadoc

Retrieves the list of imports declared in this compilation unit or null if there is no import.

Popular methods of CompilationUnit

  • getTypes
    Return the list of types declared in this compilation unit. If there is no types declared, null is r
  • getPackage
    Retrieves the package declaration of this compilation unit. If this compilation unit has no package
  • 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

  • Start an intent from android
  • scheduleAtFixedRate (ScheduledExecutorService)
  • addToBackStack (FragmentTransaction)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • ObjectMapper (com.fasterxml.jackson.databind)
    ObjectMapper provides functionality for reading and writing JSON, either to and from basic POJOs (Pl
  • System (java.lang)
    Provides access to system-related information and resources including standard input and output. Ena
  • URL (java.net)
    A Uniform Resource Locator that identifies the location of an Internet resource as specified by RFC
  • DateFormat (java.text)
    Formats or parses dates and times.This class provides factories for obtaining instances configured f
  • Scanner (java.util)
    A parser that parses a text string of primitive types and strings with the help of regular expressio
  • TreeMap (java.util)
    Walk the nodes of the tree left-to-right or right-to-left. Note that in descending iterations, next
  • Top Sublime Text 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