diff --git a/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/BasicDebuggerViewSupport.java b/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/BasicDebuggerViewSupport.java index b2fd544d0b86..4babc9709122 100644 --- a/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/BasicDebuggerViewSupport.java +++ b/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/BasicDebuggerViewSupport.java @@ -1,8 +1,10 @@ package org.jetbrains.debugger; import com.intellij.openapi.util.ActionCallback; +import com.intellij.util.ThreeState; import com.intellij.xdebugger.evaluation.XDebuggerEvaluator; import com.intellij.xdebugger.frame.XCompositeNode; +import com.intellij.xdebugger.frame.XInlineDebuggerDataCallback; import com.intellij.xdebugger.frame.XNavigatable; import com.intellij.xdebugger.frame.XValueNode; import org.jetbrains.annotations.NotNull; @@ -72,6 +74,12 @@ public class BasicDebuggerViewSupport implements DebuggerViewSupport, MemberFilt public void computeSourcePosition(@NotNull Variable variable, @NotNull VariableContext context, @NotNull XNavigatable navigatable) { } + @NotNull + @Override + public ThreeState computeInlineDebuggerData(@NotNull Variable variable, @NotNull VariableContext context, @NotNull XInlineDebuggerDataCallback callback) { + return ThreeState.UNSURE; + } + @Nullable @Override public ActionCallback computeAdditionalObjectProperties(@NotNull ObjectValue value, @NotNull Variable variable, @NotNull VariableContext context, @NotNull XCompositeNode node) { diff --git a/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/DebuggerViewSupport.java b/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/DebuggerViewSupport.java index d341dda0bec1..006ba1c18dcf 100644 --- a/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/DebuggerViewSupport.java +++ b/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/DebuggerViewSupport.java @@ -1,8 +1,10 @@ package org.jetbrains.debugger; import com.intellij.openapi.util.ActionCallback; +import com.intellij.util.ThreeState; import com.intellij.xdebugger.evaluation.XDebuggerEvaluator; import com.intellij.xdebugger.frame.XCompositeNode; +import com.intellij.xdebugger.frame.XInlineDebuggerDataCallback; import com.intellij.xdebugger.frame.XNavigatable; import com.intellij.xdebugger.frame.XValueNode; import org.jetbrains.annotations.NotNull; @@ -44,6 +46,9 @@ public interface DebuggerViewSupport { void computeSourcePosition(@NotNull Variable variable, @NotNull VariableContext context, @NotNull XNavigatable navigatable); + @NotNull + ThreeState computeInlineDebuggerData(@NotNull Variable variable, @NotNull VariableContext context, @NotNull XInlineDebuggerDataCallback callback); + // return null if you don't need to add additional properties @Nullable ActionCallback computeAdditionalObjectProperties(@NotNull ObjectValue value, @NotNull Variable variable, @NotNull VariableContext context, @NotNull XCompositeNode node); diff --git a/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/VariableView.java b/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/VariableView.java index 1cf196ca45dd..013d602e3e9c 100644 --- a/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/VariableView.java +++ b/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/VariableView.java @@ -566,6 +566,12 @@ public final class VariableView extends XNamedValue implements VariableContext { } } + @NotNull + @Override + public ThreeState computeInlineDebuggerData(@NotNull XInlineDebuggerDataCallback callback) { + return getViewSupport().computeInlineDebuggerData(variable, context, callback); + } + @Override @Nullable public String getEvaluationExpression() { diff --git a/platform/xdebugger-api/src/com/intellij/xdebugger/frame/XInlineDebuggerDataCallback.java b/platform/xdebugger-api/src/com/intellij/xdebugger/frame/XInlineDebuggerDataCallback.java new file mode 100644 index 000000000000..1227370877ee --- /dev/null +++ b/platform/xdebugger-api/src/com/intellij/xdebugger/frame/XInlineDebuggerDataCallback.java @@ -0,0 +1,24 @@ +/* + * 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.xdebugger.frame; + +import com.intellij.openapi.editor.Document; +import com.intellij.openapi.vfs.VirtualFile; +import org.jetbrains.annotations.NotNull; + +public abstract class XInlineDebuggerDataCallback { + public abstract void computed(@NotNull VirtualFile file, @NotNull Document document, int line); +} \ No newline at end of file diff --git a/platform/xdebugger-api/src/com/intellij/xdebugger/frame/XValue.java b/platform/xdebugger-api/src/com/intellij/xdebugger/frame/XValue.java index 4d3446bbfb54..ef927a5354b7 100644 --- a/platform/xdebugger-api/src/com/intellij/xdebugger/frame/XValue.java +++ b/platform/xdebugger-api/src/com/intellij/xdebugger/frame/XValue.java @@ -15,6 +15,7 @@ */ package com.intellij.xdebugger.frame; +import com.intellij.util.ThreeState; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -60,6 +61,17 @@ public abstract class XValue extends XValueContainer { navigatable.setSourcePosition(null); } + /** + * Provide inline debugger data, return ability to provide, use + * {@link ThreeState#UNSURE} if unsupported (default platform implementation will be used), + * {@link ThreeState#YES} if applicable + * {@link ThreeState#NO} if not applicable + */ + @NotNull + public ThreeState computeInlineDebuggerData(@NotNull XInlineDebuggerDataCallback callback) { + return ThreeState.UNSURE; + } + /** * Return {@code true} from this method and override {@link #computeSourcePosition(XNavigatable)} if navigation to the source * is supported for the value diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValueNodeImpl.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValueNodeImpl.java index 595322d761f1..9749fd38d770 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValueNodeImpl.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValueNodeImpl.java @@ -26,6 +26,7 @@ import com.intellij.ui.AppUIUtil; import com.intellij.ui.ColoredTextContainer; import com.intellij.ui.SimpleTextAttributes; import com.intellij.util.NotNullFunction; +import com.intellij.util.ThreeState; import com.intellij.xdebugger.XDebugSession; import com.intellij.xdebugger.XSourcePosition; import com.intellij.xdebugger.frame.*; @@ -138,27 +139,41 @@ public class XValueNodeImpl extends XValueContainerNode implements XValu if (session != null) { final XSourcePosition position = session.getCurrentPosition(); if (position != null) { - getValueContainer().computeSourcePosition(new XNearestSourcePosition() { - @Override - public void setSourcePosition(@Nullable XSourcePosition sourcePosition) { - final Map, Set> map = myTree.getProject().getUserData(XVariablesView.DEBUG_VARIABLES); - final Map timestamps = myTree.getProject().getUserData(XVariablesView.DEBUG_VARIABLES_TIMESTAMPS); - if (map == null || timestamps == null || sourcePosition == null) return; - VirtualFile file = sourcePosition.getFile(); - final Document doc = FileDocumentManager.getInstance().getDocument(file); - if (doc == null) return; - int line = sourcePosition.getLine(); - Pair key = Pair.create(file, line); - Set presentations = new LinkedHashSet(); - Set old = map.get(key); - map.put(key, presentations); - timestamps.put(file, doc.getModificationStamp()); - presentations.add(XValueNodeImpl.this); - if (old != null) { - presentations.addAll(old); - } - } - }); + final XInlineDebuggerDataCallback callback = new XInlineDebuggerDataCallback() { + @Override + public void computed(@NotNull VirtualFile file, @NotNull Document document, int line) { + final Map, Set> map = myTree.getProject().getUserData(XVariablesView.DEBUG_VARIABLES); + final Map timestamps = myTree.getProject().getUserData(XVariablesView.DEBUG_VARIABLES_TIMESTAMPS); + if (map == null || timestamps == null) { + return; + } + + Pair key = Pair.create(file, line); + Set presentations = new LinkedHashSet(); + Set old = map.put(key, presentations); + timestamps.put(file, document.getModificationStamp()); + presentations.add(XValueNodeImpl.this); + if (old != null) { + presentations.addAll(old); + } + } + }; + + if (getValueContainer().computeInlineDebuggerData(callback) == ThreeState.UNSURE) { + getValueContainer().computeSourcePosition(new XNearestSourcePosition() { + @Override + public void setSourcePosition(@Nullable XSourcePosition sourcePosition) { + final Map, Set> map = myTree.getProject().getUserData(XVariablesView.DEBUG_VARIABLES); + final Map timestamps = myTree.getProject().getUserData(XVariablesView.DEBUG_VARIABLES_TIMESTAMPS); + if (map == null || timestamps == null || sourcePosition == null) return; + VirtualFile file = sourcePosition.getFile(); + final Document doc = FileDocumentManager.getInstance().getDocument(file); + if (doc == null) return; + int line = sourcePosition.getLine(); + callback.computed(file, doc, line); + } + }); + } } } }