Package org.eclipse.dltk.ast

Examples of org.eclipse.dltk.ast.ASTNode


    if (!isInteresting(node)) {
      visitGeneral(node);
      return false;
    }

    ASTNode parent = nodesStack.peek();
    if (isConditional(parent)) {
      getScope().enterInnerBlock((Statement) parent);
    }

    if (node instanceof GlobalStatement) {
View Full Code Here


    }

    try {
      if (context instanceof ISourceModuleContext) {
        ISourceModuleContext typedContext = (ISourceModuleContext) context;
        ASTNode rootNode = typedContext.getRootNode();
        ASTNode localScopeNode = rootNode;
        if (context instanceof MethodContext) {
          localScopeNode = ((MethodContext) context).getMethodNode();
        }
        LocalReferenceDeclSearcher varDecSearcher = new LocalReferenceDeclSearcher(
            typedContext.getSourceModule(), variableReference,
            localScopeNode);
        rootNode.traverse(varDecSearcher);
        PHPModuleDeclaration phpModule = (PHPModuleDeclaration) rootNode;
        List<IGoal> subGoals = new LinkedList<IGoal>();

        List<VarComment> varComments = phpModule.getVarComments();
        List<VarComment> newList = new ArrayList<VarComment>(phpModule
            .getVarComments().size());
        newList.addAll(varComments);
        Collections.sort(newList, new Comparator<VarComment>() {

          public int compare(VarComment o1, VarComment o2) {
            return o2.sourceStart() - o1.sourceStart();
          }
        });
        for (VarComment varComment : newList) {
          if (varComment.sourceStart() > variableReference
              .sourceStart()) {
            continue;
          }
          if (varComment.getVariableReference().getName()
              .equals(variableReference.getName())) {
            List<IGoal> goals = new LinkedList<IGoal>();
            for (TypeReference ref : varComment.getTypeReferences()) {
              goals.add(new ExpressionTypeGoal(context, ref));
            }
            return (IGoal[]) goals.toArray(new IGoal[goals.size()]);
          }
        }

        List<PHPDocBlock> docBlocks = new ArrayList<PHPDocBlock>(
            phpModule.getPhpDocBlocks().size());
        docBlocks.addAll(phpModule.getPhpDocBlocks());
        Collections.sort(docBlocks, new Comparator<PHPDocBlock>() {

          @Override
          public int compare(PHPDocBlock o1, PHPDocBlock o2) {
            return o1.sourceStart() - o1.sourceStart();
          }
        });
        for (PHPDocBlock block : docBlocks) {
          if (block.sourceStart() > variableReference.sourceStart()
              || localScopeNode.sourceStart() > block
                  .sourceStart()) {
            continue;
          }

          for (PHPDocTag tag : block.getTags(PHPDocTagKinds.VAR)) {
            String value = tag.getValue().trim();
            if (value.length() < 5 || value.charAt(0) != '$') {
              continue;
            }
            String[] split = value.split("\\s+"); //$NON-NLS-1$
            if (split.length > 1
                && split[0].equals(variableReference.getName())) {
              List<IGoal> goals = new LinkedList<IGoal>();
              for (String name : split[1].split("\\|")) { //$NON-NLS-1$
                if (name.trim().length() > 0) {
                  goals.add(new ExpressionTypeGoal(context,
                      new TypeReference(
                          tag.sourceStart(), tag
                              .sourceEnd(), name
                              .trim())));
                }
              }
              return (IGoal[]) goals.toArray(new IGoal[goals
                  .size()]);
            }
          }
        }

        Declaration[] decls = varDecSearcher.getDeclarations();
        boolean mergeWithGlobalScope = false;
        for (int i = 0; i < decls.length; ++i) {
          Declaration decl = decls[i];
          // TODO check ArrayCreation and its element type
          if (decl instanceof ArrayDeclaration) {
            ArrayDeclaration arrayDeclaration = (ArrayDeclaration) decl;
            subGoals.add(new ArrayDeclarationGoal(context,
                arrayDeclaration));
          } else if (decl.getNode() instanceof GlobalStatement) {
            mergeWithGlobalScope = true;
          } else {
            ASTNode declNode = decl.getNode();
            if (declNode instanceof ForEachStatement) {
              subGoals.add(new ForeachStatementGoal(context,
                  ((ForEachStatement) declNode)
                      .getExpression()));
            } else {
View Full Code Here

      CallExpression callExpression) {
    String name = callExpression.getName();
    if ("define".equalsIgnoreCase(name)) { //$NON-NLS-1$
      CallArgumentsList args = callExpression.getArgs();
      if (args != null && args.getChilds() != null) {
        ASTNode argument = (ASTNode) args.getChilds().get(0);
        if (argument instanceof Scalar) {
          String constant = ASTUtils.stripQuotes(((Scalar) argument)
              .getValue());
          FieldDeclaration fieldDeclaration = new FieldDeclaration(
              constant, argument.sourceStart(),
              argument.sourceEnd(), callExpression.sourceStart(),
              callExpression.sourceEnd());
          fieldDeclaration.setModifier(Modifiers.AccGlobal
              | Modifiers.AccConstant | Modifiers.AccFinal);
          return fieldDeclaration;
        }
View Full Code Here

  public void doRebuild() {
    List statements = getStatements();
    if (statements != null) {
      Iterator i = statements.iterator();
      while (i.hasNext()) {
        final ASTNode node = (ASTNode) i.next();
        try {
          node.traverse(new ASTVisitor() {
            private Stack<ASTNode> parentStack = new Stack<ASTNode>();

            public boolean visit(MethodDeclaration s)
                throws Exception {
              if (s != node
View Full Code Here

    ExpressionTypeGoal typedGoal = (ExpressionTypeGoal) goal;
    CallExpression expression = (CallExpression) typedGoal.getExpression();

    // just starting to evaluate method, evaluate method receiver first:
    if (state == STATE_INIT) {
      ASTNode receiver = expression.getReceiver();
      if (receiver == null) {
        state = STATE_GOT_RECEIVER;
      } else {
        state = STATE_WAITING_RECEIVER;
        return new ExpressionTypeGoal(goal.getContext(), receiver);
View Full Code Here

      if ((this.matchContainer & PatternLocator.METHOD_CONTAINER) != 0) {
        if (enclosingElement == null)
          enclosingElement = createHandle(method, parent);
        if (encloses(enclosingElement)) {
          for (int i = 0, l = nodes.length; i < l; i++) {
            ASTNode node = nodes[i];
            Integer level = (Integer) nodeSet.matchingNodes
                .removeKey(node);
            if (DLTKCore.DEBUG) {
              System.out
                  .println("TODO: Searching. Add scope support."); //$NON-NLS-1$
View Full Code Here

        if ((this.matchContainer & PatternLocator.CLASS_CONTAINER) != 0) {
          if (enclosingElement == null)
            enclosingElement = createHandle(method, parent);
          if (encloses(enclosingElement)) {
            for (int i = 0, l = nodes.length; i < l; i++) {
              ASTNode node = nodes[i];
              Integer level = (Integer) nodeSet.matchingNodes
                  .removeKey(node);
              if (DLTKCore.DEBUG) {
                System.out
                    .println("TODO: Searching. Add scope support."); //$NON-NLS-1$
View Full Code Here

      }
      if ("define".equalsIgnoreCase(node.getName())) { //$NON-NLS-1$
        // report global constant:
        List<ASTNode> args = node.getArgs().getChilds();
        if (args.size() == 2) {
          ASTNode firstArg = args.get(0);
          ASTNode secondArg = args.get(0);
          if (firstArg instanceof Scalar
              && secondArg instanceof Scalar) {
            Scalar constantName = (Scalar) firstArg;
            Scalar constantValue = (Scalar) secondArg;
            if (this.constantName.equals(stripQuotes(constantName
View Full Code Here

          if (decl instanceof ArrayDeclaration) {
            ArrayDeclaration arrayDeclaration = (ArrayDeclaration) decl;
            subGoals.add(new ArrayDeclarationGoal(context,
                arrayDeclaration));
          } else {
            ASTNode declNode = decl.getNode();
            if (declNode instanceof ForEachStatement) {
              subGoals.add(new ForeachStatementGoal(context,
                  ((ForEachStatement) declNode)
                      .getExpression()));
            } else {
View Full Code Here

    return null;
  }

  private GoalEvaluator createExpressionEvaluator(ExpressionTypeGoal exprGoal) {

    ASTNode expression = exprGoal.getExpression();
    Class<?> expressionClass = expression.getClass();

    if (expressionClass == InterfaceDeclaration.class
        || expressionClass == ClassDeclaration.class
        || expressionClass == TraitDeclaration.class) {
      return new PHPClassEvaluator(exprGoal, (TypeDeclaration) expression);
View Full Code Here

TOP

Related Classes of org.eclipse.dltk.ast.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.