Examples of UseTrait


Examples of org.eclipse.php.internal.core.typeinference.UseTrait

   * @return
   */
  public static Map<String, IMethod> getImportedMethods(IType type) {
    Map<String, IMethod> ret = new HashMap<String, IMethod>();
   
    UseTrait parsed = TraitUtils.parse(type);
    IDLTKSearchScope scope = TraitUtils.createSearchScope(type);
   
    Map<String, IType> traits = new HashMap<String, IType>();
    Set<String> usedMethods = new HashSet<String>();
    for (String traitName : parsed.getTraits()) {
      if (findType(type.getSourceModule(), traitName) != null) {
        traits.put(traitName, findType(type.getSourceModule(), traitName)); // out of index
        continue;
      }
      IType[] traitTypes = PhpModelAccess.getDefault().findTraits(traitName, MatchRule.EXACT, 0, 0, scope, new NullProgressMonitor());
      if (traitTypes.length != 1) {
        continue; //more than one ignore it
      }
     
      traits.put(traitName, traitTypes[0]);
    }
   
    if (traits.size() == 0) {
      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;
      }
     
View Full Code Here

Examples of org.eclipse.php.internal.core.typeinference.UseTrait

  }

  private boolean isTraitMember(PHPVersion phpVersion, IType type,
      IMember member, Set<IType> typeSet) {
    if (phpVersion.isGreaterThan(PHPVersion.PHP5_3)) {
      UseTrait useTrait = TraitUtils.parse(type);
      String typeName = PHPModelUtils.getFullName(member
          .getDeclaringType());
      for (String trait : useTrait.getTraits()) {
        if (trait.equals(typeName)) {
          return true;
        }
      }

      for (String trait : useTrait.getTraits()) {
        IType[] traits = PhpModelAccess.getDefault().findTraits(trait,
            MatchRule.EXACT, 0, 0,
            TraitUtils.createSearchScope(type), null);

        for (IType traitType : traits) {
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.