Examples of IEvaluatedType


Examples of org.eclipse.dltk.ti.types.IEvaluatedType

      for (IType type : types) {
       
        IType currentNamespace = PHPModelUtils.getCurrentNamespace(type);
               
        boolean isInterface = PHPFlags.isInterface(type.getFlags());
        IEvaluatedType evaluated = getEvaluatedType(type.getElementName(), currentNamespace);
       
        if (!statements.contains(evaluated))
          statements.add(evaluated);

        for (IMethod method : type.getMethods()) {
View Full Code Here

Examples of org.eclipse.dltk.ti.types.IEvaluatedType

          try {
            offset = method.getSourceRange().getOffset();
          } catch (ModelException e) {
          }
         
          IEvaluatedType t = getArrayType(m.group(), currentNamespace, offset);
          String name = t.getTypeName();
          if (!evaluated.contains(name) && name.startsWith("$"))
            evaluated.add(t);
        } else {

            if (currentNamespace != null) {

              PHPDocBlock docBlock = PHPModelUtils
                  .getDocBlock(method);
              ModuleDeclaration moduleDeclaration = SourceParserUtil
                  .getModuleDeclaration(currentNamespace
                      .getSourceModule());
              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));
                final Map<String, UsePart> result = PHPModelUtils
                    .getAliasToNSMap(prefix,
                        moduleDeclaration,
                        docBlock.sourceStart(),
                        currentNamespace, true);
                if (result.containsKey(prefix)) {
                  String fullName = result.get(prefix)
                      .getNamespace()
                      .getFullyQualifiedName();
                  typeName = typeName.replace(prefix,
                      fullName);
                }
              } else if (typeName
                  .indexOf(NamespaceReference.NAMESPACE_SEPARATOR) < 0) {

                String prefix = typeName;
                final Map<String, UsePart> result = PHPModelUtils
                    .getAliasToNSMap(prefix,
                        moduleDeclaration,
                        docBlock.sourceStart(),
                        currentNamespace, true);
                if (result.containsKey(prefix)) {
                  String fullName = result.get(prefix)
                      .getNamespace()
                      .getFullyQualifiedName();
                  typeName = fullName;
                }
              }
            }
            IEvaluatedType type = getEvaluatedType(typeName,
                currentNamespace);
           
            if (type != null && isValidType(typeName, project) && !evaluated.contains(type.getTypeName()) && !type.getTypeName().startsWith("$")) {             
              evaluated.add(type);
            }
         
        }
      }
View Full Code Here

Examples of org.eclipse.dltk.ti.types.IEvaluatedType

   
  }
 
  public static IEvaluatedType getEvaluatedType(String typeName,
      IType currentNamespace) {
    IEvaluatedType type = PHPSimpleTypes.fromString(typeName);
    if (type == null) {
      if (typeName.indexOf(NamespaceReference.NAMESPACE_SEPARATOR) != -1
          || currentNamespace == null) {
        type = new PHPClassType(typeName);
      } else if (currentNamespace != null) {
View Full Code Here

Examples of org.eclipse.dltk.ti.types.IEvaluatedType

      return EMPTY_TYPES;
    }
  }

  private static IType[] getFunctionReturnTypes(PHPCallExpression expression, ISourceModule sourceModule, IType[] receiverTypes, IContext context) {
    IEvaluatedType evaluatedType = TYPE_INFERENCER.evaluateTypePHPDoc(new PHPDocMethodReturnTypeGoal(context, receiverTypes, expression.getName()));
    IType[] modelElements = PHPTypeInferenceUtils.getModelElements(evaluatedType, (ISourceModuleContext) context, expression.sourceStart());
    if (modelElements != null) {
      return modelElements;
    }
View Full Code Here

Examples of org.eclipse.dltk.ti.types.IEvaluatedType

    return EMPTY_TYPES;
  }

  private static IType[] getFunctionArrayReturnTypes(PHPCallExpression expression, ISourceModule sourceModule, IType[] receiverTypes, IContext context) {
    IEvaluatedType evaluatedType = TYPE_INFERENCER.evaluateTypePHPDoc(new PHPDocMethodReturnTypeGoal(context, receiverTypes, expression.getName()));
    if (evaluatedType instanceof MultiTypeType) {
      List<IType> collectingTypes = new LinkedList<IType>();
      for (IEvaluatedType possibleType : ((MultiTypeType) evaluatedType).getTypes()) {
        IType[] types = PHPTypeInferenceUtils.getModelElements(possibleType, (ISourceModuleContext) context, expression.sourceStart(), (IModelAccessCache) null);
        if (types != null) {
View Full Code Here

Examples of org.eclipse.dltk.ti.types.IEvaluatedType

        String name = null;
        // we have a namespace
        if (fqr.getNamespace() != null) {
          name = fqr.getNamespace().getName() + BACK_SLASH + fqr.getName();
        } else {
          IEvaluatedType eval = PHPTypeInferenceUtils.resolveExpression(sourceModule, fqr);
          name = eval.getTypeName();
          if (eval.getTypeName().startsWith(BACK_SLASH)) {
            name = eval.getTypeName().replaceFirst("\\\\", "");
          }         
        }
       
        if (name == null) {
          continue;
View Full Code Here

Examples of org.eclipse.dltk.ti.types.IEvaluatedType

          TraitAliasStatement statement = (TraitAliasStatement) traitStatement;
          if (statement.getAlias().getTraitMethod() instanceof FullyQualifiedTraitMethodReference) {
            FullyQualifiedTraitMethodReference reference = (FullyQualifiedTraitMethodReference) statement
                .getAlias().getTraitMethod();

            IEvaluatedType type = PHPClassType.fromTraitName(
                PHPModelUtils.getFullName(reference
                    .getClassName()), sourceModule,
                traitStatement.getStart());
            IType[] modelElements = PHPTypeInferenceUtils
                .getModelElements(type, context,
                    traitStatement.getStart(), statement
                        .getAST().getBindingResolver()
                        .getModelAccessCache());
            if (modelElements != null && modelElements.length > 0) {
              for (IType iType : modelElements) {
                boolean shouldBreak = false;
                try {
                  IModelElement[] children = iType
                      .getChildren();
                  for (IModelElement iModelElement : children) {
                    if (iModelElement.getElementName()
                        .equals(reference
                            .getFunctionName()
                            .getName())
                        && (iModelElement instanceof IMethod)) {
                      highlight(reference
                          .getFunctionName());
                      shouldBreak = true;
                      break;
                    }
                  }
                } catch (ModelException e) {
                  e.printStackTrace();
                }
                if (shouldBreak) {
                  break;
                }
              }
            }
          } else {
            Identifier method = (Identifier) statement.getAlias()
                .getTraitMethod();
            List<NamespaceName> traitList = node.getTraitList();
            for (NamespaceName namespaceName : traitList) {
              boolean shouldBreak = false;
              IEvaluatedType type = PHPClassType.fromTraitName(
                  PHPModelUtils.getFullName(namespaceName),
                  sourceModule, traitStatement.getStart());
              IType[] modelElements = PHPTypeInferenceUtils
                  .getModelElements(type, context,
                      traitStatement.getStart(),
                      statement.getAST()
                          .getBindingResolver()
                          .getModelAccessCache());
              if (modelElements != null
                  && modelElements.length > 0) {
                for (IType iType : modelElements) {
                  try {
                    IModelElement[] children = iType
                        .getChildren();
                    for (IModelElement iModelElement : children) {
                      if (iModelElement.getElementName()
                          .equals(method.getName())
                          && (iModelElement instanceof IMethod)) {
                        highlight(method);
                        shouldBreak = true;
                        break;
                      }
                    }
                  } catch (ModelException e) {
                    e.printStackTrace();
                  }
                  if (shouldBreak) {
                    break;
                  }
                }
              }
              if (shouldBreak) {
                break;
              }
            }
          }

        } else if (traitStatement instanceof TraitPrecedenceStatement) {
          TraitPrecedenceStatement statement = (TraitPrecedenceStatement) traitStatement;
          FullyQualifiedTraitMethodReference reference = statement
              .getPrecedence().getMethodReference();

          IEvaluatedType type = PHPClassType
              .fromTraitName(PHPModelUtils.getFullName(reference
                  .getClassName()), sourceModule,
                  traitStatement.getStart());
          IType[] modelElements = PHPTypeInferenceUtils
              .getModelElements(type, context,
View Full Code Here

Examples of org.eclipse.dltk.ti.types.IEvaluatedType

          TraitAliasStatement statement = (TraitAliasStatement) traitStatement;
          if (statement.getAlias().getTraitMethod() instanceof FullyQualifiedTraitMethodReference) {
            FullyQualifiedTraitMethodReference reference = (FullyQualifiedTraitMethodReference) statement
                .getAlias().getTraitMethod();

            IEvaluatedType type = PHPClassType.fromTraitName(
                PHPModelUtils.getFullName(reference
                    .getClassName()), sourceModule,
                traitStatement.getStart());
            IType[] modelElements = PHPTypeInferenceUtils
                .getModelElements(type, context,
                    traitStatement.getStart(), statement
                        .getAST().getBindingResolver()
                        .getModelAccessCache());
            if (modelElements != null && modelElements.length > 0) {
              for (IType iType : modelElements) {
                boolean shouldBreak = false;
                try {
                  IModelElement[] children = iType
                      .getChildren();
                  for (IModelElement iModelElement : children) {
                    if (iModelElement.getElementName()
                        .equals(reference
                            .getFunctionName()
                            .getName())
                        && (iModelElement instanceof IField)) {
                      highlight(reference
                          .getFunctionName());
                      shouldBreak = true;
                      break;
                    }
                  }
                } catch (ModelException e) {
                  e.printStackTrace();
                }
                if (shouldBreak) {
                  break;
                }
              }
            }
          } else {
            Identifier method = (Identifier) statement.getAlias()
                .getTraitMethod();
            List<NamespaceName> traitList = node.getTraitList();
            for (NamespaceName namespaceName : traitList) {
              boolean shouldBreak = false;
              IEvaluatedType type = PHPClassType.fromTraitName(
                  PHPModelUtils.getFullName(namespaceName),
                  sourceModule, traitStatement.getStart());
              IType[] modelElements = PHPTypeInferenceUtils
                  .getModelElements(type, context,
                      traitStatement.getStart(),
                      statement.getAST()
                          .getBindingResolver()
                          .getModelAccessCache());
              if (modelElements != null
                  && modelElements.length > 0) {
                for (IType iType : modelElements) {
                  try {
                    IModelElement[] children = iType
                        .getChildren();
                    for (IModelElement iModelElement : children) {
                      if (iModelElement.getElementName()
                          .equals(method.getName())
                          && (iModelElement instanceof IField)) {
                        highlight(method);
                        shouldBreak = true;
                        break;
                      }
                    }
                  } catch (ModelException e) {
                    e.printStackTrace();
                  }
                  if (shouldBreak) {
                    break;
                  }
                }
              }
              if (shouldBreak) {
                break;
              }
            }
          }

        } else if (traitStatement instanceof TraitPrecedenceStatement) {
          TraitPrecedenceStatement statement = (TraitPrecedenceStatement) traitStatement;
          FullyQualifiedTraitMethodReference reference = statement
              .getPrecedence().getMethodReference();

          IEvaluatedType type = PHPClassType
              .fromTraitName(PHPModelUtils.getFullName(reference
                  .getClassName()), sourceModule,
                  traitStatement.getStart());
          IType[] modelElements = PHPTypeInferenceUtils
              .getModelElements(type, context,
View Full Code Here

Examples of org.eclipse.dltk.ti.types.IEvaluatedType

        } else {
          if (formalParameter.getDefaultValue() != null
              && formalParameter.getDefaultValue() instanceof Scalar) {
            Scalar scalar = (Scalar) formalParameter
                .getDefaultValue();
            IEvaluatedType simpleType = PHPSimpleTypes
                .fromString(Scalar.getType(scalar
                    .getScalarType()));
            if (simpleType == null) {
              parameterTypes[i++] = Scalar.getType(scalar
                  .getScalarType());
            } else {
              parameterTypes[i++] = simpleType.getTypeName();
            }

          } else {
            parameterTypes[i++] = UNKNOWN_TYPE;
          }
View Full Code Here

Examples of org.eclipse.dltk.ti.types.IEvaluatedType

              protected void runTest() throws Throwable {
                String criteriaFunction = new File(fileName)
                    .getName().replaceAll("\\.pdtt", "");
                String code = pdttFile.getFile();

                IEvaluatedType evaluatedType = findEvaluatedType(
                    code, criteriaFunction, pruner);

                Assert.assertNotNull(
                    "Can't evaluate type for: " + code,
                    evaluatedType);
                Assert.assertEquals(pdttFile.getExpected()
                    .trim(), evaluatedType.getTypeName()
                    .trim());
              }
            });
          } catch (final Exception e) {
            phpVerSuite.addTest(new TestCase(fileName) { // dummy
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.