Code generation in Go

已回答

I'm working on a plugin that should generate Go code. I did not manage to find good examples of code generating plugins that work with Go. But I found one that do it in Kotlin. It uses `org.jetbrains.kotlin.psi.KtPsiFactory` to create all PsiElements. I want to know if there is similarly working factory for Go PsiElements? Or you probably can point a different approach? It would be great if you could share some example.

0

Hi Nikolay,

Thank you for contributing and your interest in the IntelliJ plugin development ecosystem.

A good entry point would be: https://plugins.jetbrains.com/docs/intellij/goland.html (at the bottom there are a few open-source examples).

Other examples are the following:

- https://github.com/Enokiy/go-struct-to-json-intellij-plugin (generates something according to PSI)

- https://github.com/xxpxxxxp/intellij-plugin-golangci-lint (example of a complex plugin)

In Go, an alternative to org.jetbrains.kotlin.psi.KtPsiFactory is com.goide.psi.impl.GoElementFactory which provides similar entrypoints.

0

请先登录再写评论。