Skip to content

How to Customize the Comment Analysis

To customize the code entities (e.g., methods or field declarations) for which Teamscale expects a comment, Teamscale provides so-called selection predicates to specify code entities. This can be used to customize and fine-tune the comment analysis to your needs.

Supported Languages

The following languages support this feature:

  • C
  • C#
  • C++
  • Java
  • JavaScript
  • Kotlin
  • MATLAB
  • Python
  • Swift
  • Visual Basic

Code Entity Selection Predicates

An entity selection predicate consists of primitives that can be connected using negation !, conjunction &, disjunction |, and parentheses ( and ). The primitives are listed in the following configuration boxes. Obviously, not all predicates are applicable to all programming languages.

Simple Example

An example that selects all public simple getters and setters would be

public & (simpleGetter | simpleSetter)

Language-level examples

A good starting point are the following examples

Javapublic & (type | method | attribute) & !(simpleGetter | simpleSetter | annotated(Override) | override)
C#public & (type | method | property) & !(simpleGetter | simpleSetter | annotated(Override) | override)
C++
(Comments expected in Headers)
type | (public & (attribute | (method & declaration)))
C++
(Comments expected at Implementation)
type | (public & (attribute | (method & !declaration)))
Swift(public & (type | method | attribute | declaration | property) & !(simpleGetter | simpleSetter | annotated(Override) | override))

Predicate Reference

The following boxes provide an overview of the available predicates.

PredicateMeaning
language(name) Entities in files with the given language.
If the given language name is invalid, no entities are matched. Valid names are for example JAVA and CPP.
module Namespaces and modules.
type Types, such as classes or structs.
method Methods and functions.
declaration Declarations of types and methods.
internalInternal entities (C# and Swift keyword).
attribute Attributes, fields and global variables.
property All properties: defined attributes that have only method children.
statementAll statements.
metaAll meta information (defines, annotations, etc.).
publicAll public entities, as well as methods inside interfaces, which are considered public in most languages.
protectedAll protected entities.
overrideAll entities marked with override keyword.
privateAll private entities.
fileprivateAll fileprivate entities (Swift keyword).
defaultAll entities with default visibility.
finalAll final entities.
staticAll static entities.
primitiveAll primitive entities (i.e. those without children).
subtype(name)Entities by their subtype. The name parameter can e.g., be if to target if-statements. Other examples for the name parameter are constructor, destructor or while.
typeSubtype(name)Entities by their parent type's subtype (e.g., to select all members of interfaces).
name(name)Entities by their name. For example a method name.
nameRegex(regex)Entities by their name using regular expression.
fileRegex(regex)Entities by their containing file's unified path using regular expression, e.g. fileRegex(.*\.ts) matches all files with the extension ».ts«.
annotated(name)All entities that are annotated with an annotation of given name (excluding the »@« sign).
simpleGetterSimple getters, i.e. methods starting with »get« or »is« and containing at most one statement. Use simpleGetterCaseInsensitive for a case insensitive version.
simpleSetterSimple setters, i.e. methods starting with »set« and containing at most one statement. Use simpleSetterCaseInsensitive for a case insensitive version.
simpleMethod(prefix)Simple methods whose name starts with the given prefix. A method is simple, if it contains as most one statement. Use simpleMethodCaseInsensitive(prefix) for a case insensitive version.
exportAll entities with ES6's export visibility.
typeexportedAll entities (e.g. methods, attributes) within types that have ES6's export visibility.
extendsTypeClasses that extend a specific type directly (e.g. extendsType(MyBaseClass))
isAbstractAll abstract entities.