Skip to content

Commit

Permalink
Implemented access to the tied information in debugger
Browse files Browse the repository at this point in the history
Fixes #1690
  • Loading branch information
hurricup committed Dec 29, 2017
1 parent dc37b4e commit 72c0557
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,8 @@ public PerlLayersDescriptor getLayers() {
public PerlValueDescriptor getTiedWith() {
return tied_with;
}

public boolean isExpandableNode() {
return isExpandable() || getLayers() != null || getTiedWith() != null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* Copyright 2015-2017 Alexandr Evstigneev
*
* 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.perl5.lang.perl.idea.run.debugger.values;

import com.intellij.icons.AllIcons;
import com.intellij.xdebugger.frame.XCompositeNode;
import com.intellij.xdebugger.frame.XValueChildrenList;
import com.intellij.xdebugger.frame.XValueGroup;
import com.perl5.lang.perl.idea.run.debugger.PerlStackFrame;
import com.perl5.lang.perl.idea.run.debugger.protocol.PerlValueDescriptor;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import javax.swing.*;

public class PerlTiedNamedValue extends XValueGroup {
private final PerlXNamedValue myPerlXNamedValue;

public PerlTiedNamedValue(@NotNull PerlValueDescriptor tiedValue,
@NotNull PerlStackFrame stackFrame) {
super("Tied with");
myPerlXNamedValue = new PerlXNamedValue(tiedValue, stackFrame);
}

@Nullable
@Override
public Icon getIcon() {
return AllIcons.Toolwindows.ToolWindowModuleDependencies;
}

@NotNull
@Override
public String getSeparator() {
return ": ";
}

@Nullable
@Override
public String getComment() {
return myPerlXNamedValue.calculateType();
}

@Override
public void computeChildren(@NotNull XCompositeNode node) {
node.addChildren(XValueChildrenList.singleton(myPerlXNamedValue), true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,12 @@ public void computeChildren(@NotNull XCompositeNode node) {
childrenList.add(new PerlXLayersNamedValue(layers));
}

//if(tiedWith != null ){
// childrenList.add(new PerlXNamedValue(tiedWith, myStackFrame));
//}

if (childrenList.size() > 0) {
node.addChildren(childrenList, false);
if (tiedWith != null) {
childrenList.addTopGroup(new PerlTiedNamedValue(tiedWith, myStackFrame));
}

node.addChildren(childrenList, !isExpandable);

if (isExpandable) {
PerlDebugUtil.requestAndComputeChildren(node, myStackFrame, offset, myPerlValueDescriptor.getSize(), myPerlValueDescriptor.getKey());
}
Expand All @@ -102,7 +100,7 @@ public void computeChildren(@NotNull XCompositeNode node) {

@Override
public void computePresentation(@NotNull XValueNode node, @NotNull XValuePlace place) {
node.setPresentation(calculateIcon(), calculateType(), myPerlValueDescriptor.getValue(), myPerlValueDescriptor.isExpandable());
node.setPresentation(calculateIcon(), calculateType(), myPerlValueDescriptor.getValue(), myPerlValueDescriptor.isExpandableNode());
}

protected String calculateType() {
Expand All @@ -120,6 +118,10 @@ else if (refDepth > 0) {
value += ", IOLayers";
}

if (myPerlValueDescriptor.getTiedWith() != null) {
value += ", Tied";
}

return value;
}

Expand Down

0 comments on commit 72c0557

Please sign in to comment.