diff --git a/org.ntlab.traceCollector/src/org/ntlab/traceCollector/tracer/trace/Alias.java b/org.ntlab.traceCollector/src/org/ntlab/traceCollector/tracer/trace/Alias.java index 54126ef..0628100 100644 --- a/org.ntlab.traceCollector/src/org/ntlab/traceCollector/tracer/trace/Alias.java +++ b/org.ntlab.traceCollector/src/org/ntlab/traceCollector/tracer/trace/Alias.java @@ -51,33 +51,92 @@ return occurrenceExp; } - @Override - public String toString() { - StringBuilder str = new StringBuilder(); + public MethodExecution getMethodExecution() { + return occurrencePoint.getMethodExecution(); + } + + public String getMethodSignature() { + return occurrencePoint.getMethodExecution().getCallerSideSignature(); + } + + public int getLineNo() { Statement statement = occurrencePoint.getStatement(); - String className = ""; + return statement.getLineNo(); + } + + public String getStatementType() { + Statement statement = occurrencePoint.getStatement(); String statementType = ""; if (statement instanceof FieldAccess) { + FieldAccess fa = (FieldAccess)statement; statementType = "FieldAccess"; - className = ((FieldAccess) statement).getValueClassName(); } else if (statement instanceof FieldUpdate) { + FieldUpdate fu = (FieldUpdate)statement; statementType = "FieldUpdate"; - className = ((FieldUpdate) statement).getValueClassName(); } else if (statement instanceof ArrayAccess) { + ArrayAccess aa = (ArrayAccess)statement; statementType = "ArrayAccess"; + } else if (statement instanceof ArrayUpdate) { + ArrayUpdate au = (ArrayUpdate)statement; + statementType = "ArrayUpdate"; + } else if (statement instanceof ArrayCreate) { + ArrayCreate ac = (ArrayCreate)statement; + statementType = "ArrayCreate"; + } else if (statement instanceof MethodInvocation) { + MethodExecution me = ((MethodInvocation)statement).getCalledMethodExecution(); + statementType = "MethodInvocation"; + } + return statementType; + } + + public String getStatementSignature() { + Statement statement = occurrencePoint.getStatement(); + String statementSignature = ""; + if (statement instanceof FieldAccess) { + FieldAccess fa = (FieldAccess)statement; + statementSignature = fa.getFieldName(); + } else if (statement instanceof FieldUpdate) { + FieldUpdate fu = (FieldUpdate)statement; + statementSignature = fu.getFieldName(); + } else if (statement instanceof ArrayAccess) { + ArrayAccess aa = (ArrayAccess)statement; + statementSignature = aa.getArrayClassName() + "[" + aa.getIndex() + "]"; + } else if (statement instanceof ArrayUpdate) { + ArrayUpdate au = (ArrayUpdate)statement; + statementSignature = au.getArrayClassName() + "[" + au.getIndex() + "]"; + } else if (statement instanceof ArrayCreate) { + ArrayCreate ac = (ArrayCreate)statement; + statementSignature = ac.getArrayClassName(); + } else if (statement instanceof MethodInvocation) { + MethodExecution me = ((MethodInvocation)statement).getCalledMethodExecution(); + statementSignature = me.getCallerSideSignature(); + } + return statementSignature; + } + + public String getClassName() { + Statement statement = occurrencePoint.getStatement(); + String className = ""; + if (statement instanceof FieldAccess) { + if (occurrenceExp == OCCURRENCE_EXP_CONTAINER) { + className = ((FieldAccess) statement).getContainerClassName(); + } else if (occurrenceExp == OCCURRENCE_EXP_FIELD) { + className = ((FieldAccess) statement).getValueClassName(); + } + } else if (statement instanceof FieldUpdate) { + if (occurrenceExp == OCCURRENCE_EXP_CONTAINER) { + className = ((FieldUpdate) statement).getContainerClassName(); + } else if (occurrenceExp == OCCURRENCE_EXP_FIELD) { + className = ((FieldUpdate) statement).getValueClassName(); + } + } else if (statement instanceof ArrayAccess) { className = ((ArrayAccess) statement).getValueClassName(); } else if (statement instanceof ArrayUpdate) { - statementType = "ArrayUpdate"; className = ((ArrayUpdate) statement).getValueClassName(); } else if (statement instanceof ArrayCreate) { - statementType = "ArrayCreate"; className = ((ArrayCreate) statement).getArrayClassName(); } else if (statement instanceof MethodInvocation) { MethodExecution me = ((MethodInvocation)statement).getCalledMethodExecution(); - statementType = "MethodInvocation -> " + me.getCallerSideSignature(); - if(((MethodInvocation)statement).getCalledMethodExecution().isConstructor()) { - statementType += " (Constructor)"; - } if (occurrenceExp == OCCURRENCE_EXP_RETURN) { className = me.getReturnValue().getActualType(); } else if (occurrenceExp == OCCURRENCE_EXP_RECEIVER) { @@ -90,12 +149,23 @@ } } } + return className; + } + + @Override + public String toString() { + Statement statement = occurrencePoint.getStatement(); + String className = getClassName(); + String methodSignature = getMethodSignature(); + String statementType = getStatementType(); + String statementSigunarure = getStatementSignature(); String indent = " "; + StringBuilder str = new StringBuilder(); str.append("objId: " + objectId + " (class = " + className + ")" + "\n"); str.append("tp: " + occurrencePoint + "\n"); - str.append(indent + "signature: " + occurrencePoint.getMethodExecution().getCallerSideSignature() + "\n"); + str.append(indent + "signature: " + methodSignature + "\n"); str.append(indent + "lineNo: " + statement.getLineNo() + "\n"); - str.append(indent + "statementType: " + statementType + "\n"); + str.append(indent + "statementType: " + statementType + " -> " + statementSigunarure + "\n"); str.append("occurrenceExp: " + occurrenceExp + "\n"); return str.toString(); }