forked from microsoft/vscode-node-debug
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebugExtension.ts
More file actions
113 lines (106 loc) · 3.45 KB
/
Copy pathdebugExtension.ts
File metadata and controls
113 lines (106 loc) · 3.45 KB
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
!function() {
var vm = require('vm');
var LookupMirror = vm.runInDebugContext('LookupMirror');
var PropertyKind = vm.runInDebugContext('PropertyKind');
var DebugCommandProcessor = vm.runInDebugContext('DebugCommandProcessor');
var JSONProtocolSerializer = vm.runInDebugContext('JSONProtocolSerializer');
JSONProtocolSerializer.prototype.serializeReferencedObjects = function () {
var content = [];
for (var i = 0; i < this.mirrors_.length; i++) {
var m = this.mirrors_[i];
if (m.isArray()) continue;
if (m.isObject() && m.propertyNames(PropertyKind.Indexed | PropertyKind.Named, 100).length >= 100) continue;
content.push(this.serialize_(m, false, false));
}
return content;
};
DebugCommandProcessor.prototype.dispatch_['vscode_range'] = function(request, response) {
var handle = request.arguments.handle;
var from_index = request.arguments.from;
var to_index = request.arguments.to;
var mirror = LookupMirror(handle);
if (!mirror) {
return response.failed('Object #' + handle + '# not found');
}
var result;
if (mirror.isArray()) {
result = new Array(to_index - from_index + 1);
var a = mirror.indexedPropertiesFromRange(from_index, to_index);
for (var i = 0; i < a.length; i++) {
result[i] = a[i].value();
}
} else if (mirror.isObject()) {
result = new Array(to_index - from_index + 1);
for (var j = from_index; j <= to_index; j++) {
var p = mirror.property(j.toString());
result[j - from_index] = p.value();
}
} else {
result = new Array(to_index - from_index + 1);
}
response.body = {
result: result
};
};
DebugCommandProcessor.prototype.vscode_dehydrate = function(mirror) {
var className = null;
var size = -1;
if (mirror.isArray()) {
className = "Array";
size = mirror.length();
} else if (mirror.isObject()) {
switch (mirror.toText()) {
case "#<Buffer>":
className = "Buffer";
size = mirror.propertyNames(PropertyKind.Indexed).length;
break;
case "#<Int8Array>":
case "#<Uint8Array>":
case "#<Uint8ClampedArray>":
case "#<Int16Array>":
case "#<Uint16Array>":
case "#<Int32Array>":
case "#<Uint32Array>":
case "#<Float32Array>":
case "#<Float64Array>":
className = mirror.className();
size = mirror.propertyNames(PropertyKind.Indexed).length;
break;
default:
break;
}
}
if (size > 1000) {
return {
handle: mirror.handle(),
type: "object",
className: className,
size: size,
value: className
};
}
return mirror;
};
DebugCommandProcessor.prototype.dispatch_['vscode_lookup'] = function(request, response) {
var result = this.lookupRequest_(request, response);
if (!result) {
var handles = request.arguments.handles;
for (var i = 0; i < handles.length; i++) {
var handle = handles[i];
response.body[handle] = this.vscode_dehydrate(response.body[handle]);
}
}
return result;
};
DebugCommandProcessor.prototype.dispatch_['vscode_evaluate'] = function(request, response) {
var result = this.evaluateRequest_(request, response);
if (!result) {
response.body = this.vscode_dehydrate(response.body);
}
return result;
};
}()