classes loaded with a separate class loader 2. Each plugin implements extension points of IDE and may provide its own 3. Plugins may depend on IDE modules and other plugins 8 Groovy Plugin Java Plugin Properties Plugin Ultimate Modules optional
support for Micronaut Framework for JVM languages ]]></description> <depends>com.intellij.modules.java</depends> <extensions defaultExtensionNs="com.intellij"> <!-- Add your extensions here → </extensions> <actions> <!-- Add your actions here → </actions> </idea-plugin> 10 Metadata Source code Build file
reference contributor, ui settings group, language parser, language formatter и т.д. ▪ Registered in XML-file – plugin.xml manifest ▪ You can find them: LangExtensionPoints.xml, PlatformExtensionPoints.xml, VcsExtensionPoints.xml, etc. Example: Groovy – plugin ( plugin.xml > 1300 LOC ) github.com/JetBrains/intellij-community 11
Profit Nothing happens! Documentation: If you are using Java or Kotlin and IntelliJ IDEA make sure you have enabled annotation processing. 15 Let’s check that Annotations Processors are enabled in Micronaut projects!
defaultExtensionNs="com.intellij"> <postStartupActivity implementation="demo.CheckAnnotationProcessorsStartupActivity"/> 2. Use UI Inspector to find the IDE mechanisms (Ctrl+Alt+Click): 16
@Controller class WelcomeController { @View("welcome") @Get("/") public HttpResponse<?> welcome() { return HttpResponse.ok(); } } 💡 Class ‘WelcomeController’ is never used. 17 Let’s teach IDE how to understand implicits!
representation: ▪ Structure of the project and code ▪ Includes semantic data ▪ Everything is PsiElement (almost) ▪ Every language provides its own PSI elements 19 PsiFile PsiElement PsiElement PsiElement PsiElement PSI Tree
language="UAST" displayName="@Inject field inspection" groupName="Micronaut" implementationClass="demo.MicronautFieldInjectionInspection"/> 2. Obtain UElement 3. Find a problem in UAST tree (or in synthetic PSI) 4. Go back to sourcePsi 5. Register problem for sourcePsi See: Tools - Internal Actions - Dump UAST Tree Examples: intellij-community/plugins/devkit/ и Android Studio 25
understand ▪ Developers hate them ▪ IDE does not help Idea: Icons on gutter with navigation to publishers / subsribers! See: LineMarkerProvider RelatedItemLineMarkerProvider 26
◦ Value – bitmask of source (in code, in comment, in string literal) ◦ Used in Find in Path, Find Usages ▪ File names and file types indexes ▪ Java Class Names index See: PsiSearchHelper 27
➜ declaration ▪ May provide auto completion ▪ We can add references without changing the underlying language See: PsiReferenceContributor PsiLanguageInjectionHost 30
application.properties keys in a form of ${some.property-name}: @Value("${datasources.default.url}") private String datasourceUrl; Idea: let’s connect those strings and config keys with PSI reference 31
Nginx) ▪ Plugins registry file: updatePlugins.xml <plugins> <!-- Each <plugin> element describes one plugin in the repository. → <plugin id="fully.qualified.id.of.this.plugin" url="https://www.mycompany.com/my_repository/mypluginname.jar" version="major.minor.update"> <idea-version since-build="181.3" until-build="191.*" /> </plugin> <plugin> <!-- And so on for other plugins... → </plugin> </plugins> See: Publishing a Plugin to a Custom Plugin Repository 35
to not write a plugin - do not create a plugin! Instead: ▪ Suppress unused for class annotated with … ▪ Setup required plugins and inspections ▪ Commit 📁 .idea directory to VCS ▪ Setup Language Injection ▪ Use JetBrains annotations (nullity, contract, pure, language) dependencies { compileOnly 'org.jetbrains:annotations:17.0.0' } 36