mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
cleanup
This commit is contained in:
@@ -53,16 +53,7 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* User: lex
|
||||
* Date: Sep 18, 2003
|
||||
* Time: 8:00:25 PM
|
||||
*/
|
||||
@State(
|
||||
name="NodeRendererSettings",
|
||||
storages= {
|
||||
@Storage("debugger.renderers.xml")}
|
||||
)
|
||||
@State(name = "NodeRendererSettings", storages = @Storage("debugger.renderers.xml"))
|
||||
public class NodeRendererSettings implements PersistentStateComponent<Element> {
|
||||
@NonNls private static final String REFERENCE_RENDERER = "Reference renderer";
|
||||
@NonNls public static final String RENDERER_TAG = "Renderer";
|
||||
@@ -131,6 +122,7 @@ public class NodeRendererSettings implements PersistentStateComponent<Element> {
|
||||
myDispatcher.addListener(listener, disposable);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public Element getState() {
|
||||
final Element element = new Element("NodeRendererSettings");
|
||||
@@ -153,6 +145,7 @@ public class NodeRendererSettings implements PersistentStateComponent<Element> {
|
||||
return element;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public void loadState(final Element root) {
|
||||
final String hexEnabled = JDOMExternalizerUtil.readField(root, HEX_VIEW_ENABLED);
|
||||
@@ -244,6 +237,7 @@ public class NodeRendererSettings implements PersistentStateComponent<Element> {
|
||||
|
||||
// user defined renderers must come first
|
||||
myCustomRenderers.iterateRenderers(new InternalIterator<NodeRenderer>() {
|
||||
@Override
|
||||
public boolean visit(final NodeRenderer renderer) {
|
||||
allRenderers.add(renderer);
|
||||
return true;
|
||||
@@ -371,6 +365,7 @@ public class NodeRendererSettings implements PersistentStateComponent<Element> {
|
||||
|
||||
private static LabelRenderer createLabelRenderer(@NonNls final String prefix, @NonNls final String expressionText, @NonNls final String postfix) {
|
||||
final LabelRenderer labelRenderer = new LabelRenderer() {
|
||||
@Override
|
||||
public String calcLabel(ValueDescriptor descriptor, EvaluationContext evaluationContext, DescriptorLabelListener labelListener) throws EvaluateException {
|
||||
final String evaluated = super.calcLabel(descriptor, evaluationContext, labelListener);
|
||||
if (prefix == null && postfix == null) {
|
||||
@@ -401,10 +396,12 @@ public class NodeRendererSettings implements PersistentStateComponent<Element> {
|
||||
myValueExpression.setReferenceExpression(new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, "this.getValue()", "", StdFileTypes.JAVA));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon calcValueIcon(ValueDescriptor descriptor, EvaluationContext evaluationContext, DescriptorLabelListener listener) throws EvaluateException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String calcLabel(ValueDescriptor descriptor, EvaluationContext evaluationContext, DescriptorLabelListener listener) throws EvaluateException {
|
||||
final DescriptorUpdater descriptorUpdater = new DescriptorUpdater(descriptor, listener);
|
||||
|
||||
@@ -434,6 +431,7 @@ public class NodeRendererSettings implements PersistentStateComponent<Element> {
|
||||
return new Pair<>(NULL_LABEL_COMPUTABLE, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUniqueId() {
|
||||
return "MapEntry renderer";
|
||||
}
|
||||
@@ -458,10 +456,12 @@ public class NodeRendererSettings implements PersistentStateComponent<Element> {
|
||||
}
|
||||
|
||||
private class MyCachedEvaluator extends CachedEvaluator {
|
||||
@Override
|
||||
protected String getClassName() {
|
||||
return MapEntryLabelRenderer.this.getClassName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpressionEvaluator getEvaluator(Project project) throws EvaluateException {
|
||||
return super.getEvaluator(project);
|
||||
}
|
||||
@@ -511,6 +511,7 @@ public class NodeRendererSettings implements PersistentStateComponent<Element> {
|
||||
myValueDescriptor = valueDescriptor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void labelChanged() {
|
||||
myTargetDescriptor.setValueLabel(constructLabelText(getDescriptorLabel(myKeyDescriptor), getDescriptorLabel(myValueDescriptor)));
|
||||
myDelegate.labelChanged();
|
||||
|
||||
+10
-22
@@ -16,19 +16,11 @@
|
||||
package com.intellij.debugger.ui.tree.render;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.InvalidDataException;
|
||||
import com.intellij.openapi.util.JDOMExternalizable;
|
||||
import com.intellij.openapi.util.JDOMExternalizerUtil;
|
||||
import com.intellij.openapi.util.WriteExternalException;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: Feb 12, 2005
|
||||
*/
|
||||
public final class BasicRendererProperties implements Cloneable, JDOMExternalizable{
|
||||
// todo: add class filters here
|
||||
public final class BasicRendererProperties implements Cloneable {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.debugger.ui.tree.render.BasicRendererProperties");
|
||||
|
||||
private static final @NonNls String NAME_OPTION = "NAME";
|
||||
@@ -40,7 +32,7 @@ public final class BasicRendererProperties implements Cloneable, JDOMExternaliza
|
||||
private static final @NonNls String CLASSNAME_OPTION = "QUALIFIED_NAME";
|
||||
private String myClassName;
|
||||
|
||||
private static final @NonNls String SHOWTYPE_OPTION = "SHOW_TYPE";
|
||||
private static final @NonNls String SHOW_TYPE_OPTION = "SHOW_TYPE";
|
||||
private boolean myShowType = true;
|
||||
|
||||
public String getName() {
|
||||
@@ -75,7 +67,7 @@ public final class BasicRendererProperties implements Cloneable, JDOMExternaliza
|
||||
myShowType = showType;
|
||||
}
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"}) public void readExternal(Element element) throws InvalidDataException {
|
||||
public void readExternal(Element element) {
|
||||
myName = null;
|
||||
myClassName = null;
|
||||
for (Element option : element.getChildren("option")) {
|
||||
@@ -90,37 +82,33 @@ public final class BasicRendererProperties implements Cloneable, JDOMExternaliza
|
||||
else if (CLASSNAME_OPTION.equals(optionName)) {
|
||||
myClassName = option.getAttributeValue("value");
|
||||
}
|
||||
else if (SHOWTYPE_OPTION.equals(optionName)) {
|
||||
else if (SHOW_TYPE_OPTION.equals(optionName)) {
|
||||
// default is true
|
||||
myShowType = !"false".equalsIgnoreCase(option.getAttributeValue("value"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"}) public void writeExternal(Element element) throws WriteExternalException {
|
||||
public void writeExternal(Element element) {
|
||||
if (myName != null) {
|
||||
addOption(element, NAME_OPTION, myName);
|
||||
JDOMExternalizerUtil.writeField(element, NAME_OPTION, myName);
|
||||
}
|
||||
if (myEnabled) {
|
||||
// default is false
|
||||
//noinspection ConstantConditions
|
||||
addOption(element, ENABLED_OPTION, Boolean.toString(myEnabled));
|
||||
JDOMExternalizerUtil.writeField(element, ENABLED_OPTION, Boolean.toString(myEnabled));
|
||||
}
|
||||
if (myClassName != null) {
|
||||
addOption(element, CLASSNAME_OPTION, myClassName);
|
||||
JDOMExternalizerUtil.writeField(element, CLASSNAME_OPTION, myClassName);
|
||||
}
|
||||
if (!myShowType) {
|
||||
// default is true
|
||||
//noinspection ConstantConditions
|
||||
addOption(element, SHOWTYPE_OPTION, Boolean.toString(myShowType));
|
||||
JDOMExternalizerUtil.writeField(element, SHOW_TYPE_OPTION, Boolean.toString(myShowType));
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
private static void addOption(final Element element, final String optionName, final String optionValue) {
|
||||
JDOMExternalizerUtil.writeField(element, optionName, optionValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BasicRendererProperties clone() {
|
||||
try {
|
||||
return (BasicRendererProperties)super.clone();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 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.
|
||||
@@ -21,8 +21,6 @@ import com.intellij.debugger.engine.evaluation.EvaluationContext;
|
||||
import com.intellij.debugger.ui.impl.watch.ValueDescriptorImpl;
|
||||
import com.intellij.debugger.ui.tree.ValueDescriptor;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.InvalidDataException;
|
||||
import com.intellij.openapi.util.WriteExternalException;
|
||||
import com.sun.jdi.ObjectReference;
|
||||
import com.sun.jdi.Value;
|
||||
import org.jdom.Element;
|
||||
@@ -47,18 +45,22 @@ public abstract class NodeRendererImpl implements NodeRenderer{
|
||||
myProperties.setName(presentableName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return myProperties.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setName(String name) {
|
||||
myProperties.setName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return myProperties.isEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnabled(boolean enabled) {
|
||||
myProperties.setEnabled(enabled);
|
||||
}
|
||||
@@ -71,10 +73,12 @@ public abstract class NodeRendererImpl implements NodeRenderer{
|
||||
myProperties.setShowType(showType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon calcValueIcon(ValueDescriptor descriptor, EvaluationContext evaluationContext, DescriptorLabelListener listener) throws EvaluateException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NodeRendererImpl clone() {
|
||||
try {
|
||||
final NodeRendererImpl cloned = (NodeRendererImpl)super.clone();
|
||||
@@ -87,11 +91,13 @@ public abstract class NodeRendererImpl implements NodeRenderer{
|
||||
return null;
|
||||
}
|
||||
|
||||
public void readExternal(Element element) throws InvalidDataException {
|
||||
@Override
|
||||
public void readExternal(Element element) {
|
||||
myProperties.readExternal(element);
|
||||
}
|
||||
|
||||
public void writeExternal(Element element) throws WriteExternalException {
|
||||
@Override
|
||||
public void writeExternal(Element element) {
|
||||
myProperties.writeExternal(element);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,9 +25,7 @@ import com.intellij.debugger.impl.DebuggerUtilsEx;
|
||||
import com.intellij.debugger.ui.tree.DebuggerTreeNode;
|
||||
import com.intellij.debugger.ui.tree.NodeDescriptor;
|
||||
import com.intellij.debugger.ui.tree.ValueDescriptor;
|
||||
import com.intellij.openapi.util.InvalidDataException;
|
||||
import com.intellij.openapi.util.JDOMExternalizerUtil;
|
||||
import com.intellij.openapi.util.WriteExternalException;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.CommonClassNames;
|
||||
import com.intellij.psi.PsiElement;
|
||||
@@ -52,18 +50,22 @@ public class ToStringRenderer extends NodeRendererImpl {
|
||||
setEnabled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUniqueId() {
|
||||
return UNIQUE_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNls String getName() {
|
||||
return "toString";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setName(String name) {
|
||||
// prohibit change
|
||||
}
|
||||
|
||||
@Override
|
||||
public ToStringRenderer clone() {
|
||||
final ToStringRenderer cloned = (ToStringRenderer)super.clone();
|
||||
final ClassFilter[] classFilters = (myClassFilters.length > 0)? new ClassFilter[myClassFilters.length] : ClassFilter.EMPTY_ARRAY;
|
||||
@@ -74,10 +76,12 @@ public class ToStringRenderer extends NodeRendererImpl {
|
||||
return cloned;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String calcLabel(final ValueDescriptor valueDescriptor, EvaluationContext evaluationContext, final DescriptorLabelListener labelListener)
|
||||
throws EvaluateException {
|
||||
final Value value = valueDescriptor.getValue();
|
||||
BatchEvaluator.getBatchEvaluator(evaluationContext.getDebugProcess()).invoke(new ToStringCommand(evaluationContext, value) {
|
||||
@Override
|
||||
public void evaluationResult(String message) {
|
||||
valueDescriptor.setValueLabel(
|
||||
StringUtil.notNullize(message)
|
||||
@@ -85,6 +89,7 @@ public class ToStringRenderer extends NodeRendererImpl {
|
||||
labelListener.labelChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void evaluationError(String message) {
|
||||
final String msg = value != null? message + " " + DebuggerBundle.message("evaluation.error.cannot.evaluate.tostring", value.type().name()) : message;
|
||||
valueDescriptor.setValueLabelFailed(new EvaluateException(msg, null));
|
||||
@@ -102,6 +107,7 @@ public class ToStringRenderer extends NodeRendererImpl {
|
||||
USE_CLASS_FILTERS = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isApplicable(Type type) {
|
||||
if(!(type instanceof ReferenceType)) {
|
||||
return false;
|
||||
@@ -133,30 +139,36 @@ public class ToStringRenderer extends NodeRendererImpl {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildChildren(Value value, ChildrenBuilder builder, EvaluationContext evaluationContext) {
|
||||
DebugProcessImpl.getDefaultRenderer(value).buildChildren(value, builder, evaluationContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiElement getChildValueExpression(DebuggerTreeNode node, DebuggerContext context) throws EvaluateException {
|
||||
return DebugProcessImpl.getDefaultRenderer(((ValueDescriptor)node.getParent().getDescriptor()).getType())
|
||||
.getChildValueExpression(node, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExpandable(Value value, EvaluationContext evaluationContext, NodeDescriptor parentDescriptor) {
|
||||
return DebugProcessImpl.getDefaultRenderer(value).isExpandable(value, evaluationContext, parentDescriptor);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public void readExternal(Element element) throws InvalidDataException {
|
||||
public void readExternal(Element element) {
|
||||
super.readExternal(element);
|
||||
final String value = JDOMExternalizerUtil.readField(element, "USE_CLASS_FILTERS");
|
||||
USE_CLASS_FILTERS = "true".equalsIgnoreCase(value);
|
||||
myClassFilters = DebuggerUtilsEx.readFilters(element.getChildren("filter"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public void writeExternal(Element element) throws WriteExternalException {
|
||||
public void writeExternal(Element element) {
|
||||
super.writeExternal(element);
|
||||
|
||||
JDOMExternalizerUtil.writeField(element, "USE_CLASS_FILTERS", USE_CLASS_FILTERS? "true" : "false");
|
||||
DebuggerUtilsEx.writeFilters(element, "filter", myClassFilters);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 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.
|
||||
@@ -27,7 +27,6 @@ import java.util.List;
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public class JDOMExternalizerUtil {
|
||||
|
||||
private static final String VALUE_ATTR_NAME = "value";
|
||||
|
||||
public static void writeField(@NotNull Element root, @NotNull @NonNls String fieldName, String value) {
|
||||
|
||||
Reference in New Issue
Block a user