Skip to content

Commit 260c159

Browse files
committed
feat: add navigation elements to endpoints
1 parent 196124a commit 260c159

File tree

5 files changed

+24
-6
lines changed

5 files changed

+24
-6
lines changed

src/main/kotlin/com/github/xepozz/temporal/common/endpoints/TemporalActivityEndpointsProvider.kt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import com.intellij.microservices.endpoints.FrameworkPresentation
99
import com.intellij.navigation.ItemPresentation
1010
import com.intellij.openapi.project.Project
1111
import com.intellij.openapi.util.ModificationTracker
12+
import com.intellij.psi.PsiElement
1213
import java.util.function.Supplier
1314
import javax.swing.Icon
1415
import com.github.xepozz.temporal.common.model.Activity as ActivityModel
@@ -25,6 +26,14 @@ class TemporalActivityEndpointsProvider : EndpointsProvider<ActivityEndpointGrou
2526
return listOf(ActivityEndpoint(group.activity))
2627
}
2728

29+
override fun getDocumentationElement(group: ActivityEndpointGroup, endpoint: ActivityEndpoint): PsiElement? {
30+
return endpoint.activity.psiAnchor?.dereference()
31+
}
32+
33+
override fun getNavigationElement(group: ActivityEndpointGroup, endpoint: ActivityEndpoint): PsiElement? {
34+
return endpoint.activity.psiAnchor?.dereference()
35+
}
36+
2837
override fun getModificationTracker(project: Project): ModificationTracker = ModificationTracker.NEVER_CHANGED
2938

3039
override fun getStatus(project: Project): EndpointsProvider.Status = EndpointsProvider.Status.AVAILABLE
@@ -34,7 +43,7 @@ class TemporalActivityEndpointsProvider : EndpointsProvider<ActivityEndpointGrou
3443
override fun getEndpointPresentation(group: ActivityEndpointGroup, endpoint: ActivityEndpoint): ItemPresentation {
3544
return object : ItemPresentation {
3645
override fun getPresentableText(): String = endpoint.activity.id
37-
override fun getLocationString(): String? = endpoint.activity.psiAnchor?.element?.containingFile?.name
46+
override fun getLocationString(): String? = endpoint.activity.psiAnchor?.dereference()?.containingFile?.name
3847
override fun getIcon(unused: Boolean): Icon = TemporalIcons.TEMPORAL
3948
}
4049
}

src/main/kotlin/com/github/xepozz/temporal/common/endpoints/TemporalWorkflowEndpointsProvider.kt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import com.intellij.microservices.endpoints.FrameworkPresentation
99
import com.intellij.navigation.ItemPresentation
1010
import com.intellij.openapi.project.Project
1111
import com.intellij.openapi.util.ModificationTracker
12+
import com.intellij.psi.PsiElement
1213
import java.util.function.Supplier
1314
import javax.swing.Icon
1415
import com.github.xepozz.temporal.common.model.Workflow as WorkflowModel
@@ -25,6 +26,14 @@ class TemporalWorkflowEndpointsProvider : EndpointsProvider<WorkflowEndpointGrou
2526
return listOf(WorkflowEndpoint(group.workflow))
2627
}
2728

29+
override fun getDocumentationElement(group: WorkflowEndpointGroup, endpoint: WorkflowEndpoint): PsiElement? {
30+
return endpoint.workflow.psiAnchor?.dereference()
31+
}
32+
33+
override fun getNavigationElement(group: WorkflowEndpointGroup, endpoint: WorkflowEndpoint): PsiElement? {
34+
return endpoint.workflow.psiAnchor?.dereference()
35+
}
36+
2837
override fun getModificationTracker(project: Project): ModificationTracker = ModificationTracker.NEVER_CHANGED
2938

3039
override fun getStatus(project: Project): EndpointsProvider.Status = EndpointsProvider.Status.AVAILABLE
@@ -34,7 +43,7 @@ class TemporalWorkflowEndpointsProvider : EndpointsProvider<WorkflowEndpointGrou
3443
override fun getEndpointPresentation(group: WorkflowEndpointGroup, endpoint: WorkflowEndpoint): ItemPresentation {
3544
return object : ItemPresentation {
3645
override fun getPresentableText(): String = endpoint.workflow.id
37-
override fun getLocationString(): String? = endpoint.workflow.psiAnchor.element?.containingFile?.name
46+
override fun getLocationString(): String? = endpoint.workflow.psiAnchor?.dereference()?.containingFile?.name
3847
override fun getIcon(unused: Boolean): Icon = TemporalIcons.TEMPORAL
3948
}
4049
}

src/main/kotlin/com/github/xepozz/temporal/common/model/Workflow.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ import com.intellij.psi.SmartPsiElementPointer
66
data class Workflow(
77
val id: String,
88
val language: String,
9-
val psiAnchor: SmartPsiElementPointer<out PsiElement>,
9+
val psiAnchor: SmartPsiElementPointer<out PsiElement>?,
1010
val parameters: Collection<String>
1111
)

src/main/kotlin/com/github/xepozz/temporal/languages/php/endpoints/PhpActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class PhpActivity : Activity {
5050
phpClass.methods.find { it.name == methodName && it.isActivity() }?.let { method ->
5151
results.add(
5252
ActivityModel(
53-
id = "$methodName (${phpClass.name})",
53+
id = "${phpClass.name}::$methodName",
5454
language = "PHP",
5555
psiAnchor = smartPointerManager.createSmartPsiElementPointer(method),
5656
parameters = emptyList()

src/main/kotlin/com/github/xepozz/temporal/languages/php/endpoints/PhpWorkflow.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ class PhpWorkflow : Workflow {
4747
val classFqn = parts[0]
4848
val methodName = parts[1]
4949
phpIndex.getClassesByFQN(classFqn).forEach { phpClass ->
50-
phpClass.methods.find { it.name == methodName && it.isWorkflow() }?.let { method ->
50+
phpClass.ownMethods.find { it.name == methodName && it.isWorkflow() }?.let { method ->
5151
results.add(
5252
WorkflowModel(
53-
id = "$methodName (${phpClass.name})",
53+
id = "${phpClass.name}::$methodName",
5454
language = "PHP",
5555
psiAnchor = smartPointerManager.createSmartPsiElementPointer(method),
5656
parameters = emptyList()

0 commit comments

Comments
 (0)