inline debugger in case of JS must use auto expression data

This commit is contained in:
Vladimir Krivosheev
2014-10-05 10:00:51 +02:00
parent 90c809ee75
commit bd35a013b2
6 changed files with 91 additions and 21 deletions
@@ -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) {
@@ -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);
@@ -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() {
@@ -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);
}
@@ -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
@@ -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<XValue> 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<Pair<VirtualFile, Integer>, Set<XValueNodeImpl>> map = myTree.getProject().getUserData(XVariablesView.DEBUG_VARIABLES);
final Map<VirtualFile, Long> 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<VirtualFile, Integer> key = Pair.create(file, line);
Set<XValueNodeImpl> presentations = new LinkedHashSet<XValueNodeImpl>();
Set<XValueNodeImpl> 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<Pair<VirtualFile, Integer>, Set<XValueNodeImpl>> map = myTree.getProject().getUserData(XVariablesView.DEBUG_VARIABLES);
final Map<VirtualFile, Long> timestamps = myTree.getProject().getUserData(XVariablesView.DEBUG_VARIABLES_TIMESTAMPS);
if (map == null || timestamps == null) {
return;
}
Pair<VirtualFile, Integer> key = Pair.create(file, line);
Set<XValueNodeImpl> presentations = new LinkedHashSet<XValueNodeImpl>();
Set<XValueNodeImpl> 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<Pair<VirtualFile, Integer>, Set<XValueNodeImpl>> map = myTree.getProject().getUserData(XVariablesView.DEBUG_VARIABLES);
final Map<VirtualFile, Long> 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);
}
});
}
}
}
}