show declared type in custom renderers only if requested in settings

This commit is contained in:
Egor.Ushakov
2014-12-22 12:42:24 +03:00
parent 691899db5c
commit 7001ba59fb
10 changed files with 32 additions and 78 deletions
@@ -99,11 +99,6 @@ public class JavaReferringObjectsValue extends JavaValue {
return "Ref";
}
@Override
public String calcValueName() {
return "Ref";
}
@Override
public PsiExpression getDescriptorEvaluation(DebuggerContext context) throws EvaluateException {
return null;
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -97,10 +97,6 @@ public class ArgumentValueDescriptorImpl extends ValueDescriptorImpl{
return myName;
}
public String calcValueName() {
return getName();
}
public PsiExpression getDescriptorEvaluation(DebuggerContext context) throws EvaluateException {
if (!myParameterNameCalcutated) {
return null;
@@ -145,10 +145,6 @@ public abstract class EvaluationDescriptor extends ValueDescriptorImpl{
}
}
public String calcValueName() {
return getName();
}
public PsiExpression getDescriptorEvaluation(DebuggerContext context) throws EvaluateException {
PsiElement evaluationCode = getEvaluationCode(context);
if(evaluationCode instanceof PsiExpressionCodeFragment) {
@@ -33,7 +33,6 @@ import com.intellij.psi.JavaPsiFacade;
import com.intellij.psi.PsiElementFactory;
import com.intellij.psi.PsiExpression;
import com.intellij.util.IncorrectOperationException;
import com.intellij.util.StringBuilderSpinAllocator;
import com.sun.jdi.Field;
import com.sun.jdi.ObjectCollectedException;
import com.sun.jdi.ObjectReference;
@@ -125,19 +124,10 @@ public class FieldDescriptorImpl extends ValueDescriptorImpl implements FieldDes
@Override
public String calcValueName() {
final ClassRenderer classRenderer = NodeRendererSettings.getInstance().getClassRenderer();
StringBuilder buf = StringBuilderSpinAllocator.alloc();
try {
buf.append(getName());
if (classRenderer.SHOW_DECLARED_TYPE) {
buf.append(": ");
buf.append(classRenderer.renderTypeName(myField.typeName()));
}
return buf.toString();
}
finally {
StringBuilderSpinAllocator.dispose(buf);
if (NodeRendererSettings.getInstance().getClassRenderer().SHOW_DECLARED_TYPE) {
return addDeclaredType(myField.typeName());
}
return super.calcValueName();
}
@Override
@@ -26,13 +26,11 @@ import com.intellij.debugger.jdi.StackFrameProxyImpl;
import com.intellij.debugger.settings.NodeRendererSettings;
import com.intellij.debugger.ui.tree.LocalVariableDescriptor;
import com.intellij.debugger.ui.tree.NodeDescriptor;
import com.intellij.debugger.ui.tree.render.ClassRenderer;
import com.intellij.openapi.project.Project;
import com.intellij.psi.JavaPsiFacade;
import com.intellij.psi.PsiElementFactory;
import com.intellij.psi.PsiExpression;
import com.intellij.util.IncorrectOperationException;
import com.intellij.util.StringBuilderSpinAllocator;
import com.sun.jdi.Value;
import org.jetbrains.annotations.NotNull;
@@ -99,19 +97,10 @@ public class LocalVariableDescriptorImpl extends ValueDescriptorImpl implements
@Override
public String calcValueName() {
final ClassRenderer classRenderer = NodeRendererSettings.getInstance().getClassRenderer();
StringBuilder buf = StringBuilderSpinAllocator.alloc();
try {
buf.append(getName());
if (classRenderer.SHOW_DECLARED_TYPE) {
buf.append(": ");
buf.append(classRenderer.renderTypeName(myTypeName));
}
return buf.toString();
}
finally {
StringBuilderSpinAllocator.dispose(buf);
if (NodeRendererSettings.getInstance().getClassRenderer().SHOW_DECLARED_TYPE) {
return addDeclaredType(myTypeName);
}
return super.calcValueName();
}
@Override
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -49,10 +49,6 @@ public class MethodReturnValueDescriptorImpl extends ValueDescriptorImpl{
return myMethod.toString();
}
public String calcValueName() {
return getName();
}
public Type getType() {
if (myValue == null) {
try {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -45,10 +45,6 @@ public class ThisDescriptorImpl extends ValueDescriptorImpl{
return "this";
}
public String calcValueName() {
return getName();
}
public PsiExpression getDescriptorEvaluation(DebuggerContext context) throws EvaluateException {
PsiElementFactory elementFactory = JavaPsiFacade.getInstance(context.getProject()).getElementFactory();
try {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -57,10 +57,6 @@ public class ThrownExceptionValueDescriptorImpl extends ValueDescriptorImpl{
return myExceptionObj.referenceType();
}
public String calcValueName() {
return getName();
}
public PsiExpression getDescriptorEvaluation(DebuggerContext context) throws EvaluateException {
throw new EvaluateException("Evaluation not supported for thrown exception object");
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,11 +29,9 @@ import com.intellij.debugger.engine.evaluation.EvaluationContextImpl;
import com.intellij.debugger.engine.evaluation.TextWithImports;
import com.intellij.debugger.settings.NodeRendererSettings;
import com.intellij.debugger.ui.tree.UserExpressionDescriptor;
import com.intellij.debugger.ui.tree.render.ClassRenderer;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiCodeFragment;
import com.intellij.util.StringBuilderSpinAllocator;
import com.sun.jdi.ObjectReference;
import com.sun.jdi.Value;
@@ -53,22 +51,15 @@ public class UserExpressionDescriptorImpl extends EvaluationDescriptor implement
return myName;
}
@Override
public String calcValueName() {
StringBuilder buffer = StringBuilderSpinAllocator.alloc();
try {
buffer.append(getName());
buffer.append(": ");
final Value value = getValue();
if(value != null) {
final ClassRenderer classRenderer = NodeRendererSettings.getInstance().getClassRenderer();
buffer.append(classRenderer.renderTypeName(value.type().name()));
if (NodeRendererSettings.getInstance().getClassRenderer().SHOW_DECLARED_TYPE) {
Value value = getValue();
if (value != null) {
return addDeclaredType(value.type().name());
}
return buffer.toString();
}
finally {
StringBuilderSpinAllocator.dispose(buffer);
}
return super.calcValueName();
}
protected PsiCodeFragment getEvaluationCode(final StackFrameContext context) throws EvaluateException {
@@ -335,11 +335,6 @@ public abstract class ValueDescriptorImpl extends NodeDescriptorImpl implements
return myValue;
}
@Override
public String calcValueName() {
return null;
}
@Override
public PsiExpression getDescriptorEvaluation(DebuggerContext context) throws EvaluateException {
return null;
@@ -375,7 +370,9 @@ public abstract class ValueDescriptorImpl extends NodeDescriptorImpl implements
return myValueIcon;
}
public abstract String calcValueName();
public String calcValueName() {
return getName();
};
@Override
public void displayAs(NodeDescriptor descriptor) {
@@ -583,4 +580,16 @@ public abstract class ValueDescriptorImpl extends NodeDescriptorImpl implements
public Project getProject() {
return myProject;
}
protected String addDeclaredType(String typeName) {
final ClassRenderer classRenderer = NodeRendererSettings.getInstance().getClassRenderer();
StringBuilder buf = StringBuilderSpinAllocator.alloc();
try {
buf.append(getName()).append(": ").append(classRenderer.renderTypeName(typeName));
return buf.toString();
}
finally {
StringBuilderSpinAllocator.dispose(buf);
}
}
}