Package org.objectstyle.wolips.bindings.wod

Examples of org.objectstyle.wolips.bindings.wod.BindingValueKey


    //System.out.println("BindingReflectionUtils.getBindingKeys: a " + type.getFullyQualifiedName());

    IField[] fields = type.getFields();
    for (int fieldNum = 0; (!requireExactNameMatch || bindingKeys.size() == 0) && fieldNum < fields.length; fieldNum++) {
      for (String prefix : BindingReflectionUtils.FIELD_PREFIXES) {
        BindingValueKey bindingKey = BindingReflectionUtils.getBindingKeyIfMatches(javaProject, declaringType, fields[fieldNum], prefix + lowercaseNameStartingWith, prefix, requireExactNameMatch, accessorsOrMutators, cache);
        if (bindingKey != null) {
          bindingKeys.add(bindingKey);
          break;
        }
      }
    }

    if (!requireExactNameMatch || bindingKeys.size() == 0) {
      IMethod[] methods = type.getMethods();
      String[] prefixes;
      if (accessorsOrMutators == BindingReflectionUtils.ACCESSORS_ONLY) {
        prefixes = BindingReflectionUtils.GET_METHOD_PREFIXES;
      }
      else if (accessorsOrMutators == BindingReflectionUtils.ACCESSORS_OR_VOID) {
        prefixes = BindingReflectionUtils.GET_METHOD_PREFIXES;
      }
      else if (accessorsOrMutators == BindingReflectionUtils.MUTATORS_ONLY) {
        prefixes = BindingReflectionUtils.SET_METHOD_PREFIXES;
      }
      else {
        prefixes = new String[0];
      }

      for (int methodNum = 0; (!requireExactNameMatch || bindingKeys.size() == 0) && methodNum < methods.length; methodNum++) {
        for (String prefix : prefixes) {
          //System.out.println("BindingReflectionUtils.getBindingKeys: checking for " + prefix + methods[methodNum].getElementName());
          BindingValueKey bindingKey = BindingReflectionUtils.getBindingKeyIfMatches(javaProject, declaringType, methods[methodNum], prefix + lowercaseNameStartingWith, prefix, requireExactNameMatch, accessorsOrMutators, cache);
          if (bindingKey != null) {
            if (allowInheritanceDuplicates || !bindingKeys.contains(bindingKey)) {
              bindingKeys.add(bindingKey);
            }
            break;
View Full Code Here


    MaybeVisible
  }
 
  public static BindingValueKey getBindingKeyIfMatches(IJavaProject javaProject, IType type, IMember member, String nameStartingWith, String prefix, boolean requireExactNameMatch, int accessorsOrMutators, TypeCache cache) throws JavaModelException {
    //System.out.println("BindingReflectionUtils.getBindingKeyIfMatches: " + member.getElementName() + " starts with " + nameStartingWith);
    BindingValueKey bindingKey = null;

    int flags = member.getFlags();
    Visibility visible = Visibility.Hidden;
   
    // Private is never an option
    if (Flags.isPrivate(flags)) {
      visible = Visibility.Hidden;
    }
    // Don't show static methods and fields
    else if (Flags.isStatic(flags)) {
      visible = Visibility.Hidden;
    }
    // Public bindings are always visible
    else if (Flags.isPublic(flags) || type.isInterface()) {
      visible = Visibility.Visible;
    }
    // Components that are not in a package can have bindings to protected fields
    //else if ((Flags.isProtected(flags) || Flags.isPackageDefault(flags)) && BindingReflectionUtils.isDefaultPackage(member)) {
    else if (Flags.isProtected(flags) || Flags.isPackageDefault(flags)) {
      if (BindingReflectionUtils.isDefaultPackage(member)) {
        visible = Visibility.Visible;
      }
      else {
        visible = Visibility.MaybeVisible;
      }
    }
   
    if (visible != Visibility.Hidden) {
      boolean memberSignatureMatches;
      if (member instanceof IMethod) {
        IMethod method = (IMethod) member;
        if (method.isConstructor()) {
          memberSignatureMatches = false;
        }
        else {
          int parameterCount = method.getParameterTypes().length;
          String returnType = method.getReturnType();
          if (accessorsOrMutators == BindingReflectionUtils.ACCESSORS_ONLY) {
            memberSignatureMatches = (parameterCount == 0 && !"V".equals(returnType));
          }
          else if (accessorsOrMutators == BindingReflectionUtils.ACCESSORS_OR_VOID) {
            memberSignatureMatches = (parameterCount == 0);
          }
          else if (accessorsOrMutators == BindingReflectionUtils.VOID_ONLY) {
            memberSignatureMatches = (parameterCount == 0 && "V".equals(returnType));
          }
          else {
            memberSignatureMatches = (parameterCount == 1 && "V".equals(returnType));
          }
        }
      }
      else {
        memberSignatureMatches = true;
      }

      if (memberSignatureMatches) {
        String memberName = member.getElementName();
        String lowercaseMemberName = memberName.toLowerCase();

        int prefixLength = prefix.length();
        if ((requireExactNameMatch && lowercaseMemberName.equals(nameStartingWith)) || (!requireExactNameMatch && lowercaseMemberName.startsWith(nameStartingWith))) {
          String bindingName = BindingReflectionUtils.toLowercaseFirstLetter(memberName.substring(prefixLength));
          //System.out.println("BindingReflectionUtils.getBindingKeyIfMatches:   bindingName = " + bindingName);
          if (nameStartingWith.length() > 0 || !bindingName.startsWith("_")) {
            if (visible == Visibility.MaybeVisible) {
              String packageName = type.getPackageFragment().getElementName();
              String kvcProtectedAccessorClassName = packageName.length() == 0 ? "KeyValueCodingProtectedAccessor" : (packageName + ".KeyValueCodingProtectedAccessor");
              IType kvcProtectedAccessor = type.getJavaProject().findType(kvcProtectedAccessorClassName);
              if (kvcProtectedAccessor != null) {
                visible = Visibility.Visible;
              }
            }
           
            if (visible == Visibility.Visible) {
              bindingKey = new BindingValueKey(bindingName, type, member, javaProject, cache);
            }
          }
        }
      }
    }
View Full Code Here

  }

  protected static void _fillInCompletionProposals(List<BindingValueKey> bindingKeys, String token, int tokenOffset, int offset, Set<WodCompletionProposal> completionProposalsSet, boolean showUsefulSystemBindings) {
    Iterator<BindingValueKey> bindingKeysIter = BindingReflectionUtils.filterSystemBindingValueKeys(bindingKeys, showUsefulSystemBindings).iterator();
    while (bindingKeysIter.hasNext()) {
      BindingValueKey bindingKey = bindingKeysIter.next();
      WodCompletionProposal completionProposal;
      if (BindingReflectionUtils.bindingPointsToDeprecatedValue(bindingKey)) {
        completionProposal = new WodDeprecatedCompletionProposal(token, tokenOffset, offset, bindingKey.getBindingName());
      } else {
        completionProposal = new WodCompletionProposal(token, tokenOffset, offset, bindingKey.getBindingName());
      }
      completionProposalsSet.add(completionProposal);
    }
  }
View Full Code Here

TOP

Related Classes of org.objectstyle.wolips.bindings.wod.BindingValueKey

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.