wiki:Documentation/T3Q/Code-Formatting

T3Q Code Formatting Feature

Starting with v0.1.1, the T3Q tool provides a feature for the automated formatting of TTCN-3 code. The feature is disabled by default and has to be manually enabled in the configuration file. This is due to the fact that the user also has to specify an output path where the formatted versions of the TTCN-3 files will be written. The output setting allows for relative paths (the directory structure will be recreated in the directory from which T3Q was called), or absolute paths (the directory structures will be recreated in a fixed destination path, independent from the location where T3Q was started). Both ways to specify the output path can be used to overwrite the original TTCN-3 resources.

Below is an extract of the settings relevant to the code formatting feature from the configuration file:

      <pathFormattedOutputPath>FORMATTED</pathFormattedOutputPath>
      <formattingParameters>
        <tabs>false</tabs>
        <unixNewline>false</unixNewline>
        <spacesBetweenAssignment>true</spacesBetweenAssignment>
        <spaceAfterComma>true</spaceAfterComma>
        <KRstyle>true</KRstyle>
        <newlineBeforeRunsOn>true</newlineBeforeRunsOn>
        <newlineBeforeSystem>true</newlineBeforeSystem>
        <newlineBeforeReturn>true</newlineBeforeReturn>
        <newlineBeforeExceptionSpec>true</newlineBeforeExceptionSpec>
        <newlineBeforeFormalPar>true</newlineBeforeFormalPar>
        <newlineAfterFormalParList>true</newlineAfterFormalParList>
        <spacesAroundParentheses>true</spacesAroundParentheses>
        <spacesCount>2</spacesCount>
        <linesBetweenModules>2</linesBetweenModules>
        <linesAfterControlPart>1</linesAfterControlPart>
        <linesAfterModuleDefinition>1</linesAfterModuleDefinition>
        <linesBetweenImportDefinitions>1</linesBetweenImportDefinitions>
      </formattingParameters>
  • <pathFormattedOutputPath>FORMATTED</pathFormattedOutputPath> - Output path for the formatted TTCN-3 files, can be relative or absolute
  • <formattingParameters - Subsection with the formatting parameters
    • <tabs>false</tabs> - Use tabs or spaces for indentation, default set to spaces
    • <unixNewline>false</unixNewline> - Use UNIX new line style, this may or may not have any visible effects on the output, depending on the editors and operating systems used
    • <spacesBetweenAssignment>true</spacesBetweenAssignment> - Add a space around assignment operators
    • <spaceAfterComma>true</spaceAfterComma> - Add a space after comma
    • <KRstyle>true</KRstyle> - Use Kernighan and Ritchie formatting style
    • <newlineBeforeRunsOn>true</newlineBeforeRunsOn> - Add a new line before runs on clauses
    • <newlineBeforeSystem>true</newlineBeforeSystem> - Add a new line before system clauses
    • <newlineBeforeReturn>true</newlineBeforeReturn> - Add a new line before return clauses
    • <newlineBeforeExceptionSpec>true</newlineBeforeExceptionSpec> - Add a new line before exception clauses
    • <newlineBeforeFormalPar>true</newlineBeforeFormalPar> - Add a new line before formal parameters, unless a single parameter is used
    • <newlineAfterFormalParList>true</newlineAfterFormalParList> - Add a new line after formal parameter lists (of more than one parameter)
    • <spacesAroundParentheses>true</spacesAroundParentheses> - Add a space around parentheses
    • <spacesCount>2</spacesCount> - Indentation depth
    • <linesBetweenModules>2</linesBetweenModules> - Number of lines between modules
    • <linesAfterControlPart>1</linesAfterControlPart> - Number of lines after control parts
    • <linesAfterModuleDefinition>1</linesAfterModuleDefinition> - Number of lines after module definitions
    • <linesBetweenImportDefinitions>1</linesAfterModuleDefinition> - Number of lines between import definitions (affects only subsequent import definitions)
  • </formattingParameters>

Upon successfully saving a formatted file, an output message is generated providing the location of the file.

Last modified 14 years ago Last modified on 06/03/10 15:59:46