Guard Types¶
The Wurbelizer provides the following guard types:
netbeans: Netbeans style guarded blocks. Also supported by other IDEs such as IntelliJ. This is the default.coffeebytes: style of the former CoffeeBytes Eclipse plugin. Support by current Eclipse versions is unknown.visualstudio: Microsoft Visual Studio style. Also supported by VSCode.
The guardtype can be changed with the wurblet property guardtype.
See build tools integration.
A single source file may use a different guard type by setting guardtype in its
.wurb file.
The wurbler recognizes the guarded blocks of all registered guard types, and the blocks are re-created whenever their wurblet runs. Hence, changing the guard type converts the existing blocks on the next run.
Fold Types¶
The wurblet property foldtype sets the default editor fold
for all guarded blocks:
collapsed: the block is collapsed in the editorexpanded: the block is expanded in the editornone: the block gets no fold handle (default)
An individual anchor can override the default with the fold wurbler directive.
Currently, only the netbeans guard type supports fold types.
Custom Guard Types¶
Custom guard types can be added as well.
A guard type must implement the interface org.wurbelizer.wurbel.SourceRegion and is
registered via META-INF/services/org.wurbelizer.wurbel.SourceRegion.
The interface requires the following methods:
type(): the unique name of the guard type, as used in theguardtypeproperty.createBegin(foldType, guardName, wurbletElement)andcreateEnd(foldType, guardName, wurbletElement): create the comment lines that begin and end a guarded block.foldTypeisnullif no fold is requested. Both must be single-line comments (// ...), because the wurbler looks for the markers of a guarded block only in single-line comments.getBeginName(comment)andgetEndName(comment): return the tag if the given comment begins or ends a guarded block of this type, otherwisenull.isEnd(comment, name): whether the comment ends the guarded block with the given tag.isDefault(): optional, returnstruefor the default guard type. Only one guard type should be the default.
org.wurbelizer.wurbel.AbstractSourceRegion provides a base implementation.
See org.wurbelizer.wurbel.NetbeansRegion for an example.
Source Types¶
The kind of a source file determines how the wurbler treats it. Source types are
pluggable as well: a source type implements the interface
org.wurbelizer.wurbel.SourceType and is registered via
META-INF/services/org.wurbelizer.wurbel.SourceType. The type is selected by the
extension of the source file (case-insensitive). Files without an extension, or with an
extension that has no dedicated source type, get the default type. The interface consists of:
getFileExtension(): the file extension including the dot, e.g..java.extractProperties(SourceDocument document): extracts variables from the parsed source, which become available to the anchors and wurblets of that file.isSmartIndent(): optional, whether smart indent is the default. The default isfalse.isDefault(): optional, returnstruefor the type used for files without an extension and for all extensions without a dedicated source type.
The Wurbelizer provides two source types:
JavaSourceTypefor.javafiles: smart indent is enabled, and the built-in variables such asclassnameandpackagenameare extracted from the code.NoneSourceType: the default for all other files, e.g..xmlor.sql. It extracts no variables and uses no smart indent.