mirror of
https://github.com/neovim/neovim.git
synced 2024-12-19 18:55:14 -07:00
remove CheckSectionSpacing
irrelevant
This commit is contained in:
parent
cb5f1fa51d
commit
ef23bbe6ee
55
clint.py
55
clint.py
@ -2898,61 +2898,6 @@ def CheckSpacing(filename, clean_lines, linenum, nesting_state, error):
|
||||
'Missing space around colon in range-based for loop')
|
||||
|
||||
|
||||
def CheckSectionSpacing(filename, clean_lines, class_info, linenum, error):
|
||||
"""Checks for additional blank line issues related to sections.
|
||||
|
||||
Currently the only thing checked here is blank line before protected/private.
|
||||
|
||||
Args:
|
||||
filename: The name of the current file.
|
||||
clean_lines: A CleansedLines instance containing the file.
|
||||
class_info: A _ClassInfo objects.
|
||||
linenum: The number of the line to check.
|
||||
error: The function to call with any errors found.
|
||||
"""
|
||||
# Skip checks if the class is small, where small means 25 lines or less.
|
||||
# 25 lines seems like a good cutoff since that's the usual height of
|
||||
# terminals, and any class that can't fit in one screen can't really
|
||||
# be considered "small".
|
||||
#
|
||||
# Also skip checks if we are on the first line. This accounts for
|
||||
# classes that look like
|
||||
# class Foo { public: ... };
|
||||
#
|
||||
# If we didn't find the end of the class, last_line would be zero,
|
||||
# and the check will be skipped by the first condition.
|
||||
if (class_info.last_line - class_info.starting_linenum <= 24 or
|
||||
linenum <= class_info.starting_linenum):
|
||||
return
|
||||
|
||||
matched = Match(r'\s*(public|protected|private):', clean_lines.lines[linenum])
|
||||
if matched:
|
||||
# Issue warning if the line before public/protected/private was
|
||||
# not a blank line, but don't do this if the previous line contains
|
||||
# "class" or "struct". This can happen two ways:
|
||||
# - We are at the beginning of the class.
|
||||
# - We are forward-declaring an inner class that is semantically
|
||||
# private, but needed to be public for implementation reasons.
|
||||
# Also ignores cases where the previous line ends with a backslash as can be
|
||||
# common when defining classes in C macros.
|
||||
prev_line = clean_lines.lines[linenum - 1]
|
||||
if (not IsBlankLine(prev_line) and
|
||||
not Search(r'\b(class|struct)\b', prev_line) and
|
||||
not Search(r'\\$', prev_line)):
|
||||
# Try a bit harder to find the beginning of the class. This is to
|
||||
# account for multi-line base-specifier lists, e.g.:
|
||||
# class Derived
|
||||
# : public Base {
|
||||
end_class_head = class_info.starting_linenum
|
||||
for i in range(class_info.starting_linenum, linenum):
|
||||
if Search(r'\{\s*$', clean_lines.lines[i]):
|
||||
end_class_head = i
|
||||
break
|
||||
if end_class_head < linenum - 1:
|
||||
error(filename, linenum, 'whitespace/blank_line', 3,
|
||||
'"%s:" should be preceded by a blank line' % matched.group(1))
|
||||
|
||||
|
||||
def GetPreviousNonBlankLine(clean_lines, linenum):
|
||||
"""Return the most recent non-blank line and its line number.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user