Package org.eclipse.jdt.core.dom

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


        catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        parser.setSource(writer.toString().toCharArray());
        ASTNode ast = parser.createAST(new NullProgressMonitor());
        ast.accept(new ASTVisitor() {

            private Map<String, String> _imports = new HashMap<String, String>();
           
            @Override
            public void endVisit(TypeDeclaration node) {
View Full Code Here


            WGUtils.inToOut(reader, writer, 1024);
        }
        catch (IOException e) {
        }
        parser.setSource(writer.toString().toCharArray());
        ASTNode ast = parser.createAST(new NullProgressMonitor());
        ast.accept(new ASTVisitor() {
            private Map<String, String> _imports = new HashMap<String, String>();

            @Override
            public void endVisit(ImportDeclaration node) {
                String packageName = node.getName().toString();
View Full Code Here

        catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        parser.setSource(writer.toString().toCharArray());
        ASTNode ast = parser.createAST(new NullProgressMonitor());
        ast.accept(new ASTVisitor() {
           
            private Map<String, String> _imports = new HashMap<String, String>();

            @Override
            public void endVisit(ImportDeclaration node) {
View Full Code Here

            CompilationUnit unit = (CompilationUnit)m_parser.createAST(null);
           
            // add all methods from output tree to class under construction
            TypeDeclaration typedecl = (TypeDeclaration)unit.types().get(0);
            for (Iterator iter = typedecl.bodyDeclarations().iterator(); iter.hasNext();) {
                ASTNode node = (ASTNode)iter.next();
                if (node instanceof MethodDeclaration) {
                    holder.addMethod((MethodDeclaration)node);
                }
            }
View Full Code Here

    {
      Document recoveredDocument = new Document();
      CompilationUnit unit = getRecoveredAST(document, offset, recoveredDocument);
      initContext(offset, importRw, unit);

      ASTNode node = NodeFinder.perform(unit, offset, 1);
      AST ast = unit.getAST();
      ASTRewrite rewrite = ASTRewrite.create(ast);

      CodeGenerationSettings settings = getCodeGenSettings();
View Full Code Here

      String placeHolder= CodeGeneration.getMethodBodyContent(cunit,
          declaringType.getName(), methodToOverride.getName(), false, bodyStatement, delimiter);

      if (placeHolder != null)
      {
        ASTNode todoNode = rewrite.createStringPlaceholder(placeHolder, ASTNode.RETURN_STATEMENT);
        stub.getBody().statements().clear();
        stub.getBody().statements().add(todoNode);
      }
    }
  }
View Full Code Here

    {
      astRoot = ASTUtil.getAstOrParse(cunit, mon);

      if( astRoot != null )
      {
        ASTNode node = NodeFinder.perform(astRoot, context.getInvocationOffset(), 1);

        mockType = MockUtil.getMockType(node);
        paramType = findMockedTypeFromNode(node);
      }
    }
View Full Code Here

    ITypeBinding binding = node.resolveBinding();

    if ( MockUtil.isMockUpType(binding.getSuperclass()) ) // new MockUp< type >
    {
      ITypeBinding typePar = ASTUtil.getFirstTypeParameter(node);
      ASTNode parent = node.getParent();

      if (parent instanceof ClassInstanceCreation && typePar.isInterface()  ) // creating interface mock
      {
        ClassInstanceCreation creation = (ClassInstanceCreation) parent;
View Full Code Here

    return true;
  }

  public void visitMockUpCreation(final ClassInstanceCreation creation)
  {
    ASTNode gparent = creation.getParent();

    Type typeNode = creation.getType();
    boolean invokesGetInst = false;

    if (gparent instanceof MethodInvocation) // method invocation follows
    {
      MethodInvocation inv = (MethodInvocation) gparent;
      IMethodBinding meth = inv.resolveMethodBinding();

      if ( MockUtil.GET_INST.equals(meth.getName()))
      {
        invokesGetInst = true;
        if (gparent.getParent() instanceof ExpressionStatement)
        {
          addMarker(inv.getName(), "Returned mock instance is not being used.", false);
        }
      }
    }
View Full Code Here

  }

  @SuppressWarnings("unchecked")
  public static <T extends ASTNode> T findAncestor(final ASTNode node, final Class<T> clazz)
  {
    ASTNode parent = node.getParent();
    while( parent != null )
    {
      if( parent.getClass() == clazz )
      {
        break;
      }
      parent = parent.getParent();
    }
    return (T) parent;
  }
View Full Code Here

TOP

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

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.