Package org.eclipse.jdt.core.dom

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


        .getPackageFragments();
    List <TypeDeclaration> expectedTypeList = new ArrayList<TypeDeclaration>();
    for(IPackageFragment packageFragment : packageFragments){
      ICompilationUnit [] iUnits = packageFragment.getCompilationUnits();     
      for(ICompilationUnit iUnit : iUnits){
        CompilationUnit unit = Visitor.parse(iUnit);
        Visitor cVisitor = new Visitor();
        unit.accept(cVisitor);
        expectedTypeList.addAll(cVisitor.getClasses());
      }
    }
    List<TypeDeclaration> actualTypeList = JdtManipulator
        .getTypeDeclarations(javaProject);
View Full Code Here


  @Test
  public void testGetTypeDeclarationIPackageFragment() throws CoreException {
    List <TypeDeclaration> expectedTypeList = new ArrayList<TypeDeclaration>();
    ICompilationUnit [] iUnits = packageFragment.getCompilationUnits();     
    for(ICompilationUnit iUnit : iUnits){
      CompilationUnit unit = Visitor.parse(iUnit);
      Visitor cVisitor = new Visitor();
      unit.accept(cVisitor);
      expectedTypeList.addAll(cVisitor.getClasses());
    }
   
    List<TypeDeclaration> actualTypeList = JdtManipulator
        .getTypeDeclarations(packageFragment);
View Full Code Here

  @Test
  public void testGetMethodDeclarationIPackageFragment() throws CoreException {
    List <MethodDeclaration> expectedMethodList = new ArrayList<MethodDeclaration>();
    ICompilationUnit [] iUnits = packageFragment.getCompilationUnits();     
    for(ICompilationUnit iUnit : iUnits){
      CompilationUnit unit = Visitor.parse(iUnit);
      Visitor visitor = new Visitor();
      unit.accept(visitor);
      List <TypeDeclaration> typeList = new ArrayList<TypeDeclaration>(visitor.getClasses());
      for(TypeDeclaration typeDeclaration: typeList){
        expectedMethodList.addAll(Arrays.asList(typeDeclaration.getMethods()));
      }
    }
View Full Code Here

  }

  private MethodDeclaration getMethodDeclaration() {
    String name = invocation.getName().getIdentifier();
    ASTNode root = invocation.getRoot();
    CompilationUnit unit = (CompilationUnit) root;
    TypeDeclaration typeDec = (TypeDeclaration) unit.types().get(0);
    MethodDeclaration[] methods = typeDec.getMethods();
    MethodDeclaration mi = null;
con:    for (MethodDeclaration method : methods) {
      String methodName = method.getName().getIdentifier();
      if (name.equals(methodName)) {
View Full Code Here

            }
          });
          WidgetAdapter beanAdapter = ExtensionRegistry.createWidgetAdapter(bean);
          ASTParser parser = ASTParser.newParser(AST.JLS3);
          parser.setSource(unit);
          CompilationUnit cunit = (CompilationUnit) parser.createAST(null);
          parseEventListener(cunit, beanAdapter);
          initDesignedWidget(cunit, bean);
          parsePropertyValue(lnf, cunit, beanAdapter);
          beanAdapter.clearDirty();
          return beanAdapter;
View Full Code Here

  public static ImportRewrite createImportRewrite(ICompilationUnit unit) {
    ASTParser parser = ASTParser.newParser(AST.JLS3);
    parser.setSource(unit);
    parser.setResolveBindings(false);
    parser.setFocalPosition(0);
    CompilationUnit cu = (CompilationUnit) parser.createAST(null);
    return CodeStyleConfiguration.createImportRewrite(cu, true);
  }
View Full Code Here

      for (String nonfield : nonExistingFields) {
        removedNames.remove(nonfield);
      }
      ASTParser astparser = ASTParser.newParser(AST.JLS3);
      astparser.setSource(unit);
      CompilationUnit cunit = (CompilationUnit) astparser.createAST(null);
      List<String> getmethods = new ArrayList<String>();
      for (int i = 0; i < removedNames.size(); i++) {
        String removed_name = removedNames.get(i);
        String getmethod = NamespaceUtil.getGetMethodName(cunit, removed_name);
        getmethods.add(getmethod);
View Full Code Here

      ICompilationUnit icunit = type.getCompilationUnit();
      String source = icunit.getBuffer().getContents();
      Document document = new Document(source);
      ASTParser parser = ASTParser.newParser(AST.JLS3);
      parser.setSource(icunit);
      CompilationUnit cunit = (CompilationUnit) parser.createAST(null);
      cunit.recordModifications();
      AST ast = cunit.getAST();
      TypeDeclaration typeDec = (TypeDeclaration) cunit.types().get(0);
      List list = typeDec.superInterfaceTypes();
      Name name = ast.newName(cName);
      Type interfaceType = ast.newSimpleType(name);
      list.add(interfaceType);
      TextEdit edits = cunit.rewrite(document, icunit.getJavaProject()
          .getOptions(true));
      edits.apply(document);
      String newSource = document.get();
      icunit.getBuffer().setContents(newSource);
    } catch (Exception e) {
View Full Code Here

*/
public class EclipseTACNewObjectTest {

  @Test
  public void testOuter() throws Exception {
    CompilationUnit cu = EclipseTACSimpleTestDriver.parseCode("MainClass", MAIN);
    MethodDeclaration m = EclipseTACSimpleTestDriver.getFirstMethod(cu);
    EclipseTAC tac = new EclipseTAC(m.resolveBinding());
    ClassInstanceCreation instance = (ClassInstanceCreation) EclipseTACSimpleTestDriver.getLastStatementReturn(m).getExpression();
    TACInstruction instr = tac.instruction(instance);
    Assert.assertTrue(instr != null);
View Full Code Here

    "    }" +
    "}";
 
  @Test
  public void testTopLevel() throws Exception {
    CompilationUnit cu = EclipseTACSimpleTestDriver.parseCode("TopLevel", TOP_LEVEL);
    MethodDeclaration m = EclipseTACSimpleTestDriver.getFirstMethod(cu);
    EclipseTAC tac = new EclipseTAC(m.resolveBinding());
    ClassInstanceCreation instance = (ClassInstanceCreation) EclipseTACSimpleTestDriver.getLastStatementReturn(m).getExpression();
    TACInstruction instr = tac.instruction(instance);
    Assert.assertTrue(instr != null);
View Full Code Here

TOP

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

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.