Use the PL/I APIs to analyze the PL/I
language elements that you select for your user-written rules.
About this task
For more information about the PL/I APIs
and the generated implementation code, see the related links at the
end of the topic.
Procedure
To implement the code analysis for a user-written rule:
- Open the Plug-in Development perspective.
- In the Package Explorer, right-click
the Java™ source file that was
generated for your user-written rule, then click . The location of the Java file in the Package Explorer is . For example: .
- In the Java editor,
add Java code to each of the
generated visit() methods to do the code analysis. A visit() method is generated for each PL/I
Application Model interface that corresponds to the PL/I language
element that you selected. Some language elements have only one corresponding
interface; other language elements have more. For example,
suppose that you selected the AllocateStatement element in the PL/I
language elements tree on the third page of the creation wizard. An
AllocateStatement element has one corresponding interface, AllocateStatement.
Therefore, a visit() method is generated for the AllocateStatement interface.
Note: The
visit() methods
belong to the interface
IPLIVisitor, in the package
com.ibm.rsar.analysis.codereview.pli.custom.model.util,
in the Custom Rules API for PL/I Code Review. Do not implement
IPLIVisitor directly;
instead, subclass
AbstractPLIVisitor. The method
signature of the
visit() method for an AllocateStatement
object is as follows:
boolean visit(com.ibm.etools.pli.application.model.pli.AllocateStatement n)
When a PL/I source file is analyzed, the code analyzer
starts a visit() method whenever it encounters an
instance of the corresponding PLINode.
- In each visit() method,
add Java code for the following
functions:
- When you are finished, close the Java editor.