-
Notifications
You must be signed in to change notification settings - Fork 206
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Yan Zhang <[email protected]>
- Loading branch information
Showing
6 changed files
with
139 additions
and
4 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
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,42 @@ | ||
import { Event } from "vscode"; | ||
import { LanguageClient } from "vscode-languageclient/node"; | ||
|
||
export interface ExtensionAPI { | ||
readonly client: LanguageClient; | ||
|
||
/** | ||
* An event which fires on live process is connected. Payload is processKey. | ||
*/ | ||
readonly onDidLiveProcessConnect: Event<string> | ||
|
||
/** | ||
* An event which fires on live process is disconnected. Payload is processKey. | ||
*/ | ||
readonly onDidLiveProcessDisconnect: Event<string> | ||
|
||
/** | ||
* A command to get live process data. | ||
*/ | ||
readonly getLiveProcessData: (query: SimpleQuery | BeansQuery) => Promise<any> | ||
|
||
} | ||
|
||
interface LiveProcessDataQuery { | ||
/** | ||
* unique identifier of a connected live process. | ||
*/ | ||
processKey: string; | ||
} | ||
|
||
interface SimpleQuery extends LiveProcessDataQuery { | ||
endpoint: "mappings" | "contextPath" | "port" | "properties"; | ||
} | ||
|
||
interface BeansQuery extends LiveProcessDataQuery { | ||
endpoint: "beans"; | ||
/** | ||
* if provided, return corresponding beans via name. | ||
*/ | ||
beanName?: string; | ||
dependingOn?: string; | ||
} |
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,31 @@ | ||
import { commands, Uri } from "vscode"; | ||
import { Emitter, LanguageClient } from "vscode-languageclient/node"; | ||
import { ExtensionAPI } from "./api"; | ||
import { LiveProcessConnectedNotification, LiveProcessDisconnectedNotification } from "./notification"; | ||
|
||
export class ApiManager { | ||
public api: ExtensionAPI; | ||
private onDidLiveProcessConnectEmitter: Emitter<string> = new Emitter<string>(); | ||
private onDidLiveProcessDisconnectEmitter: Emitter<string> = new Emitter<string>(); | ||
|
||
public constructor(private client: LanguageClient) { | ||
const onDidLiveProcessConnect = this.onDidLiveProcessConnectEmitter.event; | ||
const onDidLiveProcessDisconnect = this.onDidLiveProcessDisconnectEmitter.event; | ||
|
||
const COMMAND_LIVEDATA_GET = "sts/livedata/get"; | ||
const getLiveProcessData = async (query) => { | ||
await commands.executeCommand(COMMAND_LIVEDATA_GET, query); | ||
} | ||
|
||
// TODO: STS server should send corresponding notification back. | ||
client.onNotification(LiveProcessConnectedNotification.type, (processKey: string) => this.onDidLiveProcessConnectEmitter.fire(processKey)); | ||
client.onNotification(LiveProcessDisconnectedNotification.type, (processKey: string) => this.onDidLiveProcessDisconnectEmitter.fire(processKey)); | ||
|
||
this.api = { | ||
client, | ||
onDidLiveProcessConnect, | ||
onDidLiveProcessDisconnect, | ||
getLiveProcessData | ||
}; | ||
} | ||
} |
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,9 @@ | ||
import { NotificationType } from "vscode-languageclient"; | ||
|
||
export namespace LiveProcessConnectedNotification { | ||
export const type = new NotificationType<string>('sts/liveprocess/connected'); | ||
} | ||
|
||
export namespace LiveProcessDisconnectedNotification { | ||
export const type = new NotificationType<string>('sts/liveprocess/disconnected'); | ||
} |