Title: [260659] trunk/Tools
Revision
260659
Author
[email protected]
Date
2020-04-24 11:42:53 -0700 (Fri, 24 Apr 2020)

Log Message

check-webkit-style should recognize *Internal.h and *Private.h as primary headers
<https://webkit.org/b/210979>

Reviewed by Darin Adler.

* Scripts/webkitpy/style/checkers/cpp.py:
(_classify_include): If a header has an "Internal.h" or a
"Private.h" suffix with the same base name as the source file,
consider it a primary header--the header that comes after
"config.h".
* Scripts/webkitpy/style/checkers/cpp_unittest.py:
(OrderOfIncludesTest.test_classify_include): Add tests.

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (260658 => 260659)


--- trunk/Tools/ChangeLog	2020-04-24 18:23:43 UTC (rev 260658)
+++ trunk/Tools/ChangeLog	2020-04-24 18:42:53 UTC (rev 260659)
@@ -1,3 +1,18 @@
+2020-04-24  David Kilzer  <[email protected]>
+
+        check-webkit-style should recognize *Internal.h and *Private.h as primary headers
+        <https://webkit.org/b/210979>
+
+        Reviewed by Darin Adler.
+
+        * Scripts/webkitpy/style/checkers/cpp.py:
+        (_classify_include): If a header has an "Internal.h" or a
+        "Private.h" suffix with the same base name as the source file,
+        consider it a primary header--the header that comes after
+        "config.h".
+        * Scripts/webkitpy/style/checkers/cpp_unittest.py:
+        (OrderOfIncludesTest.test_classify_include): Add tests.
+
 2020-04-24  Alex Christensen  <[email protected]>
 
         SPI clients using fastServerTrustEvaluationEnabled need SPI to inform them of modern TLS negotiation

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


--- trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py	2020-04-24 18:23:43 UTC (rev 260658)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py	2020-04-24 18:42:53 UTC (rev 260659)
@@ -3225,6 +3225,8 @@
     if not include_state.visited_primary_section():
         if target_base.find(include_base) != -1:
             return _PRIMARY_HEADER
+        if include_base in ['{}Internal'.format(target_base), '{}Private'.format(target_base)]:
+            return _PRIMARY_HEADER
 
     # If we already encountered a primary header, perform a strict comparison.
     # In case the two filename bases are the same then the above lenient check

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


--- trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py	2020-04-24 18:23:43 UTC (rev 260658)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py	2020-04-24 18:42:53 UTC (rev 260659)
@@ -3557,6 +3557,15 @@
                                          '\n'
                                          '#include "ResourceHandleWin.h"\n',
                                          '')
+        # Internal.h and Private.h headers are primary headers.
+        self.assertEqual(cpp_style._PRIMARY_HEADER,
+                         classify_include('WKWebProcessPlugInNodeHandle.mm',
+                                          'WKWebProcessPlugInNodeHandleInternal.h',
+                                          False, include_state))
+        self.assertEqual(cpp_style._PRIMARY_HEADER,
+                         classify_include('WKWebProcessPlugInNodeHandle.mm',
+                                          'WKWebProcessPlugInNodeHandlePrivate.h',
+                                          False, include_state))
 
     def test_try_drop_common_suffixes(self):
         self.assertEqual('foo/foo', cpp_style._drop_common_suffixes('foo/foo-inl.h'))
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to