Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: m-labs/pythonparser
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: aee2f09727f4
Choose a base ref
...
head repository: m-labs/pythonparser
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: a894981f4c9c
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Aug 27, 2015

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    80f7f89 View commit details
  2. Copy the full SHA
    a894981 View commit details
Showing with 14 additions and 6 deletions.
  1. +1 −1 pythonparser/diagnostic.py
  2. +13 −5 pythonparser/source.py
2 changes: 1 addition & 1 deletion pythonparser/diagnostic.py
Original file line number Diff line number Diff line change
@@ -95,7 +95,7 @@ def render(self, only_line=False, colored=False):
if self.level != "note":
expanded_location = self.location.expanded_from
while expanded_location is not None:
notes.append(Diagnostic("note",
notes.insert(0, Diagnostic("note",
"expanded from here", {},
self.location.expanded_from))
expanded_location = expanded_location.expanded_from
18 changes: 13 additions & 5 deletions pythonparser/source.py
Original file line number Diff line number Diff line change
@@ -99,13 +99,15 @@ def begin(self):
"""
Returns a zero-length range located just before the beginning of this range.
"""
return Range(self.source_buffer, self.begin_pos, self.begin_pos)
return Range(self.source_buffer, self.begin_pos, self.begin_pos,
expanded_from=self.expanded_from)

def end(self):
"""
Returns a zero-length range located just after the end of this range.
"""
return Range(self.source_buffer, self.end_pos, self.end_pos)
return Range(self.source_buffer, self.end_pos, self.end_pos,
expanded_from=self.expanded_from)

def size(self):
"""
@@ -142,9 +144,14 @@ def join(self, other):
"""
if self.source_buffer != other.source_buffer:
raise ValueError
if self.expanded_from == other.expanded_from:
expanded_from = self.expanded_from
else:
expanded_from = None
return Range(self.source_buffer,
min(self.begin_pos, other.begin_pos),
max(self.end_pos, other.end_pos))
max(self.end_pos, other.end_pos),
expanded_from=expanded_from)

def source(self):
"""
@@ -184,7 +191,8 @@ def __eq__(self, other):
return (type(self) == type(other) and
self.source_buffer == other.source_buffer and
self.begin_pos == other.begin_pos and
self.end_pos == other.end_pos)
self.end_pos == other.end_pos and
self.expanded_from == other.expanded_from)

def __ne__(self, other):
"""
@@ -193,7 +201,7 @@ def __ne__(self, other):
return not (self == other)

def __hash__(self):
return hash((self.source_buffer, self.begin_pos, self.end_pos))
return hash((self.source_buffer, self.begin_pos, self.end_pos, self.expanded_from))

class Comment:
"""