The larger the state machine, the greater the need to quickly search for elements – for example, to find a certain state or to find all occurrences of a certain variable or event. YAKINDU Statechart Tools provides this functionality and this blog post shows how to make the most use out of it.
When searching for state machine elements one can distinguish between the two following scenarios:
- Search based on a certain name pattern
- Example: search for all states with prefix error
- Search for all references of a certain element
- Example: search for all transitions that have the event switchOff as trigger
Let’s see how we can accomplish both tasks with YAKINDU Statechart Tools.
Text based model search
Searching for text occurrences in statechart is as simple as searching for text in a text file. Just press [Ctrl+H] or open the search dialog via the menu Search -> Search…
In the search dialog, switch to the Statechart Search tab:
The model search allows you to use regular expressions and to filter for the kind of elements you want to search for. You can also define whether you want to search in the whole workspace or just in the selected statechart model.
Once the search is performed, its results are listed in the search view. With a double click on one of the search results, you can quickly navigate to the corresponding statechart element.
However, this still needs two steps: (1) search for the desired element and (2) switch to the search view and double click on the element. For simple navigation tasks, you can use the Model Navigation dialog. To open the navigation dialog, just press [Ctrl+Shift+Q]. In the text field, type in the name of the desired model element; you can also use wildcards like “*”. The dialog directly shows fitting targets where you can navigate to with a double click.
Reference based model search
The second scenario is to search for all references of an element. You can find this option in the context menu, for example, when selecting a variable in the definition section. The Find References action searches for all occurrences of exactly this variable. This means that other elements with the same name will not be found. The results are listed again in the same view as for the text based statechart search.
At this point we want to thank our former intern Abdullah Tasman who mainly implemented the hereby introduced features as part of his student internship.
Do you want to learn more about YAKINDU Statechart Tools? Give it a try!