Пример #1
0
  /**
   * @return the list of all named type declarations in the compilation units associated with this
   *     environment - usually just one compilation unit, except in batch mode where it will be all
   *     compilation units in the build. This implementation is different from the API specification
   *     in that it does not return all included source types in the universe.
   */
  public Collection<TypeDeclaration> getTypeDeclarations() {
    final List<ITypeBinding> bindings = getTypeBindings();
    if (bindings.isEmpty()) return Collections.emptyList();
    final List<TypeDeclaration> mirrorDecls = new ArrayList<TypeDeclaration>(bindings.size());

    for (ITypeBinding binding : bindings) {
      final TypeDeclaration mirrorDecl = Factory.createReferenceType(binding, this);
      if (mirrorDecl != null) mirrorDecls.add(mirrorDecl);
    }

    return mirrorDecls;
  }
Пример #2
0
  // does not generate dependencies
  public TypeDeclaration getTypeDeclaration(String name) {
    if (name == null || name.length() == 0) return null;

    // get rid of the generics parts.
    final int index = name.indexOf('<');
    if (index != -1) name = name.substring(0, index);

    ITypeBinding typeBinding = null;
    try {
      typeBinding = getTypeDefinitionBindingFromName(name);
    } catch (ArrayIndexOutOfBoundsException e) {
      // https://bugs.eclipse.org/bugs/show_bug.cgi?id=133947
      // if the name is invalid, JDT can throw an ArrayIndexOutOfBoundsException
      // We'll ignore this and return null to the user
      AptPlugin.log(e, "Unable to get type definition binding for: " + name); // $NON-NLS-1$
    }

    return Factory.createReferenceType(typeBinding, this);
  }