Examples of VariableDeclaration


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

          }
          if (AstNodeUtils.isVariable(argument)) {
            ASTNode lastAssignment =
                ExecutionFlowUtils.getLastAssignment(flowDescription, argument);
            if (lastAssignment instanceof VariableDeclaration) {
              VariableDeclaration variableDeclaration = (VariableDeclaration) lastAssignment;
              argument = variableDeclaration.getInitializer();
              continue;
            }
          }
          if (ensure) {
            return (ClassInstanceCreation) getEditor().replaceExpression(
View Full Code Here

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

            }
            return true;
        } else if (arg instanceof SimpleName) {
            SimpleName name = (SimpleName) arg;
            // System.err.println("TODO -> Name: " + name);
            VariableDeclaration varDecl = LapseView.name2decl(name, unit, resource);
            if (varDecl instanceof SingleVariableDeclaration) {
                SingleVariableDeclaration decl = (SingleVariableDeclaration) varDecl;
                if (decl.getInitializer() != null && decl.getInitializer() instanceof StringLiteral) {
                    StringLiteral l = (StringLiteral) decl.getInitializer();
                    return true;
View Full Code Here

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

  }

  static VariableDeclaration name2decl(SimpleName sn, CompilationUnit cu, IResource resource){
    DeclarationInfoManager.DeclarationInfo info = DeclarationInfoManager.retrieveDeclarationInfo(cu);
    //System.out.println(info);
    VariableDeclaration decl = info.getVariableDeclaration(sn);
    if(decl == null) {
      logError("decl == null for " + sn)
    }
    return decl;
  }
View Full Code Here

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

   
  private void processDecl(SimpleName name, CompilationUnit cu, IResource resource,
      HistoryDefinitionLocation parent, LinkedList<MethodInvocation> stack,
      IProgressMonitor monitor)
  {   
    VariableDeclaration decl = name2decl(name, cu, resource);
//    if(TRACE) System.out.print('.');
    if(monitor.isCanceled()) {
      // check if the search has been cancelled
      return;
    }
    //monitor.setTaskName("Processing " + name + " in " + resource.getName/*getFullPath*/());
    monitor.subTask("Processing " + name + " in " + resource.getName/*getFullPath*/());
       
    if(decl == null) {
      logError(
          "decl: " + decl + " on line " + (decl == null ? DefinitionLocation.INVALID_SOURCE_LINE : fRoot.getLineNumber(decl.getStartPosition())) +
          " and name: " + name + "(" + name.hashCode() + ") on line " + fRoot.getLineNumber(name.getStartPosition()));
     
      // the case of no declaration found -- add a question mark
      /*HistoryDefinitionLocation dl = */new HistoryDefinitionLocation(
          name.toString(),
          null,  // this will be ignored
          DefinitionLocation.INVALID_SOURCE_LINE,
          name, parent, HistoryDefinitionLocation.UNDEFINED);
      //System.out.println("Case 1");
    } else
    if(decl.getParent() instanceof MethodDeclaration){
      // the case of a parameter -- add the actuals and recurse
      //showMessage(decl.toString() + " is a parameter of " + parent.getClass());
      MethodDeclaration methodDecl = (MethodDeclaration) decl.getParent();
      IMethod method = new MethodFinder((IFile) resource).convertMethodDecl2IMethod(methodDecl);
      if(method == null) {
        JavaPlugin.logErrorMessage("Internal error: No method found for " + methodDecl);
        return;
      }

      HistoryDefinitionLocation paramDL = new HistoryDefinitionLocation(
          decl.toString(),
          resource,
          cu.getLineNumber(decl.getStartPosition()),
          decl, parent, HistoryDefinitionLocation.FORMAL_PARAMETER);
      if(!registerExpansion(paramDL)) {
        // recursion detected here
        return;
      }

      Expression onlyCall = (Expression) (stack.isEmpty() ? null : stack.getLast());
      log("Looking for calls from " + onlyCall);
      Collection/*<ExpressionUnitPair>*/ c = CallerFinder.getActualsForFormal(method, name, onlyCall, monitor, null);
      if(c.isEmpty()){
        logError(
            "No suitable actual arguments for formal argument " +
            name + " of " + method.getElementName() + " at " +
            resource.getName() + " found");
      } else
      for (Iterator iter = c.iterator(); iter.hasNext();) {
        Utils.ExpressionUnitPair eup = (Utils.ExpressionUnitPair) iter.next();
        Expression     e        = eup.getExpression();
        CompilationUnit nextCU     = eup.getCompilationUnit();
        IResource     nextResource = eup.getResource();
               
        processExpression(paramDL, e, nextCU, nextResource, stack, monitor, HistoryDefinitionLocation.CALL_ARG,false);
      }
      //System.out.println("Case 2");
    } else {
      /**
       * The case of a declaration -- look at the right hand side.
       * */
      Object obj = (decl.getParent() instanceof VariableDeclaration) ?
          decl.getParent() :
          decl;         
      String desc = obj.toString();
      int type = (decl.getParent() instanceof FieldDeclaration) ?
            HistoryDefinitionLocation.FIELD :
            HistoryDefinitionLocation.DECLARATION;
      // the case of a regilar declaration being found
      HistoryDefinitionLocation dl = new HistoryDefinitionLocation(
          desc,
          resource,
          cu.getLineNumber(decl.getStartPosition()),
          decl, parent, type);
      Expression e = decl.getInitializer();
     
      if(e != null) {
        // TODO: add processing of the RHS of the declaration
        processExpression(dl, e, cu, resource, stack, monitor, HistoryDefinitionLocation.COPY,false);
      }
View Full Code Here

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

            }
            return true;
        } else if (arg instanceof SimpleName) {
            SimpleName name = (SimpleName) arg;
            // System.err.println("TODO -> Name: " + name);
            VariableDeclaration varDecl = LapseView.name2decl(name, unit, resource);
            if (varDecl instanceof SingleVariableDeclaration) {
                SingleVariableDeclaration decl = (SingleVariableDeclaration) varDecl;
                if (decl.getInitializer() != null && decl.getInitializer() instanceof StringLiteral) {
                    StringLiteral l = (StringLiteral) decl.getInitializer();
                    return true;
View Full Code Here

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

      }else {
        key = "GLOBAL" + name.getFullyQualifiedName()
      }
     
      logError("Trying " + key);
      VariableDeclaration var = getVariableDeclaration(key);
      if(var == null && node != null) {
        key = "GLOBAL" + name.getFullyQualifiedName();
        log("Trying " + key);
        var = getVariableDeclaration(key);
      }
View Full Code Here

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

      List<VariableDeclaration> astParameters = ((MethodDeclaration) methods.get(0).getInternal()).parameters();

      method.parameters().clear();
      for (VariableDeclaration declaration : astParameters)
      {
         VariableDeclaration copy = (VariableDeclaration) ASTNode.copySubtree(method.getAST(), declaration);
         method.parameters().add(copy);
      }

      return this;
   }
View Full Code Here

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

      List<VariableDeclaration> astParameters = ((MethodDeclaration) methods.get(0).getInternal()).parameters();

      method.parameters().clear();
      for (VariableDeclaration declaration : astParameters)
      {
         VariableDeclaration copy = (VariableDeclaration) ASTNode.copySubtree(method.getAST(), declaration);
         method.parameters().add(copy);
      }

      return this;
   }
View Full Code Here

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

      List<VariableDeclaration> astParameters = ((MethodDeclaration) methods.get(0).getInternal()).parameters();

      ParameterSource<O> param = null;
      for (VariableDeclaration declaration : astParameters)
      {
         VariableDeclaration copy = (VariableDeclaration) ASTNode.copySubtree(method.getAST(), declaration);
         method.parameters().add(copy);
         param = new ParameterImpl<O>(parent, copy);
      }
      return param;
   }
View Full Code Here

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

      List<VariableDeclaration> astParameters = ((MethodDeclaration) methods.get(0).getInternal()).parameters();

      method.parameters().clear();
      for (VariableDeclaration declaration : astParameters)
      {
         VariableDeclaration copy = (VariableDeclaration) ASTNode.copySubtree(method.getAST(), declaration);
         method.parameters().add(copy);
      }

      return this;
   }
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.