Content Assistant
Content Assistant
Content Assistant can help programmers quickly complete the code, and there is additional functionality for automatic code completion. This is critical for a code editor and is one reason many people like to write code in the IDE. But it's not as simple as that, but let's take a look at the concepts associated with JTF and content Assistant, and here's what the Java Editor's content hints look like in Eclipse:
Figure 1. Content hints for the Java editor
Let's first introduce the three concepts that appear in Figure 1:
Proposal (Proposed): Proposal represents a possible AutoComplete option, and after the programmer chooses, the code is automatically filled in to the editor.
Proposal popup (Proposed pop-up list): Proposal popup is a window to display the AutoComplete list
Additional info (additional information): Each proposal can be accompanied by some help information, called Additional info, which appears next to the pop-up list and automatically refreshes when you select a Proposal.
Tip: After the pop-up list appears, you may find that some keyboard events are being processed by the pop-up list, such as when you press the up and down arrows, which change the Proposal that is currently selected. This is because before the list pops up, the content Tip manager adds a key to the text box to verify the event handler and intercepts the keys. The specific code can refer to Contentassistant's internal class Internallistener.
These three parts are customizable, but some of them are simply a bit cumbersome. For example, we see a line below the pop-up list that prompts "press ' alt+/' to show Template proposals", which is not in the standard pop-up list, JDT customizing this part.
Add content hint support for sample code
I intend to add the following content hint support for the sample code for this article: automatically prompt for variable names that have been declared. For example, the following statement:
Listing 1. Sample statement
a = 3;
b = 4;