예제 #1
0
 /**
  * Gets field by field name and desc
  *
  * @param name name of the field
  * @param desc desc type of the field
  * @return the field if found
  */
 public RefField getField(String name, String desc) {
   RefField[] fields = getFields();
   for (RefField f : fields) {
     if (f.getName().equals(name)) {
       if (desc == null) {
         return f;
       }
       if (desc.equals(f.getTypeDesc())) {
         return f;
       }
     }
   }
   return null;
 }
  public void appendReferencePresentation(
      RefEntity refElement, final StringBuffer buf, final boolean isPackageIncluded) {
    if (refElement instanceof RefImplicitConstructor) {
      buf.append(InspectionsBundle.message("inspection.export.results.implicit.constructor"));
      refElement = ((RefImplicitConstructor) refElement).getOwnerClass();
    }

    buf.append(HTMLComposerImpl.CODE_OPENING);

    if (refElement instanceof RefField) {
      RefField field = (RefField) refElement;
      PsiField psiField = field.getElement();
      buf.append(psiField.getType().getPresentableText());
      buf.append(HTMLComposerImpl.NBSP);
    } else if (refElement instanceof RefMethod) {
      RefMethod method = (RefMethod) refElement;
      PsiMethod psiMethod = (PsiMethod) method.getElement();
      PsiType returnType = psiMethod.getReturnType();

      if (returnType != null) {
        buf.append(returnType.getPresentableText());
        buf.append(HTMLComposerImpl.NBSP);
      }
    }

    buf.append(HTMLComposerImpl.A_HREF_OPENING);

    if (myComposer.myExporter == null) {
      buf.append(((RefElementImpl) refElement).getURL());
    } else {
      buf.append(myComposer.myExporter.getURL(refElement));
    }

    buf.append("\">");

    if (refElement instanceof RefClass && ((RefClass) refElement).isAnonymous()) {
      buf.append(InspectionsBundle.message("inspection.reference.anonymous"));
    } else if (refElement instanceof RefJavaElement
        && ((RefJavaElement) refElement).isSyntheticJSP()) {
      buf.append(XmlStringUtil.escapeString(refElement.getName()));
    } else if (refElement instanceof RefMethod) {
      PsiMethod psiMethod = (PsiMethod) ((RefMethod) refElement).getElement();
      buf.append(psiMethod.getName());
    } else {
      buf.append(refElement.getName());
    }

    buf.append(HTMLComposerImpl.A_CLOSING);

    if (refElement instanceof RefMethod) {
      PsiMethod psiMethod = (PsiMethod) ((RefMethod) refElement).getElement();
      appendMethodParameters(buf, psiMethod, false);
    }

    buf.append(HTMLComposerImpl.CODE_CLOSING);

    if (refElement instanceof RefClass && ((RefClass) refElement).isAnonymous()) {
      buf.append(" ");
      buf.append(InspectionsBundle.message("inspection.export.results.anonymous.ref.in.owner"));
      buf.append(" ");
      myComposer.appendElementReference(
          buf, ((RefElement) refElement.getOwner()), isPackageIncluded);
    } else if (isPackageIncluded) {
      buf.append(" ").append(HTMLComposerImpl.CODE_OPENING).append("(");
      myComposer.appendQualifiedName(buf, refElement.getOwner());
      //      buf.append(RefUtil.getPackageName(refElement));
      buf.append(")").append(HTMLComposerImpl.CODE_CLOSING);
    }
  }