Page MenuHomePhabricator

Symbolic names are not resolved in PluginGenerator
Closed, ResolvedPublic

Description

When creating a new plugin with the MitkPluginGenerator, the symbolic names are not correctly resolved in the created files.

I tested it with the command from our documentation:
./MitkPluginGenerator --plugin-symbolic-name org.mycompany.myplugin --view-name "My View"

Event Timeline

We tested this with a windows and linux machine using the current master (f94aca1d163721b62e1b05cef36fbe068fea84ed).

This is an example for the resulting activator header:

#ifndef $(activator - file - name) _h
#define $(activator - file - name) _h

#include <ctkPluginActivator.h>

namespace mitk
{
  class $(activator - class - name) : public QObject, public ctkPluginActivator
{

fixed and verified. Some refactoring introduced white spaces into the symbols.

We could protect the code from being formatted by surrounding the lines containing the symbolic names with

//clang-format off
Code here...
//clang-format on

However this would result in those comments being transferred to the configured files, where we would not want formatting to be forbidden. Seeing as this should not be much of an issue as this code will be mostly not touched the solution is probably to be careful in future formatting steps.

In T22243#91714, @goch wrote:

We could protect the code from being formatted by surrounding the lines containing the symbolic names with

//clang-format off
Code here...
//clang-format on

However this would result in those comments being transferred to the configured files, where we would not want formatting to be forbidden. Seeing as this should not be much of an issue as this code will be mostly not touched the solution is probably to be careful in future formatting steps.

I think we should do something about it to make sure it doesn't happen again in the future. @goch Just relying on being careful sounds a bit optimistic ;) Just ideas:

  • rename all the files from .cpp and .h to .cpp.tmpl -h.tmpl
  • provide a target "clang-format" that invokes clang-format correctly on the relevant folders
  • write a documentation page on how to use it and how to be careful ;) (if this already exists, I'm sorry, but I couldn't find it ...)
  • rename all the files from .cpp and .h to .cpp.tmpl -h.tmpl

@nolden this should be a workable fix for the specific files mentioned in this task.