The Style Check contributed tool provides a mechanism for defining simple rules to describe a coding standard. The tool will then use these rules to verify that the source code for an application conforms to the defined standards. These rules are processed in order, and the first rule that fails will be recorded to the "Problem View" and the remaining rules will be skipped.
The operation of this tool is controlled through the use of simple rules that are stored in a simple text file. The rules can be viewed in the configuration screen for this tool (see image below - click to view a larger image).
The coding standard rules are processed in order, from first to last. The first rule that fails will be tagged against the line in the "Problem View" and all remaining rules will be skipped. As a result of this processing method, any program line that has multiple coding standard violations will be flagged with the first rule that fails rather than all rules that might apply.
A new rule can be created by pressing the [Add] button on the screen that displays the list of rules.
The information associated with a rule is:
Any existing rule can be modified by pressing the [Edit] button on the screen that displays the list of rules.
The string expression is validated for correctness; update of the rule cannot occur until the expression is valid.
Any existing rule can be deleted by pressing the [Delete] button on the screen that displays the list of rules.
The external tools must be enabled on the "Contributed Tools / Extensions" preference page. The Style Check can then be enabled as an observer and will be triggered when a file is saved in the editor. When the style check is executed as part of the save process, all rule violations will be updated to the "Problems View" but no modifications will be made to the source files.
When the style check is executed from the 'Contributed Tools' menu, any rule that includes a replacement text value, or option to delete the search value will be applied to the source file. Any remaining rule violations will be updated to the "Problems View".
A developer who wants to implement a style check (or coding style validation mechanism) as part of the standard application development process must create a simple class based on the generic style check class. The generic style check class has been provided as a simple example that uses a simple text file to define the rules describing the coding style. There is no additional code in the class - it is simply a clone of the standard class that is included with the plug-in. The documentation for this class can be accessed through the link.
The source code for the class can be viewed by clicking on the link.
The plug-in includes a standard class that is loosely based on the "Prototype" design pattern. This class defines the characteristics of a style check capability that can be implemented by a developer. The standard capabilities of the style check feature are implemented in this standard class. A developer can extend these methods or add specialized logic to implement rules that cannot be easily described using search patterns.
The documentation for the standard class can be accessed through the online help for the plug-on or by clicking on the link.