Package org.eclipse.jdt.core.dom

Examples of org.eclipse.jdt.core.dom.ImportDeclaration


  public ImportDeclaration newImportDeclaration(AST ast, Optional<String> name) {
    Name qualifier = ast.newName(this.name);
    SimpleName theName = ast.newSimpleName(name.or("*"));
    QualifiedName qualifiedName = ast.newQualifiedName(qualifier, theName);

    ImportDeclaration declaration = ast.newImportDeclaration();
    declaration.setName(qualifiedName);
    return declaration;
  }
View Full Code Here


    // modify imports (-com.google.gwt.*, -*Exception, +AsyncCallback)
    {
      List<ImportDeclaration> imports = DomGenerics.imports(serviceRoot);
      // remove useless imports
      for (Iterator<ImportDeclaration> I = imports.iterator(); I.hasNext();) {
        ImportDeclaration importDeclaration = I.next();
        String importName = importDeclaration.getName().getFullyQualifiedName();
        if (importName.startsWith("com.google.gwt.user.client.rpc.")
            || importName.equals("com.google.gwt.core.client.GWT")
            || importName.endsWith("Exception")) {
          I.remove();
        }
View Full Code Here

      if (importDeclaration.getName().toString().equals(qualifiedName)) {
        return;
      }
    }
    // add new ImportDeclaration
    ImportDeclaration importDeclaration = ast.newImportDeclaration();
    importDeclaration.setName(ast.newName(qualifiedName));
    imports.add(importDeclaration);
  }
View Full Code Here

      }
    }
    else group = model;
    // 2°) Second step, we build a rewriter from the compilation unit
    AST ast = u.getAST();
    ImportDeclaration id = ast.newImportDeclaration();
    id.setName(ast.newName(new String[] {"java", "util", "Set"}));
    ASTRewrite rewriter = ASTRewrite.create(ast);
    // 3°) Third step, we can process the type declaration
    if(t.isInterface()) {
      result = new InterfaceService(t, group, rewriter, u);
    }
View Full Code Here

        assert javaElementName != null;
        return createImportDeclaration(ast, importClass.getName() + "." + javaElementName, true);
    }

    private ImportDeclaration createImportDeclaration(AST ast, String name, boolean isStatic) {
        ImportDeclaration importDeclaration = ast.newImportDeclaration();
        importDeclaration.setName(ast.newName(name));
        importDeclaration.setStatic(isStatic);
        return importDeclaration;
    }
View Full Code Here

        checkForNull(imports, "imports");

        final AST ast = rewrite.getAST();
        SortedSet<ImportDeclaration> importDeclarations = new TreeSet<ImportDeclaration>(comparator);
        for (String importName : imports) {
            ImportDeclaration importDeclaration = ast.newImportDeclaration();
            importDeclaration.setName(ast.newName(importName));
            importDeclaration.setStatic(staticImports);
            importDeclarations.add(importDeclaration);
        }
        addImports(rewrite, compilationUnit, importDeclarations);
    }
View Full Code Here

    }

    private static void addImports(ListRewrite importRewrite, Comparator<? super ImportDeclaration> comparator,
            Iterator<ImportDeclaration> newImports) {
        try {
            ImportDeclaration newImport = newImports.next();
            List<?> imports = importRewrite.getRewrittenList();
            for (Object importObj : imports) {
                ImportDeclaration anImport = (ImportDeclaration) importObj;
                int comp = comparator.compare(newImport, anImport);
                if (comp > 0) {
                    continue;
                }
                if (comp < 0) {
View Full Code Here

    PackageDeclaration p1 = ast.newPackageDeclaration();
    p1.setName(ast.newSimpleName("foo"));
    cu.setPackage(p1);

    ImportDeclaration id = ast.newImportDeclaration();
    id.setName(ast.newName(new String[] {
        "java", "util", "Set" }));
    cu.imports().add(id);

    TypeDeclaration td = ast.newTypeDeclaration();
    td.setName(ast.newSimpleName("Foo"));
View Full Code Here

    if (decls.isEmpty()) {
      return;
    }
    PackageEntry currPackage= null;

    ImportDeclaration curr= (ImportDeclaration) decls.get(0);
    int currOffset= curr.getStartPosition();
    int currLength= curr.getLength();
    int currEndLine= root.getLineNumber(currOffset + currLength);

    for (int i= 1; i < decls.size(); i++) {
      boolean isStatic= curr.isStatic();
      String name= getFullName(curr);
      String packName= getQualifier(curr);
      if (currPackage == null || currPackage.compareTo(packName, isStatic) != 0) {
        currPackage= new PackageEntry(packName, null, isStatic);
        this.packageEntries.add(currPackage);
      }

      ImportDeclaration next= (ImportDeclaration) decls.get(i);
      int nextOffset= next.getStartPosition();
      int nextLength= next.getLength();
      int nextOffsetLine= root.getLineNumber(nextOffset);

      int extendedStart = root.getExtendedStartPosition(curr);
      int extendedLength = root.getExtendedLength(curr);
      if (extendedStart < this.replaceRange.getOffset()) {
View Full Code Here

    /* for the first comment, we only take the trailing comment if any and the replace range doesn't
     * include the preceding comment
     */
    for (int i= 0; i < decls.size(); i++) {
      ImportDeclaration next= (ImportDeclaration) decls.get(i);
      int nextOffset= next.getStartPosition();
      int nextLength= next.getLength();

      int extendedStart = root.getExtendedStartPosition(next);
      int extendedLength = root.getExtendedLength(next);
      int nextOffsetLine= root.getLineNumber(nextOffset);

View Full Code Here

TOP

Related Classes of org.eclipse.jdt.core.dom.ImportDeclaration

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.