Ejemplo n.º 1
0
 @Nullable
 @NonNls
 private static String htmlEscapeToolTip(@Nullable String unescapedTooltip) {
   return unescapedTooltip == null
       ? null
       : XmlStringUtil.wrapInHtml(XmlStringUtil.escapeString(unescapedTooltip));
 }
  protected void setValue(@Nullable final String value) {
    final XmlTag tag = ensureTagExists();
    final String attributeName = getXmlElementName();
    final String namespace = getXmlApiCompatibleNamespace(getParentHandler());
    final String oldValue = StringUtil.unescapeXml(tag.getAttributeValue(attributeName, namespace));
    final String newValue = XmlStringUtil.escapeString(value);
    if (Comparing.equal(oldValue, newValue, true)) return;

    getManager()
        .runChange(
            new Runnable() {
              public void run() {
                try {
                  XmlAttribute attribute = tag.setAttribute(attributeName, namespace, newValue);
                  setXmlElement(attribute);
                  getManager()
                      .cacheHandler(
                          DomManagerImpl.DOM_ATTRIBUTE_HANDLER_KEY,
                          attribute,
                          AttributeChildInvocationHandler.this);
                } catch (IncorrectOperationException e) {
                  LOG.error(e);
                }
              }
            });
    final DomElement proxy = getProxy();
    final DomElement element = proxy;
    getManager()
        .fireEvent(oldValue != null ? new DomEvent(proxy, false) : new DomEvent(element, true));
  }
Ejemplo n.º 3
0
 public String getToolTip() {
   String toolTip = this.toolTip;
   String description = this.description;
   if (toolTip == null || description == null || !toolTip.contains(DESCRIPTION_PLACEHOLDER))
     return toolTip;
   String decoded =
       StringUtil.replace(
           toolTip, DESCRIPTION_PLACEHOLDER, XmlStringUtil.escapeString(description));
   return XmlStringUtil.wrapInHtml(decoded);
 }
 @Override
 public String getToolTip(int line, Editor editor) {
   LastRevision revision = myRevisions.get(line);
   if (revision != null) {
     return XmlStringUtil.escapeString(
         revision.getAuthor()
             + " "
             + DateFormatUtil.formatDateTime(revision.getDate())
             + "\n"
             + revision.getMessage());
   }
   return null;
 }
 protected Annotation createAnnotation(
     TextRange range, HighlightSeverity severity, @Nullable String message) {
   //noinspection HardCodedStringLiteral
   // TODO: FIXME
   @NonNls
   String tooltip =
       message == null
           ? null
           : "<html><body>" + XmlStringUtil.escapeString(message) + "</body></html>";
   Annotation annotation =
       new Annotation(range.getStartOffset(), range.getEndOffset(), severity, message, tooltip);
   add(annotation);
   return annotation;
 }
 @Nullable
 public String getQualifiedName(final RefEntity refEntity) {
   if (refEntity instanceof RefJavaElement && ((RefJavaElement) refEntity).isSyntheticJSP()) {
     return XmlStringUtil.escapeString(refEntity.getName());
   } else if (refEntity instanceof RefMethod) {
     PsiMethod psiMethod = (PsiMethod) ((RefMethod) refEntity).getElement();
     if (psiMethod != null) {
       return psiMethod.getName();
     } else {
       return refEntity.getName();
     }
   }
   return null;
 }
 @SuppressWarnings("HardCodedStringLiteral")
 @NotNull
 public String getDescription() {
   final StringBuilder buf = StringBuilderSpinAllocator.alloc();
   try {
     buf.append("<html><body>");
     buf.append(getDisplayName());
     if (myInvalidMessage != null && !myInvalidMessage.isEmpty()) {
       buf.append("<br><font color='red'>");
       buf.append(DebuggerBundle.message("breakpoint.warning", myInvalidMessage));
       buf.append("</font>");
     }
     buf.append("&nbsp;<br>&nbsp;");
     buf.append(DebuggerBundle.message("breakpoint.property.name.suspend.policy")).append(" : ");
     if (DebuggerSettings.SUSPEND_NONE.equals(getSuspendPolicy()) || !isSuspend()) {
       buf.append(DebuggerBundle.message("breakpoint.properties.panel.option.suspend.none"));
     } else if (DebuggerSettings.SUSPEND_ALL.equals(getSuspendPolicy())) {
       buf.append(DebuggerBundle.message("breakpoint.properties.panel.option.suspend.all"));
     } else if (DebuggerSettings.SUSPEND_THREAD.equals(getSuspendPolicy())) {
       buf.append(DebuggerBundle.message("breakpoint.properties.panel.option.suspend.thread"));
     }
     buf.append("&nbsp;<br>&nbsp;");
     buf.append(DebuggerBundle.message("breakpoint.property.name.log.message")).append(": ");
     buf.append(isLogEnabled() ? CommonBundle.getYesButtonText() : CommonBundle.getNoButtonText());
     if (isLogExpressionEnabled()) {
       buf.append("&nbsp;<br>&nbsp;");
       buf.append(DebuggerBundle.message("breakpoint.property.name.log.expression")).append(": ");
       buf.append(XmlStringUtil.escapeString(getLogMessage().getText()));
     }
     if (isConditionEnabled()
         && getCondition() != null
         && getCondition().getText() != null
         && !getCondition().getText().isEmpty()) {
       buf.append("&nbsp;<br>&nbsp;");
       buf.append(DebuggerBundle.message("breakpoint.property.name.condition")).append(": ");
       buf.append(XmlStringUtil.escapeString(getCondition().getText()));
     }
     if (isCountFilterEnabled()) {
       buf.append("&nbsp;<br>&nbsp;");
       buf.append(DebuggerBundle.message("breakpoint.property.name.pass.count")).append(": ");
       buf.append(getCountFilter());
     }
     if (isClassFiltersEnabled()) {
       buf.append("&nbsp;<br>&nbsp;");
       buf.append(DebuggerBundle.message("breakpoint.property.name.class.filters")).append(": ");
       ClassFilter[] classFilters = getClassFilters();
       for (ClassFilter classFilter : classFilters) {
         buf.append(classFilter.getPattern()).append(" ");
       }
     }
     if (isInstanceFiltersEnabled()) {
       buf.append("&nbsp;<br>&nbsp;");
       buf.append(DebuggerBundle.message("breakpoint.property.name.instance.filters"));
       InstanceFilter[] instanceFilters = getInstanceFilters();
       for (InstanceFilter instanceFilter : instanceFilters) {
         buf.append(Long.toString(instanceFilter.getId())).append(" ");
       }
     }
     buf.append("</body></html>");
     return buf.toString();
   } finally {
     StringBuilderSpinAllocator.dispose(buf);
   }
 }
 private String escapeString(String line, Function<String, String> escapeFunction) {
   line = XmlStringUtil.escapeString(line);
   return escapeFunction == null ? line : escapeFunction.fun(line);
 }
  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);
    }
  }
 private String escapeString(String line) {
   return XmlStringUtil.escapeString(line);
 }