Changeset 222937 in webkit


Ignore:
Timestamp:
Oct 5, 2017, 3:41:15 PM (8 years ago)
Author:
Megan Gardner
Message:

check-webkit-style erroneously requires a space between the carrot and brace in obj-c blocks.
https://bugs.webkit.org/show_bug.cgi?id=177897

Reviewed by Dan Bernstein and Jonathan Bedard.

Remove the check for a space between and {,
as this is valid and expected Obj-C. Now check to make sure there is
no space at all between
and {, and also that there is a space between
the end of an argument list and the {.

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

(regex_for_lambdas_and_blocks):

Location:
trunk/Tools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r222918 r222937  
     12017-10-04  Megan Gardner  <megan_gardner@apple.com>
     2
     3        check-webkit-style erroneously requires a space between the carrot and brace in obj-c blocks.
     4        https://bugs.webkit.org/show_bug.cgi?id=177897
     5
     6        Reviewed by Dan Bernstein and Jonathan Bedard.
     7
     8        Remove the check for a space between ^ and {,
     9        as this is valid and expected Obj-C. Now check to make sure there is
     10        no space at all between ^ and {, and also that there is a space between
     11        the end of an argument list and the {.
     12
     13        * Scripts/webkitpy/style/checkers/cpp.py:
     14        (regex_for_lambdas_and_blocks):
     15
    1162017-10-05  Carlos Garcia Campos  <cgarcia@igalia.com>
    217
  • trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py

    r220896 r222937  
    12421242def regex_for_lambdas_and_blocks(line, line_number, file_state, error):
    12431243    cpp_result = search(r'\s\[.*?\]\s', line)
    1244     objc_result = search(r'(\s\^\s?\(.*?\)\s|\^\s?\{|:\^\s?\(.*?\)\s\{)', line)
     1244    objc_result = search(r'(\s\^\s?\(.*?\)\s?|\^\s*\{|:\^\s?\(.*?\)\s\{)', line)
    12451245    if cpp_result:
    12461246        group = cpp_result.group()
     
    12491249        if search(r'(\[\s|\s\]|\s,)', group):
    12501250            targ_error = [line_number, 'whitespace/brackets', 4,
    1251               'Extra space in capture list.']
     1251              'Extra space in capture list.',line]
    12521252
    12531253        if targ_error and regex_for_lambdas_and_blocks.__last_error != targ_error:
     
    12621262        if search(r'(\(\s|\s\)|\s,)', group):
    12631263            targ_error = [line_number, 'whitespace/brackets', 4,
    1264               'Extra space in block arguments.']
    1265         if search(r'\^\{', group):
     1264              'Extra space in block arguments.',line]
     1265        if search(r'\^\s+\{', group):
    12661266            targ_error = [line_number, 'whitespace/brackets', 4,
    1267               'No space between ^ and block definition.']
     1267              'Extra space between ^ and block definition.',line]
    12681268        if search(r'\^\s\(', group):
    12691269            targ_error = [line_number, 'whitespace/brackets', 4,
    1270               'Extra space between ^ and block arguments.']
     1270              'Extra space between ^ and block arguments.',line]
    12711271
    12721272        if targ_error and regex_for_lambdas_and_blocks.__last_error != targ_error:
  • trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py

    r220896 r222937  
    19431943        self.assert_lint('        ^(var,var_ref) {', 'Missing space after ,  [whitespace/comma] [3]', 'foo.m')
    19441944        self.assert_lint('        ^(var, var_ref) {', 'Place brace on its own line for function definitions.  [whitespace/braces] [4]', 'foo.cpp')
    1945         self.assert_lint('        ^ {', '', 'foo.m')
    1946         self.assert_lint('        ^{', 'No space between ^ and block definition.  [whitespace/brackets] [4]', 'foo.m')
     1945        self.assert_lint('        ^{', '', 'foo.m')
     1946        self.assert_lint('        ^ {', 'Extra space between ^ and block definition.  [whitespace/brackets] [4]', 'foo.m')
     1947        self.assert_lint('        ^   {', 'Extra space between ^ and block definition.  [whitespace/brackets] [4]', 'foo.m')
    19471948        self.assert_lint('        ^ (arg1, arg2) {', 'Extra space between ^ and block arguments.  [whitespace/brackets] [4]', 'foo.m')
     1949        self.assert_lint('        ^(arg1, arg2){', 'Missing space before {  [whitespace/braces] [5]', 'foo.m')
    19481950
    19491951    def test_objective_c_block_as_argument(self):
    19501952        self.assert_lint('        withLambda:^(var, var_ref) {', '', 'foo.mm')
    1951         self.assert_lint('        withLambda:^ {', '', 'foo.m')
    1952         self.assert_lint('        withLambda:^{', 'No space between ^ and block definition.  [whitespace/brackets] [4]', 'foo.m')
     1953        self.assert_lint('        withLambda:^{', '', 'foo.m')
     1954        self.assert_lint('        withLambda:^ {', 'Extra space between ^ and block definition.  [whitespace/brackets] [4]', 'foo.m')
    19531955
    19541956    def test_spacing_around_else(self):
Note: See TracChangeset for help on using the changeset viewer.