blob: fb4e8771a48b925588d9f210ebae24944323e66b (
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
|
package org.jetbrains.debugger.frame;
import com.intellij.icons.AllIcons;
import com.intellij.ui.ColoredTextContainer;
import com.intellij.ui.SimpleTextAttributes;
import com.intellij.xdebugger.evaluation.XDebuggerEvaluator;
import com.intellij.xdebugger.frame.XStackFrame;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.debugger.SourceInfo;
// todo remove when Firefox implementation will use SDK
public abstract class StackFrameImplBase extends XStackFrame {
protected final SourceInfo sourceInfo;
protected XDebuggerEvaluator evaluator;
public StackFrameImplBase(@Nullable SourceInfo sourceInfo) {
this.sourceInfo = sourceInfo;
}
@Override
public final XDebuggerEvaluator getEvaluator() {
if (evaluator == null) {
evaluator = createEvaluator();
}
return evaluator;
}
protected abstract XDebuggerEvaluator createEvaluator();
@Override
@Nullable
public SourceInfo getSourcePosition() {
return sourceInfo;
}
protected boolean isInFileScope() {
return false;
}
protected boolean isInLibraryContent() {
return false;
}
@Override
public final void customizePresentation(@NotNull ColoredTextContainer component) {
if (sourceInfo == null) {
customizeInvalidFramePresentation(component);
return;
}
String fileName = sourceInfo.getFile().getName();
int line = sourceInfo.getLine() + 1;
boolean isInLibraryContent = isInLibraryContent();
SimpleTextAttributes textAttributes = isInLibraryContent ? SimpleTextAttributes.GRAYED_ATTRIBUTES : SimpleTextAttributes.REGULAR_ATTRIBUTES;
String functionName = sourceInfo.getFunctionName();
if (functionName == null || (functionName.isEmpty() && isInFileScope())) {
component.append(fileName + ":" + line, textAttributes);
}
else {
if (functionName.isEmpty()) {
component.append("anonymous", isInLibraryContent ? SimpleTextAttributes.GRAYED_ITALIC_ATTRIBUTES : SimpleTextAttributes.REGULAR_ITALIC_ATTRIBUTES);
}
else {
component.append(functionName, textAttributes);
}
component.append("(), " + fileName + ":" + line, textAttributes);
}
component.setIcon(AllIcons.Debugger.StackFrame);
}
protected void customizeInvalidFramePresentation(ColoredTextContainer component) {
super.customizePresentation(component);
}
}
|