Package org.eclipse.jdt.core.dom

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


  }

  private IRegion evaluateReplaceRange(CompilationUnit root) {
    List imports= root.imports();
    if (!imports.isEmpty()) {
      ImportDeclaration first= (ImportDeclaration) imports.get(0);
      ImportDeclaration last= (ImportDeclaration) imports.get(imports.size() - 1);

      int startPos= first.getStartPosition(); // no extended range for first: bug 121428
      int endPos= root.getExtendedStartPosition(last) + root.getExtendedLength(last);
      int endLine= root.getLineNumber(endPos);
      if (endLine > 0) {
View Full Code Here


      source.append(";\n"); //$NON-NLS-1$
    }

    for (Iterator<ImportDeclaration> iterator = compilationUnit.imports().iterator(); iterator
        .hasNext();) {
      ImportDeclaration importDeclaration = iterator
          .next();
      source.append("import "); //$NON-NLS-1$
      if (importDeclaration.isStatic()) {
        source.append("static "); //$NON-NLS-1$
      }
      source.append(getQualifiedIdentifier(importDeclaration.getName()));
      if (importDeclaration.isOnDemand()) {
        source.append(".*"); //$NON-NLS-1$
      }
      source.append(";\n"); //$NON-NLS-1$
    }

View Full Code Here

        // reconcile the imports
        List<ImportDeclaration> newImports = getNewImports(cu.imports(), newJavaFileVisitor);
        for (ImportDeclaration newImport : newImports) {
            Name name = ast.newName(newImport.getName().getFullyQualifiedName());
            ImportDeclaration newId = ast.newImportDeclaration();
            newId.setName(name);
            cu.imports().add(newId);
        }

        TextEdit textEdit = cu.rewrite(document, null);
        try {
View Full Code Here

        List<ImportDeclaration> newImports = getNewImports(cu.imports(),
                newJavaFileVisitor);
        for (ImportDeclaration newImport : newImports) {
            Name name = ast
                    .newName(newImport.getName().getFullyQualifiedName());
            ImportDeclaration newId = ast.newImportDeclaration();
            newId.setName(name);
            cu.imports().add(newId);
        }

        TextEdit textEdit = cu.rewrite(document, null);
        try {
View Full Code Here

      List<String> importedPackages = new ArrayList<String>();

      for (CompilationUnit cu2 : result) {
        Name packageToCompare = cu2.getPackage().getName();
        ImportDeclaration importDeclaration = null;
        if (packageName.getFullyQualifiedName().equals(
            packageToCompare.getFullyQualifiedName()))
          continue;
        ImportCheckerVisitor iv = new ImportCheckerVisitor();
        cu2.accept(iv);
View Full Code Here

    return result;
  }

  private ImportDeclaration importPacakge(Name packageToCompare) {
    ImportDeclaration importDeclaration = ast.newImportDeclaration();
    importDeclaration.setName(ast.newSimpleName(packageToCompare
        .getFullyQualifiedName()));
    importDeclaration.setOnDemand(true);
    return importDeclaration;
  }
View Full Code Here

    Map<String, List<String>> r = getRelations(packageRelations);
    List<String> imported = r.get(classId);

    if (imported != null) {
      for (String importedPackage : imported) {
        ImportDeclaration importDeclaration = ast
            .newImportDeclaration();
        importDeclaration.setName(ast.newSimpleName(importedPackage));
        importDeclaration.setOnDemand(true);
        result.add(importDeclaration);
      }
    }

    return result;
View Full Code Here

    //
    // Add a static import for this method
    //
    ListRewrite lr = result.getListRewrite(astRoot, CompilationUnit.IMPORTS_PROPERTY);
    ImportDeclaration id = ast.newImportDeclaration();
    id.setStatic(true);
    id.setName(ast.newName("org.testng.AssertJUnit." + m_assert));
    lr.insertFirst(id, null);

    return result;
  }
View Full Code Here

  }

  private void addImport(AST ast, ASTRewrite rewriter, CompilationUnit astRoot, String imp,
      boolean isStatic) {
    ListRewrite lr = rewriter.getListRewrite(astRoot, CompilationUnit.IMPORTS_PROPERTY);
    ImportDeclaration id = ast.newImportDeclaration();
    id.setStatic(isStatic);
    id.setName(ast.newName(imp));
    lr.insertFirst(id, null);
  }
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.