Skip to content

Commit

Permalink
[IJ Plugin] Fix presentation of Kotlin elements when navigating to th…
Browse files Browse the repository at this point in the history
…em from GraphQL (#5739)
  • Loading branch information
BoD authored Mar 19, 2024
1 parent e7e7296 commit 0e35608
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ package com.apollographql.ijplugin.navigation

import com.apollographql.ijplugin.telemetry.TelemetryEvent
import com.apollographql.ijplugin.telemetry.telemetryService
import com.intellij.navigation.ItemPresentation
import com.intellij.navigation.NavigationItem
import com.intellij.psi.PsiElement

private class LogNavigationPsiElement(
private val wrapped: PsiElement,
private val telemetryEvent: () -> TelemetryEvent,
) : PsiElement by wrapped {
) : PsiElement by wrapped, NavigationItem {
private var hasLogged = false

override fun getNavigationElement(): PsiElement {
Expand All @@ -26,6 +28,14 @@ private class LogNavigationPsiElement(

override fun toString(): String = wrapped.toString()

override fun getName(): String? {
return (wrapped as? NavigationItem)?.name
}

override fun getPresentation(): ItemPresentation? {
return (wrapped as? NavigationItem)?.presentation
}

// Hack: detect if we're only hovering over the element, which we don't want to log
private fun isHovering(): Boolean = Thread.currentThread().stackTrace.any { it.methodName == "getCtrlMouseData" }
}
Expand Down

0 comments on commit 0e35608

Please sign in to comment.