mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-10-01 13:11:39 +07:00
show evaluate exceptions text in red
This commit is contained in:
@@ -113,11 +113,14 @@ public class JavaValue extends XNamedValue implements NodeDescriptorProvider {
|
||||
if (myValueDescriptor.isString()) {
|
||||
presentation = new TypedStringValuePresentation(StringUtil.unquoteString(value), type);
|
||||
}
|
||||
else if (myValueDescriptor.getLastRenderer() instanceof ToStringRenderer) {
|
||||
presentation = new XRegularValuePresentation(StringUtil.wrapWithDoubleQuote(value), type);
|
||||
}
|
||||
else {
|
||||
presentation = new XRegularValuePresentation(value, type);
|
||||
EvaluateException exception = myValueDescriptor.getEvaluateException();
|
||||
if (myValueDescriptor.getLastRenderer() instanceof ToStringRenderer && exception == null) {
|
||||
presentation = new XRegularValuePresentation(StringUtil.wrapWithDoubleQuote(value), type);
|
||||
}
|
||||
else {
|
||||
presentation = new JavaValuePresentation(value, type, exception != null ? exception.getMessage() : null);
|
||||
}
|
||||
}
|
||||
if (value.length() > XValueNode.MAX_VALUE_LENGTH) {
|
||||
node.setFullValueEvaluator(new XFullValueEvaluator() {
|
||||
@@ -150,6 +153,37 @@ public class JavaValue extends XNamedValue implements NodeDescriptorProvider {
|
||||
});
|
||||
}
|
||||
|
||||
private static class JavaValuePresentation extends XValuePresentation {
|
||||
private final String myValue;
|
||||
private final String myType;
|
||||
private final String myError;
|
||||
|
||||
public JavaValuePresentation(@NotNull String value, @Nullable String type, @Nullable String error) {
|
||||
myValue = value;
|
||||
myType = type;
|
||||
myError = error;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getType() {
|
||||
return myType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderValue(@NotNull XValueTextRenderer renderer) {
|
||||
if (myError != null) {
|
||||
if (myValue.endsWith(myError)) {
|
||||
renderer.renderValue(myValue.substring(0, myValue.length() - myError.length()));
|
||||
}
|
||||
renderer.renderError(myError);
|
||||
}
|
||||
else {
|
||||
renderer.renderValue(myValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String getValueString() {
|
||||
return splitValue(myValueDescriptor.getValueLabel())[1];
|
||||
}
|
||||
|
||||
+5
@@ -91,5 +91,10 @@ public abstract class XValuePresentation {
|
||||
* Appends {@code symbol} which is not part of the value
|
||||
*/
|
||||
void renderSpecialSymbol(@NotNull String symbol);
|
||||
|
||||
/**
|
||||
* Appends red colored {@code error}
|
||||
*/
|
||||
void renderError(@NotNull String error);
|
||||
}
|
||||
}
|
||||
+5
@@ -119,6 +119,11 @@ public class XValuePresentationUtil {
|
||||
myBuilder.append(comment);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderError(@NotNull String error) {
|
||||
myBuilder.append(error);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderSpecialSymbol(@NotNull String symbol) {
|
||||
myBuilder.append(symbol);
|
||||
|
||||
+5
@@ -60,6 +60,11 @@ class XValueTextRendererImpl extends XValueTextRendererBase {
|
||||
myText.append(comment, SimpleTextAttributes.GRAY_ATTRIBUTES);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderError(@NotNull String error) {
|
||||
myText.append(error, SimpleTextAttributes.ERROR_ATTRIBUTES);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderSpecialSymbol(@NotNull String symbol) {
|
||||
myText.append(symbol, SimpleTextAttributes.REGULAR_ATTRIBUTES);
|
||||
|
||||
Reference in New Issue
Block a user