diff --git a/core/src/main/java/org/teavm/debugging/Value.java b/core/src/main/java/org/teavm/debugging/Value.java index 0d93a8acb..faee4e4c5 100644 --- a/core/src/main/java/org/teavm/debugging/Value.java +++ b/core/src/main/java/org/teavm/debugging/Value.java @@ -57,4 +57,8 @@ public class Value { } return jsValue.getInstanceId(); } + + public JavaScriptValue getOriginalValue() { + return jsValue; + } } diff --git a/tools/idea/plugin/src/main/java/org/teavm/idea/debug/TeaVMOriginalValue.java b/tools/idea/plugin/src/main/java/org/teavm/idea/debug/TeaVMOriginalValue.java new file mode 100644 index 000000000..decb51416 --- /dev/null +++ b/tools/idea/plugin/src/main/java/org/teavm/idea/debug/TeaVMOriginalValue.java @@ -0,0 +1,58 @@ +/* + * Copyright 2018 Alexey Andreev. + * + * 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 org.teavm.idea.debug; + +import com.intellij.util.PlatformIcons; +import com.intellij.xdebugger.frame.XCompositeNode; +import com.intellij.xdebugger.frame.XNamedValue; +import com.intellij.xdebugger.frame.XValueChildrenList; +import com.intellij.xdebugger.frame.XValueNode; +import com.intellij.xdebugger.frame.XValuePlace; +import javax.swing.Icon; +import org.jetbrains.annotations.NotNull; +import org.teavm.debugging.javascript.JavaScriptValue; +import org.teavm.debugging.javascript.JavaScriptVariable; + +public class TeaVMOriginalValue extends XNamedValue { + private boolean root; + private JavaScriptValue innerValue; + + public TeaVMOriginalValue(@NotNull String name, boolean root, JavaScriptValue innerValue) { + super(name); + this.root = root; + this.innerValue = innerValue; + } + + @Override + public void computePresentation(@NotNull XValueNode node, @NotNull XValuePlace place) { + Icon icon = root ? PlatformIcons.VARIABLE_ICON : PlatformIcons.FIELD_ICON; + String representation = innerValue.getRepresentation(); + if (representation == null) { + representation = "null"; + } + node.setPresentation(icon, innerValue.getClassName(), representation, !innerValue.getProperties().isEmpty()); + } + + + @Override + public void computeChildren(@NotNull XCompositeNode node) { + XValueChildrenList children = new XValueChildrenList(); + for (JavaScriptVariable variable : innerValue.getProperties().values()) { + children.add(new TeaVMOriginalValue(variable.getName(), false, variable.getValue())); + } + node.addChildren(children, true); + } +} diff --git a/tools/idea/plugin/src/main/java/org/teavm/idea/debug/TeaVMStackFrame.java b/tools/idea/plugin/src/main/java/org/teavm/idea/debug/TeaVMStackFrame.java index e10a9ba9b..7b0318ceb 100644 --- a/tools/idea/plugin/src/main/java/org/teavm/idea/debug/TeaVMStackFrame.java +++ b/tools/idea/plugin/src/main/java/org/teavm/idea/debug/TeaVMStackFrame.java @@ -20,11 +20,13 @@ import com.intellij.openapi.vfs.VirtualFileManager; import com.intellij.xdebugger.XDebuggerUtil; import com.intellij.xdebugger.XSourcePosition; import com.intellij.xdebugger.frame.XCompositeNode; +import com.intellij.xdebugger.frame.XNamedValue; import com.intellij.xdebugger.frame.XStackFrame; import com.intellij.xdebugger.frame.XValueChildrenList; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.teavm.debugging.CallFrame; +import org.teavm.debugging.Value; import org.teavm.debugging.Variable; import org.teavm.debugging.information.SourceLocation; import org.teavm.debugging.javascript.JavaScriptCallFrame; @@ -74,8 +76,14 @@ class TeaVMStackFrame extends XStackFrame { public void computeChildren(@NotNull XCompositeNode node) { XValueChildrenList children = new XValueChildrenList(); for (Variable variable : innerFrame.getVariables().values()) { - children.add(new TeaVMValue(variable.getName(), true, variable.getValue())); + children.add(createValueNode(variable.getName(), true, variable.getValue())); } node.addChildren(children, true); } + + static XNamedValue createValueNode(String name, boolean root, Value value) { + return !value.getType().startsWith("@") + ? new TeaVMValue(name, root, value) + : new TeaVMOriginalValue(name, root, value.getOriginalValue()); + } } diff --git a/tools/idea/plugin/src/main/java/org/teavm/idea/debug/TeaVMValue.java b/tools/idea/plugin/src/main/java/org/teavm/idea/debug/TeaVMValue.java index 9062d7bae..e01d64e9d 100644 --- a/tools/idea/plugin/src/main/java/org/teavm/idea/debug/TeaVMValue.java +++ b/tools/idea/plugin/src/main/java/org/teavm/idea/debug/TeaVMValue.java @@ -92,7 +92,7 @@ public class TeaVMValue extends XNamedValue { public void computeChildren(@NotNull XCompositeNode node) { XValueChildrenList children = new XValueChildrenList(); for (Variable variable : innerValue.getProperties().values()) { - children.add(new TeaVMValue(variable.getName(), true, variable.getValue())); + children.add(TeaVMStackFrame.createValueNode(variable.getName(), false, variable.getValue())); } node.addChildren(children, true); }