congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
CompilationUnit.getTypes
Code IndexAdd Tabnine to your IDE (free)

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

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

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

private TypeDeclaration typeDeclarationFromCompilationUnit()
{
  List<TypeDeclaration> typeDeclarations = compilationUnit.getTypes();
  if (typeDeclarations == null)
  {
    throw new IllegalArgumentException("Source file does not contain a Java class");
  }
  if (typeDeclarations.size() > 1)
  {
    throw new IllegalArgumentException("Source file contains more than one Java class");
  }
  return typeDeclarations.get(0);
}
origin: paypal/SeLion

private void initializeFieldDetails(CompilationUnit cu) {
  List<TypeDeclaration> types = cu.getTypes();
  for (TypeDeclaration type : types) {
    List<BodyDeclaration> members = type.getMembers();
    for (BodyDeclaration member : members) {
      if (member instanceof FieldDeclaration) {
        FieldDeclaration field = (FieldDeclaration) member;
        fields.add(field);
      }
    }
  }
}
origin: com.google.code.javaparser/javaparser

/**
 * Adds the given type declaration to the compilation unit. The list of
 * types will be initialized if it is <code>null</code>.
 * 
 * @param cu
 *            compilation unit
 * @param type
 *            type declaration
 */
public static void addTypeDeclaration(CompilationUnit cu, TypeDeclaration type) {
  List<TypeDeclaration> types = cu.getTypes();
  if (types == null) {
    types = new ArrayList<TypeDeclaration>();
    cu.setTypes(types);
  }
  types.add(type);
}
origin: org.kuali.rice/rice-development-tools

  private String getTypeNameForMsg(final Node n) {
    final CompilationUnit unit = getCompilationUnit(n);
    final TypeDeclaration parent = unit.getTypes().get(0);
    return parent.getName();
  }
}
origin: paypal/SeLion

private void initializeMethodDetails(CompilationUnit cu) {
  String className = file.getName();
  className = className.substring(0, className.indexOf("."));
  List<TypeDeclaration> types = cu.getTypes();
  for (TypeDeclaration type : types) {
    List<BodyDeclaration> members = type.getMembers();
    for (BodyDeclaration member : members) {
      if (member instanceof MethodDeclaration) {
        MethodDeclaration method = (MethodDeclaration) member;
        method.setJavaDoc(new JavadocComment("@deprecated This method is moved to the class {@link "
            + className + "}"));
        methods.add(method);
      }
    }
  }
}
origin: org.kuali.rice/rice-development-tools

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

final CompilationUnit compilationUnit = JavaParser.parse(reader, true);
final List<TypeDeclaration> typeDeclarations = compilationUnit
    .getTypes();
if (typeDeclarations.size() > 1) {
  throw new ParseException(
origin: org.kuali.rice/rice-development-tools

private String getTypeOrFieldNameForMsg(final BodyDeclaration n) {
  if (n instanceof TypeDeclaration) {
    return ((TypeDeclaration) n).getName();
  } else if (n instanceof FieldDeclaration) {
    final FieldDeclaration fd = (FieldDeclaration) n;
    //this wont work for nested classes but we should be in nexted classes at this point
    final CompilationUnit unit = getCompilationUnit(n);
    final TypeDeclaration parent = unit.getTypes().get(0);
    Collection<String> variableNames = new ArrayList<String>();
    if (fd.getVariables() != null) {
      for (VariableDeclarator vd : fd.getVariables()) {
        variableNames.add(vd.getId().getName());
      }
    }
    return variableNames.size() == 1 ?
        parent.getName() + "." + variableNames.iterator().next() :
        parent.getName() + "." + variableNames.toString();
  }
  return null;
}
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: org.juzu/juzu-core

public ClassOrInterfaceDeclaration assertDeclaration() {
 List<TypeDeclaration> decls = assertCompilationUnit().getTypes();
 AbstractTestCase.assertEquals(1, decls.size());
 TypeDeclaration decl = decls.get(0);
 return AbstractTestCase.assertInstanceOf(ClassOrInterfaceDeclaration.class, decl);
}
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: juzu/juzu

public ClassOrInterfaceDeclaration assertDeclaration() {
 List<TypeDeclaration> decls = assertCompilationUnit().getTypes();
 AbstractTestCase.assertEquals(1, decls.size());
 TypeDeclaration decl = decls.get(0);
 return AbstractTestCase.assertInstanceOf(ClassOrInterfaceDeclaration.class, decl);
}
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.getTypes() != null) {
  for (final TypeDeclaration typeDeclaration : n.getTypes()) {
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 TypeDeclaration parent = unit.getTypes().get(0);
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.astCompilationUnitgetTypes

Javadoc

Return the list of types declared in this compilation unit.
If there is no types declared, null is returned.

Popular methods of CompilationUnit

  • getPackage
    Retrieves the package declaration of this compilation unit. If this compilation unit has no package
  • 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

  • Start an intent from android
  • setContentView (Activity)
  • runOnUiThread (Activity)
  • addToBackStack (FragmentTransaction)
  • VirtualMachine (com.sun.tools.attach)
    A Java virtual machine. A VirtualMachine represents a Java virtual machine to which this Java vir
  • Font (java.awt)
    The Font class represents fonts, which are used to render text in a visible way. A font provides the
  • KeyStore (java.security)
    KeyStore is responsible for maintaining cryptographic keys and their owners. The type of the syste
  • LinkedList (java.util)
    Doubly-linked list implementation of the List and Dequeinterfaces. Implements all optional list oper
  • Loader (org.hibernate.loader)
    Abstract superclass of object loading (and querying) strategies. This class implements useful common
  • Option (scala)
  • Best IntelliJ 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