utils: checkstyle: Run the CLangFormatter last
The IncludeOrderFormatter will be extended with more formatting rules that should be applied before clang-format gets run, as it will influence its output. Add a priority mechanism for formatters, and give a negative priority to the CLangFormatter to make it run last. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
This commit is contained in:
@@ -279,6 +279,8 @@ class ClassRegistry(type):
|
||||
newclass = super().__new__(cls, clsname, bases, attrs)
|
||||
if bases:
|
||||
bases[0].subclasses.append(newclass)
|
||||
bases[0].subclasses.sort(key=lambda x: getattr(x, 'priority', 0),
|
||||
reverse=True)
|
||||
return newclass
|
||||
|
||||
|
||||
@@ -568,6 +570,7 @@ class Formatter(metaclass=ClassRegistry):
|
||||
|
||||
class CLangFormatter(Formatter):
|
||||
patterns = ('*.c', '*.cpp', '*.h')
|
||||
priority = -1
|
||||
|
||||
@classmethod
|
||||
def format(cls, filename, data):
|
||||
|
||||
Reference in New Issue
Block a user