Interface SourceRegion

All Known Implementing Classes:
AbstractSourceRegion, CoffeeBytesRegion, NetbeansRegion, VisualStudioRegion

public interface SourceRegion
Generates comments to mark generated code as named regions.

Source region types must be registed in META-INF/services/org.wurbelizer.wurbel.SourceRegion.
The wurbelizer already provides some implementations with 'netbeans' being by default.

  • Method Details

    • type

      String type()
      Gets the unique name of the region type.
      Returns:
      the type name
    • isDefault

      default boolean isDefault()
      Returns whether this is the default region type.
      Returns:
      true if default
    • createBegin

      String createBegin(SourceRegion.FoldType foldType, String guardName, SourceWurbletSubElement wurbletElement)
      Creates the start comment.
      Parameters:
      foldType - the fold type, null if none
      guardName - the name of the guarded section
      wurbletElement - the wurblet element
      Returns:
      the comment
    • createEnd

      String createEnd(SourceRegion.FoldType foldType, String guardName, SourceWurbletSubElement wurbletElement)
      Creates the end comment.
      Parameters:
      foldType - the fold type, null if none
      guardName - the name of the guarded section
      wurbletElement - the wurblet element
      Returns:
      the comment
    • getBeginName

      String getBeginName(String comment)
      Gets the region's name (wurblet tag) if this is the start comment is of this region type.
      Parameters:
      comment - the comment string
      Returns:
      the region's name if is of this type
    • getEndName

      String getEndName(String comment)
      Gets the region's name (wurblet tag) if this is the end comment is of this region type.
      Parameters:
      comment - the comment string
      Returns:
      the region's name if is of this type
    • isEnd

      boolean isEnd(String comment, String name)
      Returns whether this is the end comment for the given region's name.
      Parameters:
      comment - the comment string
      name - the region's name
      Returns:
      true if matching end comment
    • getAll

      static Collection<SourceRegion> getAll()
      Gets all registered source regions.
      Returns:
      the source regions
    • get

      static SourceRegion get(String type) throws WurbelException
      Gets the source region of given type.
      Parameters:
      type - the type, null if default type
      Returns:
      the region of given type
      Throws:
      WurbelException - if no matching region type configured