Package org.eclipse.jdt.core.dom

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


        return checkAndReturnAssists(varDecl, varDecl.getName(), context);
      }
      else if (decl instanceof MethodDeclaration) {
        MethodDeclaration methodDecl = (MethodDeclaration) decl;
        Block body = methodDecl.getBody();

        // if coveringNode is not in the method body, show assists
        if (getSurroundingBlock(coveringNode) != body) {
          return checkAndReturnAssists(methodDecl, methodDecl.getName(), context);
        }
View Full Code Here


                  Type varDeclType = varDeclStmt.getType();
                  if (varDeclType instanceof SimpleType) {
                    SimpleType sType = (SimpleType) varDeclType;
                    parentNode = parentNode.getParent();
                    if (parentNode instanceof Block) {
                      Block block = (Block) parentNode;

                      try {
                        if (viewer.getDocument().getChar(block.getStartPosition()) != '{') {
                          parentNode = parentNode.getParent();
                          if (parentNode instanceof MethodDeclaration) {
                            MethodDeclaration methodDecl = (MethodDeclaration) parentNode;
                            return getProposals(methodDecl, sType.getName()
                                .getFullyQualifiedName(), invocationOffset,
                                varDeclStmt, javaContext);
                          }
                        }
                      }
                      catch (BadLocationException e) {
                        StatusHandler.log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, e
                            .getMessage(), e));
                      }
                    }
                  }
                }
              }

              // cursor is at the start of a param type
              else if (parentNode instanceof SimpleType) {
                SimpleType sType = (SimpleType) parentNode;
                parentNode = sType.getParent();
                if (parentNode instanceof SingleVariableDeclaration) {
                  SingleVariableDeclaration varDecl = (SingleVariableDeclaration) parentNode;
                  parentNode = varDecl.getParent();
                  if (parentNode instanceof MethodDeclaration) {
                    MethodDeclaration methodDecl = (MethodDeclaration) parentNode;
                    return getProposals(methodDecl, sType.getName().getFullyQualifiedName(),
                        invocationOffset, sType, javaContext);
                  }
                }
              }
            }

            // param at the end of a method param list
            // [method(param,
            // w^)]
            else if (node instanceof Block) {
              Block block = (Block) node;
              ASTNode parentNode = block.getParent();
              if (parentNode instanceof MethodDeclaration) {
                MethodDeclaration methodDecl = (MethodDeclaration) parentNode;
                try {
                  String blockContent = viewer.getDocument().get(block.getStartPosition(),
                      block.getLength());
                  if (blockContent.startsWith(",")) {
                    blockContent = blockContent.substring(1);

                    boolean isAnnotation = false;
                    while (blockContent.length() > 0) {
View Full Code Here

    fooParser.setKind(ASTParser.K_STATEMENTS);
    String mockMethodInvocationCode = getNewMethodName() + "(" + getNewMethodParameters() + ");";
    fooParser.setSource(mockMethodInvocationCode.toCharArray());
    fooParser.setResolveBindings(true);
    ASTNode parsedAstNode = fooParser.createAST(null);
    Block codeBlock = (Block) parsedAstNode;
    ExpressionStatement methodInvocationExpressionStatement = (ExpressionStatement) codeBlock.statements().get(0);
    return methodInvocationExpressionStatement.getExpression();
  }
View Full Code Here

TOP

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

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.