PSI Implementation for C / CPP files
Hello,
I am implementing a code vision feature into the Pieces Jetbrains plugin.
My implementation is largely based off of the intellij-community VCSCodeVisionProvider: https://github.com/JetBrains/intellij-community/blob/master/platform/vcs-impl/src/com/intellij/codeInsight/hints/VcsCodeVisionProvider.kt
Along with some added hard coded language support based on PSI element types:
```kt
protected val hardCodedPSIElementTypes: Map<ClassificationSpecificEnum, List<String>> = mapOf(
ClassificationSpecificEnum.DART to listOf(
"CLASS_DEFINITION",
"METHOD_DECLARATION",
"FUNCTION_DECLARATION_WITH_BODY_OR_NATIVE"
),
ClassificationSpecificEnum.CS to listOf(
"cs:ctor-declaration",
"cs:method-declaration",
"cs:class-declaration"
)
)
```
When I use the PSI viewer plugin to try and view PSI elements for C and CPP files however, it seems that the PSI provided is simply a ‘dummy’ PSI that does not contain critical information for this implementation strategy, do you have any recommendations?
FYI I have seen this post outlining how this process is different than other languages as it utilizes ReSharper: https://intellij-support.jetbrains.com/hc/en-us/community/posts/5232268857618-Discrepancies-between-Idea-and-Rider-for-PsiElement
Please sign in to leave a comment.
I'm afraid there's not much to add to the linked post. Rider has a different architecture, and the PSI isn't implemented in the IntelliJ Platform, but in the ReSharper engine. Typically, code that extends C# or C++ would be written as dotnet assemblies that have access to the full PSI and semantic model.
Mapping the hardcoded ‘debugName’ of PSI Element Types is somewhat unreliable, as they could potentially change at any time. It would be more stable to build against the actual
IElementType
constants orPsiElement
implementation class.Checking about the C/CPP problem..