show evaluate exceptions text in red

This commit is contained in:
Egor.Ushakov
2014-07-04 12:35:50 +04:00
parent 3b38527170
commit db2625930d
4 changed files with 53 additions and 4 deletions
@@ -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];
}
@@ -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);
}
}
@@ -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);
@@ -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);