Skip to content

Commit

Permalink
Merge pull request #29 from adambullmer/class-definition-content
Browse files Browse the repository at this point in the history
Fixed bug where parser wasn't properly stopping class definition content
  • Loading branch information
adambullmer authored Jan 24, 2018
2 parents f3febda + 5e62506 commit 9a9e6ad
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions parsers/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,10 @@ def read_above(cls, view, position):
if not current_indentation == indentation_level - 1:
break

# Keeping it simple, will not parse multiline decorators
if docstring_type is not None and not re.match(r'^\s*(\@)', current_line_string):
break

# Set to module, class, or function
if docstring_type is None:
if re.match(r'^\s*(class )', current_line_string):
Expand Down Expand Up @@ -328,23 +332,24 @@ def get_definition_contents(cls, view, position):
for current_line in read_next_line(view, position):
# Not an empty line
current_line_string = view.substr(current_line).rstrip()
if len(current_line_string) is 0:
if len(current_line_string) == 0:
continue

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

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

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

# If this is a module or a class, we only care about the lines on
# the same indentation level for contextual reasons
if not docstring_type == 'function' and not current_indentation == indentation_level:
continue

definition += current_line_string + '\n'

return definition
Expand Down

0 comments on commit 9a9e6ad

Please sign in to comment.