Link a resource

Resource Traceability: Source code syntax

Developers add a source code comment using the syntax below to customize what information is included with the linked resource.

Required - @wi tells the parsers to include the following line(s) in the Linked Resources section of the specified Work Item(s).

(Optional).linkrolename (Add how it relates to the Work Item.)

(Optional) The Project ID name.

Required - The Work Item ID. Can also be the full Work Item URL.

(https://polariondomain.com/polarion/#/project/test/work-item?id=TST-1007&revision=5678 message.)

(Optional) The revision number. (It will provide a link in Linked Resources directly to the revision that the source code change refers to.)

(Optional) An additional commented message from the developer that will also appear in the Linked Resources section of the Work Items.

Linked resource example

Link Role

Branch

Category

Revision

Repository

Message

Parser

This reference can be linkable and bring users directly to the code that implemented the Work Item change.

If administrators set the View Traceable Resource Local URL. (Administration Repository )

Element

Position

To add a linked resource like the example above (for Java or C parsers), add the following commented code where the change was implemented.

/**
* @wi.implements elibrary/EL-115:164 Returns author of this book
*/
public String getAuthor() {
return this.author;
}  

Multiline message

There is no limit to the number of commented lines for a developer message.

Just start the message with a "{" and end it with "}".

/**
* {@wi.implements elibrary_alm/EL-122 messages can take up 
* several lines in the code. Just surround the whole parsing syntax 
* with {}  
* Anything commented after will not be included.
*/ 

Supported elements

Developers can add the Resource Traceability feature to comments for the following elements:

For Java: (.java is the supported extension.)

  • method

  • constructor

  • field

  • class

  • interface

  • enum

  • static block

For C: (Supported extensions - .c, .h and additional custom extensions depending on how the parser and project preferences are configured.)

  • function

  • function prototype

  • global variable

  • struct

  • union

  • enum

Where to place the comment

Where the comment should be placed, varies depending on the parser used.

For Java and C:

If using a Java or C parser, the Resource Traceability syntax links the element that directly follows it in the source code.

(public String getAuthor() in the example above.)

For XML:

For XML, add the comment inside the target element as in the example below.

The second example will link to the Plugin instead of the groupId.