I haven't found a question related with this topic.
I'm using this implementation of a Suffix Tree: http://en.literateprograms.org/Suffix_tree_%28Java%29
As you can see in this link, nodes of the tree have a toString() method that calls itself recursively - it shows a representation of the node and its children. This method increases a static integer variable every time it's called (it's static, so its value is preserved between calls).
When I pause execution of the code with Eclipse Debugger, I can hover over a node variable to see its value. The problem is Eclipse calls toString() method to show the content of a variable, so the static variable is increased every time I check the value of a node, while the program is paused.
I don't know how to prevent Eclipse from displaying the toString() method when debugging. Also, I haven't found a way to change the method so it works the same way without using static variables. Both solutions would help me, but the first one is more interesting to me. What would you do?
PS: I add the code of SuffixTreeNode's toString() method. Please check the previous link for more details.
SuffixTreeEdge incomingEdge = null;
int nodeDepth = -1;
int label = -1;
Collection<SuffixTreeNode> children = null;
SuffixTreeNode parent = null;
int stringDepth;
int id = 0;
public static int c;
public String toString() {
StringBuilder result = new StringBuilder();
String incomingLabel = this.isRoot() ? "" : this.incomingEdge.label;
for (int i = 1; i <= this.nodeDepth; i++)
result.append("\t");
if (this.isRoot()) {
c = 1;
this.id = 1;
} else {
this.id = c;
result.append(this.parent.id + " -> ");
result.append(this.id + "[label=\"" + incomingLabel + "\"];\n");
}
for (SuffixTreeNode child : children) {
c++;
child.id = c;
result.append(child.toString());
}
return result.toString();
}