How to check if a PsiElement is the last element in a line
Answered
Scenes
I need to display Type Hint after `MyPsiMethod`.
I'm going to use InlayHintsSink.addInlineElement
to append Inlay Hint at the end of the line.
For the following statements:
object
.outer(call.inner())
.method().chain();
`MyPsiMethod` has 4 in total
.outer(call.inner())
.inner()
.method()
.chain()
But I only want to generate Type Hint for .outer
and .chain
.
Question
How should I check if a PsiElement is the last element in a line?
The calling environment is InlayHintsCollector.collect
, additional Editor
context can be used.
Please sign in to leave a comment.
Hi,
A similar case is implemented in isFirstInLine in https://github.com/JetBrains/intellij-community/blob/master/platform/lang-impl/src/com/intellij/codeInsight/hints/InlayHintsUtils.kt. I suggest implementing a similar approach.