@@ -38,13 +38,19 @@ public static class StackFrameImpl implements StackFrame {
38
38
private final int mLine ;
39
39
private final int mColumn ;
40
40
private final String mFileName ;
41
+ private final boolean mIsCollapsed ;
41
42
42
- private StackFrameImpl (String file , String method , int line , int column ) {
43
+ private StackFrameImpl (String file , String method , int line , int column , boolean isCollapsed ) {
43
44
mFile = file ;
44
45
mMethod = method ;
45
46
mLine = line ;
46
47
mColumn = column ;
47
48
mFileName = file != null ? new File (file ).getName () : "" ;
49
+ mIsCollapsed = isCollapsed ;
50
+ }
51
+
52
+ private StackFrameImpl (String file , String method , int line , int column ) {
53
+ this (file , method , line , column , false );
48
54
}
49
55
50
56
private StackFrameImpl (String file , String fileName , String method , int line , int column ) {
@@ -53,6 +59,7 @@ private StackFrameImpl(String file, String fileName, String method, int line, in
53
59
mMethod = method ;
54
60
mLine = line ;
55
61
mColumn = column ;
62
+ mIsCollapsed = false ;
56
63
}
57
64
58
65
/**
@@ -90,14 +97,19 @@ public String getFileName() {
90
97
return mFileName ;
91
98
}
92
99
100
+ public boolean isCollapsed () {
101
+ return mIsCollapsed ;
102
+ }
103
+
93
104
/** Convert the stack frame to a JSON representation. */
94
105
public JSONObject toJSON () {
95
106
return new JSONObject (
96
107
MapBuilder .of (
97
108
"file" , getFile (),
98
109
"methodName" , getMethod (),
99
110
"lineNumber" , getLine (),
100
- "column" , getColumn ()));
111
+ "column" , getColumn (),
112
+ "collapse" , isCollapsed ()));
101
113
}
102
114
}
103
115
@@ -114,6 +126,8 @@ public static StackFrame[] convertJsStackTrace(@Nullable ReadableArray stack) {
114
126
ReadableMap frame = stack .getMap (i );
115
127
String methodName = frame .getString ("methodName" );
116
128
String fileName = frame .getString ("file" );
129
+ boolean collapse =
130
+ frame .hasKey ("collapse" ) && !frame .isNull ("collapse" ) && frame .getBoolean ("collapse" );
117
131
int lineNumber = -1 ;
118
132
if (frame .hasKey (LINE_NUMBER_KEY ) && !frame .isNull (LINE_NUMBER_KEY )) {
119
133
lineNumber = frame .getInt (LINE_NUMBER_KEY );
@@ -122,7 +136,7 @@ public static StackFrame[] convertJsStackTrace(@Nullable ReadableArray stack) {
122
136
if (frame .hasKey (COLUMN_KEY ) && !frame .isNull (COLUMN_KEY )) {
123
137
columnNumber = frame .getInt (COLUMN_KEY );
124
138
}
125
- result [i ] = new StackFrameImpl (fileName , methodName , lineNumber , columnNumber );
139
+ result [i ] = new StackFrameImpl (fileName , methodName , lineNumber , columnNumber , collapse );
126
140
} else if (type == ReadableType .String ) {
127
141
result [i ] = new StackFrameImpl (null , stack .getString (i ), -1 , -1 );
128
142
}
@@ -150,7 +164,9 @@ public static StackFrame[] convertJsStackTrace(JSONArray stack) {
150
164
if (frame .has (COLUMN_KEY ) && !frame .isNull (COLUMN_KEY )) {
151
165
columnNumber = frame .getInt (COLUMN_KEY );
152
166
}
153
- result [i ] = new StackFrameImpl (fileName , methodName , lineNumber , columnNumber );
167
+ boolean collapse =
168
+ frame .has ("collapse" ) && !frame .isNull ("collapse" ) && frame .getBoolean ("collapse" );
169
+ result [i ] = new StackFrameImpl (fileName , methodName , lineNumber , columnNumber , collapse );
154
170
}
155
171
} catch (JSONException exception ) {
156
172
throw new RuntimeException (exception );
0 commit comments