Package org.eclipse.dltk.ti.types

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


    return arrayType;
  }

  public static IEvaluatedType getEvaluatedType(String typeName,
      IType currentNamespace) {
    IEvaluatedType type = PHPSimpleTypes.fromString(typeName);
    if (type == null) {
      if (typeName.indexOf(NamespaceReference.NAMESPACE_SEPARATOR) > 0
          && currentNamespace != null) {
        typeName = NamespaceReference.NAMESPACE_SEPARATOR
            + currentNamespace.getElementName()
View Full Code Here


            }
            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 {
View Full Code Here

    return arrayType;
  }

  private IEvaluatedType getEvaluatedType(String typeName,
      IType currentNamespace) {
    IEvaluatedType type = PHPSimpleTypes.fromString(typeName);
    if (type == null) {
      if (typeName.indexOf(NamespaceReference.NAMESPACE_SEPARATOR) > 0
          && currentNamespace != null) {
        typeName = NamespaceReference.NAMESPACE_SEPARATOR
            + currentNamespace.getElementName()
View Full Code Here

    String className = typeReference.getName();

    if (isSelfOrStatic()) {
      if (context instanceof MethodContext) {
        MethodContext methodContext = (MethodContext) context;
        IEvaluatedType instanceType = methodContext.getInstanceType();
        if (instanceType instanceof PHPClassType) {
          result = instanceType;
        }
      }
    } else if (isParent()) { //$NON-NLS-1$
      if (context instanceof MethodContext) {
        final MethodContext methodContext = (MethodContext) context;
        ModuleDeclaration rootNode = methodContext.getRootNode();
        ISourceModule sourceModule = ((ISourceModuleContext) context)
            .getSourceModule();
        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 {
          rootNode.traverse(new ASTVisitor() {
            private TypeDeclaration currentType;
            private boolean found;

            public boolean visit(MethodDeclaration s)
                throws Exception {
              if (s == methodDecl
                  && currentType instanceof ClassDeclaration) {
                ClassDeclaration classDecl = (ClassDeclaration) currentType;

                ASTListNode superClasses = classDecl
                    .getSuperClasses();
                List childs = superClasses.getChilds();
                for (Iterator iterator = childs.iterator(); iterator
                    .hasNext();) {
                  ASTNode node = (ASTNode) iterator.next();
                  NamespaceReference namespace = null;
                  SimpleReference reference = null;
                  if (node instanceof SimpleReference) {
                    reference = (SimpleReference) node;
                    String typeName = reference.getName();
                    if (reference instanceof FullyQualifiedReference) {
                      FullyQualifiedReference ref = (FullyQualifiedReference) node;
                      namespace = ref.getNamespace();
                    }
                    if (namespace != null
                        && !namespace.getName().equals(
                            "")) { //$NON-NLS-1$
                      String nsName = namespace.getName();
                      if (nsName.equals("\\")) { //$NON-NLS-1$
                        typeName = nsName + typeName;
                      } else {
                        if (nsName
                            .startsWith("namespace\\")) { //$NON-NLS-1$
                          nsName = nsName.replace(
                              "namespace\\", ""); //$NON-NLS-1$ //$NON-NLS-2$
                        }
                        typeName = nsName
                            + NamespaceReference.NAMESPACE_SEPARATOR
                            + typeName;
                      }
                    }
                    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,
                              reference
                                  .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,
                              reference
                                  .sourceStart(),
                              currentNamespace,
                              true);
                      if (result.containsKey(prefix)) {
                        String fullName = result
                            .get(prefix)
                            .getNamespace()
                            .getFullyQualifiedName();
                        typeName = fullName;
                      }
                    }
                    IEvaluatedType type = PHPSimpleTypes
                        .fromString(typeName);
                    if (type == null) {
                      if (typeName
                          .indexOf(NamespaceReference.NAMESPACE_SEPARATOR) != -1
                          || currentNamespace == null) {
View Full Code Here

        moduleDeclaration, offset);
    SourceRange replacementRange = getReplacementRange(abstractContext);
    for (String useType : useTypes) {
      if (useType.trim().toLowerCase().startsWith(prefix.toLowerCase())) {

        IEvaluatedType type = PHPClassType.fromTraitName(useType,
            sourceModule, offset);
        IType[] modelElements = PHPTypeInferenceUtils.getModelElements(
            type, fileContext, offset);
        if (modelElements != null) {
          for (IType typeElement : modelElements) {
View Full Code Here

TOP

Related Classes of org.eclipse.dltk.ti.types.IEvaluatedType

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.