Completing code in the editor using in-line suggestions

Developers can obtain context aware AI-driven suggestions while working on existing code.

With context awareness, AI suggestions are generated either using surrounding code in the current file for a more accurate suggestion, or using code from available files in the workspace, which generates suggestions using the developer's current coding standards.

This option allows early-tenure developers to have a faster learning curve. For senior developers, this option provides increased code efficiency as it helps to generate code for complex use cases.

There are three approaches to generate in-line code using the code generation component:

Context used for in-editor code generation

The key ingredient for code generation is context, that is, the surrounding code that you pass to the model. For in-editor code generation, IBM® watsonx Code Assistant™ for Z uses:

  • The 40 lines of code before the line where the generation is triggered.
  • The 40 lines of code after the line where the generation is triggered.
  • Up to 400 lines from the beginning of the current file where generation is triggered.

To improve the results of in-editor code generation, help IBM watsonx Code Assistant for Z by starting with a data definition, or use the IBM watsonx Code Assistant for Z chat to create the initial outline, copy the result into a file in your workspace, and then continue with in-editor code generation. Do not use in-editor code generation when you start from zero or almost empty files, as these conditions do not provide enough context.

This section discusses the following topics: