コード例 #1
0
  private static void appendMethodReference(IMethod meth, StringBuffer buf)
      throws JavaModelException {
    buf.append(meth.getElementName());

    /*
     * The Javadoc tool for Java SE 8 changed the anchor syntax and now tries to avoid "strange" characters in URLs.
     * This breaks all clients that directly create such URLs.
     * We can't know what format is required, so we just guess by the project's compiler compliance.
     */
    boolean is18OrHigher = JavaModelUtil.is18OrHigher(meth.getJavaProject());
    buf.append(is18OrHigher ? '-' : '(');
    String[] params = meth.getParameterTypes();
    IType declaringType = meth.getDeclaringType();
    boolean isVararg = Flags.isVarargs(meth.getFlags());
    int lastParam = params.length - 1;
    for (int i = 0; i <= lastParam; i++) {
      if (i != 0) {
        buf.append(is18OrHigher ? "-" : ", "); // $NON-NLS-1$ //$NON-NLS-2$
      }
      String curr = Signature.getTypeErasure(params[i]);
      String fullName = JavaModelUtil.getResolvedTypeName(curr, declaringType);
      if (fullName == null) { // e.g. a type parameter "QE;"
        fullName = Signature.toString(Signature.getElementType(curr));
      }
      if (fullName != null) {
        buf.append(fullName);
        int dim = Signature.getArrayCount(curr);
        if (i == lastParam && isVararg) {
          dim--;
        }
        while (dim > 0) {
          buf.append(is18OrHigher ? ":A" : "[]"); // $NON-NLS-1$ //$NON-NLS-2$
          dim--;
        }
        if (i == lastParam && isVararg) {
          buf.append("..."); // $NON-NLS-1$
        }
      }
    }
    buf.append(is18OrHigher ? '-' : ')');
  }
コード例 #2
0
 boolean isValidDestination(ASTNode node) {
   boolean isInterface = node instanceof TypeDeclaration && ((TypeDeclaration) node).isInterface();
   return !(node instanceof AnnotationTypeDeclaration)
       && !(isInterface && !JavaModelUtil.is18OrHigher(fCUnit.getJavaProject()));
 }