Package org.eclipse.dltk.ti.goals

Examples of org.eclipse.dltk.ti.goals.ExpressionTypeGoal


  private static final PHPTypeInferencer TYPE_INFERENCER = new PHPTypeInferencer();

  public static IType[] getTypes(ASTNode expression, ISourceModule sourceModule) {
    IContext context = ASTUtils.findContext(sourceModule, SourceParserUtil.getModuleDeclaration(sourceModule), expression.sourceStart());
    if (context != null) {
      IType[] types = getTypes(new PHPTypeInferencer().evaluateType(new ExpressionTypeGoal(context, expression)), context, expression.sourceStart());
      if (types != null) {
        return types;
      }
    }
View Full Code Here


      Assert.assertNotNull("Method call " + criteriaFunction
          + "() in code: " + code, searcher.getResult());
      Assert.assertNotNull("Can't find context for " + criteriaFunction
          + "() in code: " + code, searcher.getContext());

      final ExpressionTypeGoal goal = new ExpressionTypeGoal(searcher
          .getContext(), searcher.getResult());
      perfMonitor.execute("PerformanceTests.testCodeAssist" + "_"
          + fileName, new Operation() {
        public void run() throws Exception {
          if ("phpdocGoals".equals(pruner)) {
View Full Code Here

      Assert.assertNotNull("Method call " + criteriaFunction
          + "() in code: " + code, searcher.getResult());
      Assert.assertNotNull("Can't find context for " + criteriaFunction
          + "() in code: " + code, searcher.getContext());

      ExpressionTypeGoal goal = new ExpressionTypeGoal(
          searcher.getContext(), searcher.getResult());

      if ("phpdocGoals".equals(pruner)) {
        return typeInferenceEngine.evaluateTypeHeavy(goal,
            ENGINE_TIMEOUT);
View Full Code Here

  public static IEvaluatedType resolveExpression(
      IPHPTypeInferencer inferencer, ISourceModule sourceModule,
      ModuleDeclaration moduleDeclaration, IContext context,
      ASTNode expression) {
    if (context != null) {
      return inferencer.evaluateType(new ExpressionTypeGoal(context,
          expression));
    }
    return UnknownType.INSTANCE;
  }
View Full Code Here

  protected IEvaluatedType getType(SourceRange sourceRange, IContext context,
      ASTNode node) {
    IPHPTypeInferencer typeInferencer = cachedInferencer == null ? new PHPTypeInferencer()
        : cachedInferencer;
    return typeInferencer.evaluateType(
        new ExpressionTypeGoal(context, node), timeLimit);
  }
View Full Code Here

    IContext context = ASTUtils.findContext(sourceModule,
        moduleDeclaration, position);
    if (context != null) {
      VariableReference varReference = getVariableReference(variableName,
          position);
      ExpressionTypeGoal goal = new ExpressionTypeGoal(context,
          varReference);
      PHPTypeInferencer typeInferencer = new PHPTypeInferencer();
      IEvaluatedType evaluatedType = typeInferencer.evaluateType(goal);
      if (evaluatedType instanceof MultiTypeType
          || evaluatedType instanceof AmbiguousType) {
View Full Code Here

    IContext context = ASTUtils.findContext(sourceModule,
        moduleDeclaration, position);
    if (context != null) {
      VariableReference varReference = getVariableReference(variableName,
          position);
      ExpressionTypeGoal goal = new ExpressionTypeGoal(context,
          varReference);
      PHPTypeInferencer typeInferencer = new PHPTypeInferencer();
      IEvaluatedType evaluatedType = typeInferencer.evaluateType(goal);

      IType[] modelElements = getTypes(position, context, evaluatedType);
View Full Code Here

    }

    if (visitor.getNode() != null) {
      PHPTypeInferencer typeInferencer = new PHPTypeInferencer();
      IEvaluatedType evaluatedType = typeInferencer
          .evaluateType(new ExpressionTypeGoal(visitor.getContext(),
              visitor.getNode()));
      modelElements = PHPTypeInferenceUtils.getModelElements(
          evaluatedType, (FileContext) visitor.getContext(), offset);
    }
View Full Code Here

  public CatchClauseEvaluator(IGoal goal) {
    super(goal);
  }

  public IGoal[] init() {
    ExpressionTypeGoal typedGoal = (ExpressionTypeGoal) goal;
    CatchClause catchClause = (CatchClause) typedGoal.getExpression();

    SimpleReference type = catchClause.getClassName();
    if (type != null) {
      result = PHPClassType.fromSimpleReference(type);
    }
View Full Code Here

          }
          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 {
              subGoals.add(new ExpressionTypeGoal(context,
                  declNode));
            }
          }
        }
        if (mergeWithGlobalScope
View Full Code Here

TOP

Related Classes of org.eclipse.dltk.ti.goals.ExpressionTypeGoal

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.