Package org.eclipse.dltk.evaluation.types

Examples of org.eclipse.dltk.evaluation.types.MultiTypeType


  public static MultiTypeType getArrayType(String type, IType currentNamespace,
      int offset) {
    int beginIndex = type.indexOf("[") + 1;
    int endIndex = type.lastIndexOf("]");
    type = type.substring(beginIndex, endIndex);
    MultiTypeType arrayType = new MultiTypeType();
    Matcher m = ARRAY_TYPE_PATTERN.matcher(type);
    if (m.find()) {
      arrayType
          .addType(getArrayType(m.group(), currentNamespace, offset));
      type = m.replaceAll("");
    }
    String[] typeNames = type.split(",");
    for (String name : typeNames) {
      if (!"".equals(name)) {

        if (name.indexOf(NamespaceReference.NAMESPACE_SEPARATOR) > 0
            && currentNamespace != null) {
          // check if the first part is an
          // alias,then get the full name
          ModuleDeclaration moduleDeclaration = SourceParserUtil
              .getModuleDeclaration(currentNamespace
                  .getSourceModule());
          String prefix = name.substring(0, name
              .indexOf(NamespaceReference.NAMESPACE_SEPARATOR));
          final Map<String, UsePart> result = PHPModelUtils
              .getAliasToNSMap(prefix, moduleDeclaration, offset,
                  currentNamespace, true);
          if (result.containsKey(prefix)) {
            String fullName = result.get(prefix).getNamespace()
                .getFullyQualifiedName();
            name = name.replace(prefix, fullName);
          }
        }
        arrayType.addType(getEvaluatedType(name, currentNamespace));
      }
    }
    return arrayType;
  }
View Full Code Here


    int beginIndex = type.indexOf("[") + 1; //$NON-NLS-1$
    int endIndex = type.lastIndexOf("]"); //$NON-NLS-1$
    if (endIndex != -1) {
      type = type.substring(beginIndex, endIndex);
    }
    MultiTypeType arrayType = new MultiTypeType();
    Matcher m = ARRAY_TYPE_PATTERN.matcher(type);
    if (m.find()) {
      arrayType
          .addType(getArrayType(m.group(), currentNamespace, offset));
      type = m.replaceAll(""); //$NON-NLS-1$
    }
    String[] typeNames = type.split(","); //$NON-NLS-1$
    for (String name : typeNames) {
      if (!"".equals(name)) { //$NON-NLS-1$

        if (name.indexOf(NamespaceReference.NAMESPACE_SEPARATOR) > 0
            && currentNamespace != null) {
          // check if the first part is an
          // alias,then get the full name
          ModuleDeclaration moduleDeclaration = SourceParserUtil
              .getModuleDeclaration(currentNamespace
                  .getSourceModule());
          String prefix = name.substring(0, name
              .indexOf(NamespaceReference.NAMESPACE_SEPARATOR));
          final Map<String, UsePart> result = PHPModelUtils
              .getAliasToNSMap(prefix, moduleDeclaration, offset,
                  currentNamespace, true);
          if (result.containsKey(prefix)) {
            String fullName = result.get(prefix).getNamespace()
                .getFullyQualifiedName();
            name = name.replace(prefix, fullName);
            if (name.charAt(0) != NamespaceReference.NAMESPACE_SEPARATOR) {
              name = NamespaceReference.NAMESPACE_SEPARATOR
                  + name;
            }
          }
        }
        arrayType.addType(getEvaluatedType(name, currentNamespace));
      }
    }
    return arrayType;
  }
View Full Code Here

        evaluateReturnType(returnTypeList, docBlock, method);
        typeNames = returnTypeList.toArray(new String[returnTypeList
            .size()]);
      }
      if (typeNames != null) {
        MultiTypeType evalMultiType = null;
        for (String typeName : typeNames) {
          Matcher m = ARRAY_TYPE_PATTERN.matcher(typeName);
          Matcher multi = MULTITYPE_PATTERN.matcher(typeName);
          if (m.find()) {
            int offset = 0;
            try {
              offset = method.getSourceRange().getOffset();
            } catch (ModelException e) {
            }
            evaluated.add(getArrayType(m.group(), currentNamespace,
                offset));

          } else if (typeName.endsWith(BRACKETS)
              && typeName.length() > 2) {
            int offset = 0;
            try {
              offset = method.getSourceRange().getOffset();
            } catch (ModelException e) {
            }
            evaluated.add(getArrayType(
                typeName.substring(0, typeName.length() - 2),
                currentNamespace, offset));
          } else {
            boolean isMulti = false;

            if (multi.find()) {
              if (evalMultiType == null) {
                evalMultiType = new MultiTypeType();
              }
              isMulti = true;
              typeName = multi.group(1);
            }
            AbstractMethodReturnTypeGoal goal = (AbstractMethodReturnTypeGoal) getGoal();
            IType[] types = goal.getTypes();
            if (typeName.equals(SELF_RETURN_TYPE) && types != null) {
              for (IType t : types) {
                IEvaluatedType type = getEvaluatedType(
                    PHPModelUtils.getFullName(t), null);
                if (type != null) {
                  if (isMulti) {
                    evalMultiType.addType(type);
                  } else {
                    evaluated.add(type);
                  }
                }
              }
            } 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);
                    if (typeName.charAt(0) != NamespaceReference.NAMESPACE_SEPARATOR) {
                      typeName = NamespaceReference.NAMESPACE_SEPARATOR
                          + typeName;
                    }
                  }
                } 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;
                    if (typeName.charAt(0) != NamespaceReference.NAMESPACE_SEPARATOR) {
                      typeName = NamespaceReference.NAMESPACE_SEPARATOR
                          + typeName;
                    }
                  }
                }
              }
              IEvaluatedType type = getEvaluatedType(typeName,
                  currentNamespace);
              if (type != null) {
                if (isMulti) {
                  evalMultiType.addType(type);
                } else {
                  evaluated.add(type);
                }
              }
            }
View Full Code Here

    int endIndex = type.lastIndexOf("]"); //$NON-NLS-1$
    if (endIndex != -1) {
      type = type.substring(beginIndex, endIndex);
    }

    MultiTypeType arrayType = new MultiTypeType();
    Matcher m = ARRAY_TYPE_PATTERN.matcher(type);
    if (m.find()) {
      arrayType
          .addType(getArrayType(m.group(), currentNamespace, offset));
      type = m.replaceAll(""); //$NON-NLS-1$
    } else if (type.endsWith(BRACKETS) && type.length() > 2) {
      arrayType.addType(getArrayType(
          type.substring(0, type.length() - 2), currentNamespace,
          offset));
      type = type.replaceAll(BRACKETS, ""); //$NON-NLS-1$
    }
    String[] typeNames = type.split(","); //$NON-NLS-1$
    for (String name : typeNames) {
      if (!"".equals(name)) { //$NON-NLS-1$

        if (name.indexOf(NamespaceReference.NAMESPACE_SEPARATOR) > 0
            && currentNamespace != null) {
          // check if the first part is an
          // alias,then get the full name
          ModuleDeclaration moduleDeclaration = SourceParserUtil
              .getModuleDeclaration(currentNamespace
                  .getSourceModule());
          String prefix = name.substring(0, name
              .indexOf(NamespaceReference.NAMESPACE_SEPARATOR));
          final Map<String, UsePart> result = PHPModelUtils
              .getAliasToNSMap(prefix, moduleDeclaration, offset,
                  currentNamespace, true);
          if (result.containsKey(prefix)) {
            String fullName = result.get(prefix).getNamespace()
                .getFullyQualifiedName();
            name = name.replace(prefix, fullName);
            if (name.charAt(0) != NamespaceReference.NAMESPACE_SEPARATOR) {
              name = NamespaceReference.NAMESPACE_SEPARATOR
                  + name;
            }
          }
        }
        arrayType.addType(getEvaluatedType(name, currentNamespace));
      }
    }
    return arrayType;
  }
View Full Code Here

        }
      }
      result = new AmbiguousType(types.toArray(new IEvaluatedType[types
          .size()]));
    } else if (result instanceof MultiTypeType) {
      MultiTypeType multiTypeType = (MultiTypeType) result;
      List<IEvaluatedType> types = multiTypeType.getTypes();
      result = new AmbiguousType(types.toArray(new IEvaluatedType[types
          .size()]));
    }
    this.result = (IEvaluatedType) result;
    return IGoal.NO_GOALS;
View Full Code Here

      cache = (IModelAccessCache) ((IModelCacheContext) goal.getContext())
          .getCache();
    }
    if (state != GoalState.RECURSIVE) {
      if (result instanceof GeneratorClassType) {
        MultiTypeType type = new MultiTypeType();
        type.getTypes()
            .addAll(((GeneratorClassType) result).getTypes());
        this.result = type;
        return IGoal.NO_GOALS;
      } else if (result instanceof PHPClassType) {
        if (subgoal instanceof ExpressionTypeGoal) {
          ISourceModule sourceModule = ((ISourceModuleContext) subgoal
              .getContext()).getSourceModule();
          PHPClassType classType = (PHPClassType) result;
          List<IGoal> subGoals = new LinkedList<IGoal>();
          try {
            IType[] types = PHPModelUtils.getTypes(
                classType.getTypeName(), sourceModule, 0,
                cache, null);
            for (IType type : types) {
              IType[] superTypes = PHPModelUtils.getSuperClasses(
                  type,
                  cache == null ? null : cache
                      .getSuperTypeHierarchy(type, null));

              if (subgoal.getContext() instanceof MethodContext) {

                MethodContext methodContext = (MethodContext) subgoal
                    .getContext();

                if (isArrayType(methodContext, type)) {
                  MultiTypeType mType = new MultiTypeType();
                  mType.addType((IEvaluatedType) result);
                  this.result = mType;
                  return IGoal.NO_GOALS;
                }
              }

              if (isImplementedIterator(superTypes)) {
                subGoals.add(new MethodElementReturnTypeGoal(
                    subgoal.getContext(),
                    new IType[] { type }, "current")); //$NON-NLS-1$
                subGoals.add(new PHPDocMethodReturnTypeGoal(
                    subgoal.getContext(),
                    new IType[] { type }, "current")); //$NON-NLS-1$
              }
            }
            if (subGoals.size() == 0) {
              MultiTypeType mType = new MultiTypeType();
              mType.addType((IEvaluatedType) result);
              this.result = mType;
              return IGoal.NO_GOALS;
            }
            return subGoals.toArray(new IGoal[subGoals.size()]);
          } catch (ModelException e) {
            if (DLTKCore.DEBUG) {
              e.printStackTrace();
            }
          }
        }
        MultiTypeType type = new MultiTypeType();
        type.addType((IEvaluatedType) result);
        this.result = type;
        return IGoal.NO_GOALS;
      }
      this.result = (IEvaluatedType) result;
    }
View Full Code Here

                          typeName.length() - 2);
                    }
                    if (typeName.indexOf('|') >= 0) {
                      String[] typeNames = typeName
                          .split("|"); //$NON-NLS-1$
                      MultiTypeType arrayType = new MultiTypeType();
                      for (int i = 0; i < typeNames.length; i++) {
                        if (typeNames[i].trim()
                            .length() == 0
                            || typeNames[i]
                                .equals("|")) { //$NON-NLS-1$
                          continue;
                        }
                        arrayType
                            .addType(PHPClassType
                                .fromTypeName(
                                    typeNames[i],
                                    methodContext
                                        .getSourceModule(),
View Full Code Here

TOP

Related Classes of org.eclipse.dltk.evaluation.types.MultiTypeType

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.