title |
---|
9. Completion Contributor |
Custom languages provide code completion using one of two approaches: Contributor and Reference-based (see 10. Reference Contributor) completion.
Reference: Code Completion
- bullet list {:toc}
For this tutorial, the simple_language_plugin
provides custom completion for values in Simple Language property files.
Create a completion contributor by subclassing CompletionContributor
.
This rudimentary completion contributor always adds "Hello" to the results set, regardless of context:
{% include /code_samples/simple_language_plugin/src/main/java/org/intellij/sdk/language/SimpleCompletionContributor.java %}
The SimpleCompletionContributor
implementation is registered in the plugin configuration file with the IntelliJ Platform using the com.intellij.completion.contributor
extension point.
<extensions defaultExtensionNs="com.intellij">
<completion.contributor language="Simple"
implementationClass="org.intellij.sdk.language.SimpleCompletionContributor"/>
</extensions>
Run the simple_language_plugin
in a Development Instance and open the test.simple
file.
Erase the property "English" and invoke Basic Code Completion.
The choice "Hello" is shown: