Need help with creating an auto complete plugin

Answered
I want to create a plug-in that adds Tailwind css class name autocomplete when used inside of a string inside a certain method name in php files. I created a plug-in that uses live templates to accomplish this, but it seems like more of a hack. Basically I want to have it so it will auto complete css classes the same way it does inside of HTML element class=“” attribute. I want it to autocomplete inside a method called class. For example, my code had a chained method called class and it works like this: $v->div(“hello world”)->class(“bg-red-500 text-white”); So I want auto complete inside that class method string of my php files. I tried searching through the sdk docs and couldn’t figure it out. How do I do this? Can someone point me in the right direction?
0
3 comments

Yeah but it does so using live templates. I think I have to figure out how to do it properly with a completion contributor so it doesn’t autocomplete in the places I don’t want.

0

You need to provide PsiReference to resolve to CSS class PSI in your plugin.

https://plugins.jetbrains.com/docs/intellij/psi-references.html

There are some existing PHP plugins to look into how to use PHP PSI where you need to register your PsiReferenceContributor for https://plugins.jetbrains.com/docs/intellij/existing-plugins.html

Then provide custom PsiReference extending com.intellij.psi.css.resolve.CssClassOrIdReference (not open source) which performs resolving/completion.

 

0

Please sign in to leave a comment.