IDM PowerTips
Parse Source Code with the Function List
When coding, the Function List is one feature you can’t do without… The function list displays all the functions in the active file/project. Want to jump to a specific function? Double-clicking on a function name in the list repositions the file to that function. Clearly, the Function List is indespensible for your day-to-day programming tasks…
The following Power Tip will guide you through some of the common tasks/actions for the Function List.
Open the Function List
If the Function List is not visible, you can open it from View : Views/Lists : Function List.
Navigating through code with the function list
As we’ll discuss further below, the function list is populated – on a per language basis – based on regular expressions in the wordfile. The regular expressions match strings of text from your file and use that text to populate the function list.
The functions in the function list “map” to the function in the file, so you can double-click on the functions to navigate to the corresponding function in your file.
Not only is the function list highly-flexible in what it displays, but it also provides a few configuration items that relate to how it is used.
Right-click in the function list area to view these options, you will see the following menu:
Sort
The sort option will sort the function list entries alphabetically. If you uncheck the sort, the function list items will be displayed in the order in which they appear in the file.
List for all project files
If the list for all project files option is enabled, the function list will display all functions for the project – as opposed to only the functions for the active file.
See our power tip on working with projects in UltraEdit.
Refresh
For performance reasons, the function list data is not populated as you type. If you want to update the function list, before you save your current changes, you can select the Refresh button. Additionally, you can hit the hotkey F8 to refresh the data in the function list.
Flat list
As of UltraEdit v16.00, the function list data is displayed in a tree-view. If you wish to view the function list data as a list format, you can enable the Flat list option.
Configuring Function definitions
The Function List is highly flexible/customizable because it is populated based on regular expressions – the function strings (regular expressions) are stored in the respective wordfile.
A discussion on regular expressions is outside the scope of this tutorial; however, you can learn more about regular expressions syntax in the Help (See “Regular Expressions”) at our regular expressions power tip. We recommend using Perl regular expressions in your wordfiles.
UltraEdit provides a dialog for configuring your Function List regualar expressions, you can access the Function List configuration dialog in Advanced : Configuration : Function List:
Add a Group
The Function List supports “grouped” items in a tree structure; therefore, you can add top-level groups and subgroups.
For our first example, we will add a top-level “imports” group to the Java language.
- In the Modify Groups dialog, select the top-level Groups item, then type “Imports” in the Group text field:
- Now, click the Add button.
- Your new “Imports” group should be active (selected) in the Existing Groups box. Now you can add your Regular Expression string. To do this, double-click in the “Regular Expression to match group” field – it will become a text-entry field.
- Now, paste your Regular Expression string. You should have something that looks like the following:
Note: In this example, we will not enter anything in the Open/Close tag fields. The Open/Close tag strings are used to define a scope – ie the scope at which the search for those strings will be executed. For example, to match parameters for a function, you might define the following Open/Close tag as “(” and “)” respectively. This would cause the regular expression to ONLY return results (matches) that occur between the “(” and “)”. - Click Ok
- You’re done, the Function List will now display “Imports” – in addition to the other supported groups.
Add a Subgroup
The process for adding a group is almost identical to the process of adding a top-level group – the only difference being that you select the group under which you wish to add the subgroup instead of the top-level “Groups” item.
As an example, consider you wish to add a subgroup under Methods for “To do’s” – defined as: “//TODO: ….”. The process is as follows:
- Select the Methods item, then type TODO in the Group text field:
- Now, double-click in the “Regular expression to match group” field and type your regular expression string.
- As we described above, the Open/Close tag fields define the scope of the search. So, since we want to restrict “To do’s” to the specific method, we will define the Open/Close tag’s as “{” and “}” respectively.
When you are done, your entry will look like the following:
- Click Ok, to accept your changes.
- Refresh your function list, you should now see your “To Do’s” in the function list under the respective Method/Function:
Searching
As you can see, at the top of the dialog, the Function List also features a search box. If you are editing a file with many functions, you can simply type your desired function/etc and hit ENTER.
UltraEdit will locate the Function name – even expanding collapsed nodes.