Package org.eclipse.dltk.ti

Examples of org.eclipse.dltk.ti.IContext


public class PDTTypeInferenceUtils {
  private static final IType[] EMPTY_TYPES = new IType[] {};
  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


  }

  public static IType[] getTypes(PHPCallExpression expression, ISourceModule sourceModule) {
    IType[] receiverTypes = getTypes(expression.getReceiver(), sourceModule);
    if (receiverTypes != null && receiverTypes.length > 0) {
      IContext context = ASTUtils.findContext(sourceModule, SourceParserUtil.getModuleDeclaration(sourceModule), expression.sourceStart());
      if (expression.getArgs() instanceof PHPCallArgumentsList && ((PHPCallArgumentsList) expression.getArgs()).getArrayDereferenceList() != null) {
        return getFunctionArrayReturnTypes(expression, sourceModule, receiverTypes, context);
      } else {
        return getFunctionReturnTypes(expression, sourceModule, receiverTypes, context);
      }
View Full Code Here

  static public IType[] getTypes(String typeName, ISourceModule sm,
      int offset, IType currentNamespace) {
    ModuleDeclaration moduleDeclaration = SourceParserUtil
        .getModuleDeclaration(sm, null);
    IContext context = ASTUtils.findContext(sm, moduleDeclaration, offset);
    if (currentNamespace != null) {
      if (typeName.indexOf(NamespaceReference.NAMESPACE_SEPARATOR) > 0) {
        // check if the first part is an alias,then get the full name
        String prefix = typeName.substring(0, typeName
            .indexOf(NamespaceReference.NAMESPACE_SEPARATOR));
View Full Code Here

      }
    }
    ASTNode node = ASTUtils.findMinimalNode(parsedUnit, offset, end);
    if (node != null) {

      IContext context = ASTUtils.findContext(sourceModule, parsedUnit,
          node);
      if (context != null) {
        if (context instanceof IModelCacheContext) {
          ((IModelCacheContext) context).setCache(cache);
        }
View Full Code Here

  public static IEvaluatedType resolveExpression(ISourceModule sourceModule,
      ASTNode expression) {
    ModuleDeclaration moduleDeclaration = SourceParserUtil
        .getModuleDeclaration(sourceModule);
    IContext context = ASTUtils.findContext(sourceModule,
        moduleDeclaration, expression);
    return resolveExpression(sourceModule, moduleDeclaration, context,
        expression);
  }
View Full Code Here

      IType[] types = getLhsTypes();
      if (types != null && types.length > 0) {
        ModuleDeclaration moduleDeclaration = SourceParserUtil
            .getModuleDeclaration(sourceModule);
        if (moduleDeclaration != null) {
          IContext context = ASTUtils.findContext(sourceModule,
              moduleDeclaration, offset);
          if (context instanceof MethodContext) {
            IEvaluatedType instanceType = ((MethodContext) context)
                .getInstanceType();
            if (instanceType instanceof PHPClassType) {
View Full Code Here

    ContextFinder contextFinder = getContext(sourceRange);
    ASTNode node = contextFinder.getNode();

    if (node instanceof VariableReference) {
      ASTNode localScopeNode = rootNode;
      IContext context = contextFinder.getContext();
      if (context instanceof MethodContext) {
        localScopeNode = ((MethodContext) context).getMethodNode();
      }
      VariableReferenceEvaluator.LocalReferenceDeclSearcher varDecSearcher = new VariableReferenceEvaluator.LocalReferenceDeclSearcher(
          sourceModule, (VariableReference) node, localScopeNode);
View Full Code Here

    for (Expression expr : returnExpressions) {
      SourceRange sourceRange = new SourceRange(expr);
      try {
        ContextFinder contextFinder = getContext(sourceRange);
        IContext context = contextFinder.getContext();
        IEvaluatedType resolvedExpression = PHPTypeInferenceUtils
            .resolveExpression(cachedInferencer, sourceModule,
                sourceModuleDeclaration, context, expr);
        if (resolvedExpression != null) {
          evaluated.add(resolvedExpression);
        }
      } catch (ModelException e) {
        if (DLTKCore.DEBUG) {
          e.printStackTrace();
        }
        continue;
      }
    }
    if (yieldExpressions.size() > 0) {
      GeneratorClassType generator = new GeneratorClassType();
      for (Expression expr : yieldExpressions) {
        if (expr == null) {
          generator.getTypes().add(PHPSimpleTypes.NULL);
        } else {
          SourceRange sourceRange = new SourceRange(expr);
          try {
            ContextFinder contextFinder = getContext(sourceRange);
            IContext context = contextFinder.getContext();
            IEvaluatedType resolvedExpression = PHPTypeInferenceUtils
                .resolveExpression(cachedInferencer,
                    sourceModule, sourceModuleDeclaration,
                    context, expr);
            if (resolvedExpression != null) {
View Full Code Here

   */
  public static IType[] getArrayVariableType(ISourceModule sourceModule,
      String variableName, int position) {
    ModuleDeclaration moduleDeclaration = SourceParserUtil
        .getModuleDeclaration(sourceModule, null);
    IContext context = ASTUtils.findContext(sourceModule,
        moduleDeclaration, position);
    if (context != null) {
      VariableReference varReference = getVariableReference(variableName,
          position);
      ExpressionTypeGoal goal = new ExpressionTypeGoal(context,
View Full Code Here

   */
  public static IType[] getVariableType(ISourceModule sourceModule,
      String variableName, int position) {
    ModuleDeclaration moduleDeclaration = SourceParserUtil
        .getModuleDeclaration(sourceModule, null);
    IContext context = ASTUtils.findContext(sourceModule,
        moduleDeclaration, position);
    if (context != null) {
      VariableReference varReference = getVariableReference(variableName,
          position);
      ExpressionTypeGoal goal = new ExpressionTypeGoal(context,
View Full Code Here

TOP

Related Classes of org.eclipse.dltk.ti.IContext

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.