Skip to content

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.

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:

TypeResults
FilesAny files whose names contain the search term.
CodeCode snippets that contain the search term.
CommitsCommits that contain the search term in the commit message
Issues & Spec ItemsAny 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:

OptionResult
EverywhereApply search to files, code, commits, issues, requirements and tests.
- only filesApply search to files only.
- only codeApply search to code only.
- only commitsApply search to commit messages only.
- only issues & spec itemsApply search to issues, requirements and tests only.
Advanced code searchApply advanced search to code.

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 TypeExample
Literalse.g., string literals like "foo" or 123
Keywordse.g., reserved (language-specific) keywords like private
Identifierse.g., variable names
Operatorse.g., +, ++, == etc.
Delimiterse.g., parentheses, braces or semicolons
Commentse.g., commented out code or documentation
Specialse.g., special language constructs like pragma directives (#pragma in C++)
Errorse.g., illegal characters
Whitespacese.g., spaces, tabs and linebreaks
SyntheticsSynthetic 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.

Search Treemap

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:

ModeDescription
case-insensitiveBy default, regex search is case-sensitive. Case-insensitive matching is enabled via the embedded flag expression (?i).
multilineBy 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.
DOTALLBy default "." does not match the line terminator. Embedded flag expression (?s) turns on DOTALL mode where "." also matches the line terminator.