Searching with Teamscale
Teamscale comes with different ways to search for specific code, files, commits or issues. The search view can be opened by typing some search query in the search field in the top right corner of the UI. Additionally, selecting the "Configure Search..." option that appears when clicking into the mentioned field will also navigate to the search view.
Simple Search
The default mode of Teamscale's search is the simple search. In this mode, Teamscale takes the entered term from "Query" field, and searches the project(s) for this term. Note that it is possible to restrict the search to a specified project by selecting the target project from the dropdown menu in the top left. In addition, you can also select a path within the project to which the search should be limited in order to receive results for a specified part of the given project.
Results
After entering a search term and, optionally, a code path, Teamscale searches the (specified) projects for the search term and presents four different result types:
Type | Results |
---|---|
Files | Any files whose names contain the search term. |
Code | Code snippets that contain the search term. |
Commits | Commits that contain the search term in the commit message |
Issues & Spec Items | Any issues & spec items (e.g. Jira tickets or test cases) that contain the search term. |
Note that the search could also be configured to search for and present results of only one of these types by selecting the desired type from the dropdown next to the query field:
Option | Result |
---|---|
Everywhere | Apply search to files, code, commits, issues, requirements and tests. |
- only files | Apply search to files only. |
- only code | Apply search to code only. |
- only commits | Apply search to commit messages only. |
- only issues & spec items | Apply search to issues, requirements and tests only. |
Advanced code search | Apply advanced search to code. |
Advanced Code Search
Teamscale further provides the so-called advanced code search that can be used to apply regex-search to selected code. Code can be selected like for the simple code search via selection of the desired project and path.
TIP
We also provide a short demo on YouTube.
To make the advanced code search mode even more powerful than basic regular expression matching, Teamscale additionally provides options to restrict the search. You can define set of token types, the code representation on which the search is applied. This way, you can restrict the search to code entities such as comments or literals. Currently, Teamscale supports searching for the following token types:
Token Type | Example |
---|---|
Literals | e.g., string literals like "foo" or 123 |
Keywords | e.g., reserved (language-specific) keywords like private |
Identifiers | e.g., variable names |
Operators | e.g., + , ++ , == etc. |
Delimiters | e.g., parentheses, braces or semicolons |
Comments | e.g., commented out code or documentation |
Specials | e.g., special language constructs like pragma directives (#pragma in C++) |
Errors | e.g., illegal characters |
Whitespaces | e.g., spaces, tabs and linebreaks |
Synthetics | Synthetic tokens to represent language specific features, e.g., indents in Python |
Per default, the All
option will be selected to include all different types of tokens in the search. However, excluding certain types of tokens from the search might be the more interesting use case for selecting token types, e.g., to exclude comments from a code search. For this, you can simply deselect the non-required tokens in the list. In case of comments, there is also an option "All except comments" that excludes comments from the search.
Results
The results of the advanced code search are displayed in two ways: in a treemap indicating the matches in the code base and in a match list below.
The treemap represent the selected code scope with every rectangle representing one specific file with size of a rectangle relating to a file's included lines of code. The results of the advanced code search are displayed by coloring the different files, with the color intensity referring the count of matches within a file, i.e. the darker the color the more matches Teamscale found in a file. In addition, it is possible to hover the different rectangles to show the match count and concrete file name. It is also possible to directly navigate to the affected file via this perspective.
Below the match treemap, Teamscale lists the found matches together with the file in which the match was found. Note that a match shows the complete code that was matched with the entered regular expression.
Embedded Flag Expressions
By default, the advanced code search uses case-sensitive, single line regex matching. However, the search can be configured to use the following modes by adding embedded flag expressions, in this case Java regex modifiers, to the regex:
Mode | Description |
---|---|
case-insensitive | By default, regex search is case-sensitive. Case-insensitive matching is enabled via the embedded flag expression (?i) . |
multiline | By default, multiline mode is disabled. Hence, ^ and $ match at the beginning/end of file. If multiline mode is enabled via the embedded flag expression (?i) , ^ and $ match just after or just before, respectively, a line terminator or the end of the file. |
DOTALL | By default "." does not match the line terminator. Embedded flag expression (?s) turns on DOTALL mode where "." also matches the line terminator. |