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] Improve the presentation of GraphQL elements when navigating to them #5900

Merged
merged 1 commit into from
May 17, 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 @@ -7,6 +7,7 @@ import com.intellij.navigation.NavigationItem
import com.intellij.platform.backend.navigation.NavigationRequest
import com.intellij.pom.Navigatable
import com.intellij.psi.PsiElement
import javax.swing.Icon

private class LogNavigationPsiElement(
private val wrapped: PsiElement,
Expand All @@ -24,8 +25,13 @@ private class LogNavigationPsiElement(
return (wrapped as? NavigationItem)?.name
}

override fun getPresentation(): ItemPresentation? {
return (wrapped as? NavigationItem)?.presentation
override fun getPresentation(): ItemPresentation {
return (wrapped as? NavigationItem)?.presentation ?: object : ItemPresentation {
// We don't want the presentation to be too wide: fallback to the first line of text, truncated to 80 characters
override fun getPresentableText(): String? = wrapped.text.split('\n').firstOrNull()?.take(80)

override fun getIcon(unused: Boolean): Icon? = null
}
}

@Suppress("UnstableApiUsage")
Expand Down
Loading