.. _Code Completion:

Code Completion
===============

AI Assistant has the ability to insert LLM generated, context-aware code completion, while typing.

To enable / disable code completions:

- Open VS Code Settings using :kbd:`Ctrl+,` and check / uncheck :menuselection:`DVT --> AI --> Code Completion --> Enabled`
- Open Eclipse Preferences using :menuselection:`Window --> Preferences` and check / uncheck :menuselection:`DVT --> AI Assistant --> Insert "Show AI Assistant Code Completions ..." in the 'default' content assist list`

To trigger code completion automatically in VS Code, start typing in the editor pausing briefly to wait for the inline suggestions to appear.
To trigger it manually, run the **DVT AI: Trigger Code Completion** command.

   
   .. figure:: ../../images/common/ai-code-completion-vscode.png
	  :align: center

In Eclipse, use the Content Assist :kbd:`Ctrl+Space` and select **Show AI Assistant Code Completions...** to request code completions from the LLM.
Once generated, one or more suggestions will be displayed.
   
   .. figure:: ../../images/common/ai-code-completion-eclipse-1.png
	  :align: center

   .. figure:: ../../images/common/ai-code-completion-eclipse-2.png
	  :align: center


.. note::

   To customize the code completion prompt, run the **DVT AI: Edit Code Completion Blueprint** command and modify the generated blueprint.

.. note::
   
   To generate relevant completions, the LLM request may include:

   - Contents of the current file
   - Type dependencies from other files
   - Recently opened files