Title: [270282] trunk/Tools
Revision
270282
Author
wenson_hs...@apple.com
Date
2020-11-30 19:59:26 -0800 (Mon, 30 Nov 2020)

Log Message

check-webkit-style should allow WebKitAdditions headers to appear after soft linking headers
https://bugs.webkit.org/show_bug.cgi?id=219382

Reviewed by Darin Adler.

The header include ordering rule that forces soft linking headers to be included last in implementation (cpp and
mm) files shouldn't really apply to WebKitAdditions headers, since those additions headers are only meant to
contain method and function implementations anyways.

Fix this by adding code to recognize WebKitAdditions headers as a special type of header, and exempt these
headers from the `'*SoftLink.h header should be included after all other headers.'` rule.

* Scripts/webkitpy/style/checkers/cpp.py:
(_IncludeState):
(_IncludeState.check_next_include_order):
(_classify_include):
* Scripts/webkitpy/style/checkers/cpp_unittest.py: Add a test case to exercise this scenario.

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (270281 => 270282)


--- trunk/Tools/ChangeLog	2020-12-01 02:37:53 UTC (rev 270281)
+++ trunk/Tools/ChangeLog	2020-12-01 03:59:26 UTC (rev 270282)
@@ -1,3 +1,23 @@
+2020-11-30  Wenson Hsieh  <wenson_hs...@apple.com>
+
+        check-webkit-style should allow WebKitAdditions headers to appear after soft linking headers
+        https://bugs.webkit.org/show_bug.cgi?id=219382
+
+        Reviewed by Darin Adler.
+
+        The header include ordering rule that forces soft linking headers to be included last in implementation (cpp and
+        mm) files shouldn't really apply to WebKitAdditions headers, since those additions headers are only meant to
+        contain method and function implementations anyways.
+
+        Fix this by adding code to recognize WebKitAdditions headers as a special type of header, and exempt these
+        headers from the `'*SoftLink.h header should be included after all other headers.'` rule.
+
+        * Scripts/webkitpy/style/checkers/cpp.py:
+        (_IncludeState):
+        (_IncludeState.check_next_include_order):
+        (_classify_include):
+        * Scripts/webkitpy/style/checkers/cpp_unittest.py: Add a test case to exercise this scenario.
+
 2020-11-30  Brian Burg  <bb...@apple.com>
 
         filter-build-webkit: reduce non-actionable warnings from objc runtime and xcodebuild

Modified: trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py (270281 => 270282)


--- trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py	2020-12-01 02:37:53 UTC (rev 270281)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py	2020-12-01 03:59:26 UTC (rev 270282)
@@ -122,6 +122,7 @@
 _OTHER_HEADER = 2
 _SOFT_LINK_HEADER = 3
 _MOC_HEADER = 4
+_WEBKIT_ADDITIONS_HEADER = 5
 
 
 # Files which is generated by some sort of code generator.
@@ -292,6 +293,7 @@
         _OTHER_HEADER: 'other header',
         _SOFT_LINK_HEADER: '*SoftLink.h header',
         _MOC_HEADER: 'moc file',
+        _WEBKIT_ADDITIONS_HEADER: 'WebKitAdditions header',
         }
     _SECTION_NAMES = {
         _INITIAL_SECTION: "... nothing.",
@@ -364,8 +366,7 @@
                 if primary_header_exists and not filename.endswith('SoftLink.cpp'):
                     error_message = before_error_message
             self._section = self._OTHER_SECTION
-        else:
-            assert header_type == _SOFT_LINK_HEADER
+        elif header_type == _SOFT_LINK_HEADER:
             if file_is_header:
                 error_message = '{} should never be included in a header.'.format(
                     self._TYPE_NAMES[header_type])
@@ -372,7 +373,7 @@
             self._section = self._SOFT_LINK_SECTION
             self._visited_soft_link_section = True
 
-        if not error_message and self.visited_soft_link_section() and header_type != _SOFT_LINK_HEADER:
+        if not error_message and self.visited_soft_link_section() and header_type != _SOFT_LINK_HEADER and header_type != _WEBKIT_ADDITIONS_HEADER:
             error_message = '*SoftLink.h header should be included after all other headers.'
 
         return error_message
@@ -3428,6 +3429,9 @@
       _OTHER_HEADER
     """
 
+    if 'WebKitAdditions/' in include:
+        return _WEBKIT_ADDITIONS_HEADER
+
     # If it is a system header we know it is classified as _OTHER_HEADER.
     if is_system and not include.startswith('public/') and not include.startswith('wtf/') and not include.endswith('SoftLink.h'):
         return _OTHER_HEADER

Modified: trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py (270281 => 270282)


--- trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py	2020-12-01 02:37:53 UTC (rev 270281)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py	2020-12-01 03:59:26 UTC (rev 270282)
@@ -3427,11 +3427,21 @@
                                          '#include <Framework/Bar.h>\n',
                                          '*SoftLink.h header should be included after all other headers.  [build/include_order] [4]')
 
+        # Allow WebKitAdditions headers to appear after *SoftLink.h headers.
         self.assert_language_rules_check('Foo.cpp',
                                          '#include "config.h"\n'
                                          '#include "Foo.h"\n'
                                          '\n'
                                          '#include "ALocalHeader.h"\n'
+                                         '#include "FrameworkSoftLink.h"\n'
+                                         '#include <WebKitAdditions/FooAdditions.h>\n',
+                                         '')
+
+        self.assert_language_rules_check('Foo.cpp',
+                                         '#include "config.h"\n'
+                                         '#include "Foo.h"\n'
+                                         '\n'
+                                         '#include "ALocalHeader.h"\n'
                                          '#include <Framework/Bar.h>\n'
                                          '\n'
                                          '#include "FrameworkSoftLink.h"\n'
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to