Package org.eclipse.jdt.core.dom

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


                    return false;
                }
            }
            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) {
View Full Code Here


      IProgressMonitor monitor, int defaultType, boolean first)
  {
    log("In processExpression with expr=" + e);
   
    monitor.subTask("Processing " + e.toString());
    SimpleName nextName = CallerFinder.SlicingUtils.getVariable(e);
    if(nextName != null) {
      /**
       * Follow a simple assignment.
       * */
      HistoryDefinitionLocation actualDL = new HistoryDefinitionLocation(
          nextName/*.getParent()*/.toString(),
          resource,
          cu.getLineNumber(nextName.getStartPosition()),
          nextName,
          parent, defaultType);
      //showMessage("Type " + nextName.getParent().getClass());         
     
      // marks actualDL as recursive if necessary
      if(registerExpansion(actualDL)) {
        processDecl(nextName, cu, resource, actualDL, stack, monitor);
      }
    } else
    if(e instanceof MethodInvocation) {
      /**
       * Go back through a method invocation.
       * */
      MethodInvocation mi = (MethodInvocation) e;
      SimpleName methodName = mi.getName();
      log("Going back through callee " + methodName.toString());
      HistoryDefinitionLocation callDL;
      if(!first){
      callDL= new HistoryDefinitionLocation(
          mi.toString(),
          resource,
          cu.getLineNumber(mi.getStartPosition()),
          mi,
          parent, HistoryDefinitionLocation.CALL);
      }
      else{
        callDL=parent;
      }
     
      if(registerExpansion(callDL)) {
        Collection/*<MethodDeclarationUnitPair>*/ callees = CallerFinder.findCallees(monitor, methodName.toString(), null, false);
        if(callees.isEmpty()) {
          if(SinkView.isDerivationName(methodName.getFullyQualifiedName()))
          {
              HistoryDefinitionLocation dl = new HistoryDefinitionLocation(
                  mi.getExpression().toString(),
                  resource,
                  cu.getLineNumber(mi.getStartPosition()),
                  mi.getExpression(), callDL, HistoryDefinitionLocation.DERIVATION);
              if(registerExpansion(dl)) {
                Expression expr = mi.getExpression();
                if(expr != null) {
                  // Recurse on the returned expression
                  processExpression(dl, expr, cu, resource, stack, monitor, HistoryDefinitionLocation.DERIVATION,false);
                 
                }
              }
          }
          else{
          logError("No suitable callees for " + methodName + " in " + resource + " found");
          System.out.println("No suitable callees for " + methodName + " in " + resource + " found");
          }
        } else
        for (Iterator iter = callees.iterator(); iter.hasNext();) {
          Utils.MethodDeclarationUnitPair element
                            = (Utils.MethodDeclarationUnitPair) iter.next();
          MethodDeclaration methodDeclaration = element.getMethod();
          CompilationUnit nextCU         = element.getCompilationUnit();
          IResource nextResource         = element.getResource();       
       
          if(methodDeclaration  != null){
            if(!LapsePlugin.FOLLOW_INTO_FUNCTIONS) {
              /*HistoryDefinitionLocation dl = */new HistoryDefinitionLocation(
                  "Method " + methodDeclaration.getName().getFullyQualifiedName(),
                  nextResource,
                  nextCU.getLineNumber(e.getStartPosition()),
                  methodDeclaration, callDL, HistoryDefinitionLocation.RETURN);
            } else {
              Collection/*<ReturnStatement>*/ returns = CallerFinder.findReturns(monitor, methodDeclaration, null);
              for (Iterator iter2 = returns.iterator(); iter2.hasNext();) {
                ReturnStatement returnStmt = (ReturnStatement) iter2.next();
             
                HistoryDefinitionLocation dl = new HistoryDefinitionLocation(
                    returnStmt.toString(),
                    nextResource,
                    nextCU.getLineNumber(returnStmt.getStartPosition()),
                    returnStmt, callDL, HistoryDefinitionLocation.RETURN);
                if(registerExpansion(dl)) {
                  Expression expr = returnStmt.getExpression();
                  if(expr != null) {
                    // Recurse on the returned expression
                    stack.addLast(mi);
                    processExpression(dl, expr, nextCU, nextResource, stack, monitor, HistoryDefinitionLocation.COPY,false);
                    stack.removeLast();
                  }
                }
              }
            }
          }
          else{
            //check if it is a derivtion expression
            if(SinkView.isDerivationName(methodName.getFullyQualifiedName()))
            {
       
                    processExpression(callDL, mi.getExpression(), cu, resource, stack, monitor, HistoryDefinitionLocation.DERIVATION,false);
               
                break;
View Full Code Here

                    return false;
                }
            }
            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) {
View Full Code Here

      fCurrentMethod = node;
      return true;
    }
   
    public boolean visit(SingleVariableDeclaration node) {
      SimpleName name = node.getName();
      boolean isFinal = Modifier.isFinal(node.getModifiers());
      if(isFinal) {
        info.setFinal(name);
      }
     
View Full Code Here

    String[] parts = classToImport.split("\\."); //$NON-NLS-1$

    Name name = null;

    for (int i = 0; i < parts.length; i++) {
      SimpleName simpleName = ast.newSimpleName(parts[i]);
      if (i == 0) {
        name = simpleName;
      } else {
        name = ast.newQualifiedName(name, simpleName);
      }
View Full Code Here

  public void convertMethodToConstructor(String className, String methodName, String[] signature) {
    try {
      TypeDeclaration typeDeclaration = compilationUnitCache.getTypeDeclaration(className);
      MethodDeclaration methodDeclaration = compilationUnitCache.getMethodDeclaration(className, methodName, signature);
      methodDeclaration.setConstructor(true);
      SimpleName newMethodName = methodDeclaration.getAST().newSimpleName(typeDeclaration.getName().toString());
      methodDeclaration.setName(newMethodName);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
View Full Code Here

    String[] parts = targetClass.split("\\."); //$NON-NLS-1$

    Type type = null;

    for (int i = 0; i < parts.length; i++) {
      SimpleName name = ast.newSimpleName(parts[i]);
      if (i == 0) {
        type = ast.newSimpleType(name);
      } else {
        type = ast.newQualifiedType(type, name);
      }
View Full Code Here

  }

  @Override
  public ImportDeclaration newImportDeclaration(AST ast, Optional<String> name) {
    Name qualifier = ast.newName(this.name);
    SimpleName theName = ast.newSimpleName(name.or("*"));
    QualifiedName qualifiedName = ast.newQualifiedName(qualifier, theName);

    ImportDeclaration declaration = ast.newImportDeclaration();
    declaration.setName(qualifiedName);
    return declaration;
View Full Code Here

    this.block = block;
  }

  public void throwNew(Class<? extends Exception> exceptionClass) {
    String simpleName = exceptionClass.getSimpleName();
    SimpleName exName = ast.newSimpleName(simpleName);

    SimpleType exType = ast.newSimpleType(exName);
    ClassInstanceCreation newExType = ast.newClassInstanceCreation();
    newExType.setType(exType);
View Full Code Here

    return res;
  }

  @Override
  public Type toType(AST ast) {
    SimpleName typeName = ast.newSimpleName(name);
    return ast.newSimpleType(typeName);
  }
View Full Code Here

TOP

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

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.