Skip to content

Commit 916a204

Browse files
committed
protocol commands
1 parent 073b22f commit 916a204

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

ide-common/src/main/kotlin/org/digma/intellij/plugin/protocol/DigmaProtocolCommand.kt

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,26 @@ const val DIGMA_COMMAND = "digma"
2222
const val DIGMA_PLUGIN_TARGET = "plugin"
2323

2424

25-
//jetbrains://idea/digma/plugin?action=assets
26-
//jetbrains://idea/digma/plugin?project=spring-petclinic&action=assets
25+
/*
26+
show digma settings
27+
"jetbrains://idea/settings?name=Digma Plugin"
28+
29+
show code object id not encoded
30+
"jetbrains://idea/digma/plugin?action=showAsset&codeObjectId=span:io.opentelemetry.tomcat-10.0$_$HTTP GET /owners/{ownerId}&environmentId=LOCAL#ID#42E6067A-E755-4211-BA0F-B2F84BA8B065"
31+
32+
show code object id encoded
33+
"jetbrains://idea/digma/plugin?action=showAsset&codeObjectId=span%3Aio.opentelemetry.tomcat-10.0%24_%24HTTP%20GET%20%2Fowners%2F%7BownerId%7D&environmentId=LOCAL%23ID%2342E6067A-E755-4211-BA0F-B2F84BA8B065"
34+
35+
*/
2736

2837
class DigmaProtocolCommand : JBProtocolCommand(DIGMA_COMMAND) {
2938
private val logger: Logger = Logger.getInstance(this::class.java)
3039

31-
// override fun perform(target: String?, parameters: Map<String, String>, fragment: String?): Future<String?> {
3240
override suspend fun execute(target: String?, parameters: Map<String, String>, fragment: String?): String? {
3341
try {
34-
return executeImpl(target,parameters,fragment)
35-
}catch (e:Throwable){
36-
ErrorReporter.getInstance().reportError("DigmaProtocolCommand.execute",e)
42+
return executeImpl(target, parameters, fragment)
43+
} catch (e: Throwable) {
44+
ErrorReporter.getInstance().reportError("DigmaProtocolCommand.execute", e)
3745
return "Error $e"
3846
}
3947
}
@@ -42,7 +50,6 @@ class DigmaProtocolCommand : JBProtocolCommand(DIGMA_COMMAND) {
4250
private suspend fun executeImpl(target: String?, parameters: Map<String, String>, fragment: String?): String? {
4351

4452
if (target != DIGMA_PLUGIN_TARGET) {
45-
// return CompletableFuture.completedFuture("DigmaProtocolCommand Supports Only Plugin Target")
4653
return "DigmaProtocolCommand Supports Only Plugin Target"
4754
}
4855

@@ -59,7 +66,6 @@ class DigmaProtocolCommand : JBProtocolCommand(DIGMA_COMMAND) {
5966
var project = if (parameters.containsKey(PROJECT_NAME_KEY)) {
6067
when (val openProjectResult = openProject(parameters)) {
6168
is ProtocolOpenProjectResult.Success -> openProjectResult.project
62-
// is ProtocolOpenProjectResult.Error -> return CompletableFuture.completedFuture(openProjectResult.message)
6369
is ProtocolOpenProjectResult.Error -> return openProjectResult.message
6470
}
6571
} else {
@@ -71,6 +77,7 @@ class DigmaProtocolCommand : JBProtocolCommand(DIGMA_COMMAND) {
7177
RecentProjectListActionProvider.getInstance().getActions().asSequence().filterIsInstance(ReopenProjectAction::class.java)
7278
.firstOrNull()?.projectPath ?: RecentProjectsManager.getInstance().lastProjectCreationLocation
7379
if (recentProjectPath != null) {
80+
@Suppress("UnstableApiUsage")
7481
project = RecentProjectsManagerBase.getInstanceEx().openProject(Path.of(recentProjectPath), OpenProjectTask())
7582
}
7683
}
@@ -81,7 +88,6 @@ class DigmaProtocolCommand : JBProtocolCommand(DIGMA_COMMAND) {
8188
Log.log(logger::trace, "got project {}", project.name)
8289

8390
val action = getActionFromParameters(parameters)
84-
// ?: return CompletableFuture.completedFuture("DigmaProtocolCommand no action in request")
8591
?: return "DigmaProtocolCommand no action in request"
8692

8793

@@ -98,16 +104,11 @@ class DigmaProtocolCommand : JBProtocolCommand(DIGMA_COMMAND) {
98104
Log.log(logger::trace, "executing action {}", action)
99105
val result = project.service<DigmaProtocolApi>().performAction(project, parameters, waitForJcef)
100106
Log.log(logger::trace, "after execute action {}", action)
101-
// return CompletableFuture.completedFuture(null)
102107
return result
103108
}
104109

105-
// return CompletableFuture.completedFuture("DigmaProtocolCommand can not find project")
106110
return "DigmaProtocolCommand can not open any project"
107111

108112
}
109113

110-
// override suspend fun execute(target: String?, parameters: Map<String, String>, fragment: String?): String? {
111-
// return super.execute(target, parameters, fragment)
112-
// }
113114
}

ide-common/src/main/kotlin/org/digma/intellij/plugin/protocol/ProtocolCommandEvent.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import com.intellij.util.messages.Topic
77
* this is an application event that should fire when we change the api client,
88
* usually when user changes the api url in settings.
99
*/
10-
//todo: maybe we don't need it
1110
fun interface ProtocolCommandEvent {
1211

1312

0 commit comments

Comments
 (0)