Skip to content

Latest commit

 

History

History
37 lines (28 loc) · 1.9 KB

completion_contributor.md

File metadata and controls

37 lines (28 loc) · 1.9 KB
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}

9.1. Define a Completion Contributor

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 %}

9.2. Register the Completion Contributor

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>

9.3. Run the Project

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:

Completion