Skip to content
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

[IJ Plugin] Fix presentation of Kotlin elements when navigating to them from GraphQL #5739

Merged
merged 1 commit into from
Mar 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading