This repository has been archived by the owner on Jul 3, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changes: - add showContextQuickPick function to API - add node-ipc library to package-lock.json file
- Loading branch information
Showing
6 changed files
with
200 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import ipc = require('node-ipc'); | ||
import { timeout } from 'promised-timeout'; | ||
import { Logger } from './log'; | ||
|
||
ipc.config.appspace = 'vscode-janus-debug.'; | ||
ipc.config.id = 'debug_adapter'; | ||
ipc.config.retry = 1500; | ||
|
||
const log = Logger.create('DebugAdapterIPC'); | ||
|
||
/** | ||
* Acts as the client in our communication. | ||
* | ||
* @export | ||
* @class DebugAdapter | ||
*/ | ||
export class DebugAdapterIPC { | ||
|
||
public async connect() { | ||
ipc.connectTo('sock', () => { | ||
|
||
ipc.of.sock.on('connect', () => { | ||
log.debug(`connected to VS Code extension`); | ||
}); | ||
|
||
ipc.of.sock.on('disconnect', () => { | ||
log.debug(`disconnected from VS Code extension`); | ||
}); | ||
|
||
ipc.of.sock.on('contextChosen', this.contextChosenDefaultHandler); | ||
}); | ||
} | ||
|
||
public async disconnect(): Promise<void> { | ||
ipc.disconnect('sock'); | ||
} | ||
|
||
public async showContextQuickPick(contextList: string[]): Promise<string> { | ||
log.debug(`showContextQuickPick ${JSON.stringify(contextList)}`); | ||
|
||
const waitForResponse = timeout({ | ||
promise: new Promise<string>(resolve => { | ||
ipc.of.sock.on('contextChosen', (contextLabel: string) => { | ||
log.debug(`user picked '${contextLabel}'`); | ||
resolve(contextLabel); | ||
}); | ||
}), | ||
time: 10000, | ||
error: new Error('Request timed out'), | ||
}); | ||
ipc.of.sock.emit('showContextQuickPick', contextList); | ||
let result: string; | ||
try { | ||
result = await waitForResponse; | ||
} finally { | ||
ipc.of.sock.on('contextChosen', this.contextChosenDefaultHandler); | ||
} | ||
return result; | ||
} | ||
|
||
private contextChosenDefaultHandler(data: any) { | ||
log.warn(`got 'contextChosen' message from VS Code extension but we haven't asked!`); | ||
} | ||
} |
Oops, something went wrong.