⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 252433 in webkit


Ignore:
Timestamp:
Nov 13, 2019, 2:56:54 PM (7 years ago)
Author:
Megan Gardner
Message:

check-webkit-style: fix false errors for obj-c method calls in range-based for statements using colon syntax
https://bugs.webkit.org/show_bug.cgi?id=204142

Reviewed by Jonathan Bedard.

Allow for the existance of an obj-c method call in a range-based for statement that also uses colons.
Do not allow colons between square brackets to trigger the error.
Also add a test for this specific case.

  • Scripts/webkitpy/style/checkers/cpp.py:

(check_spacing):

  • Scripts/webkitpy/style/checkers/cpp_unittest.py:

(WebKitStyleTest.test_spacing):

Location:
trunk/Tools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r252430 r252433  
     12019-11-13  Megan Gardner  <megan_gardner@apple.com>
     2
     3        check-webkit-style: fix false errors for obj-c method calls in range-based for statements using colon syntax
     4        https://bugs.webkit.org/show_bug.cgi?id=204142
     5
     6        Reviewed by Jonathan Bedard.
     7
     8        Allow for the existance of an obj-c method call in a range-based for statement that also uses colons.
     9        Do not allow colons between square brackets to trigger the error.
     10        Also add a test for this specific case.
     11
     12        * Scripts/webkitpy/style/checkers/cpp.py:
     13        (check_spacing):
     14        * Scripts/webkitpy/style/checkers/cpp_unittest.py:
     15        (WebKitStyleTest.test_spacing):
     16
    1172019-11-13  Aakash Jain  <aakash_jain@apple.com>
    218
  • trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py

    r249906 r252433  
    19791979    # We don't want: "if ( foo)" or "if ( foo   )".
    19801980    # Exception: "for ( ; foo; bar)" and "for (foo; bar; )" are allowed.
     1981    # Exception: "for (foo n in [foo bar:baz])" is allowed because of obj-c method calls
    19811982    matched = search(r'\b(?P<statement>if|for|while|switch)\s*\((?P<remainder>.*)$', line)
    19821983    if matched:
     
    19841985        condition, rest = up_to_unmatched_closing_paren(matched.group('remainder'))
    19851986        if condition is not None:
    1986             if statement == 'for' and search(r'(?:[^ :]:[^:]|[^:]:[^ :])', condition):
    1987                 error(line_number, 'whitespace/colon', 4, 'Missing space around : in range-based for statement')
     1987            if statement == 'for' and search(r'(?:[^ :]:[^:]|[^:]:[^ :])', condition) and not search(r'\[[^\]]+:[^\]]*\]', condition):
     1988                    error(line_number, 'whitespace/colon', 4, 'Missing space around : in range-based for statement')
    19881989            condition_match = search(r'(?P<leading>[ ]*)(?P<separator>.).*[^ ]+(?P<trailing>[ ]*)', condition)
    19891990            if condition_match:
  • trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py

    r249906 r252433  
    43614361
    43624362        self.assert_multi_line_lint(
     4363            '    for (foo *bar in [foo bar:baz])\n'
     4364            '        process(bar);\n',
     4365            '',
     4366            'foo.mm')
     4367
     4368        self.assert_multi_line_lint(
    43634369            '    for (const Vector& vector: vectors)\n'
    43644370            '        process(vector);\n',
Note: See TracChangeset for help on using the changeset viewer.