diff --git a/src/org/ntlab/traceDebugger/CallStackModel.java b/src/org/ntlab/traceDebugger/CallStackModel.java index 5fbc854..ff24a40 100644 --- a/src/org/ntlab/traceDebugger/CallStackModel.java +++ b/src/org/ntlab/traceDebugger/CallStackModel.java @@ -1,66 +1,78 @@ -package org.ntlab.traceDebugger; - -import org.ntlab.traceAnalysisPlatform.tracer.trace.MethodExecution; -import org.ntlab.traceAnalysisPlatform.tracer.trace.Trace; -import org.ntlab.traceAnalysisPlatform.tracer.trace.TracePoint; - -public class CallStackModel { - private TracePoint tracePoint; - private boolean isHighlighting; - - public CallStackModel(TracePoint tracePoint) { - this.tracePoint = tracePoint; - } - - public TracePoint getTracePoint() { - return tracePoint; - } - - public MethodExecution getMethodExecution() { - return tracePoint.getMethodExecution(); - } - - public int getCallLineNo() { - return tracePoint.getStatement().getLineNo(); - } - - public String getSignature() { - return tracePoint.getMethodExecution().getSignature(); - } - - public String getCallStackSignature() { - String signature = ""; - signature = getSignature(); - MethodExecution methodExecution = tracePoint.getMethodExecution(); - String objectType = methodExecution.getThisClassName(); - objectType = objectType.substring(objectType.lastIndexOf(".") + 1); - boolean isConstructor = methodExecution.isConstructor(); - String declaringType = Trace.getDeclaringType(signature, isConstructor); - declaringType = declaringType.substring(declaringType.lastIndexOf(".") + 1); - String methodName = Trace.getMethodName(signature); - String args = "("; - String delimiter = ""; - String[] argArray = signature.split("\\(")[1].split(","); - for (String arg : argArray) { - args += (delimiter + arg.substring(arg.lastIndexOf(".") + 1)); - delimiter = ", "; - } - - StringBuilder sb = new StringBuilder(); - sb.append(objectType); - if (!declaringType.equals(objectType)) { - sb.append("(" + declaringType + ")"); - } - sb.append("." + methodName + args); - signature = sb.toString(); - return signature; - } - - public boolean isHighlighting() { - return isHighlighting; - } - - public void setHighlighting(boolean isHighlighting) { - this.isHighlighting = isHighlighting; - } -} +package org.ntlab.traceDebugger; + +import org.ntlab.traceAnalysisPlatform.tracer.trace.MethodExecution; +import org.ntlab.traceAnalysisPlatform.tracer.trace.Trace; +import org.ntlab.traceAnalysisPlatform.tracer.trace.TracePoint; + +public class CallStackModel { + private TracePoint tracePoint; + private boolean isHighlighting; + + public CallStackModel(TracePoint tracePoint) { + this.tracePoint = tracePoint; + } + + public TracePoint getTracePoint() { + return tracePoint; + } + + public MethodExecution getMethodExecution() { + return tracePoint.getMethodExecution(); + } + + public int getCallLineNo() { + return tracePoint.getStatement().getLineNo(); + } + + public String getSignature() { + return tracePoint.getMethodExecution().getSignature(); + } + + public String getCallStackSignature() { + String signature = ""; + signature = getSignature(); + MethodExecution methodExecution = tracePoint.getMethodExecution(); + String objectType = methodExecution.getThisClassName(); + objectType = objectType.substring(objectType.lastIndexOf(".") + 1); + boolean isConstructor = methodExecution.isConstructor(); + String declaringType = Trace.getDeclaringType(signature, isConstructor); + + declaringType = removePackageNameFromSignature(declaringType); + String methodName = Trace.getMethodName(signature); + String args = "("; + String delimiter = ""; + String[] argArray = signature.split("\\(")[1].split(","); + for (String arg : argArray) { + args += (delimiter + removePackageNameFromSignature(arg)); + delimiter = ", "; + } + + StringBuilder sb = new StringBuilder(); + sb.append(objectType); + if (!declaringType.equals(objectType)) { + sb.append("(" + declaringType + ")"); + } + sb.append("." + methodName + args); + signature = sb.toString(); + return signature; + } + + private String removePackageNameFromSignature(String signature) { + String subSignature = signature; + while (true) { + if (!(subSignature.contains("."))) break; + subSignature = subSignature.substring(subSignature.indexOf(".") + 1); + if (subSignature.isEmpty()) break; + if (Character.isUpperCase(subSignature.charAt(0))) break; + } + return subSignature; + } + + public boolean isHighlighting() { + return isHighlighting; + } + + public void setHighlighting(boolean isHighlighting) { + this.isHighlighting = isHighlighting; + } +} diff --git a/src/org/ntlab/traceDebugger/Variable.java b/src/org/ntlab/traceDebugger/Variable.java index 0156d8d..125ff5f 100644 --- a/src/org/ntlab/traceDebugger/Variable.java +++ b/src/org/ntlab/traceDebugger/Variable.java @@ -132,6 +132,10 @@ public TracePoint getBeforeTracePoint() { return before; } + + public void setBeforeTracePoint(TracePoint before) { + this.before = before; + } public Variable getParent() { return parent; diff --git a/src/org/ntlab/traceDebugger/Variables.java b/src/org/ntlab/traceDebugger/Variables.java index 915b369..b0e5bbb 100644 --- a/src/org/ntlab/traceDebugger/Variables.java +++ b/src/org/ntlab/traceDebugger/Variables.java @@ -155,19 +155,20 @@ } public void updateForDifferential(TracePoint from, TracePoint to, boolean isReturned) { - updateForDifferential(); + updateForDifferential(to); resetSpecialValues(); createSpecialVariables(from, to, isReturned); } - private void updateForDifferential() { + private void updateForDifferential(TracePoint before) { for (Variable variable : roots) { - updateForDifferential(variable, new HashSet()); + updateForDifferential(variable, new HashSet(), before); } containerIdToDifferentialUpdateTracePoints.clear(); } - private void updateForDifferential(Variable variable, Set hasCheckedObjectIdSet) { + private void updateForDifferential(Variable variable, Set hasCheckedObjectIdSet, TracePoint before) { + variable.setBeforeTracePoint(before); Set containerIdList = containerIdToDifferentialUpdateTracePoints.keySet(); String containerId = variable.getContainerId(); if (containerIdList.contains(containerId)) { @@ -191,7 +192,7 @@ hasCheckedObjectIdSetOnNext.add(variable.getContainerId()); for (Variable child : variable.getChildren()) { if (hasCheckedObjectIdSetOnNext.contains(child.getContainerId())) continue; - updateForDifferential(child, hasCheckedObjectIdSetOnNext); + updateForDifferential(child, hasCheckedObjectIdSetOnNext, before); } }