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.
A simple rules-based style check (simpleStyleCheck) is included with the plug-in.
The operation of this tool is controlled through the use of simple rules that are stored in a text file located in the same folder as the primary class used to implement the style check.
A secondary rule file can be created in the folder specified by the
preference 'Contributed Extensions / Tools: Directory for user-defined
observers' with the same name as the primary class for the style check. When this
file exists, any new or modified rules will be saved to this file; the rules in this
file will be added to the list of existing (standard) rules for the style check. The name of the style check class will be displayed in parenthesis after the description of the plug-in on the 'Contributed Extensions / Tools' preference page once the plug-in has started. |
The rules can be viewed in the configuration screen for this tool (see image below - click to view a larger image).
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 class based on the simple style check class. This class has been provided as an example that uses a text file to define the rules describing the coding style.
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.