Package org.eclipse.jdt.core.dom

Examples of org.eclipse.jdt.core.dom.AST.newName()


    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


  int length = charFragments.length;
  String[] strFragments = new String[length];
  for (int i = 0; i < length; i++) {
    strFragments[i] = String.valueOf(charFragments[i]);
  }
  Name name = ast.newName(strFragments);
  importDeclaration.setName(name);
  if (onDemand) importDeclaration.setOnDemand(true);
  return importDeclaration;
}
/**
 
View Full Code Here

      }
    } else {
      org.eclipse.jdt.core.dom.PackageDeclaration pkg = astCU.getPackage();
      if (pkg != null) {
        // rename package statement
        Name name = ast.newName(pkgName);
        rewriter.set(pkg, PackageDeclaration.NAME_PROPERTY, name, null);
      } else {
        // create new package statement
        pkg = ast.newPackageDeclaration();
        pkg.setName(ast.newName(pkgName));
View Full Code Here

        Name name = ast.newName(pkgName);
        rewriter.set(pkg, PackageDeclaration.NAME_PROPERTY, name, null);
      } else {
        // create new package statement
        pkg = ast.newPackageDeclaration();
        pkg.setName(ast.newName(pkgName));
        rewriter.set(astCU, CompilationUnit.PACKAGE_PROPERTY, pkg, null);
      }
    }
  }
View Full Code Here

      return null;
    }
  }
  AST ast = this.cuAST.getAST();
  PackageDeclaration pkgDeclaration = ast.newPackageDeclaration();
  Name astName = ast.newName(this.name);
  pkgDeclaration.setName(astName);
  return pkgDeclaration;
}
/**
* Creates and returns the handle for the element this operation created.
View Full Code Here

        tag.setTagName(TagElement.TAG_SEE);
        doc.tags().add(tag);
        MethodRef method = ast.newMethodRef();
        tag.fragments().add(method);
        SimpleName name = ast.newSimpleName("Test");
        method.setQualifier(ast.newQualifiedName(ast.newQualifiedName(ast.newName("org"), ast.newSimpleName("junit")), name));
        name = ast.newSimpleName("test");
        method.setName(name);
        return super.visit(doc);
      }
    };
View Full Code Here

                AstUtils.rewriteReplace(
                    compilationUnit, singleMemberAnnotation.getValue(), replacement);
                return;
            } else {
                MarkerAnnotation replacementAnnotation = ast.newMarkerAnnotation();
                replacementAnnotation.setTypeName(ast.newName(singleMemberAnnotation.getTypeName().getFullyQualifiedName()));
                AstUtils.rewriteReplace(
                    compilationUnit, singleMemberAnnotation, replacementAnnotation);
                return;
            }
        }
View Full Code Here

            annotation(declaration, MarkerAnnotation.class);
        if (markerAnnotation != null) {
            AST ast = markerAnnotation.getAST();
            if (value != QualifiedNameValue.DEFAULT_VALUE) {
                SingleMemberAnnotation replacementAnnotation = ast.newSingleMemberAnnotation();
                replacementAnnotation.setTypeName(ast.newName(markerAnnotation.getTypeName().getFullyQualifiedName()));
                Expression memberValueExpression = 
                    value != null? AstUtils.createExpression(
                            ast, value): null;
                replacementAnnotation.setValue(memberValueExpression);
                AstUtils.rewriteReplace(
View Full Code Here

  public void test_Existing_Static_Imports2() {
    AST ast = AST.newAST(AST.JLS4);
    CompilationUnit cu = ast.newCompilationUnit();

    PackageDeclaration packageDeclaration = ast.newPackageDeclaration();
    packageDeclaration.setName(ast.newName("org.kissmda.test.junit"));
    cu.setPackage(packageDeclaration);

    ImportDeclaration importDeclaration = ast.newImportDeclaration();
    importDeclaration
        .setName(ast.newName("org.junit.Assert.assertNotNull"));
View Full Code Here

    packageDeclaration.setName(ast.newName("org.kissmda.test.junit"));
    cu.setPackage(packageDeclaration);

    ImportDeclaration importDeclaration = ast.newImportDeclaration();
    importDeclaration
        .setName(ast.newName("org.junit.Assert.assertNotNull"));
    importDeclaration.setStatic(true);
    cu.imports().add(importDeclaration);

    logger.info(cu.toString());
    new ImportPacker(cu).pack();
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.