Title: [219577] trunk/Tools
Revision
219577
Author
commit-qu...@webkit.org
Date
2017-07-17 15:40:18 -0700 (Mon, 17 Jul 2017)

Log Message

Update style checker to deal with "final"
https://bugs.webkit.org/show_bug.cgi?id=174528

Patch by Yoshiaki Jitsukawa <yoshiaki.jitsuk...@sony.com> on 2017-07-17
Reviewed by Alex Christensen.

check-webkit-style shouldn't complain about an open brace to start a
line after a function definition with "final" or "const final".

* Scripts/webkitpy/style/checkers/cpp.py:
(check_braces):
* Scripts/webkitpy/style/checkers/cpp_unittest.py:
(CppStyleTest.test_brace_at_begin_of_line):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (219576 => 219577)


--- trunk/Tools/ChangeLog	2017-07-17 21:54:34 UTC (rev 219576)
+++ trunk/Tools/ChangeLog	2017-07-17 22:40:18 UTC (rev 219577)
@@ -1,3 +1,18 @@
+2017-07-17  Yoshiaki Jitsukawa  <yoshiaki.jitsuk...@sony.com>
+
+        Update style checker to deal with "final"
+        https://bugs.webkit.org/show_bug.cgi?id=174528
+
+        Reviewed by Alex Christensen.
+        
+        check-webkit-style shouldn't complain about an open brace to start a
+        line after a function definition with "final" or "const final".
+
+        * Scripts/webkitpy/style/checkers/cpp.py:
+        (check_braces):
+        * Scripts/webkitpy/style/checkers/cpp_unittest.py:
+        (CppStyleTest.test_brace_at_begin_of_line):
+
 2017-07-17  Alex Christensen  <achristen...@webkit.org>
 
         Modernize content extension code

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


--- trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py	2017-07-17 21:54:34 UTC (rev 219576)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py	2017-07-17 22:40:18 UTC (rev 219577)
@@ -2430,7 +2430,7 @@
         # We also allow '#' for #endif and '=' for array initialization,
         # and '- (' and '+ (' for Objective-C methods.
         previous_line = get_previous_non_blank_line(clean_lines, line_number)[0]
-        if ((not search(r'[;:}{)=]\s*$|\)\s*((const|override|const override)\s*)?(->\s*\S+)?\s*$', previous_line)
+        if ((not search(r'[;:}{)=]\s*$|\)\s*((const|override|const override|final|const final)\s*)?(->\s*\S+)?\s*$', previous_line)
              or search(r'\b(if|for|while|switch|else|NS_ENUM)\b', previous_line)
              or regex_for_lambdas_and_blocks(previous_line, line_number, file_state, error))
             and previous_line.find('#') < 0
@@ -2438,7 +2438,7 @@
             and previous_line.find('+ (') != 0):
             error(line_number, 'whitespace/braces', 4,
                   'This { should be at the end of the previous line')
-    elif (search(r'\)\s*(((const|override)\s*)*\s*)?{\s*$', line)
+    elif (search(r'\)\s*(((const|override|final)\s*)*\s*)?{\s*$', line)
           and line.count('(') == line.count(')')
           and not search(r'(\s*(if|for|while|switch|NS_ENUM|@synchronized)|} @catch)\b', line)
           and not regex_for_lambdas_and_blocks(line, line_number, file_state, error)

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


--- trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py	2017-07-17 21:54:34 UTC (rev 219576)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py	2017-07-17 22:40:18 UTC (rev 219577)
@@ -1792,6 +1792,12 @@
             'int foo() override {',
             'Place brace on its own line for function definitions.  [whitespace/braces] [4]')
         self.assert_multi_line_lint(
+            'int foo() const final {',
+            'Place brace on its own line for function definitions.  [whitespace/braces] [4]')
+        self.assert_multi_line_lint(
+            'int foo() final {',
+            'Place brace on its own line for function definitions.  [whitespace/braces] [4]')
+        self.assert_multi_line_lint(
             'int foo() const\n'
             '{\n'
             '}\n',
@@ -1802,6 +1808,11 @@
             '}\n',
             '')
         self.assert_multi_line_lint(
+            'int foo() final\n'
+            '{\n'
+            '}\n',
+            '')
+        self.assert_multi_line_lint(
             '[]() {\n'
             '}\n',
             '')
@@ -1822,6 +1833,11 @@
             '}\n',
             '')
         self.assert_multi_line_lint(
+            'int foo() const final\n'
+            '{\n'
+            '}\n',
+            '')
+        self.assert_multi_line_lint(
             '    @try {\n'
             '    } @catch (NSException *exception) {\n'
             '    }\n',
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to