From 4088a6f41b0ab276bd171b69ec015d1d4c8ba175 Mon Sep 17 00:00:00 2001 From: Nikolay Chashnikov Date: Mon, 3 Mar 2008 10:44:15 +0300 Subject: [PATCH] javascript debugger settings --- .../actions/CustomizeContextViewAction.java | 2 +- .../actions/QuickEvaluateActionHandler.java | 5 +- ...enericDebuggerParametersRunnerConfigurable.java | 2 +- .../intellij/debugger/ui/JavaDebuggerSupport.java | 29 +++++ .../impl/com/intellij/debugger/ui/ValueHint.java | 17 +-- .../src/messages/DebuggerBundle.properties | 1 - .../src/messages/XDebuggerBundle.properties | 2 + .../intellij/xdebugger/impl/DebuggerSupport.java | 3 + .../intellij/xdebugger/impl/XDebuggerSupport.java | 8 ++ .../intellij/xdebugger/impl/XDebuggerUtilImpl.java | 51 ++++++-- .../impl/actions/QuickEvaluateAction.java | 4 +- .../impl/breakpoints/XBreakpointBase.java | 31 +---- .../impl/breakpoints/XLineBreakpointImpl.java | 6 +- .../breakpoints/ui/XBreakpointPanelProvider.java | 3 + .../impl/evaluate/quick/XQuickEvaluateHandler.java | 45 +++++-- .../xdebugger/impl/evaluate/quick/XValueHint.java | 3 +- .../evaluate/quick/common/AbstractValueHint.java | 19 ++- .../quick/common/QuickEvaluateHandler.java | 4 +- .../impl/evaluate/quick/common/ValueHintType.java | 10 ++ .../evaluate/quick/common/ValueLookupManager.java | 8 +- .../impl}/settings/CompositeConfigurable.java | 20 ++- .../impl}/settings/DebuggerConfigurable.java | 32 +++-- .../settings/DebuggerSettingsPanelProvider.java | 19 +++ .../impl/settings/XDebuggerSettingsManager.java | 139 +++++++++++++++++++++ .../XDebuggerSettingsPanelProviderImpl.java | 27 ++++ .../com/intellij/xdebugger/XDebuggerUtil.java | 3 + .../xdebugger/evaluation/XDebuggerEvaluator.java | 23 +++- .../xdebugger/settings/XDebuggerSettings.java | 31 +++++ .../intellij/xdebugger/XDebuggerSettingsTest.java | 70 +++++++++++ 29 files changed, 511 insertions(+), 106 deletions(-) create mode 100644 xdebugger/impl/com/intellij/xdebugger/impl/evaluate/quick/common/ValueHintType.java rename {debugger/impl/com/intellij/debugger => xdebugger/impl/com/intellij/xdebugger/impl}/settings/CompositeConfigurable.java (70%) rename {debugger/impl/com/intellij/debugger => xdebugger/impl/com/intellij/xdebugger/impl}/settings/DebuggerConfigurable.java (59%) create mode 100644 xdebugger/impl/com/intellij/xdebugger/impl/settings/DebuggerSettingsPanelProvider.java create mode 100644 xdebugger/impl/com/intellij/xdebugger/impl/settings/XDebuggerSettingsManager.java create mode 100644 xdebugger/impl/com/intellij/xdebugger/impl/settings/XDebuggerSettingsPanelProviderImpl.java create mode 100644 xdebugger/openapi/com/intellij/xdebugger/settings/XDebuggerSettings.java create mode 100644 xdebugger/tests/com/intellij/xdebugger/XDebuggerSettingsTest.java diff --git a/debugger/impl/com/intellij/debugger/actions/CustomizeContextViewAction.java b/debugger/impl/com/intellij/debugger/actions/CustomizeContextViewAction.java index 56dddb5750..f5911fa3de 100644 --- a/debugger/impl/com/intellij/debugger/actions/CustomizeContextViewAction.java +++ b/debugger/impl/com/intellij/debugger/actions/CustomizeContextViewAction.java @@ -2,7 +2,7 @@ package com.intellij.debugger.actions; import com.intellij.debugger.DebuggerBundle; import com.intellij.debugger.settings.BaseRenderersConfigurable; -import com.intellij.debugger.settings.CompositeConfigurable; +import com.intellij.xdebugger.impl.settings.CompositeConfigurable; import com.intellij.debugger.settings.NodeRendererSettings; import com.intellij.debugger.settings.UserRenderersConfigurable; import com.intellij.debugger.ui.impl.FrameDebuggerTree; diff --git a/debugger/impl/com/intellij/debugger/actions/QuickEvaluateActionHandler.java b/debugger/impl/com/intellij/debugger/actions/QuickEvaluateActionHandler.java index 7388eb4c3f..7ceeef2f13 100644 --- a/debugger/impl/com/intellij/debugger/actions/QuickEvaluateActionHandler.java +++ b/debugger/impl/com/intellij/debugger/actions/QuickEvaluateActionHandler.java @@ -12,6 +12,7 @@ import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.Project; import com.intellij.xdebugger.impl.evaluate.quick.common.QuickEvaluateHandler; import com.intellij.xdebugger.impl.evaluate.quick.common.AbstractValueHint; +import com.intellij.xdebugger.impl.evaluate.quick.common.ValueHintType; import org.jetbrains.annotations.NotNull; import java.awt.*; @@ -23,7 +24,7 @@ public class QuickEvaluateActionHandler extends QuickEvaluateHandler { return debuggerSession != null && debuggerSession.isPaused(); } - public AbstractValueHint createValueHint(@NotNull final Project project, @NotNull final Editor editor, @NotNull final Point point, final int type) { + public AbstractValueHint createValueHint(@NotNull final Project project, @NotNull final Editor editor, @NotNull final Point point, final ValueHintType type) { return ValueHint.createValueHint(project, editor, point, type); } @@ -32,7 +33,7 @@ public class QuickEvaluateActionHandler extends QuickEvaluateHandler { return debuggerSession != null && debuggerSession.isAttached(); } - public int getValueLookupDelay() { + public int getValueLookupDelay(final Project project) { return DebuggerSettings.getInstance().VALUE_LOOKUP_DELAY; } } diff --git a/debugger/impl/com/intellij/debugger/impl/GenericDebuggerParametersRunnerConfigurable.java b/debugger/impl/com/intellij/debugger/impl/GenericDebuggerParametersRunnerConfigurable.java index f994222532..bdb9e513cc 100644 --- a/debugger/impl/com/intellij/debugger/impl/GenericDebuggerParametersRunnerConfigurable.java +++ b/debugger/impl/com/intellij/debugger/impl/GenericDebuggerParametersRunnerConfigurable.java @@ -1,6 +1,6 @@ package com.intellij.debugger.impl; -import com.intellij.debugger.settings.DebuggerConfigurable; +import com.intellij.xdebugger.impl.settings.DebuggerConfigurable; import com.intellij.debugger.settings.DebuggerSettings; import com.intellij.debugger.engine.DebuggerUtils; import com.intellij.debugger.DebuggerBundle; diff --git a/debugger/impl/com/intellij/debugger/ui/JavaDebuggerSupport.java b/debugger/impl/com/intellij/debugger/ui/JavaDebuggerSupport.java index 6cc39b530b..41b9900c75 100644 --- a/debugger/impl/com/intellij/debugger/ui/JavaDebuggerSupport.java +++ b/debugger/impl/com/intellij/debugger/ui/JavaDebuggerSupport.java @@ -1,6 +1,9 @@ package com.intellij.debugger.ui; import com.intellij.debugger.DebuggerManagerEx; +import com.intellij.debugger.settings.DebuggerGeneralConfigurable; +import com.intellij.debugger.settings.UserRenderersConfigurable; +import com.intellij.debugger.settings.NodeRendererSettings; import com.intellij.debugger.actions.*; import com.intellij.debugger.ui.breakpoints.Breakpoint; import com.intellij.debugger.ui.breakpoints.BreakpointFactory; @@ -9,7 +12,9 @@ import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.editor.Document; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.DialogWrapper; +import com.intellij.openapi.options.Configurable; import com.intellij.xdebugger.impl.DebuggerSupport; +import com.intellij.xdebugger.impl.settings.DebuggerSettingsPanelProvider; import com.intellij.xdebugger.impl.evaluate.quick.common.QuickEvaluateHandler; import com.intellij.xdebugger.impl.actions.DebuggerActionHandler; import com.intellij.xdebugger.impl.breakpoints.ui.AbstractBreakpointPanel; @@ -38,6 +43,7 @@ public class JavaDebuggerSupport extends DebuggerSupport { private ShowExecutionPointActionHandler myShowExecutionPointActionHandler; private EvaluateActionHandler myEvaluateActionHandler; private QuickEvaluateActionHandler myQuickEvaluateHandler; + private JavaDebuggerSettingsPanelProvider myDebuggerSettingsPanelProvider; public JavaDebuggerSupport() { myBreakpointPanelProvider = new JavaBreakpointPanelProvider(); @@ -54,6 +60,7 @@ public class JavaDebuggerSupport extends DebuggerSupport { myShowExecutionPointActionHandler = new ShowExecutionPointActionHandler(); myEvaluateActionHandler = new EvaluateActionHandler(); myQuickEvaluateHandler = new QuickEvaluateActionHandler(); + myDebuggerSettingsPanelProvider = new JavaDebuggerSettingsPanelProvider(); } @NotNull @@ -126,6 +133,11 @@ public class JavaDebuggerSupport extends DebuggerSupport { return myQuickEvaluateHandler; } + @NotNull + public DebuggerSettingsPanelProvider getSettingsPanelProvider() { + return myDebuggerSettingsPanelProvider; + } + private static class JavaBreakpointPanelProvider extends BreakpointPanelProvider { @NotNull public Collection> getBreakpointPanels(@NotNull final Project project, @NotNull final DialogWrapper parentDialog) { @@ -153,4 +165,21 @@ public class JavaDebuggerSupport extends DebuggerSupport { DebuggerManagerEx.getInstanceEx(project).getBreakpointManager().updateAllRequests(); } } + + public static class JavaDebuggerSettingsPanelProvider extends DebuggerSettingsPanelProvider { + public int getPriority() { + return 1; + } + + public Collection getConfigurables(final Project project) { + ArrayList configurables = new ArrayList(); + configurables.add(new DebuggerGeneralConfigurable(project)); + configurables.add(new UserRenderersConfigurable(project)); + return configurables; + } + + public void apply() { + NodeRendererSettings.getInstance().fireRenderersChanged(); + } + } } diff --git a/debugger/impl/com/intellij/debugger/ui/ValueHint.java b/debugger/impl/com/intellij/debugger/ui/ValueHint.java index bec6b8dac4..517bd19fa3 100644 --- a/debugger/impl/com/intellij/debugger/ui/ValueHint.java +++ b/debugger/impl/com/intellij/debugger/ui/ValueHint.java @@ -28,6 +28,7 @@ import com.intellij.ui.SimpleTextAttributes; import com.intellij.util.IncorrectOperationException; import com.intellij.xdebugger.impl.evaluate.quick.common.AbstractValueHintTreeComponent; import com.intellij.xdebugger.impl.evaluate.quick.common.AbstractValueHint; +import com.intellij.xdebugger.impl.evaluate.quick.common.ValueHintType; import com.sun.jdi.PrimitiveValue; import com.sun.jdi.Value; import org.jetbrains.annotations.Nullable; @@ -44,12 +45,12 @@ public class ValueHint extends AbstractValueHint { private static final Logger LOG = Logger.getInstance("#com.intellij.debugger.ui.ValueHint"); private PsiExpression myCurrentExpression = null; - private ValueHint(Project project, Editor editor, Point point, int type, final PsiExpression selectedExpression, final TextRange textRange) { + private ValueHint(Project project, Editor editor, Point point, ValueHintType type, final PsiExpression selectedExpression, final TextRange textRange) { super(project, editor, point, type, textRange); myCurrentExpression = selectedExpression; } - public static ValueHint createValueHint(Project project, Editor editor, Point point, int type) { + public static ValueHint createValueHint(Project project, Editor editor, Point point, ValueHintType type) { Pair pair = getSelectedExpression(project, editor, point, type); return new ValueHint(project, editor, point, type, pair.getFirst(), pair.getSecond()); } @@ -77,9 +78,9 @@ public class ValueHint extends AbstractValueHint { final Value value = evaluator.evaluate(evaluationContext); final WatchItemDescriptor descriptor = new WatchItemDescriptor(getProject(), text, value); - if (!isActiveTootlipApplicable(value) || getType() == MOUSE_OVER_HINT) { + if (!isActiveTootlipApplicable(value) || getType() == ValueHintType.MOUSE_OVER_HINT) { descriptor.setContext(evaluationContext); - if (getType() == MOUSE_OVER_HINT) { + if (getType() == ValueHintType.MOUSE_OVER_HINT) { // force using default renderer for mouse over hint in order to not to call accidentaly methods while rendering // otherwise, if the hint is invoked explicitly, show it with the right "auto" renderer descriptor.setRenderer(debuggerContext.getDebugProcess().getDefaultRenderer(value)); @@ -87,7 +88,7 @@ public class ValueHint extends AbstractValueHint { descriptor.updateRepresentation(evaluationContext, new DescriptorLabelListener() { public void labelChanged() { if(getCurrentRange() != null) { - if(getType() != MOUSE_OVER_HINT || descriptor.isValueValid()) { + if(getType() != ValueHintType.MOUSE_OVER_HINT || descriptor.isValueValid()) { final SimpleColoredText simpleColoredText = DebuggerTreeRenderer.getDescriptorText(debuggerContext, descriptor, true); if (isActiveTootlipApplicable(value)){ simpleColoredText.append(" (" + DebuggerBundle.message("active.tooltip.suggestion") + ")", SimpleTextAttributes.GRAYED_ATTRIBUTES); @@ -156,7 +157,7 @@ public class ValueHint extends AbstractValueHint { }); } if (!showHint(component)) return; - if(getType() == MOUSE_CLICK_HINT) { + if(getType() == ValueHintType.MOUSE_CLICK_HINT) { HintUtil.createInformationLabel(text).requestFocusInWindow(); } } @@ -220,7 +221,7 @@ public class ValueHint extends AbstractValueHint { return null; } - private static Pair getSelectedExpression(final Project project, final Editor editor, final Point point, final int type) { + private static Pair getSelectedExpression(final Project project, final Editor editor, final Point point, final ValueHintType type) { final Ref selectedExpression = Ref.create(null); final Ref currentRange = Ref.create(null); @@ -237,7 +238,7 @@ public class ValueHint extends AbstractValueHint { int selectionStart = editor.getSelectionModel().getSelectionStart(); int selectionEnd = editor.getSelectionModel().getSelectionEnd(); - if((type == MOUSE_CLICK_HINT || type == MOUSE_ALT_OVER_HINT) && (selectionStart <= offset && offset <= selectionEnd)) { + if((type == ValueHintType.MOUSE_CLICK_HINT || type == ValueHintType.MOUSE_ALT_OVER_HINT) && (selectionStart <= offset && offset <= selectionEnd)) { PsiElement ctx = (selectionStart > 0) ? psiFile.findElementAt(selectionStart - 1) : psiFile.findElementAt(selectionStart); try { String text = editor.getSelectionModel().getSelectedText(); diff --git a/resources_eng/src/messages/DebuggerBundle.properties b/resources_eng/src/messages/DebuggerBundle.properties index 72f09a181c..4b0723729d 100644 --- a/resources_eng/src/messages/DebuggerBundle.properties +++ b/resources_eng/src/messages/DebuggerBundle.properties @@ -196,7 +196,6 @@ button.move.up=Move &Up button.move.down=Move &Down label.compound.renderer.configurable.table.header.name=Name label.compound.renderer.configurable.table.header.expression=Expression -debugger.configurable.display.name=Debugger debugger.general.configurable.display.name=General label.debugger.general.configurable.hide.window=Hide debug &window on process termination label.debugger.general.configurable.hotswap.background=Reload classes in &background diff --git a/resources_eng/src/messages/XDebuggerBundle.properties b/resources_eng/src/messages/XDebuggerBundle.properties index bb7892a91c..7d4b95df22 100644 --- a/resources_eng/src/messages/XDebuggerBundle.properties +++ b/resources_eng/src/messages/XDebuggerBundle.properties @@ -1,5 +1,7 @@ xdebugger.colors.page.name=Debugger +debugger.configurable.display.name=Debugger + xdebugger.remove.line.breakpoint.action.text=Remove xdebugger.disable.breakpoint.action.text=Disable xdebugger.enable.breakpoint.action.text=Enable diff --git a/xdebugger/impl/com/intellij/xdebugger/impl/DebuggerSupport.java b/xdebugger/impl/com/intellij/xdebugger/impl/DebuggerSupport.java index 3d4d2080d8..0336fdb502 100644 --- a/xdebugger/impl/com/intellij/xdebugger/impl/DebuggerSupport.java +++ b/xdebugger/impl/com/intellij/xdebugger/impl/DebuggerSupport.java @@ -5,6 +5,7 @@ import com.intellij.openapi.extensions.Extensions; import com.intellij.xdebugger.impl.actions.DebuggerActionHandler; import com.intellij.xdebugger.impl.breakpoints.ui.BreakpointPanelProvider; import com.intellij.xdebugger.impl.evaluate.quick.common.QuickEvaluateHandler; +import com.intellij.xdebugger.impl.settings.DebuggerSettingsPanelProvider; import org.jetbrains.annotations.NotNull; /** @@ -21,6 +22,8 @@ public abstract class DebuggerSupport { @NotNull public abstract BreakpointPanelProvider getBreakpointPanelProvider(); + @NotNull + public abstract DebuggerSettingsPanelProvider getSettingsPanelProvider(); @NotNull public abstract DebuggerActionHandler getStepOverHandler(); diff --git a/xdebugger/impl/com/intellij/xdebugger/impl/XDebuggerSupport.java b/xdebugger/impl/com/intellij/xdebugger/impl/XDebuggerSupport.java index d7ad2be620..cf18a932dc 100644 --- a/xdebugger/impl/com/intellij/xdebugger/impl/XDebuggerSupport.java +++ b/xdebugger/impl/com/intellij/xdebugger/impl/XDebuggerSupport.java @@ -9,6 +9,8 @@ import com.intellij.xdebugger.impl.breakpoints.ui.BreakpointPanelProvider; import com.intellij.xdebugger.impl.breakpoints.ui.XBreakpointPanelProvider; import com.intellij.xdebugger.impl.evaluate.quick.common.QuickEvaluateHandler; import com.intellij.xdebugger.impl.evaluate.quick.XQuickEvaluateHandler; +import com.intellij.xdebugger.impl.settings.DebuggerSettingsPanelProvider; +import com.intellij.xdebugger.impl.settings.XDebuggerSettingsPanelProviderImpl; import org.jetbrains.annotations.NotNull; /** @@ -29,6 +31,7 @@ public class XDebuggerSupport extends DebuggerSupport { private XDebuggerSuspendedActionHandler myShowExecutionPointHandler; private XDebuggerEvaluateActionHandler myEvaluateHandler; private XQuickEvaluateHandler myQuickEvaluateHandler; + private final XDebuggerSettingsPanelProviderImpl mySettingsPanelProvider; public XDebuggerSupport() { myBreakpointPanelProvider = new XBreakpointPanelProvider(); @@ -77,6 +80,7 @@ public class XDebuggerSupport extends DebuggerSupport { }; myEvaluateHandler = new XDebuggerEvaluateActionHandler(); myQuickEvaluateHandler = new XQuickEvaluateHandler(); + mySettingsPanelProvider = new XDebuggerSettingsPanelProviderImpl(); } @NotNull @@ -149,4 +153,8 @@ public class XDebuggerSupport extends DebuggerSupport { return myQuickEvaluateHandler; } + @NotNull + public DebuggerSettingsPanelProvider getSettingsPanelProvider() { + return mySettingsPanelProvider; + } } diff --git a/xdebugger/impl/com/intellij/xdebugger/impl/XDebuggerUtilImpl.java b/xdebugger/impl/com/intellij/xdebugger/impl/XDebuggerUtilImpl.java index 10d3b3534c..cd1fba4d43 100644 --- a/xdebugger/impl/com/intellij/xdebugger/impl/XDebuggerUtilImpl.java +++ b/xdebugger/impl/com/intellij/xdebugger/impl/XDebuggerUtilImpl.java @@ -10,24 +10,31 @@ import com.intellij.openapi.fileEditor.FileDocumentManager; import com.intellij.openapi.fileEditor.FileEditorManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.openapi.extensions.Extensions; +import com.intellij.openapi.components.PersistentStateComponent; import com.intellij.xdebugger.XDebuggerManager; import com.intellij.xdebugger.XDebuggerUtil; import com.intellij.xdebugger.XSourcePosition; +import com.intellij.xdebugger.settings.XDebuggerSettings; import com.intellij.xdebugger.impl.breakpoints.ui.grouping.XBreakpointFileGroupingRule; import com.intellij.xdebugger.impl.breakpoints.XBreakpointUtil; import com.intellij.xdebugger.breakpoints.*; import com.intellij.xdebugger.breakpoints.ui.XBreakpointGroupingRule; +import com.intellij.util.ReflectionUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.*; +import java.lang.reflect.Type; +import java.lang.reflect.TypeVariable; /** * @author nik */ public class XDebuggerUtilImpl extends XDebuggerUtil { private XLineBreakpointType[] myLineBreakpointTypes; - private Map>, XBreakpointType> myTypeByClass; + private Map, XBreakpointType> myBreakpointTypeByClass; + private Map, XDebuggerSettings> mySettingsByClass; public XLineBreakpointType[] getLineBreakpointTypes() { if (myLineBreakpointTypes == null) { @@ -78,19 +85,29 @@ public class XDebuggerUtilImpl extends XDebuggerUtil { } public > XBreakpointType findBreakpointType(@NotNull Class> typeClass) { - if (myTypeByClass == null) { - myTypeByClass = new HashMap>, XBreakpointType>(); + if (myBreakpointTypeByClass == null) { + myBreakpointTypeByClass = new HashMap, XBreakpointType>(); for (XBreakpointType breakpointType : XBreakpointUtil.getBreakpointTypes()) { - if (breakpointType.getClass().equals(typeClass)) { - myTypeByClass.put(typeClass, breakpointType); - } + myBreakpointTypeByClass.put(breakpointType.getClass(), breakpointType); } } - XBreakpointType type = myTypeByClass.get(typeClass); + XBreakpointType type = myBreakpointTypeByClass.get(typeClass); //noinspection unchecked return (XBreakpointType)type; } + public > T getDebuggerSettings(Class aClass) { + if (mySettingsByClass == null) { + mySettingsByClass = new HashMap, XDebuggerSettings>(); + XDebuggerSettings[] extensions = Extensions.getExtensions(XDebuggerSettings.EXTENSION_POINT); + for (XDebuggerSettings extension : extensions) { + mySettingsByClass.put(extension.getClass(), extension); + } + } + //noinspection unchecked + return (T)mySettingsByClass.get(aClass); + } + @Nullable public XSourcePosition createPosition(@NotNull final VirtualFile file, final int line) { return XSourcePositionImpl.create(file, line); @@ -139,4 +156,24 @@ public class XDebuggerUtilImpl extends XDebuggerUtil { } }; } + + public static Class getStateClass(final Class aClass) { + Type type = resolveVariable(PersistentStateComponent.class.getTypeParameters()[0], aClass); + return ReflectionUtil.getRawType(type); + } + + private static Type resolveVariable(final TypeVariable variable, final Class aClass) { + Type type; + Class current = aClass; + while ((type = ReflectionUtil.resolveVariable(variable, current, false)) == null) { + current = current.getSuperclass(); + if (current == null) { + return null; + } + } + if (type instanceof TypeVariable) { + return resolveVariable((TypeVariable)type, aClass); + } + return type; + } } diff --git a/xdebugger/impl/com/intellij/xdebugger/impl/actions/QuickEvaluateAction.java b/xdebugger/impl/com/intellij/xdebugger/impl/actions/QuickEvaluateAction.java index a87d79f2d9..4463b00f7a 100644 --- a/xdebugger/impl/com/intellij/xdebugger/impl/actions/QuickEvaluateAction.java +++ b/xdebugger/impl/com/intellij/xdebugger/impl/actions/QuickEvaluateAction.java @@ -6,9 +6,9 @@ import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.LogicalPosition; import com.intellij.openapi.project.Project; import com.intellij.xdebugger.impl.DebuggerSupport; -import com.intellij.xdebugger.impl.evaluate.quick.common.AbstractValueHint; import com.intellij.xdebugger.impl.evaluate.quick.common.QuickEvaluateHandler; import com.intellij.xdebugger.impl.evaluate.quick.common.ValueLookupManager; +import com.intellij.xdebugger.impl.evaluate.quick.common.ValueHintType; import org.jetbrains.annotations.NotNull; /** @@ -36,7 +36,7 @@ public class QuickEvaluateAction extends XDebuggerActionBase { if(editor != null) { LogicalPosition logicalPosition = editor.getCaretModel().getLogicalPosition(); - ValueLookupManager.getInstance(project).showHint(myHandler, editor, editor.logicalPositionToXY(logicalPosition), AbstractValueHint.MOUSE_CLICK_HINT); + ValueLookupManager.getInstance(project).showHint(myHandler, editor, editor.logicalPositionToXY(logicalPosition), ValueHintType.MOUSE_CLICK_HINT); } } diff --git a/xdebugger/impl/com/intellij/xdebugger/impl/breakpoints/XBreakpointBase.java b/xdebugger/impl/com/intellij/xdebugger/impl/breakpoints/XBreakpointBase.java index 22fae3e4af..3efa30f99d 100644 --- a/xdebugger/impl/com/intellij/xdebugger/impl/breakpoints/XBreakpointBase.java +++ b/xdebugger/impl/com/intellij/xdebugger/impl/breakpoints/XBreakpointBase.java @@ -1,18 +1,16 @@ package com.intellij.xdebugger.impl.breakpoints; -import com.intellij.openapi.components.PersistentStateComponent; import com.intellij.openapi.fileEditor.OpenFileDescriptor; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.UserDataHolderBase; import com.intellij.pom.Navigatable; -import com.intellij.util.ReflectionUtil; import com.intellij.util.xmlb.XmlSerializer; -import com.intellij.util.xmlb.SkipDefaultValuesSerializationFilters; import com.intellij.util.xmlb.annotations.Attribute; import com.intellij.util.xmlb.annotations.Property; import com.intellij.util.xmlb.annotations.Tag; import com.intellij.xdebugger.XSourcePosition; +import com.intellij.xdebugger.impl.XDebuggerUtilImpl; import com.intellij.xdebugger.breakpoints.SuspendPolicy; import com.intellij.xdebugger.breakpoints.XBreakpoint; import com.intellij.xdebugger.breakpoints.XBreakpointProperties; @@ -21,16 +19,13 @@ import org.jdom.Element; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.lang.reflect.Type; -import java.lang.reflect.TypeVariable; - /** * @author nik */ public class XBreakpointBase, P extends XBreakpointProperties, S extends XBreakpointBase.BreakpointState> extends UserDataHolderBase implements XBreakpoint

{ private final XBreakpointType myType; private final @Nullable P myProperties; - private final S myState; + protected final S myState; private final XBreakpointManagerImpl myBreakpointManager; public XBreakpointBase(final XBreakpointType type, XBreakpointManagerImpl breakpointManager, final @Nullable P properties, final S state) { @@ -47,7 +42,7 @@ public class XBreakpointBase, P extends XBreakpointP myProperties = type.createProperties(); if (myProperties != null) { //noinspection unchecked - Object state = XmlSerializer.deserialize(myState.getPropertiesElement(), getStateClass(myProperties.getClass())); + Object state = XmlSerializer.deserialize(myState.getPropertiesElement(), XDebuggerUtilImpl.getStateClass(myProperties.getClass())); //noinspection unchecked myProperties.loadState(state); } @@ -65,26 +60,6 @@ public class XBreakpointBase, P extends XBreakpointP myBreakpointManager.fireBreakpointChanged(this); } - private static Class getStateClass(final Class propertiesClass) { - Type type = resolveVariable(PersistentStateComponent.class.getTypeParameters()[0], propertiesClass); - return ReflectionUtil.getRawType(type); - } - - private static Type resolveVariable(final TypeVariable variable, final Class aClass) { - Type type; - Class current = aClass; - while ((type = ReflectionUtil.resolveVariable(variable, current, false)) == null) { - current = current.getSuperclass(); - if (current == null) { - return null; - } - } - if (type instanceof TypeVariable) { - return resolveVariable((TypeVariable)type, aClass); - } - return type; - } - public XSourcePosition getSourcePosition() { return null; } diff --git a/xdebugger/impl/com/intellij/xdebugger/impl/breakpoints/XLineBreakpointImpl.java b/xdebugger/impl/com/intellij/xdebugger/impl/breakpoints/XLineBreakpointImpl.java index 1765ceddda..b6ce45c761 100644 --- a/xdebugger/impl/com/intellij/xdebugger/impl/breakpoints/XLineBreakpointImpl.java +++ b/xdebugger/impl/com/intellij/xdebugger/impl/breakpoints/XLineBreakpointImpl.java @@ -122,11 +122,11 @@ public class XLineBreakpointImpl

extends XBreak } public int getLine() { - return getState().getLine(); + return myState.getLine(); } public String getFileUrl() { - return getState().getFileUrl(); + return myState.getFileUrl(); } @Nullable @@ -236,7 +236,7 @@ public class XLineBreakpointImpl

extends XBreak private void setLine(final int line) { if (getLine() != line) { - getState().setLine(line); + myState.setLine(line); fireBreakpointChanged(); } } diff --git a/xdebugger/impl/com/intellij/xdebugger/impl/breakpoints/ui/XBreakpointPanelProvider.java b/xdebugger/impl/com/intellij/xdebugger/impl/breakpoints/ui/XBreakpointPanelProvider.java index a07851ce6a..4f350eca4d 100644 --- a/xdebugger/impl/com/intellij/xdebugger/impl/breakpoints/ui/XBreakpointPanelProvider.java +++ b/xdebugger/impl/com/intellij/xdebugger/impl/breakpoints/ui/XBreakpointPanelProvider.java @@ -29,6 +29,9 @@ public class XBreakpointPanelProvider extends BreakpointPanelProvider type : XDebuggerUtil.getInstance().getLineBreakpointTypes()) { XLineBreakpoint breakpoint = breakpointManager.findBreakpointAtLine(type, file, line); if (breakpoint != null) { diff --git a/xdebugger/impl/com/intellij/xdebugger/impl/evaluate/quick/XQuickEvaluateHandler.java b/xdebugger/impl/com/intellij/xdebugger/impl/evaluate/quick/XQuickEvaluateHandler.java index d58b6a6ce7..29b8559a23 100644 --- a/xdebugger/impl/com/intellij/xdebugger/impl/evaluate/quick/XQuickEvaluateHandler.java +++ b/xdebugger/impl/com/intellij/xdebugger/impl/evaluate/quick/XQuickEvaluateHandler.java @@ -1,15 +1,18 @@ package com.intellij.xdebugger.impl.evaluate.quick; -import org.jetbrains.annotations.NotNull; -import com.intellij.openapi.project.Project; import com.intellij.openapi.editor.Editor; +import com.intellij.openapi.editor.SelectionModel; +import com.intellij.openapi.project.Project; import com.intellij.openapi.util.TextRange; -import com.intellij.xdebugger.impl.evaluate.quick.common.QuickEvaluateHandler; -import com.intellij.xdebugger.impl.evaluate.quick.common.AbstractValueHint; -import com.intellij.xdebugger.XDebuggerManager; import com.intellij.xdebugger.XDebugSession; +import com.intellij.xdebugger.XDebuggerManager; import com.intellij.xdebugger.evaluation.XDebuggerEvaluator; import com.intellij.xdebugger.frame.XSuspendContext; +import com.intellij.xdebugger.impl.evaluate.quick.common.AbstractValueHint; +import com.intellij.xdebugger.impl.evaluate.quick.common.QuickEvaluateHandler; +import com.intellij.xdebugger.impl.evaluate.quick.common.ValueHintType; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.awt.*; @@ -26,7 +29,7 @@ public class XQuickEvaluateHandler extends QuickEvaluateHandler { return context != null && context.getEvaluator() != null; } - public AbstractValueHint createValueHint(@NotNull final Project project, @NotNull final Editor editor, @NotNull final Point point, final int type) { + public AbstractValueHint createValueHint(@NotNull final Project project, @NotNull final Editor editor, @NotNull final Point point, final ValueHintType type) { XDebugSession session = XDebuggerManager.getInstance(project).getCurrentSession(); if (session == null) return null; @@ -34,17 +37,41 @@ public class XQuickEvaluateHandler extends QuickEvaluateHandler { XDebuggerEvaluator evaluator = suspendContext.getEvaluator(); if (evaluator == null) return null; - TextRange range = evaluator.getSelectedExpressionRange(editor, AbstractValueHint.calculateOffset(editor, point)); + int offset = AbstractValueHint.calculateOffset(editor, point); + TextRange range = getExpressionRange(evaluator, project, type, editor, offset); if (range == null) return null; return new XValueHint(project, editor, point, type, range, evaluator, session); } + @Nullable + private static TextRange getExpressionRange(final XDebuggerEvaluator evaluator, final Project project, final ValueHintType type, final Editor editor, + final int offset) { + SelectionModel selectionModel = editor.getSelectionModel(); + int selectionStart = selectionModel.getSelectionStart(); + int selectionEnd = selectionModel.getSelectionEnd(); + if ((type == ValueHintType.MOUSE_CLICK_HINT || type == ValueHintType.MOUSE_ALT_OVER_HINT) && selectionModel.hasSelection() + && selectionStart <= offset && offset <= selectionEnd) { + return new TextRange(selectionStart, selectionEnd); + } + return evaluator.getExpressionRangeAtOffset(project, editor.getDocument(), offset); + } + public boolean canShowHint(@NotNull final Project project) { return isEnabled(project); } - public int getValueLookupDelay() { - return 700;//todo[nik] use settings + public int getValueLookupDelay(final Project project) { + XDebugSession session = XDebuggerManager.getInstance(project).getCurrentSession(); + if (session != null) { + XSuspendContext suspendContext = session.getSuspendContext(); + if (suspendContext != null) { + XDebuggerEvaluator evaluator = suspendContext.getEvaluator(); + if (evaluator != null) { + return evaluator.getValuePopupDelay(); + } + } + } + return 700; } } diff --git a/xdebugger/impl/com/intellij/xdebugger/impl/evaluate/quick/XValueHint.java b/xdebugger/impl/com/intellij/xdebugger/impl/evaluate/quick/XValueHint.java index 54b40456a6..74483d3ba6 100644 --- a/xdebugger/impl/com/intellij/xdebugger/impl/evaluate/quick/XValueHint.java +++ b/xdebugger/impl/com/intellij/xdebugger/impl/evaluate/quick/XValueHint.java @@ -13,6 +13,7 @@ import com.intellij.xdebugger.evaluation.XDebuggerEvaluator; import com.intellij.xdebugger.frame.XValue; import com.intellij.xdebugger.frame.XValueNode; import com.intellij.xdebugger.impl.evaluate.quick.common.AbstractValueHint; +import com.intellij.xdebugger.impl.evaluate.quick.common.ValueHintType; import com.intellij.xdebugger.impl.ui.DebuggerUIUtil; import com.intellij.xdebugger.impl.ui.XDebuggerUIConstants; import com.intellij.xdebugger.impl.ui.tree.XDebuggerTree; @@ -32,7 +33,7 @@ public class XValueHint extends AbstractValueHint { private final XDebugSession myDebugSession; private String myExpression; - public XValueHint(final Project project, final Editor editor, final Point point, final int type, final TextRange textRange, + public XValueHint(final Project project, final Editor editor, final Point point, final ValueHintType type, final TextRange textRange, final XDebuggerEvaluator evaluator, final XDebugSession session) { super(project, editor, point, type, textRange); myEvaluator = evaluator; diff --git a/xdebugger/impl/com/intellij/xdebugger/impl/evaluate/quick/common/AbstractValueHint.java b/xdebugger/impl/com/intellij/xdebugger/impl/evaluate/quick/common/AbstractValueHint.java index ab7c1a84d7..394e008076 100644 --- a/xdebugger/impl/com/intellij/xdebugger/impl/evaluate/quick/common/AbstractValueHint.java +++ b/xdebugger/impl/com/intellij/xdebugger/impl/evaluate/quick/common/AbstractValueHint.java @@ -34,9 +34,6 @@ public abstract class AbstractValueHint { private static final Logger LOG = Logger.getInstance("#com.intellij.xdebugger.impl.evaluate.quick.common.AbstractValueHint"); @NonNls private final static String DIMENSION_SERVICE_KEY = "DebuggerActiveHint"; private static final Icon COLLAPSED_TREE_ICON = IconLoader.getIcon("/general/add.png"); - public final static int MOUSE_OVER_HINT = 0; - public final static int MOUSE_ALT_OVER_HINT = 1; - public final static int MOUSE_CLICK_HINT = 2; private static final int HINT_TIMEOUT = 7000; // ms private final KeyListener myEditorKeyListener = new KeyAdapter() { public void keyReleased(KeyEvent e) { @@ -56,14 +53,14 @@ public abstract class AbstractValueHint { private Cursor myStoredCursor; private final Project myProject; private final Editor myEditor; - private final int myType; + private final ValueHintType myType; private Point myPoint; private LightweightHint myCurrentHint; private JBPopup myPopup; private boolean myHintHidden; private TextRange myCurrentRange; - public AbstractValueHint(Project project, Editor editor, Point point, int type, final TextRange textRange) { + public AbstractValueHint(Project project, Editor editor, Point point, ValueHintType type, final TextRange textRange) { myPoint = point; myProject = project; myEditor = editor; @@ -111,10 +108,10 @@ public abstract class AbstractValueHint { } public boolean isKeepHint(Editor editor, Point point) { - if(myType == MOUSE_ALT_OVER_HINT) { + if(myType == ValueHintType.MOUSE_ALT_OVER_HINT) { return false; } - else if(myType == MOUSE_CLICK_HINT) { + else if(myType == ValueHintType.MOUSE_CLICK_HINT) { if(myCurrentHint != null && myCurrentHint.isVisible()) { return true; } @@ -162,7 +159,7 @@ public abstract class AbstractValueHint { return; } - if (myType == MOUSE_ALT_OVER_HINT) { + if (myType == ValueHintType.MOUSE_ALT_OVER_HINT) { myHighlighter = myEditor.getMarkupModel().addRangeHighlighter(myCurrentRange.getStartOffset(), myCurrentRange.getEndOffset(), HighlighterLayer.SELECTION + 1, ourReferenceAttributes, HighlighterTargetArea.EXACT_RANGE); @@ -200,7 +197,7 @@ public abstract class AbstractValueHint { return myEditor; } - protected int getType() { + protected ValueHintType getType() { return myType; } @@ -297,7 +294,7 @@ public abstract class AbstractValueHint { return modifiers == InputEvent.ALT_MASK; } - public static int getType(final EditorMouseEvent e) { - return isAltMask(e.getMouseEvent().getModifiers()) ? MOUSE_ALT_OVER_HINT : MOUSE_OVER_HINT; + public static ValueHintType getType(final EditorMouseEvent e) { + return isAltMask(e.getMouseEvent().getModifiers()) ? ValueHintType.MOUSE_ALT_OVER_HINT : ValueHintType.MOUSE_OVER_HINT; } } diff --git a/xdebugger/impl/com/intellij/xdebugger/impl/evaluate/quick/common/QuickEvaluateHandler.java b/xdebugger/impl/com/intellij/xdebugger/impl/evaluate/quick/common/QuickEvaluateHandler.java index c69b72a780..d63ad091c6 100644 --- a/xdebugger/impl/com/intellij/xdebugger/impl/evaluate/quick/common/QuickEvaluateHandler.java +++ b/xdebugger/impl/com/intellij/xdebugger/impl/evaluate/quick/common/QuickEvaluateHandler.java @@ -15,9 +15,9 @@ public abstract class QuickEvaluateHandler { public abstract boolean isEnabled(@NotNull Project project); @Nullable - public abstract AbstractValueHint createValueHint(@NotNull Project project, @NotNull Editor editor, @NotNull Point point, int type); + public abstract AbstractValueHint createValueHint(@NotNull Project project, @NotNull Editor editor, @NotNull Point point, ValueHintType type); public abstract boolean canShowHint(@NotNull Project project); - public abstract int getValueLookupDelay(); + public abstract int getValueLookupDelay(final Project project); } diff --git a/xdebugger/impl/com/intellij/xdebugger/impl/evaluate/quick/common/ValueHintType.java b/xdebugger/impl/com/intellij/xdebugger/impl/evaluate/quick/common/ValueHintType.java new file mode 100644 index 0000000000..240c6570c3 --- /dev/null +++ b/xdebugger/impl/com/intellij/xdebugger/impl/evaluate/quick/common/ValueHintType.java @@ -0,0 +1,10 @@ +package com.intellij.xdebugger.impl.evaluate.quick.common; + +/** + * @author nik +*/ +public enum ValueHintType { + MOUSE_OVER_HINT, + MOUSE_ALT_OVER_HINT, + MOUSE_CLICK_HINT +} diff --git a/xdebugger/impl/com/intellij/xdebugger/impl/evaluate/quick/common/ValueLookupManager.java b/xdebugger/impl/com/intellij/xdebugger/impl/evaluate/quick/common/ValueLookupManager.java index c720f60770..983ba583bd 100644 --- a/xdebugger/impl/com/intellij/xdebugger/impl/evaluate/quick/common/ValueLookupManager.java +++ b/xdebugger/impl/com/intellij/xdebugger/impl/evaluate/quick/common/ValueLookupManager.java @@ -64,14 +64,14 @@ public class ValueLookupManager implements EditorMouseMotionListener, ProjectCom } } - private void requestHint(final QuickEvaluateHandler handler, final Editor editor, final Point point, final int type) { + private void requestHint(final QuickEvaluateHandler handler, final Editor editor, final Point point, final ValueHintType type) { myAlarm.cancelAllRequests(); - if(type == AbstractValueHint.MOUSE_OVER_HINT) { + if(type == ValueHintType.MOUSE_OVER_HINT) { myAlarm.addRequest(new Runnable() { public void run() { showHint(handler, editor, point, type); } - }, handler.getValueLookupDelay()); + }, handler.getValueLookupDelay(myProject)); } else { showHint(handler, editor, point, type); } @@ -85,7 +85,7 @@ public class ValueLookupManager implements EditorMouseMotionListener, ProjectCom } } - public void showHint(final QuickEvaluateHandler handler, Editor editor, Point point, int type) { + public void showHint(final QuickEvaluateHandler handler, Editor editor, Point point, ValueHintType type) { myAlarm.cancelAllRequests(); hideHint(); if (editor.isDisposed() || !handler.canShowHint(myProject)) return; diff --git a/debugger/impl/com/intellij/debugger/settings/CompositeConfigurable.java b/xdebugger/impl/com/intellij/xdebugger/impl/settings/CompositeConfigurable.java similarity index 70% rename from debugger/impl/com/intellij/debugger/settings/CompositeConfigurable.java rename to xdebugger/impl/com/intellij/xdebugger/impl/settings/CompositeConfigurable.java index 1dd9005bc3..92c15c6c20 100644 --- a/debugger/impl/com/intellij/debugger/settings/CompositeConfigurable.java +++ b/xdebugger/impl/com/intellij/xdebugger/impl/settings/CompositeConfigurable.java @@ -1,4 +1,4 @@ -package com.intellij.debugger.settings; +package com.intellij.xdebugger.impl.settings; import com.intellij.openapi.options.BaseConfigurable; import com.intellij.openapi.options.Configurable; @@ -6,9 +6,8 @@ import com.intellij.openapi.options.ConfigurationException; import com.intellij.ui.TabbedPaneWrapper; import javax.swing.*; -import java.util.Iterator; -import java.util.List; import java.awt.*; +import java.util.List; /* * Copyright (c) 2000-2004 by JetBrains s.r.o. All Rights Reserved. @@ -20,23 +19,20 @@ public abstract class CompositeConfigurable extends BaseConfigurable { private TabbedPaneWrapper myTabbedPane; public void reset() { - for (Iterator iterator = getConfigurables().iterator(); iterator.hasNext();) { - Configurable configurable = iterator.next(); + for (Configurable configurable : getConfigurables()) { configurable.reset(); } } public void apply() throws ConfigurationException { - for (Iterator iterator = getConfigurables().iterator(); iterator.hasNext();) { - Configurable configurable = iterator.next(); + for (Configurable configurable : getConfigurables()) { configurable.apply(); } } public boolean isModified() { - for (Iterator iterator = getConfigurables().iterator(); iterator.hasNext();) { - Configurable configurable = iterator.next(); - if(configurable.isModified()) { + for (Configurable configurable : getConfigurables()) { + if (configurable.isModified()) { return true; } } @@ -56,8 +52,8 @@ public abstract class CompositeConfigurable extends BaseConfigurable { public void disposeUIResources() { myTabbedPane = null; if (myConfigurables != null) { - for (Iterator it = myConfigurables.iterator(); it.hasNext();) { - it.next().disposeUIResources(); + for (final Configurable myConfigurable : myConfigurables) { + myConfigurable.disposeUIResources(); } myConfigurables = null; } diff --git a/debugger/impl/com/intellij/debugger/settings/DebuggerConfigurable.java b/xdebugger/impl/com/intellij/xdebugger/impl/settings/DebuggerConfigurable.java similarity index 59% rename from debugger/impl/com/intellij/debugger/settings/DebuggerConfigurable.java rename to xdebugger/impl/com/intellij/xdebugger/impl/settings/DebuggerConfigurable.java index f4bc7041ce..edcb8f76af 100644 --- a/debugger/impl/com/intellij/debugger/settings/DebuggerConfigurable.java +++ b/xdebugger/impl/com/intellij/xdebugger/impl/settings/DebuggerConfigurable.java @@ -1,6 +1,5 @@ -package com.intellij.debugger.settings; +package com.intellij.xdebugger.impl.settings; -import com.intellij.debugger.DebuggerBundle; import com.intellij.ide.DataManager; import com.intellij.openapi.actionSystem.PlatformDataKeys; import com.intellij.openapi.options.Configurable; @@ -9,27 +8,27 @@ import com.intellij.openapi.options.SearchableConfigurable; import com.intellij.openapi.project.Project; import com.intellij.openapi.project.ProjectManager; import com.intellij.openapi.util.IconLoader; +import com.intellij.xdebugger.XDebuggerBundle; +import com.intellij.xdebugger.impl.DebuggerSupport; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.util.ArrayList; +import java.util.Collections; import java.util.List; +import java.util.Comparator; /** * @author Eugene Belyaev & Eugene Zhuravlev */ public class DebuggerConfigurable extends CompositeConfigurable implements SearchableConfigurable { - public DebuggerConfigurable() { - super(); - } - public Icon getIcon() { return IconLoader.getIcon("/general/configurableDebugger.png"); } public String getDisplayName() { - return DebuggerBundle.message("debugger.configurable.display.name"); + return XDebuggerBundle.message("debugger.configurable.display.name"); } public String getHelpTopic() { @@ -42,14 +41,27 @@ public class DebuggerConfigurable extends CompositeConfigurable implements Searc if(project == null) { project = ProjectManager.getInstance().getDefaultProject(); } - configurables.add(new DebuggerGeneralConfigurable(project)); - configurables.add(new UserRenderersConfigurable(project)); + DebuggerSupport[] supports = DebuggerSupport.getDebuggerSupports(); + List providers = new ArrayList(); + for (DebuggerSupport support : supports) { + providers.add(support.getSettingsPanelProvider()); + } + Collections.sort(providers, new Comparator() { + public int compare(final DebuggerSettingsPanelProvider o1, final DebuggerSettingsPanelProvider o2) { + return o2.getPriority() - o1.getPriority(); + } + }); + for (DebuggerSettingsPanelProvider provider : providers) { + configurables.addAll(provider.getConfigurables(project)); + } return configurables; } public void apply() throws ConfigurationException { super.apply(); - NodeRendererSettings.getInstance().fireRenderersChanged(); + for (DebuggerSupport support : DebuggerSupport.getDebuggerSupports()) { + support.getSettingsPanelProvider().apply(); + } } @NonNls diff --git a/xdebugger/impl/com/intellij/xdebugger/impl/settings/DebuggerSettingsPanelProvider.java b/xdebugger/impl/com/intellij/xdebugger/impl/settings/DebuggerSettingsPanelProvider.java new file mode 100644 index 0000000000..09e1a9efc2 --- /dev/null +++ b/xdebugger/impl/com/intellij/xdebugger/impl/settings/DebuggerSettingsPanelProvider.java @@ -0,0 +1,19 @@ +package com.intellij.xdebugger.impl.settings; + +import com.intellij.openapi.options.Configurable; +import com.intellij.openapi.project.Project; + +import java.util.Collection; + +/** + * @author nik + */ +public abstract class DebuggerSettingsPanelProvider { + + public abstract int getPriority(); + + public abstract Collection getConfigurables(final Project project); + + public void apply() { + } +} diff --git a/xdebugger/impl/com/intellij/xdebugger/impl/settings/XDebuggerSettingsManager.java b/xdebugger/impl/com/intellij/xdebugger/impl/settings/XDebuggerSettingsManager.java new file mode 100644 index 0000000000..71a9157866 --- /dev/null +++ b/xdebugger/impl/com/intellij/xdebugger/impl/settings/XDebuggerSettingsManager.java @@ -0,0 +1,139 @@ +package com.intellij.xdebugger.impl.settings; + +import com.intellij.openapi.components.ApplicationComponent; +import com.intellij.openapi.components.PersistentStateComponent; +import com.intellij.openapi.components.State; +import com.intellij.openapi.components.Storage; +import com.intellij.openapi.extensions.Extensions; +import com.intellij.openapi.application.ApplicationManager; +import com.intellij.util.xmlb.SkipDefaultValuesSerializationFilters; +import com.intellij.util.xmlb.XmlSerializer; +import com.intellij.util.xmlb.annotations.AbstractCollection; +import com.intellij.util.xmlb.annotations.Attribute; +import com.intellij.util.xmlb.annotations.Tag; +import com.intellij.xdebugger.impl.XDebuggerUtilImpl; +import com.intellij.xdebugger.settings.XDebuggerSettings; +import org.jdom.Element; +import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; + +import java.util.*; + +/** + * @author nik + */ +@State( + name = XDebuggerSettingsManager.COMPONENT_NAME, + storages = { + @Storage( + id ="other", + file = "$APP_CONFIG$/other.xml" + ) + } +) +public class XDebuggerSettingsManager implements ApplicationComponent, PersistentStateComponent{ + @NonNls public static final String COMPONENT_NAME = "XDebuggerSettings"; + private Map> mySettingsById; + + public static XDebuggerSettingsManager getInstance() { + return ApplicationManager.getApplication().getComponent(XDebuggerSettingsManager.class); + } + + public SettingsState getState() { + SettingsState settingsState = new SettingsState(); + for (XDebuggerSettings settings : getSettingsList()) { + SpecificSettingsState state = new SpecificSettingsState(); + state.setId(settings.getId()); + state.setSettingsElement(XmlSerializer.serialize(settings.getState(), new SkipDefaultValuesSerializationFilters())); + settingsState.getSpecificStates().add(state); + } + return settingsState; + } + + private Collection> getSettingsList() { + initSettings(); + return mySettingsById.values(); + } + + public void loadState(final SettingsState state) { + for (SpecificSettingsState settingsState : state.getSpecificStates()) { + XDebuggerSettings settings = findSettings(settingsState.getId()); + if (settings != null) { + loadState(settings, settingsState.getSettingsElement()); + } + } + } + + private static void loadState(final XDebuggerSettings settings, final Element settingsElement) { + Class stateClass = XDebuggerUtilImpl.getStateClass(settings.getClass()); + //noinspection unchecked + settings.loadState((T)XmlSerializer.deserialize(settingsElement, stateClass)); + } + + + private XDebuggerSettings findSettings(String id) { + initSettings(); + return mySettingsById.get(id); + } + + private void initSettings() { + if (mySettingsById == null) { + mySettingsById = new HashMap>(); + for (XDebuggerSettings settings : Extensions.getExtensions(XDebuggerSettings.EXTENSION_POINT)) { + mySettingsById.put(settings.getId(), settings); + } + } + } + + @NotNull + public String getComponentName() { + return COMPONENT_NAME; + } + + public void initComponent() { + } + + public void disposeComponent() { + } + + public static class SettingsState { + private List mySpecificStates = new ArrayList(); + + @Tag("debuggers") + @AbstractCollection(surroundWithTag = false) + public List getSpecificStates() { + return mySpecificStates; + } + + public void setSpecificStates(final List specificStates) { + mySpecificStates = specificStates; + } + } + + @Tag("debugger") + public static class SpecificSettingsState { + private String myId; + private Element mySettingsElement; + + + @Attribute("id") + public String getId() { + return myId; + } + + @Tag("configuration") + public Element getSettingsElement() { + return mySettingsElement; + } + + public void setSettingsElement(final Element settingsElement) { + mySettingsElement = settingsElement; + } + + public void setId(final String id) { + myId = id; + } + + + } +} diff --git a/xdebugger/impl/com/intellij/xdebugger/impl/settings/XDebuggerSettingsPanelProviderImpl.java b/xdebugger/impl/com/intellij/xdebugger/impl/settings/XDebuggerSettingsPanelProviderImpl.java new file mode 100644 index 0000000000..d05b3b3300 --- /dev/null +++ b/xdebugger/impl/com/intellij/xdebugger/impl/settings/XDebuggerSettingsPanelProviderImpl.java @@ -0,0 +1,27 @@ +package com.intellij.xdebugger.impl.settings; + +import com.intellij.openapi.options.Configurable; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.extensions.Extensions; +import com.intellij.xdebugger.settings.XDebuggerSettings; + +import java.util.Collection; +import java.util.ArrayList; + +/** + * @author nik + */ +public class XDebuggerSettingsPanelProviderImpl extends DebuggerSettingsPanelProvider { + public int getPriority() { + return 0; + } + + public Collection getConfigurables(final Project project) { + ArrayList list = new ArrayList(); + XDebuggerSettings[] settingses = Extensions.getExtensions(XDebuggerSettings.EXTENSION_POINT); + for (XDebuggerSettings settings : settingses) { + list.add(settings.createConfigurable()); + } + return list; + } +} diff --git a/xdebugger/openapi/com/intellij/xdebugger/XDebuggerUtil.java b/xdebugger/openapi/com/intellij/xdebugger/XDebuggerUtil.java index 570407a13b..026e01cf4a 100644 --- a/xdebugger/openapi/com/intellij/xdebugger/XDebuggerUtil.java +++ b/xdebugger/openapi/com/intellij/xdebugger/XDebuggerUtil.java @@ -21,6 +21,7 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.xdebugger.breakpoints.*; import com.intellij.xdebugger.breakpoints.ui.XBreakpointGroupingRule; +import com.intellij.xdebugger.settings.XDebuggerSettings; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -52,4 +53,6 @@ public abstract class XDebuggerUtil { public abstract > Comparator getDefaultBreakpointComparator(XBreakpointType type); public abstract

Comparator> getDefaultLineBreakpointComparator(); + + public abstract > T getDebuggerSettings(Class aClass); } diff --git a/xdebugger/openapi/com/intellij/xdebugger/evaluation/XDebuggerEvaluator.java b/xdebugger/openapi/com/intellij/xdebugger/evaluation/XDebuggerEvaluator.java index c8fc26bab5..d8ea1ea2d7 100644 --- a/xdebugger/openapi/com/intellij/xdebugger/evaluation/XDebuggerEvaluator.java +++ b/xdebugger/openapi/com/intellij/xdebugger/evaluation/XDebuggerEvaluator.java @@ -1,10 +1,11 @@ package com.intellij.xdebugger.evaluation; +import com.intellij.openapi.editor.Document; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.TextRange; +import com.intellij.xdebugger.frame.XValue; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import com.intellij.xdebugger.frame.XValue; -import com.intellij.openapi.util.TextRange; -import com.intellij.openapi.editor.Editor; /** * @author nik @@ -32,8 +33,22 @@ public abstract class XDebuggerEvaluator { */ public abstract void evaluate(@NotNull String expression, XEvaluationCallback callback); + /** + * Return text range of expression which can be evaluated. + * @param project project + * @param document document + * @param offset offset + * @return text range of expression + */ @Nullable - public abstract TextRange getSelectedExpressionRange(@NotNull Editor editor, int offset); + public abstract TextRange getExpressionRangeAtOffset(final Project project, final Document document, int offset); + + /** + * @return delay before showing value tooltip (in ms) + */ + public int getValuePopupDelay() { + return 700; + } public static interface XEvaluationCallback { diff --git a/xdebugger/openapi/com/intellij/xdebugger/settings/XDebuggerSettings.java b/xdebugger/openapi/com/intellij/xdebugger/settings/XDebuggerSettings.java new file mode 100644 index 0000000000..8425cfeb81 --- /dev/null +++ b/xdebugger/openapi/com/intellij/xdebugger/settings/XDebuggerSettings.java @@ -0,0 +1,31 @@ +package com.intellij.xdebugger.settings; + +import com.intellij.openapi.components.PersistentStateComponent; +import com.intellij.openapi.extensions.ExtensionPointName; +import com.intellij.openapi.options.Configurable; +import com.intellij.xdebugger.XDebuggerUtil; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NonNls; + +/** + * @author nik + */ +public abstract class XDebuggerSettings implements PersistentStateComponent { + public static final ExtensionPointName EXTENSION_POINT = ExtensionPointName.create("com.intellij.xdebugger.settings"); + private final String myId; + + protected XDebuggerSettings(final @NotNull @NonNls String id) { + myId = id; + } + + protected static > S getInstance(Class aClass) { + return XDebuggerUtil.getInstance().getDebuggerSettings(aClass); + } + + public final String getId() { + return myId; + } + + @NotNull + public abstract Configurable createConfigurable(); +} diff --git a/xdebugger/tests/com/intellij/xdebugger/XDebuggerSettingsTest.java b/xdebugger/tests/com/intellij/xdebugger/XDebuggerSettingsTest.java new file mode 100644 index 0000000000..6e3c341de7 --- /dev/null +++ b/xdebugger/tests/com/intellij/xdebugger/XDebuggerSettingsTest.java @@ -0,0 +1,70 @@ +package com.intellij.xdebugger; + +import com.intellij.openapi.options.Configurable; +import com.intellij.testFramework.LiteFixture; +import com.intellij.util.xmlb.XmlSerializer; +import com.intellij.util.xmlb.annotations.Attribute; +import com.intellij.xdebugger.impl.XDebuggerUtilImpl; +import com.intellij.xdebugger.impl.settings.XDebuggerSettingsManager; +import com.intellij.xdebugger.settings.XDebuggerSettings; +import org.jdom.Element; +import org.jetbrains.annotations.NotNull; + +/** + * @author nik + */ +public class XDebuggerSettingsTest extends LiteFixture { + protected void setUp() throws Exception { + super.setUp(); + initApplication(); + registerExtensionPoint(XDebuggerSettings.EXTENSION_POINT, XDebuggerSettings.class); + registerExtension(XDebuggerSettings.EXTENSION_POINT, new MyDebuggerSettings()); + getApplication().registerService(XDebuggerUtil.class, XDebuggerUtilImpl.class); + registerComponentImplementation(getApplication().getPicoContainer(), XDebuggerSettingsManager.class, XDebuggerSettingsManager.class); + } + + public void testSerialize() throws Exception { + XDebuggerSettingsManager settingsManager = XDebuggerSettingsManager.getInstance(); + + MyDebuggerSettings settings = MyDebuggerSettings.getInstance(); + assertNotNull(settings); + settings.myOption = "239"; + + Element element = XmlSerializer.serialize(settingsManager.getState()); + //System.out.println(JDOMUtil.writeElement(element, SystemProperties.getLineSeparator())); + + settings.myOption = "42"; + assertSame(settings, MyDebuggerSettings.getInstance()); + + settingsManager.loadState(XmlSerializer.deserialize(element, XDebuggerSettingsManager.SettingsState.class)); + assertSame(settings, MyDebuggerSettings.getInstance()); + assertEquals("239", settings.myOption); + } + + + public static class MyDebuggerSettings extends XDebuggerSettings { + @Attribute("option") + public String myOption; + + public MyDebuggerSettings() { + super("test"); + } + + public static MyDebuggerSettings getInstance() { + return getInstance(MyDebuggerSettings.class); + } + + public MyDebuggerSettings getState() { + return this; + } + + public void loadState(final MyDebuggerSettings state) { + myOption = state.myOption; + } + + @NotNull + public Configurable createConfigurable() { + throw new UnsupportedOperationException("'createConfigurable' not implemented in " + getClass().getName()); + } + } +} -- 2.11.4.GIT