Code Assistance in the MPLAB® X IDE Editor

Last modified by Microchip on 2023/11/09 09:11

Code Assistance

Code Assistance is a feature that analyzes the first few characters you have typed and provides a list of possible endings. For example, if you are using a library with a series of functions that start with 'lcd', after typing in those letters, you will see a list of functions such as 'lcdInit()' and 'lcdWrite()' displayed for you to select from.

To activate the Code Assistance window:

In the editor, type in the first few letters of an identifier (e.g. variable or function name).
Press the keys Ctrl+Space (you may need to do this twice).

When activated, you will be presented with a list of all identifiers (macros, variables, functions, etc.) that start with those letters. Double-clicking on any item in the list will add it to your code by completing the text you started to type in.

Selecting an item in the list (single click) displays a documentation window that by default will have nothing in it. You need to provide the content for this window using specially formatted comments in your code.

code assist example

Once you have inserted a new function, a tooltip will appear to prompt you for any required parameters. If there are multiple parameters, the next one to be entered will be highlighted with bold text.

Tool Tip dialog box

Back to Top

Code Documentation

The Code Assistance window can display documentation for the selected identifier.

Shows auto complete with documtention completed

To create documentation for a function, you need to add a Javadoc comment block immediately above the function prototype (or definition if available) that starts with '/**' on the first line. The editor can assist you by auto-populating a basic Javadoc comment block.
To add a documentation comment with the editor's assistance:

Type in the following sequence of characters on the line immediately above the item you wish to document: /**
Press Enter
The editor will automatically add a skeleton for the documentation similar to the one shown below (if documenting a function).
* @param num
* @param radix

void lcdPutInt(long num, char radix);

On the first line with a '*', you can type in a description of the function. The @param lines were added automatically based on the parameter list of the function immediately below. You can add comments after each parameter on the same line and they will also appear in the documentation window.

The documentation shown in the image above was generated by the following comments immediately above the lcdPutCur function declaration.

* Positions the cursor on a character LCD module at the specified row and column, both of which are zero-based.
* @param row    Row number of the display, where the top row is 0.
* @param column    Column number of the display, where the leftmost column is 0.

void lcdPutCur(char row, char col);

Javadoc formatted comments can be considerably more complex. Comments may be formatted as HTML which can then be used to generate documentation in the form of web pages. For more details on the syntax and capabilities of this feature, please see the Oracle website's page on the topic.

Back to Top

Code Assistance Options

Enable or disable the automatic display of code assistance

From the main menu, select Tools ▸ Options
Click on the editor icon at the top of the window, then select the Code Completion tab. Check or uncheck the options to suit your needs.

Code Complete Options window

Back to Top