Search in sources :

Example 1 with XStringValuePresentation

use of com.intellij.xdebugger.frame.presentation.XStringValuePresentation in project go-lang-idea-plugin by go-lang-plugin-org.

the class DlvXValue method getPresentation.

@NotNull
private XValuePresentation getPresentation() {
    String value = myVariable.value;
    if (myVariable.isNumber())
        return new XNumericValuePresentation(value);
    if (myVariable.isString())
        return new XStringValuePresentation(value);
    if (myVariable.isBool()) {
        return new XValuePresentation() {

            @Override
            public void renderValue(@NotNull XValueTextRenderer renderer) {
                renderer.renderValue(value);
            }
        };
    }
    String type = myVariable.type;
    boolean isSlice = myVariable.isSlice();
    boolean isArray = myVariable.isArray();
    if (isSlice || isArray) {
        return new XRegularValuePresentation("len:" + myVariable.len + (isSlice ? ", cap:" + myVariable.cap : ""), type.replaceFirst("struct ", ""));
    }
    String prefix = myVariable.type + " ";
    return new XRegularValuePresentation(StringUtil.startsWith(value, prefix) ? value.replaceFirst(Pattern.quote(prefix), "") : value, type);
}
Also used : XValuePresentation(com.intellij.xdebugger.frame.presentation.XValuePresentation) XNumericValuePresentation(com.intellij.xdebugger.frame.presentation.XNumericValuePresentation) XStringValuePresentation(com.intellij.xdebugger.frame.presentation.XStringValuePresentation) NotNull(org.jetbrains.annotations.NotNull) XRegularValuePresentation(com.intellij.xdebugger.frame.presentation.XRegularValuePresentation) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with XStringValuePresentation

use of com.intellij.xdebugger.frame.presentation.XStringValuePresentation in project intellij-plugins by JetBrains.

the class DartVmServiceValue method computeRegExpPresentation.

private boolean computeRegExpPresentation(@NotNull final XValueNode node) {
    if (myInstanceRef.getKind() == InstanceKind.RegExp) {
        // The pattern is always an instance of kind String.
        final InstanceRef pattern = myInstanceRef.getPattern();
        assert pattern.getKind() == InstanceKind.String : pattern;
        final String patternString = StringUtil.replace(pattern.getValueAsString(), "\"", "\\\"");
        node.setPresentation(getIcon(), new XStringValuePresentation(patternString) {

            @Nullable
            @Override
            public String getType() {
                return myInstanceRef.getClassRef().getName();
            }
        }, true);
        if (pattern.getValueAsStringIsTruncated()) {
            addFullStringValueEvaluator(node, pattern);
        }
        return true;
    }
    return false;
}
Also used : XStringValuePresentation(com.intellij.xdebugger.frame.presentation.XStringValuePresentation) Nullable(org.jetbrains.annotations.Nullable)

Example 3 with XStringValuePresentation

use of com.intellij.xdebugger.frame.presentation.XStringValuePresentation in project intellij-plugins by JetBrains.

the class DartVmServiceValue method computeVarHavingStringValuePresentation.

private boolean computeVarHavingStringValuePresentation(@NotNull final XValueNode node) {
    // getValueAsString() is provided for the instance kinds: Null, Bool, Double, Int, String (value may be truncated), Float32x4, Float64x2, Int32x4, StackTrace
    switch(myInstanceRef.getKind()) {
        case Null:
        case Bool:
            node.setPresentation(getIcon(), new XKeywordValuePresentation(myInstanceRef.getValueAsString()), false);
            break;
        case Double:
        case Int:
            node.setPresentation(getIcon(), new XNumericValuePresentation(myInstanceRef.getValueAsString()), false);
            break;
        case String:
            final String presentableValue = StringUtil.replace(myInstanceRef.getValueAsString(), "\"", "\\\"");
            node.setPresentation(getIcon(), new XStringValuePresentation(presentableValue), false);
            if (myInstanceRef.getValueAsStringIsTruncated()) {
                addFullStringValueEvaluator(node, myInstanceRef);
            }
            break;
        case Float32x4:
        case Float64x2:
        case Int32x4:
        case StackTrace:
            node.setFullValueEvaluator(new ImmediateFullValueEvaluator("Click to see stack trace...", myInstanceRef.getValueAsString()));
            node.setPresentation(getIcon(), myInstanceRef.getClassRef().getName(), "", true);
            break;
        default:
            return false;
    }
    return true;
}
Also used : XNumericValuePresentation(com.intellij.xdebugger.frame.presentation.XNumericValuePresentation) XKeywordValuePresentation(com.intellij.xdebugger.frame.presentation.XKeywordValuePresentation) XStringValuePresentation(com.intellij.xdebugger.frame.presentation.XStringValuePresentation)

Aggregations

XStringValuePresentation (com.intellij.xdebugger.frame.presentation.XStringValuePresentation)3 XNumericValuePresentation (com.intellij.xdebugger.frame.presentation.XNumericValuePresentation)2 XKeywordValuePresentation (com.intellij.xdebugger.frame.presentation.XKeywordValuePresentation)1 XRegularValuePresentation (com.intellij.xdebugger.frame.presentation.XRegularValuePresentation)1 XValuePresentation (com.intellij.xdebugger.frame.presentation.XValuePresentation)1 NotNull (org.jetbrains.annotations.NotNull)1 Nullable (org.jetbrains.annotations.Nullable)1