The Program Structure Interface, commonly referred to as just PSI, is the layer in the IntelliJ Platform that is responsible for parsing files and creating the syntactic and semantic code model that powers so many of the platform’s features.
Questions tagged [intellij-platform-psi]
9 questions
5
votes
1 answer
how to create a new statement in dart with intellij Dart plugin
final PsiElementFactory factory = JavaPsiFacade.getInstance(project).getElementFactory();
PsiStatement useMemoStatement = instance.createStatementFromText("int a = plus(b + c);", null);
in java we can create a statement like above.
i cloned flutter…

Ahmadreza Moodi
- 463
- 4
- 10
4
votes
0 answers
Acquire annotation parameters (or annotation instance) from Kotlin PSI
I have a Kotlin annotation:
@Retention(AnnotationRetention.SOURCE)
@Target(AnnotationTarget.CLASS)
annotation class Type(
val type: String
)
It can be used on the Kotlin classes in two ways: using the named parameter syntax, or using the…

madhead
- 31,729
- 16
- 153
- 201
3
votes
1 answer
How do a get a fully qualified domain name of class in Kotlin PSI?
I have a Kotlin data class:
package a.b.c
data class Example(
…
)
I am analyzing it with detekt which provides access to the Kotlin PSI.
I'm trying to get the FQDN of my class:
println(klass.nameAsName?.identifier)
where, klass has a type of…

madhead
- 31,729
- 16
- 153
- 201
3
votes
1 answer
annotations vs annotationEntries in IntelliJ / Kotlin PSI
I have a Kotlin annotation:
@Retention(AnnotationRetention.SOURCE)
@Target(AnnotationTarget.CLASS)
annotation class Type(
val type: String
)
It can be used on the Kotlin classes:
@Type(type = "type")
data class Annotated(
…
)
I am…

madhead
- 31,729
- 16
- 153
- 201
2
votes
1 answer
How to get KtClass from PsiElement or VirtualFile?
I want to make an plugin that generate some template code for some specific kotlin files. Now I need to get KtClass from PsiElement or VirtualFile. I tried some code as below, but it's not working.
val psiFile = e.getData(CommonDataKeys.PSI_FILE)
…

boybeak
- 417
- 5
- 19
0
votes
0 answers
Compute a constant for annotation parameter in intellij plugin inspection
How I can compute a constant value passed as argument of annotation, I have access to the KtNamedFunction.
@StreamListener(MyConst.INPUT) fun consume(message:Message) { // .. }
interface MyConst { companion object { const val INPUT =…

GUISSOUMA Issam
- 2,572
- 2
- 16
- 27
0
votes
0 answers
Intellij API. Saving User Data to PsiElement
Saving User Data to PsiElement
Hello. I have got a question.
We need to solve the following problem. Save User Data to PsiElement. So that they are saved when parsing a file. For example, when calling the function…
0
votes
1 answer
Custom language plugin - braces alignment when returning an object
I am developing a plugin for IntelliJ IDEA which supports my custom Lua-based language formatting.
I expect to get following result
func () {
//do something
return {
data = {
v1 = "some value",
v2 = 123
…

Stanislav Kozlov
- 1
- 2
0
votes
1 answer
Intellij plugin: elements returned by PsiFile.findElementAt() providing very little language/syntax info
I'm trying to create an Intellij plugin that does the same thing as a VSCode extension I recently created, Ligatures Limited, which is designed prevent font coding ligatures from fonts like Fira Code from being rendered out-of-context, so that they…

kshetline
- 12,547
- 4
- 37
- 73