Skip to content

Add test to prevent using .txx file extension #2230

@hjmjohnson

Description

@hjmjohnson

Issue created in response to: Slicer/Slicer#8741 (comment)

STYLE: Rename .txx files to .hxx for C++ recognition

Converting them to .hxx makes them more consistent with the community
standards, and can assist IDE and static analysis tools to properly
treat these as C++ containing files.

This is motivated by the realization that:
CMake’s AUTOMOC mechanism scans files with standard header extensions
(.h, .hpp, .hxx, etc.) for Q_OBJECT and automatically runs moc when
needed. However, .txx is not included in that default extension list,
so AUTOMOC will ignore .txx files entirely.

AUTOMOC is supported in Qt5.8 and above.
AUTOMOC is essentially required to build a Qt6 project properly using CMake.

Increasingly, tools are being created to help the programmer better
understand and analyze, and provide hints to proper coding options
dynamically in the development environment (color coding, auto-completion).

The obscure .txx file requires special configuration of each development
environment tool to indicate that it is really a C++ header. For new
developers, this is often a frustrating and challenging task. This is
confirmed by the large amount of documentation for just a few of the
standard editors. Tools that recognize and respect the .hxx extension:
uncrustify, vim, emacs, VisualStudios, clang, SlickEdit,
kwrite, etc....) None of these tools recognizes the .txx extension without
end-user customizations.

find . -name "*.txx" > ../CHANGE_FILE_EXTENSION_LIST
for i in $(cat ../CHANGE_FILE_EXTENSION_LIST ); do
  rm ${i//.txx/.hxx}
  git mv $i ${i//.txx/.hxx}
done
for i in $(cat ../CHANGE_FILE_EXTENSION_LIST ); do
  fn=$(basename $i)
  for reff in  $(git grep -l ${fn}); do
    sed -i "s/${fn//\.txx/}_txx/${fn/\.txx/_hxx}/g" $reff
  done
  for reff in  $(git grep -l ${fn}); do
    sed -i "s/${fn//\.txx/}\.txx/${fn/\.txx/.hxx}/g" $reff
  done
done

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions