-
Notifications
You must be signed in to change notification settings - Fork 95
Add new language support
To add support for a new language you have to do the following steps:
-
Check out the source code of this plugin and try to compile it via
./gradlew buildPlugin
-
Install the following IDEA plugins:
- PsiViewer
- Lombok
- Plugin DevKit
-
Open this project in IDEA
-
Press the compile button two times (first compilation will fail)
-
Run
./gradlew runIde
on console or use the gradle menu for that (Tasks->Intellij->runIde)- a new IDEA instance will start with the plugin installed
- Make sure that the postfix completion works
- Create the necessary folders and files for the new language (in the following I use the variables
$languageId
and$language
as placeholders in path names and file names, whereas$language
denotes the real name, e.g.SQL
, and$languageId
denotes just an ID for the language (usually the lower case variant), e.g.sql
):-
create the folder
src/de/endrullis/idea/postfixtemplates/languages/$languageId
-
copy all classes from
src/de/endrullis/idea/postfixtemplates/languages/javascript
tosrc/de/endrullis/idea/postfixtemplates/languages/$languageId
by replacing each JavaScript occurrence by your language name or camel case language name (e.g.Sql
) -
create the folder
resources/postfixTemplates/Custom${language}StringPostfixTemplate
-
copy all files from
resources/postfixTemplates/CustomJavaScriptStringPostfixTemplate
toresources/postfixTemplates/Custom${language}StringPostfixTemplate
-
add the following lines to the
plugin.xml
:<codeInsight.template.postfixTemplateProvider language="$language" implementationClass="de.endrullis.idea.postfixtemplates.languages.$languageId.${language}PostfixTemplateProvider"/>
-
- Start the plugin and test if it works by opening any $language file and pressing Shift+Alt+P. If you are offered to create a new template file, the file type detection works.
- Go back to a $language file and try to apply the
.example
template on any expression. If it works all basic steps are done and you have an untyped postfix template support for $language. - You can now try to add a typed postfix template support. I suggest you to install the PsiViewer plugin to analyse the different expression types in IDEA.