当前位置: 首页>>代码示例>>Java>>正文


Java Signature.C_UNRESOLVED属性代码示例

本文整理汇总了Java中org.eclipse.jdt.core.Signature.C_UNRESOLVED属性的典型用法代码示例。如果您正苦于以下问题:Java Signature.C_UNRESOLVED属性的具体用法?Java Signature.C_UNRESOLVED怎么用?Java Signature.C_UNRESOLVED使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.eclipse.jdt.core.Signature的用法示例。


在下文中一共展示了Signature.C_UNRESOLVED属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: resolveParameterType

private static final void resolveParameterType(final IMethod method,
    final String parameterType, final StringBuilder result)
    throws JavaModelException {
  final char kind = parameterType.charAt(0);
  switch (kind) {
  case Signature.C_UNRESOLVED:
    final String identifier = parameterType.substring(1,
        parameterType.length() - 1);
    if (resolveType(method.getDeclaringType(), identifier, result)) {
      return;
    }
    if (resolveTypeParameter(method, identifier, result)) {
      return;
    }
    break;
  }
  result.append(parameterType);
}
 
开发者ID:eclipse,项目名称:eclemma,代码行数:18,代码来源:SignatureResolver.java

示例2: getResolvedTypeName

/**
 * Resolves a type name in the context of the declaring type.
 *
 * @param refTypeSig the type name in signature notation (for example 'QVector') this can also be
 *     an array type, but dimensions will be ignored.
 * @param declaringType the context for resolving (type where the reference was made in)
 * @return returns the fully qualified type name or build-in-type name. if a unresolved type
 *     couldn't be resolved null is returned
 * @throws JavaModelException thrown when the type can not be accessed
 */
public static String getResolvedTypeName(String refTypeSig, IType declaringType)
    throws JavaModelException {
  int arrayCount = Signature.getArrayCount(refTypeSig);
  char type = refTypeSig.charAt(arrayCount);
  if (type == Signature.C_UNRESOLVED) {
    String name = ""; // $NON-NLS-1$
    int bracket = refTypeSig.indexOf(Signature.C_GENERIC_START, arrayCount + 1);
    if (bracket > 0) name = refTypeSig.substring(arrayCount + 1, bracket);
    else {
      int semi = refTypeSig.indexOf(Signature.C_SEMICOLON, arrayCount + 1);
      if (semi == -1) {
        throw new IllegalArgumentException();
      }
      name = refTypeSig.substring(arrayCount + 1, semi);
    }
    String[][] resolvedNames = declaringType.resolveType(name);
    if (resolvedNames != null && resolvedNames.length > 0) {
      return JavaModelUtil.concatenateName(resolvedNames[0][0], resolvedNames[0][1]);
    }
    return null;
  } else {
    return Signature.toString(refTypeSig.substring(arrayCount));
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:34,代码来源:JavaModelUtil.java

示例3: appendClassTypeSignatureForAnchor

private static int appendClassTypeSignatureForAnchor(
    char[] string, int start, StringBuffer buffer) {
  // need a minimum 3 chars "Lx;"
  if (start >= string.length - 2) {
    throw new IllegalArgumentException();
  }
  // must start in "L" or "Q"
  char c = string[start];
  if (c != Signature.C_RESOLVED && c != Signature.C_UNRESOLVED) {
    throw new IllegalArgumentException();
  }
  int p = start + 1;
  while (true) {
    if (p >= string.length) {
      throw new IllegalArgumentException();
    }
    c = string[p];
    switch (c) {
      case Signature.C_SEMICOLON:
        // all done
        return p;
      case Signature.C_GENERIC_START:
        int e = scanGenericEnd(string, p + 1);
        // once we hit type arguments there are no more package prefixes
        p = e;
        break;
      case Signature.C_DOT:
        buffer.append('.');
        break;
      case '/':
        buffer.append('/');
        break;
      case Signature.C_DOLLAR:
        // once we hit "$" there are no more package prefixes
        /**
         * Convert '$' in resolved type signatures into '.'. NOTE: This assumes that the type
         * signature is an inner type signature. This is true in most cases, but someone can
         * define a non-inner type name containing a '$'.
         */
        buffer.append('.');
        break;
      default:
        buffer.append(c);
    }
    p++;
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:47,代码来源:Util.java

示例4: methodSignaturesEqual

private static boolean methodSignaturesEqual(IType type2, String methodName,
    String[] paramTypes, boolean isConstructor, IMethod method2) {
  try {
    // Method names must match, unless we're comparing constructors
    if (!isConstructor && !method2.getElementName().equals(methodName)) {
      return false;
    }

    // Only compare ctors to ctors and methods to methods
    if (isConstructor != method2.isConstructor()) {
      return false;
    }

    // Parameter count must match
    String signature2 = method2.getSignature();
    String[] paramTypes2 = Signature.getParameterTypes(signature2);
    if (paramTypes.length != paramTypes2.length) {
      return false;
    }

    // Compare each parameter type
    for (int i = 0; i < paramTypes.length; i++) {
      String paramType = paramTypes[i];
      String paramType2 = paramTypes2[i];

      // Compare array nesting depth ([] = 1, [][] = 2, etc.)
      if (Signature.getArrayCount(paramType) != Signature.getArrayCount(paramType2)) {
        return false;
      }

      // Remove any array nesting and generic type parameters
      paramType = getBaseType(paramType);
      paramType2 = getBaseType(paramType2);

      // Extract the full type names from the signatures
      String paramTypeName = getQualifiedTypeName(paramType);
      String paramTypeName2 = getQualifiedTypeName(paramType2);

      if (isTypeParameter(method2, paramTypeName2)) {
        // Skip parameters whose type is a generic type parameter of the
        // method we're comparing against, or the method's containing class
        continue;

        /*
         * TODO: we're currently not checking the bounds of generic type
         * parameters, so sometimes we may return true here even when the
         * caller's method signature doesn't match the method we're comparing
         * against. We could try to add that logic here, or better still, we
         * could integrate TypeOracle and take advantage of its type searching
         * capabilities.
         */
      }

      // If we run into an unresolved parameter type in the method we're
      // searching, we'll need to resolve that before doing the comparison
      if (paramType2.charAt(0) == Signature.C_UNRESOLVED) {
        paramTypeName2 = resolveTypeName(type2, paramTypeName2);
      }

      // Finally, compare the type names
      if (!paramTypeName.equals(paramTypeName2)) {
        return false;
      }
    }

    // We passed all the checks, so the signatures are equal
    return true;

  } catch (JavaModelException e) {
    CorePluginLog.logError(e,
        "Error comparing method signatures of {0} and {1}", methodName,
        method2.getElementName());
    return false;
  }
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:75,代码来源:JavaModelSearch.java


注:本文中的org.eclipse.jdt.core.Signature.C_UNRESOLVED属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。