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”.
@Andrea_Guarino Trying to test the implementation by incorporating this function in our script. Not able to find any associated Javadoc. Included the package “com.sonarsource.cobol.api.pp.CobolPreprocessorEvent” in the import statement and also, implemented the CobolPreprocessorEvent Interface. But not sure, what is the Argument type to be passed to the method “void onCopyPreprocessorEvent(CopyPreprocessorEventContext context)”. I’m not sure how to resolve the type context. Please help me by providing more information regarding this method or link to the Javadoc regarding the same.
You should indeed implement CopyPreprocessorEvent and override the following method: onCopyPreprocessorEvent(CopyPreprocessorEventContext context)
When you override that method, you can call the tokens method on the context parameter (of type CopyPreprocessorEventContext). It will give you the tokens of the COPY statement.