Package org.eclipse.dltk.core

Examples of org.eclipse.dltk.core.IType


    assertContents(getSavedHierarchy("test2"), tree.toString());
  }

  public void testSearchMethod() throws Exception {
    ISourceModule sourceModule = getSourceModule(getFilePath("test3/c.php"));
    IType type = sourceModule.getType("Test3");
    IMethod[] method = PHPModelUtils.getTypeHierarchyMethod(type, "foo",
        true, null);

    Assert.assertTrue("Can't find method", method.length > 0);
    Assert.assertEquals("Wrong method was found", "a.php", method[0]
View Full Code Here


        .getSourceModule().getElementName());
  }

  public void testSearchMethodBadNetwork() throws Exception {
    ISourceModule sourceModule = getSourceModule(getFilePath("test4/c.php"));
    IType type = sourceModule.getType("Test4");
    IMethod[] method = PHPModelUtils.getTypeHierarchyMethod(type, "foo",
        true, null);

    Assert.assertTrue("There should be two methods found",
        method.length == 2);
View Full Code Here

      try {
        String tabs = getTabs(element);
        stream.print(tabs);

        if (element.getElementType() == IModelElement.TYPE) {
          IType type = (IType) element;

          int flags = type.getFlags();
          if ((flags & Modifiers.AccInterface) != 0) {
            stream.print("INTERFACE: ");
          } else if ((flags & Modifiers.AccNameSpace) != 0) {
            stream.print("NAMESPACE: ");
          } else {
            stream.print("CLASS: ");
          }
        } else if (element.getElementType() == IModelElement.METHOD) {
          IMethod method = (IMethod) element;
          IType declaringType = method.getDeclaringType();
          if (declaringType == null
              || (declaringType.getFlags() & Modifiers.AccNameSpace) != 0) {
            stream.print("FUNCTION: ");
          } else {
            stream.print("METHOD: ");
          }
        } else if (element.getElementType() == IModelElement.FIELD) {
View Full Code Here

  };

  @Override
  protected boolean isInnerType(IModelElement element) {
    if (element != null && element.getElementType() == IModelElement.TYPE) {
      IType type = (IType) element;
      type = type.getDeclaringType();
      try {
        if (type != null && !PHPFlags.isNamespace(type.getFlags())) {
          return true;
        }
      } catch (ModelException e) {
      }
    }
View Full Code Here

                  typeName = typeName.substring(i + 1);
                }
                if (namespace.charAt(0) == NamespaceReference.NAMESPACE_SEPARATOR) {
                  namespace = namespace.substring(1);
                }
                IType currentNamespace = PHPModelUtils
                    .getCurrentNamespace(types[0]);
                if (currentNamespace != null) {
                  isThis = namespace.equals(currentNamespace
                      .getElementName())
                      && typeName.equals(types[0]
                          .getElementName());
                }
              } else {
View Full Code Here

   */
  public static PHPClassType fromIType(IType type) {
    String elementName = type.getElementName();
    try {
      if (PHPFlags.isTrait(type.getFlags())) {
        IType namespace = type.getDeclaringType();
        if (namespace != null) {
          return new PHPTraitType(namespace.getElementName(),
              elementName);
        }
        return new PHPTraitType(elementName);
      }
    } catch (ModelException e) {
    }
    IType namespace = type.getDeclaringType();
    if (namespace != null) {
      return new PHPClassType(namespace.getElementName(), elementName);
    }
    return new PHPClassType(elementName);
  }
View Full Code Here

    if ((keyword.context & PHPKeywords.METHOD_BODY) != 0
        && isParent(keyword)) {
      ICompletionContext context = getContext();
      if (context instanceof GlobalMethodStatementContext) {
        GlobalMethodStatementContext globalContext = (GlobalMethodStatementContext) context;
        IType type = globalContext.getEnclosingType();
        try {
          if (type != null && PHPFlags.isClass(type.getFlags())) {
            ITypeHierarchy hierarchy = getCompanion()
                .getSuperTypeHierarchy(type, null);
            IType[] superTypes = hierarchy.getAllSupertypes(type);
            for (IType superType : superTypes) {
              if (PHPFlags.isClass(superType.getFlags())) {
View Full Code Here

                  typeName = typeName.substring(i + 1);
                }
                if (namespace.charAt(0) == NamespaceReference.NAMESPACE_SEPARATOR) {
                  namespace = namespace.substring(1);
                }
                IType currentNamespace = PHPModelUtils
                    .getCurrentNamespace(types[0]);
                if (!isParent) {
                  if (currentNamespace != null
                      && types.length >= 2) {
                    IType parentType = types[1];
                    isParent = namespace
                        .equals(currentNamespace
                            .getElementName())
                        && typeName.equals(parentType
                            .getElementName());
                  }
                }
                if (!isSelf) {
                  if (currentNamespace != null) {
                    isSelf = namespace
                        .equals(currentNamespace
                            .getElementName())
                        && typeName.equals(types[0]
                            .getElementName());
                  }
                }
              } else {
                if (!isParent) {
                  if (types.length >= 2) {
                    IType parentType = types[1];
                    isParent = typeName.equals(parentType
                        .getElementName());
                  }
                }
                if (!isSelf) {
                  isSelf = typeName.equals(types[0]
View Full Code Here

    CompletionRequestor requestor = concreteContext
        .getCompletionRequestor();

    String prefix = concreteContext.getPrefix();
    boolean exactName = requestor.isContextInformationMode();
    IType declaringClass = concreteContext.getDeclaringClass();

    String suffix = getSuffix(concreteContext);
    SourceRange replaceRange = null;
    if (suffix.equals("")) { //$NON-NLS-1$
      replaceRange = getReplacementRange(concreteContext);
    } else {
      replaceRange = getReplacementRangeWithBraces(concreteContext);
    }

    try {
      ITypeHierarchy hierarchy = getCompanion().getSuperTypeHierarchy(
          declaringClass, null);
      IMethod[] superClassMethods = PHPModelUtils
          .getSuperTypeHierarchyMethod(declaringClass, hierarchy,
              prefix, exactName, null);
      for (IMethod superMethod : superClassMethods) {
        if (declaringClass.getMethod(superMethod.getElementName())
            .exists()) {
          continue;
        }
        int flags = superMethod.getFlags();
        if (!PHPFlags.isFinal(flags) && !PHPFlags.isPrivate(flags)
            && !PHPFlags.isStatic(flags)) {
          reporter.reportMethod(superMethod, CONSTRUCTOR_SUFFIX,
              replaceRange);
        }
      }
    } catch (CoreException e) {
      PHPCorePlugin.log(e);
    }

    PHPVersion phpVersion = concreteContext.getPhpVersion();

    // Add magic methods:
    Set<String> functions = new TreeSet<String>();
    functions.addAll(Arrays.asList(PHPMagicMethods.getMethods(phpVersion)));

    // Add constructors:
    functions.add(declaringClass.getElementName());
    if (phpVersion.isGreaterThan(PHPVersion.PHP4)) {
      functions.add("__construct"); //$NON-NLS-1$
      functions.add("__destruct"); //$NON-NLS-1$
    }
View Full Code Here

          if (declaringType != null
              && realType != null
              && declaringType.getElementName().equals(
                  node.getName())) {
            if (realType.getParent() instanceof IType) {
              IType ns = (IType) realType.getParent();
              instanceType = new PHPThisClassType(
                  ns.getElementName(),
                  realType.getElementName(), realType);
            } else {
              instanceType = new PHPThisClassType(
                  realType.getElementName(), realType);
            }
View Full Code Here

TOP

Related Classes of org.eclipse.dltk.core.IType

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.