Skip to content

Commit 9a9e6ad

Browse files
authored
Merge pull request #29 from adambullmer/class-definition-content
Fixed bug where parser wasn't properly stopping class definition content
2 parents f3febda + 5e62506 commit 9a9e6ad

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

parsers/parser.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,10 @@ def read_above(cls, view, position):
285285
if not current_indentation == indentation_level - 1:
286286
break
287287

288+
# Keeping it simple, will not parse multiline decorators
289+
if docstring_type is not None and not re.match(r'^\s*(\@)', current_line_string):
290+
break
291+
288292
# Set to module, class, or function
289293
if docstring_type is None:
290294
if re.match(r'^\s*(class )', current_line_string):
@@ -328,23 +332,24 @@ def get_definition_contents(cls, view, position):
328332
for current_line in read_next_line(view, position):
329333
# Not an empty line
330334
current_line_string = view.substr(current_line).rstrip()
331-
if len(current_line_string) is 0:
335+
if len(current_line_string) == 0:
332336
continue
333337

334338
# Remove comments
335339
if re.match(r'^\s*(\#)', current_line_string):
336340
continue
337341

338-
# If this is a module or a class, we only care about the lines on
339-
# the same indentation level for contextual reasons
340342
current_indentation = view.indentation_level(current_line.end())
341-
if not docstring_type == 'function' and not current_indentation == indentation_level:
342-
continue
343343

344-
# Still within the same indentation level
344+
# Exit if this has de-indented below the current level
345345
if current_indentation < indentation_level:
346346
break
347347

348+
# If this is a module or a class, we only care about the lines on
349+
# the same indentation level for contextual reasons
350+
if not docstring_type == 'function' and not current_indentation == indentation_level:
351+
continue
352+
348353
definition += current_line_string + '\n'
349354

350355
return definition

0 commit comments

Comments
 (0)