Package org.eclipse.dltk.ast.declarations

Examples of org.eclipse.dltk.ast.declarations.MethodDeclaration


    }
    try {
      ISourceModule sourceModule = method.getSourceModule();
      ModuleDeclaration moduleDeclaration = SourceParserUtil
          .getModuleDeclaration(sourceModule);
      MethodDeclaration methodDeclaration = PHPModelUtils
          .getNodeByMethod(moduleDeclaration, method);
      if (methodDeclaration instanceof IPHPDocAwareDeclaration) {
        return ((IPHPDocAwareDeclaration) methodDeclaration)
            .getPHPDoc();
      }
View Full Code Here


      getMethodFields(method, prefix, exactName, elements, processedVars);

      // collect global variables
      ModuleDeclaration rootNode = SourceParserUtil
          .getModuleDeclaration(method.getSourceModule());
      MethodDeclaration methodDeclaration = PHPModelUtils
          .getNodeByMethod(rootNode, method);
      if (methodDeclaration != null) {
        methodDeclaration.traverse(new ASTVisitor() {
          public boolean visit(Statement s) throws Exception {
            if (s instanceof GlobalStatement) {
              GlobalStatement globalStatement = (GlobalStatement) s;
              for (Expression e : globalStatement.getVariables()) {
                if (e instanceof VariableReference) {
View Full Code Here

  public IEvaluatedType[] getFunctionReturnType(IMethod functionElement) {

    ISourceModule sourceModule = functionElement.getSourceModule();
    ModuleDeclaration sourceModuleDeclaration = SourceParserUtil
        .getModuleDeclaration(sourceModule);
    MethodDeclaration functionDeclaration = null;
    try {
      functionDeclaration = PHPModelUtils.getNodeByMethod(
          sourceModuleDeclaration, functionElement);

    } catch (ModelException e) {
      if (DLTKCore.DEBUG) {
        e.printStackTrace();
      }
    }
    // FileContext fileContext = new FileContext(sourceModule,
    // sourceModuleDeclaration);

    final List<IEvaluatedType> evaluated = new LinkedList<IEvaluatedType>();
    final List<Expression> returnExpressions = new LinkedList<Expression>();
    final List<Expression> yieldExpressions = new LinkedList<Expression>();

    if (functionDeclaration != null) {

      ASTVisitor visitor = new ASTVisitor() {
        public boolean visitGeneral(ASTNode node) throws Exception {
          if (node instanceof ReturnStatement) {
            ReturnStatement statement = (ReturnStatement) node;
            Expression expr = statement.getExpr();
            if (expr == null) {
              evaluated.add(PHPSimpleTypes.VOID);
            } else {
              returnExpressions.add(expr);
            }
          } else if (node instanceof YieldExpression) {
            YieldExpression statement = (YieldExpression) node;
            Expression expr = statement.getExpr();
            yieldExpressions.add(expr);
          }
          return super.visitGeneral(node);
        }
      };

      try {
        functionDeclaration.traverse(visitor);
      } catch (Exception e) {
        if (DLTKCore.DEBUG) {
          e.printStackTrace();
        }
      }
View Full Code Here

      }
      // checking specific case for "return $this;" statement
      if ("this".equalsIgnoreCase(scalar.getValue())) { //$NON-NLS-1$
        IContext context = goal.getContext();
        if (context instanceof MethodContext) {
          MethodDeclaration methodNode = ((MethodContext) context)
              .getMethodNode();
          if (methodNode != null) {
            String declaringTypeName = methodNode
                .getDeclaringTypeName();
            if (declaringTypeName != null) {
              IEvaluatedType resolved = PHPSimpleTypes
                  .fromString(declaringTypeName);
              if (resolved == null) {
View Full Code Here

        final IType currentNamespace = PHPModelUtils
            .getCurrentNamespace(sourceModule,
                rootNode.sourceStart());
        final ModuleDeclaration moduleDeclaration = SourceParserUtil
            .getModuleDeclaration(sourceModule);
        final MethodDeclaration methodDecl = methodContext
            .getMethodNode();

        // Look for parent class types:
        final List<IEvaluatedType> types = new LinkedList<IEvaluatedType>();
        try {
View Full Code Here

      ISourceModule sourceModule = method.getSourceModule();
      ModuleDeclaration module = SourceParserUtil
          .getModuleDeclaration(sourceModule);

      MethodDeclaration decl = null;
      try {
        decl = PHPModelUtils.getNodeByMethod(module, method);
      } catch (ModelException e) {
        if (DLTKCore.DEBUG) {
          e.printStackTrace();
        }
      }
      // final boolean found[] = new boolean[1];
      if (decl != null) {
        final IContext innerContext = ASTUtils.findContext(
            sourceModule, module, decl);
        if (innerContext instanceof MethodContext) {
          MethodContext mc = (MethodContext) innerContext;
          mc.setCurrentType(mat.types[i]);
        }
        if (goal.getContext() instanceof IModelCacheContext
            && innerContext instanceof IModelCacheContext) {
          ((IModelCacheContext) innerContext)
              .setCache(((IModelCacheContext) goal.getContext())
                  .getCache());
        }

        ASTVisitor visitor = new ASTVisitor() {
          public boolean visitGeneral(ASTNode node) throws Exception {
            if (node instanceof ReturnStatement) {
              ReturnStatement statement = (ReturnStatement) node;
              Expression expr = statement.getExpr();
              if (expr == null) {
                evaluated.add(PHPSimpleTypes.VOID);
              } else {
                subGoals.add(new ExpressionTypeGoal(
                    innerContext, expr));
              }
            } else if (node instanceof YieldExpression) {
              YieldExpression statement = (YieldExpression) node;
              Expression expr = statement.getExpr();
              if (expr == null) {
                yieldEvaluated.add(PHPSimpleTypes.NULL);
              } else {
                final ExpressionTypeGoal yg = new ExpressionTypeGoal(
                    innerContext, expr);
                subGoals.add(yg);
                yieldGoals.add(yg);
              }
            }
            return super.visitGeneral(node);
          }
        };

        try {
          decl.traverse(visitor);
        } catch (Exception e) {
          if (DLTKCore.DEBUG) {
            e.printStackTrace();
          }
        }
View Full Code Here

TOP

Related Classes of org.eclipse.dltk.ast.declarations.MethodDeclaration

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.