Package org.eclipse.dltk.core

Examples of org.eclipse.dltk.core.IType


    if (projectTypes.length != 1) {
      return;
    }

    IType currentType = projectTypes[0];
    ITypeHierarchy hierarchy = this.getCompanion().getSuperTypeHierarchy(type, new NullProgressMonitor());
    IType[] superTypes = hierarchy.getAllSupertypes(currentType);

    List<String> reported = new ArrayList<String>();
View Full Code Here


    List<IEvaluatedType> statements = new ArrayList<IEvaluatedType>();
   
    try {
      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))
View Full Code Here

        return false;
      }
     
      for (String n : type.getSuperClasses()) {
        if (type.getSourceModule().getType(n) != null) {
          final IType sub = type.getSourceModule().getType(n);
          for (IMethod m : sub.getMethods()) {
            if (!list.contains(m) && m.getElementName().equals(prefix) || (!exactName && m.getElementName().startsWith(prefix))) {
              list.add(m);
              return true;
            }
          }
View Full Code Here

    IScriptProject project = method.getScriptProject();
   
    if (project == null)
      return evaluated;
   
    IType currentNamespace = PHPModelUtils.getCurrentNamespace(method);
    String[] typeNames = null;
    if (method instanceof IPHPDocAwareElement) {
      typeNames = ((IPHPDocAwareElement) method).getReturnTypes();
    } else {
      List<String> returnTypeList = new LinkedList<String>();
      PHPDocBlock docBlock = PHPModelUtils.getDocBlock(method);
      if (docBlock == null) {
        return null;
      }
      PHPDocTag[] tags = docBlock.getTags(PHPDocTagKinds.PARAM);
      if (tags != null && tags.length > 0) {
        for (PHPDocTag phpDocTag : tags) {
          if (phpDocTag.getReferences() != null
              && phpDocTag.getReferences().length > 0) {
            for (SimpleReference ref : phpDocTag
                .getReferences()) {
             
              if (ref instanceof TypeReference) {
                String type = ref.getName();
                if (type != null && isValidType(type, project)) {
                  returnTypeList.add(type);
                }               
              }
            }
          }
        }
      }
      typeNames = returnTypeList.toArray(new String[returnTypeList
          .size()]);
    }
    if (typeNames != null) {
      for (String typeName : typeNames) {
        Matcher m = ARRAY_TYPE_PATTERN.matcher(typeName);
        if (m.find()) {
          int offset = 0;
          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
View Full Code Here

      return ret;
    }
   
    //load aliases
    for (TraitAliasObject alias : parsed.getTraitAliases()) {
      IType trait = traits.get(alias.traitName);
      if (trait == null) {
        continue;
      }

      IMethod[] methods;
      try {
       
        methods = PHPModelUtils.getTypeMethod(trait, alias.traitMethodName, true);
        if (methods.length != 1) {
          continue;
        }
        usedMethods.add(alias.traitName + "::" + alias.traitMethodName);
        ret.put(alias.newMethodName, methods[0]);
      } catch (ModelException e) {
        Logger.logException(e);
      }
    }
   
    //load precedences
    for (Entry<String, TraitPrecedenceObject> entry : parsed.getPrecedenceMap().entrySet()) {
      IType trait = traits.get(entry.getValue().traitName);
      if (trait == null) {
        continue;
      }
     
      IMethod[] methods;
View Full Code Here

    Assert.isNotNull(sourceModule);

    IModelElement[] sourceElements = sourceModule.codeSelect(offset, length);
    if (sourceElements.length > 0) {
      if (sourceElements[0].getElementType() == IModelElement.METHOD && ((IMethod) sourceElements[0]).isConstructor()) {
        IType sourceType = fixInvalidSourceElement((IMethod) sourceElements[0], offset, length);
        if (sourceType != null) {
          return sourceType;
        }
      }
View Full Code Here

    Collection<TypeReference> interfaces = getClassDeclaration().getInterfaceList();
   
    List<IMethod> unimplemented = new ArrayList<IMethod>();   
    IDLTKSearchScope scope = SearchEngine.createSearchScope(project);   
    PhpModelAccess model = PhpModelAccess.getDefault();   
    IType nss = PHPModelUtils.getCurrentNamespace(sourceModule, getClassDeclaration().getNameStart());
    String search = nss != null ? nss.getElementName() + BACK_SLASH + getClassDeclaration().getName() : getClassDeclaration().getName();
     
    IType classType = context != null ? PDTModelUtils.findType(sourceModule, search) : null;
       
    if (classType == null) {
      for (IType t : PDTModelUtils.findTypes(project, search)) {
        classType = t;
        break;
      }
      if (classType == null) {
        return false;
      }
    }
   
   
    Map<String, IMethod> listImported = PDTModelUtils.getImportedMethods(classType);
    // iterate over all interfaces and check if the current class
    // or any of the superclasses implements the method
    if (listImported == null) {
      return true;
    }
    for (TypeReference interf : interfaces) {
     
      if (interf instanceof FullyQualifiedReference) {
       
        FullyQualifiedReference fqr = (FullyQualifiedReference) interf;
        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;
        }
        IType[] types;
       
        if (PDTModelUtils.findType(sourceModule, name) != null) {
          types = new IType[] {PDTModelUtils.findType(sourceModule, name)};
        } else {
          types = model.findTypes(name, MatchRule.EXACT, 0, 0, scope, new NullProgressMonitor());
        }
       
        if (types.length != 1) {
          continue;
        }
       
        IType type = types[0];
       
       
        try {
          for (IMethod method : type.getMethods()) {

            boolean implemented = false;
            String methodSignature = PDTModelUtils.getMethodSignature(method);
            if (methodSignature == null) {
              continue;
View Full Code Here

                    @Override
                    public boolean visit(FullyQualifiedReference s) throws Exception {
                      if (s.sourceStart() == match.getOffset() && s.sourceEnd() == match.getOffset() + match.getLength()) {
                        IModelElement sourceElement = PDTModelUtils.getSourceElement(module, s.sourceStart(), s.matchLength());
                        if (sourceElement != null) {
                          IType sourceType = (IType) sourceElement.getAncestor(IModelElement.TYPE);
                          if (sourceType != null && new PHPType(sourceType).isInstanceOf((IType) modelElement)) {
                            int offset;
                            if (s.getNamespace() == null) {
                              offset = s.sourceStart();
                            } else {
View Full Code Here

                    }
                  }
                } else {
                  IModelElement sourceElement = PDTModelUtils.getSourceElement(module, expression.getCallName().sourceStart(), expression.getCallName().matchLength());
                  if (sourceElement != null && sourceElement.getElementType() == IModelElement.METHOD) {
                    IType declaringType = ((IMethod) sourceElement).getDeclaringType();
                    if (declaringType != null && new PHPType(declaringType).isInstanceOf(method.getDeclaringType())) {
                      try {
                        addTextEdit(
                          changeManager.get(module),
                          getProcessorName(),
View Full Code Here

  }

  private List<IMethod> getOverridingMethods(IProgressMonitor pm) throws ModelException {
    if (overridingMethods == null) {
      overridingMethods = new ArrayList<IMethod>();
      IType declaringType = ((IMethod) modelElement).getDeclaringType();
      if (declaringType != null) {
        for (IType subType: declaringType.newTypeHierarchy(pm).getAllSubtypes(declaringType)) {
          for (IMethod methodBySubType: subType.getMethods()) {
            if (methodBySubType.getElementName().equals(getCurrentElementName())) {
              overridingMethods.add(methodBySubType);
              break;
            }
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.