roku-debug 0.21.18 → 0.21.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/LaunchConfiguration.d.ts +7 -0
  3. package/dist/adapters/DebugProtocolAdapter.d.ts +1 -1
  4. package/dist/adapters/DebugProtocolAdapter.js.map +1 -1
  5. package/dist/adapters/TelnetAdapter.d.ts +2 -0
  6. package/dist/adapters/TelnetAdapter.js +6 -0
  7. package/dist/adapters/TelnetAdapter.js.map +1 -1
  8. package/dist/bsc/BscProject.d.ts +27 -0
  9. package/dist/bsc/BscProject.js +50 -0
  10. package/dist/bsc/BscProject.js.map +1 -0
  11. package/dist/bsc/BscProjectThreaded.d.ts +45 -0
  12. package/dist/bsc/BscProjectThreaded.js +90 -0
  13. package/dist/bsc/BscProjectThreaded.js.map +1 -0
  14. package/dist/bsc/threading/BscProjectWorkerPool.d.ts +5 -0
  15. package/dist/bsc/threading/BscProjectWorkerPool.js +29 -0
  16. package/dist/bsc/threading/BscProjectWorkerPool.js.map +1 -0
  17. package/dist/bsc/threading/ThreadMessageHandler.d.ts +99 -0
  18. package/dist/bsc/threading/ThreadMessageHandler.js +138 -0
  19. package/dist/bsc/threading/ThreadMessageHandler.js.map +1 -0
  20. package/dist/bsc/threading/ThreadRunner.d.ts +30 -0
  21. package/dist/bsc/threading/ThreadRunner.js +50 -0
  22. package/dist/bsc/threading/ThreadRunner.js.map +1 -0
  23. package/dist/bsc/threading/WorkerPool.d.ts +38 -0
  24. package/dist/bsc/threading/WorkerPool.js +78 -0
  25. package/dist/bsc/threading/WorkerPool.js.map +1 -0
  26. package/dist/debugSession/BrightScriptDebugSession.d.ts +7 -0
  27. package/dist/debugSession/BrightScriptDebugSession.js +304 -19
  28. package/dist/debugSession/BrightScriptDebugSession.js.map +1 -1
  29. package/dist/interfaces.d.ts +12 -0
  30. package/dist/managers/ProjectManager.d.ts +31 -12
  31. package/dist/managers/ProjectManager.js +61 -9
  32. package/dist/managers/ProjectManager.js.map +1 -1
  33. package/dist/util.d.ts +6 -1
  34. package/dist/util.js +20 -0
  35. package/dist/util.js.map +1 -1
  36. package/package.json +2 -2
  37. package/roku-debug-0.21.19.tgz +0 -0
  38. package/roku-debug-0.21.18.tgz +0 -0
@@ -0,0 +1,99 @@
1
+ /// <reference types="node" />
2
+ import type { parentPort } from 'worker_threads';
3
+ interface PseudoMessagePort {
4
+ on: (name: 'message', cb: (message: any) => any) => any;
5
+ postMessage: typeof parentPort['postMessage'];
6
+ }
7
+ export declare class ThreadMessageHandler<T, TRequestName = MethodNames<T>> {
8
+ constructor(options: {
9
+ name?: string;
10
+ port: PseudoMessagePort;
11
+ onRequest?: (message: WorkerRequest) => any;
12
+ onResponse?: (message: WorkerResponse) => any;
13
+ onUpdate?: (message: WorkerUpdate) => any;
14
+ });
15
+ /**
16
+ * An optional name to help with debugging this handler
17
+ */
18
+ readonly name: string;
19
+ private port;
20
+ private disposables;
21
+ private emitter;
22
+ private activeRequests;
23
+ /**
24
+ * Get the response with this ID
25
+ * @param id the ID of the response
26
+ * @returns the message
27
+ */
28
+ private onResponse;
29
+ /**
30
+ * A unique sequence for identifying messages
31
+ */
32
+ private idSequence;
33
+ /**
34
+ * Send a request to the worker, and wait for a response.
35
+ * @param name the name of the request
36
+ * @param options the request options
37
+ * @param options.data an array of data that will be passed in as params to the target function
38
+ * @param options.id an id for this request
39
+ */
40
+ sendRequest<R>(name: TRequestName, options?: {
41
+ data: any[];
42
+ id?: number;
43
+ }): Promise<WorkerResponse<R>>;
44
+ /**
45
+ * Send a request to the worker, and wait for a response.
46
+ * @param request the request we are responding to
47
+ * @param options options for this request
48
+ */
49
+ sendResponse(request: WorkerMessage, options?: {
50
+ data: any;
51
+ } | {
52
+ error: Error;
53
+ } | undefined): void;
54
+ /**
55
+ * Send a request to the worker, and wait for a response.
56
+ * @param name the name of the request
57
+ * @param options options for the update
58
+ * @param options.data an array of data that will be passed in as params to the target function
59
+ * @param options.id an id for this update
60
+ */
61
+ sendUpdate<T>(name: string, options?: {
62
+ data?: any[];
63
+ id?: number;
64
+ }): void;
65
+ /**
66
+ * Convert an Error object into a plain object so it can be serialized
67
+ * @param error the error to object-ify
68
+ * @returns an object version of an error
69
+ */
70
+ private errorToObject;
71
+ dispose(): void;
72
+ }
73
+ export interface WorkerRequest<TData = any> {
74
+ id: number;
75
+ type: 'request';
76
+ name: string;
77
+ data?: TData;
78
+ }
79
+ export interface WorkerResponse<TData = any> {
80
+ id: number;
81
+ type: 'response';
82
+ name: string;
83
+ data?: TData;
84
+ /**
85
+ * An error occurred on the remote side. There will be no `.data` value
86
+ */
87
+ error?: Error;
88
+ }
89
+ export interface WorkerUpdate<TData = any> {
90
+ id: number;
91
+ type: 'update';
92
+ name: string;
93
+ data?: TData;
94
+ }
95
+ export declare type WorkerMessage<T = any> = WorkerRequest<T> | WorkerResponse<T> | WorkerUpdate<T>;
96
+ export declare type MethodNames<T> = {
97
+ [K in keyof T]: T[K] extends (...args: any[]) => any ? K : never;
98
+ }[keyof T];
99
+ export {};
@@ -0,0 +1,138 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ThreadMessageHandler = void 0;
4
+ const EventEmitter = require("eventemitter3");
5
+ const brighterscript_1 = require("brighterscript");
6
+ const util_1 = require("../../util");
7
+ class ThreadMessageHandler {
8
+ constructor(options) {
9
+ this.disposables = [];
10
+ this.emitter = new EventEmitter();
11
+ this.activeRequests = new Map();
12
+ /**
13
+ * A unique sequence for identifying messages
14
+ */
15
+ this.idSequence = 0;
16
+ this.name = options === null || options === void 0 ? void 0 : options.name;
17
+ this.port = options === null || options === void 0 ? void 0 : options.port;
18
+ const listener = (message) => {
19
+ var _a, _b, _c;
20
+ switch (message.type) {
21
+ case 'request':
22
+ (_a = options === null || options === void 0 ? void 0 : options.onRequest) === null || _a === void 0 ? void 0 : _a.call(options, message);
23
+ break;
24
+ case 'response':
25
+ (_b = options === null || options === void 0 ? void 0 : options.onResponse) === null || _b === void 0 ? void 0 : _b.call(options, message);
26
+ this.emitter.emit(`${message.type}-${message.id}`, message);
27
+ break;
28
+ case 'update':
29
+ (_c = options === null || options === void 0 ? void 0 : options.onUpdate) === null || _c === void 0 ? void 0 : _c.call(options, message);
30
+ break;
31
+ }
32
+ };
33
+ options === null || options === void 0 ? void 0 : options.port.on('message', listener);
34
+ this.disposables.push(() => this.emitter.removeAllListeners(), () => (options === null || options === void 0 ? void 0 : options.port).off('message', listener));
35
+ }
36
+ /**
37
+ * Get the response with this ID
38
+ * @param id the ID of the response
39
+ * @returns the message
40
+ */
41
+ onResponse(id) {
42
+ const deferred = new brighterscript_1.Deferred();
43
+ //store this request so we can resolve it later, or reject if this class is disposed
44
+ this.activeRequests.set(id, {
45
+ id: id,
46
+ deferred: deferred
47
+ });
48
+ this.emitter.once(`response-${id}`, (response) => {
49
+ deferred.resolve(response);
50
+ this.activeRequests.delete(id);
51
+ });
52
+ return deferred.promise;
53
+ }
54
+ /**
55
+ * Send a request to the worker, and wait for a response.
56
+ * @param name the name of the request
57
+ * @param options the request options
58
+ * @param options.data an array of data that will be passed in as params to the target function
59
+ * @param options.id an id for this request
60
+ */
61
+ async sendRequest(name, options) {
62
+ var _a, _b;
63
+ const request = {
64
+ type: 'request',
65
+ name: name,
66
+ data: (_a = options === null || options === void 0 ? void 0 : options.data) !== null && _a !== void 0 ? _a : [],
67
+ id: (_b = options === null || options === void 0 ? void 0 : options.id) !== null && _b !== void 0 ? _b : this.idSequence++
68
+ };
69
+ const responsePromise = this.onResponse(request.id);
70
+ this.port.postMessage(request);
71
+ const response = await responsePromise;
72
+ if ('error' in response) {
73
+ //throw the error so it causes a rejected promise (like we'd expect)
74
+ throw new Error(`Worker thread encountered an error: ${JSON.stringify(response.error.stack)}`);
75
+ }
76
+ return response;
77
+ }
78
+ /**
79
+ * Send a request to the worker, and wait for a response.
80
+ * @param request the request we are responding to
81
+ * @param options options for this request
82
+ */
83
+ sendResponse(request, options) {
84
+ const response = {
85
+ type: 'response',
86
+ name: request.name,
87
+ id: request.id
88
+ };
89
+ if ('error' in options) {
90
+ //hack: turn the error into a plain json object
91
+ response.error = this.errorToObject(options.error);
92
+ }
93
+ else if ('data' in options) {
94
+ response.data = options.data;
95
+ }
96
+ this.port.postMessage(response);
97
+ }
98
+ /**
99
+ * Send a request to the worker, and wait for a response.
100
+ * @param name the name of the request
101
+ * @param options options for the update
102
+ * @param options.data an array of data that will be passed in as params to the target function
103
+ * @param options.id an id for this update
104
+ */
105
+ sendUpdate(name, options) {
106
+ var _a, _b;
107
+ let update = {
108
+ type: 'update',
109
+ name: name,
110
+ data: (_a = options === null || options === void 0 ? void 0 : options.data) !== null && _a !== void 0 ? _a : [],
111
+ id: (_b = options === null || options === void 0 ? void 0 : options.id) !== null && _b !== void 0 ? _b : this.idSequence++
112
+ };
113
+ this.port.postMessage(update);
114
+ }
115
+ /**
116
+ * Convert an Error object into a plain object so it can be serialized
117
+ * @param error the error to object-ify
118
+ * @returns an object version of an error
119
+ */
120
+ errorToObject(error) {
121
+ var _a, _b;
122
+ return {
123
+ name: error.name,
124
+ message: error.message,
125
+ stack: error.stack,
126
+ cause: ((_a = error.cause) === null || _a === void 0 ? void 0 : _a.message) && ((_b = error.cause) === null || _b === void 0 ? void 0 : _b.stack) ? this.errorToObject(error.cause) : error.cause
127
+ };
128
+ }
129
+ dispose() {
130
+ util_1.util.applyDispose(this.disposables);
131
+ //reject all active requests
132
+ for (const request of this.activeRequests.values()) {
133
+ request.deferred.reject(new Error(`Request ${request.id} has been rejected because MessageHandler is now disposed`));
134
+ }
135
+ }
136
+ }
137
+ exports.ThreadMessageHandler = ThreadMessageHandler;
138
+ //# sourceMappingURL=ThreadMessageHandler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ThreadMessageHandler.js","sourceRoot":"","sources":["../../../src/bsc/threading/ThreadMessageHandler.ts"],"names":[],"mappings":";;;AACA,8CAA8C;AAE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E,KAAK,CAAA,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,KAAyB,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK;SAC1I,CAAC;IACN,CAAC;IAEM,OAAO;QACV,WAAI,CAAC,YAAY,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACpC,4BAA4B;QAC5B,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,EAAE;YAChD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,WAAW,OAAO,CAAC,EAAE,2DAA2D,CAAC,CAAC,CAAC;SACxH;IACL,CAAC;CACJ;AA/JD,oDA+JC"}
@@ -0,0 +1,30 @@
1
+ /// <reference types="node" />
2
+ import type { MessagePort } from 'worker_threads';
3
+ /**
4
+ * Runner logic for Running a Project in a worker thread.
5
+ */
6
+ export declare class ThreadRunner<T extends ThreadRunnerSubject> {
7
+ private subjectFactory;
8
+ constructor(subjectFactory: () => T);
9
+ private requestInterceptors;
10
+ /**
11
+ * The instance of the object this runner will communicate with. It should have methods with the same names as the request being sent.
12
+ */
13
+ private subject;
14
+ private messageHandler;
15
+ run(parentPort: MessagePort): void;
16
+ /**
17
+ * Fired anytime we get an `activate` request from the client. This allows us to clean up the previous project and make a new one
18
+ */
19
+ private onActivate;
20
+ }
21
+ export interface ThreadRunnerSubject {
22
+ /**
23
+ * Called whenever a new subject has been activated
24
+ */
25
+ activate(...args: any[]): void | Promise<any>;
26
+ /**
27
+ * Called whenever a subject will no longer be used. Allows for cleaning up a subject.
28
+ */
29
+ dispose(): void | Promise<any>;
30
+ }
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ThreadRunner = void 0;
4
+ const ThreadMessageHandler_1 = require("./ThreadMessageHandler");
5
+ /**
6
+ * Runner logic for Running a Project in a worker thread.
7
+ */
8
+ class ThreadRunner {
9
+ constructor(subjectFactory) {
10
+ this.subjectFactory = subjectFactory;
11
+ //collection of interceptors that will be called when events are fired
12
+ this.requestInterceptors = {};
13
+ }
14
+ run(parentPort) {
15
+ this.messageHandler = new ThreadMessageHandler_1.ThreadMessageHandler({
16
+ name: 'WorkerThread',
17
+ port: parentPort,
18
+ onRequest: async (request) => {
19
+ var _a, _b, _c;
20
+ try {
21
+ //if we have a request interceptor registered for this event, call it
22
+ (_b = (_a = this.requestInterceptors)[request.name]) === null || _b === void 0 ? void 0 : _b.call(_a, request.data);
23
+ //only the LspProject interface method names will be passed as request names, so just call those functions on the Project class directly
24
+ let responseData = await this.subject[request.name](...(_c = request.data) !== null && _c !== void 0 ? _c : []);
25
+ this.messageHandler.sendResponse(request, { data: responseData });
26
+ //we encountered a runtime crash. Pass that error along as the response to this request
27
+ }
28
+ catch (e) {
29
+ const error = e;
30
+ this.messageHandler.sendResponse(request, { error: error });
31
+ }
32
+ },
33
+ onUpdate: (update) => {
34
+ }
35
+ });
36
+ this.requestInterceptors.activate = this.onActivate.bind(this);
37
+ }
38
+ /**
39
+ * Fired anytime we get an `activate` request from the client. This allows us to clean up the previous project and make a new one
40
+ */
41
+ onActivate() {
42
+ var _a;
43
+ //clean up any existing project
44
+ void ((_a = this.subject) === null || _a === void 0 ? void 0 : _a.dispose());
45
+ //make a new instance of the subject
46
+ this.subject = this.subjectFactory();
47
+ }
48
+ }
49
+ exports.ThreadRunner = ThreadRunner;
50
+ //# sourceMappingURL=ThreadRunner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ThreadRunner.js","sourceRoot":"","sources":["../../../src/bsc/threading/ThreadRunner.ts"],"names":[],"mappings":";;;AAEA,iEAA8D;AAE9D;;GAEG;AACH,MAAa,YAAY;IAErB,YACY,cAAuB;QAAvB,mBAAc,GAAd,cAAc,CAAS;QAKnC,sEAAsE;QAC9D,wBAAmB,GAAG,EAAgD,CAAC;IAH/E,CAAC;IAYM,GAAG,CAAC,UAAuB;QAC9B,IAAI,CA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5
+ constructor(factory: () => Worker);
6
+ logger: import("@rokucommunity/logger/dist/Logger").Logger;
7
+ /**
8
+ * List of workers that are free to be used by a new task
9
+ */
10
+ private freeWorkers;
11
+ /**
12
+ * List of all workers that we've ever created
13
+ */
14
+ private allWorkers;
15
+ /**
16
+ * Ensure that there are ${count} workers available in the pool
17
+ * @param count the number of total free workers that should exist when this function exits
18
+ */
19
+ preload(count: number): void;
20
+ /**
21
+ * Create a new worker
22
+ */
23
+ private createWorker;
24
+ /**
25
+ * Get a worker from the pool, or create a new one if none are available
26
+ * @returns a worker
27
+ */
28
+ getWorker(): Worker;
29
+ /**
30
+ * Give the worker back to the pool so it can be used by someone else
31
+ * @param worker the worker
32
+ */
33
+ releaseWorker(worker: Worker): void;
34
+ /**
35
+ * Shut down all active worker pools
36
+ */
37
+ dispose(): void;
38
+ }
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WorkerPool = void 0;
4
+ const logging_1 = require("../../logging");
5
+ class WorkerPool {
6
+ constructor(factory) {
7
+ this.factory = factory;
8
+ this.logger = (0, logging_1.createLogger)();
9
+ /**
10
+ * List of workers that are free to be used by a new task
11
+ */
12
+ this.freeWorkers = [];
13
+ /**
14
+ * List of all workers that we've ever created
15
+ */
16
+ this.allWorkers = [];
17
+ }
18
+ /**
19
+ * Ensure that there are ${count} workers available in the pool
20
+ * @param count the number of total free workers that should exist when this function exits
21
+ */
22
+ preload(count) {
23
+ while (this.freeWorkers.length < count) {
24
+ this.freeWorkers.push(this.createWorker());
25
+ }
26
+ }
27
+ /**
28
+ * Create a new worker
29
+ */
30
+ createWorker() {
31
+ const worker = this.factory();
32
+ this.allWorkers.push(worker);
33
+ return worker;
34
+ }
35
+ /**
36
+ * Get a worker from the pool, or create a new one if none are available
37
+ * @returns a worker
38
+ */
39
+ getWorker() {
40
+ //we have no free workers. spin up a new one
41
+ if (this.freeWorkers.length === 0) {
42
+ this.logger.log('Creating new worker thread');
43
+ return this.createWorker();
44
+ }
45
+ else {
46
+ //return an existing free worker
47
+ this.logger.log('Reusing existing worker thread');
48
+ return this.freeWorkers.pop();
49
+ }
50
+ }
51
+ /**
52
+ * Give the worker back to the pool so it can be used by someone else
53
+ * @param worker the worker
54
+ */
55
+ releaseWorker(worker) {
56
+ //add this worker back to the free workers list (if it's not already in there)
57
+ if (!this.freeWorkers.includes(worker)) {
58
+ this.freeWorkers.push(worker);
59
+ }
60
+ }
61
+ /**
62
+ * Shut down all active worker pools
63
+ */
64
+ dispose() {
65
+ for (const worker of this.allWorkers) {
66
+ try {
67
+ void worker.terminate().catch((e) => console.error(e));
68
+ }
69
+ catch (e) {
70
+ console.error(e);
71
+ }
72
+ }
73
+ this.allWorkers = [];
74
+ this.freeWorkers = [];
75
+ }
76
+ }
77
+ exports.WorkerPool = WorkerPool;
78
+ //# sourceMappingURL=WorkerPool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WorkerPool.js","sourceRoot":"","sources":["../../../src/bsc/threading/WorkerPool.ts"],"names":[],"mappings":";;;AACA,2CAA6C;AAE7C,MAAa,UAAU;IACnB,YACY,OAAqB;QAArB,YAAO,GAAP,OAAO,CAAc;QAK1B,WAAM,GAAG,IAAA,sBAAY,GAAE,CAAC;QAE/B;;WAEG;QACK,gBAAW,GAAa,EAAE,CAAC;QACnC;;WAEG;QACK,eAAU,GAAa,EAAE,CAAC;IAXlC,CAAC;IAaD;;;OAGG;IACI,OAAO,CAAC,KAAa;QACxB,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,GAAG,KAAK,EAAE;YACpC,IAAI,CAAC,WAAW,CAAC,IAAI,CACjB,IAAI,CAAC,YAAY,EAAE,CACtB,CAAC;SACL;IACL,CAAC;IAED;;OAEG;IACK,YAAY;QAChB,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;QAC9B,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC7B,OAAO,MAAM,CAAC;IAClB,CAAC;IAED;;;OAGG;IACI,SAAS;QACZ,4CAA4C;QAC5C,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE;YAC/B,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC;YAC9C,OAAO,IAAI,CAAC,YAAY,EAAE,CAAC;SAC9B;aAAM;YACH,gCAAgC;YAChC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAC;YAClD,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC;SACjC;IACL,CAAC;IAED;;;OAGG;IACI,aAAa,CAAC,MAAc;QAC/B,8EAA8E;QAC9E,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;YACpC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;SACjC;IACL,CAAC;IAED;;OAEG;IACI,OAAO;QACV,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,UAAU,EAAE;YAClC,IAAI;gBACA,KAAK,MAAM,CAAC,SAAS,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;aAC1D;YAAC,OAAO,CAAC,EAAE;gBACR,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;aACpB;SACJ;QACD,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;QACrB,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;IAC1B,CAAC;CACJ;AAhFD,gCAgFC"}
@@ -154,6 +154,13 @@ export declare class BrightScriptDebugSession extends BaseDebugSession {
154
154
  evaluateRequest(response: DebugProtocol.EvaluateResponse, args: DebugProtocol.EvaluateArguments): Promise<void>;
155
155
  private evaluateExpressionToTempVar;
156
156
  private bulkEvaluateExpressionToTempVar;
157
+ protected completionsRequest(response: DebugProtocol.CompletionsResponse, args: DebugProtocol.CompletionsArguments, request?: DebugProtocol.Request): Promise<void>;
158
+ /**
159
+ * Gets the closest completion details the incoming completion request.
160
+ */
161
+ private getClosestCompletionDetails;
162
+ private findVariableByPath;
163
+ private debuggerVarTypeToRoType;
157
164
  /**
158
165
  * Called when the host stops debugging
159
166
  * @param response