| @@ 3282-3309 (lines=28) @@ | ||
| 3279 | 'Should have a space between // and comment') |
|
| 3280 | ||
| 3281 | ||
| 3282 | def CheckAccess(filename, clean_lines, linenum, nesting_state, error): |
|
| 3283 | """Checks for improper use of DISALLOW* macros. |
|
| 3284 | ||
| 3285 | Args: |
|
| 3286 | filename: The name of the current file. |
|
| 3287 | clean_lines: A CleansedLines instance containing the file. |
|
| 3288 | linenum: The number of the line to check. |
|
| 3289 | nesting_state: A NestingState instance which maintains information about |
|
| 3290 | the current stack of nested blocks being parsed. |
|
| 3291 | error: The function to call with any errors found. |
|
| 3292 | """ |
|
| 3293 | line = clean_lines.elided[linenum] # get rid of comments and strings |
|
| 3294 | ||
| 3295 | matched = Match((r'\s*(DISALLOW_COPY_AND_ASSIGN|' |
|
| 3296 | r'DISALLOW_IMPLICIT_CONSTRUCTORS)'), line) |
|
| 3297 | if not matched: |
|
| 3298 | return |
|
| 3299 | if nesting_state.stack and isinstance(nesting_state.stack[-1], _ClassInfo): |
|
| 3300 | if nesting_state.stack[-1].access != 'private': |
|
| 3301 | error(filename, linenum, 'readability/constructors', 3, |
|
| 3302 | '%s must be in the private: section' % matched.group(1)) |
|
| 3303 | ||
| 3304 | else: |
|
| 3305 | # Found DISALLOW* macro outside a class declaration, or perhaps it |
|
| 3306 | # was used inside a function when it should have been part of the |
|
| 3307 | # class declaration. We could issue a warning here, but it |
|
| 3308 | # probably resulted in a compiler error already. |
|
| 3309 | pass |
|
| 3310 | ||
| 3311 | ||
| 3312 | def CheckSpacing(filename, clean_lines, linenum, nesting_state, error): |
|
| @@ 3282-3309 (lines=28) @@ | ||
| 3279 | 'Should have a space between // and comment') |
|
| 3280 | ||
| 3281 | ||
| 3282 | def CheckAccess(filename, clean_lines, linenum, nesting_state, error): |
|
| 3283 | """Checks for improper use of DISALLOW* macros. |
|
| 3284 | ||
| 3285 | Args: |
|
| 3286 | filename: The name of the current file. |
|
| 3287 | clean_lines: A CleansedLines instance containing the file. |
|
| 3288 | linenum: The number of the line to check. |
|
| 3289 | nesting_state: A NestingState instance which maintains information about |
|
| 3290 | the current stack of nested blocks being parsed. |
|
| 3291 | error: The function to call with any errors found. |
|
| 3292 | """ |
|
| 3293 | line = clean_lines.elided[linenum] # get rid of comments and strings |
|
| 3294 | ||
| 3295 | matched = Match((r'\s*(DISALLOW_COPY_AND_ASSIGN|' |
|
| 3296 | r'DISALLOW_IMPLICIT_CONSTRUCTORS)'), line) |
|
| 3297 | if not matched: |
|
| 3298 | return |
|
| 3299 | if nesting_state.stack and isinstance(nesting_state.stack[-1], _ClassInfo): |
|
| 3300 | if nesting_state.stack[-1].access != 'private': |
|
| 3301 | error(filename, linenum, 'readability/constructors', 3, |
|
| 3302 | '%s must be in the private: section' % matched.group(1)) |
|
| 3303 | ||
| 3304 | else: |
|
| 3305 | # Found DISALLOW* macro outside a class declaration, or perhaps it |
|
| 3306 | # was used inside a function when it should have been part of the |
|
| 3307 | # class declaration. We could issue a warning here, but it |
|
| 3308 | # probably resulted in a compiler error already. |
|
| 3309 | pass |
|
| 3310 | ||
| 3311 | ||
| 3312 | def CheckSpacing(filename, clean_lines, linenum, nesting_state, error): |
|