-
Notifications
You must be signed in to change notification settings - Fork 213
add extension APIs to get live data #751
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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; | ||
} |
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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Corresponding logic has not been implemented in
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think (For example line 155 would be the place to send connect notification. Note |
||
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 | ||
}; | ||
} | ||
} |
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'); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't
getProcessKey()
be removed completely in favour ofgetArgumentByKey(String key)
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think
getProcessKey()
is just a convenience method, I don't mind having such a method. But I also don't mind if we removedgetProcessKey()
and instead calledgetArgumentByKey(params, "processKey")
.