blob: 1857cd12c9df426659786da4c6d4d47345aa2853 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
/*
* WarmRoast
* Copyright (C) 2013 Albert Pham <http://www.sk89q.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.warmroast;
import java.util.List;
public class StackTraceNode extends StackNode {
private final String className;
private final String methodName;
public StackTraceNode(String className, String methodName) {
super(className + "." + methodName + "()");
this.className = className;
this.methodName = methodName;
}
public String getClassName() {
return className;
}
public String getMethodName() {
return methodName;
}
@Override
public String getNameHtml(McpMapping mapping) {
ClassMapping classMapping = mapping.mapClass(getClassName());
if (classMapping != null) {
String className = "<span class=\"matched\" title=\"" +
escapeHtml(getClassName()) + "\">" +
escapeHtml(classMapping.getActual()) + "</span>";
List<String> actualMethods = classMapping.mapMethod(getMethodName());
if (actualMethods.size() == 0) {
return className + "." + escapeHtml(getMethodName()) + "()";
} else if (actualMethods.size() == 1) {
return className +
".<span class=\"matched\" title=\"" +
escapeHtml(getMethodName()) + "\">" +
escapeHtml(actualMethods.get(0)) + "</span>()";
} else {
StringBuilder builder = new StringBuilder();
boolean first = true;
for (String m : actualMethods) {
if (!first) {
builder.append(" ");
}
builder.append(m);
first = false;
}
return className +
".<span class=\"multiple-matches\" title=\"" +
builder.toString() + "\">" + escapeHtml(getMethodName()) + "</span>()";
}
} else {
String actualMethod = mapping.fromMethodId(getMethodName());
if (actualMethod == null) {
return escapeHtml(getClassName()) + "." + escapeHtml(getMethodName()) + "()";
} else {
return className +
".<span class=\"matched\" title=\"" +
escapeHtml(getMethodName()) + "\">" +
escapeHtml(actualMethod) + "</span>()";
}
}
}
@Override
public int compareTo(StackNode o) {
if (getTotalTime() == o.getTotalTime()) {
return 0;
} else if (getTotalTime()> o.getTotalTime()) {
return -1;
} else {
return 1;
}
}
}
|