Sonar - Cobol -Plugin Development

We are trying to add more custom rules through Plugin in our Sonar Profile for analysis of Cobol programs.

As a first step, to understand the AST, I started using SSLR tool kit. I observed that no tokens are used to represent the COPY statements. Is there any specific reason for this? I have a requirement to collect the copybooks used and do some validation on them. Since no tokens are representing COPY statements, should I go for function calls like “getCopyBookOriginalLine”.

Thanks,
Ramapriya

Hello @Ramapriya ,

Sorry for the late answer.

I observed that no tokens are used to represent the COPY statements. Is there any specific reason for this?

COPY statements are pre-processed to be directly replaced with the content of the targeted copybook.

If you want to collect COPY statements, your check could implement CobolPreprocessorEvent interface, which exposes the following method:

void onCopyPreprocessorEvent(CopyPreprocessorEventContext context)

CopyPreprocessorEventContext contains the information about copybooks.

Hope that helps,
Andrea G.

@Andrea_Guarino Thanks a lot for explaining. This helped me a lot. Thanks Again!