Skip to content

Commit

Permalink
Correctly use semantic parent in qid
Browse files Browse the repository at this point in the history
Fixes #53
  • Loading branch information
Jesse van den Kieboom committed Jul 10, 2014
1 parent 23b4e6b commit 212d63a
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 14 deletions.
17 changes: 6 additions & 11 deletions cldoc/nodes/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,21 +97,16 @@ def __init__(self, cursor, comment):

self._arguments.append(Argument(self, child))

@property
def qid(self):
if not isinstance(self.semantic_parent, Namespace):
return self.name
else:
return Node.qid.fget(self)

@property
def semantic_parent(self):
from namespace import Namespace

if isinstance(self.parent, Namespace):
return self.parent
else:
return None
parent = self.parent

while not parent is None and not isinstance(parent, Namespace):
parent = parent.parent

return parent

@property
def resolve_nodes(self):
Expand Down
2 changes: 1 addition & 1 deletion cldoc/nodes/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def qid(self):
if not parent:
return meid
else:
q = self.parent.qid
q = parent.qid

if not q:
return meid
Expand Down
9 changes: 9 additions & 0 deletions tests/input/operator.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace N
{
struct A
{
bool operator<(const A &other);
};

bool operator==(const A &a, const A &b);
}
4 changes: 2 additions & 2 deletions tests/output/namespace-A.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
<brief>Enum E.</brief>
<doc>Enum E in namespace A.
</doc>
<enumvalue id="A::E::E_1" name="E_1" value="0">
<enumvalue id="A::E_1" name="E_1" value="0">
<brief>E_1 value.</brief>
</enumvalue>
<enumvalue id="A::E::E_2" name="E_2" value="1">
<enumvalue id="A::E_2" name="E_2" value="1">
<brief>E_2 value.</brief>
</enumvalue>
</enum>
Expand Down
4 changes: 4 additions & 0 deletions tests/output/operator-N.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version='1.0' encoding='utf-8'?>
<namespace id="N" name="N" xmlns="http://jessevdk.github.com/cldoc/1.0">
<struct name="A" ref="N::A#N::A" />
</namespace>
22 changes: 22 additions & 0 deletions tests/output/operator-N::A.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version='1.0' encoding='utf-8'?>
<struct id="N::A" interface="true" name="A" xmlns="http://jessevdk.github.com/cldoc/1.0">
<method abstract="yes" id="N::A::operator&lt;" name="operator&lt;">
<return>
<type builtin="yes" name="bool" />
</return>
<argument id="N::A::operator&lt;::other" name="other">
<type name="A" qualifier=" const &amp;" ref="N::A#N::A" />
</argument>
</method>
<function id="N::operator==" name="operator==">
<return>
<type builtin="yes" name="bool" />
</return>
<argument id="N::operator==::a" name="a">
<type name="A" qualifier=" const &amp;" ref="N::A#N::A" />
</argument>
<argument id="N::operator==::b" name="b">
<type name="A" qualifier=" const &amp;" ref="N::A#N::A" />
</argument>
</function>
</struct>
6 changes: 6 additions & 0 deletions tests/output/operator-index.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version='1.0' encoding='utf-8'?>
<index xmlns="http://jessevdk.github.com/cldoc/1.0">
<namespace name="N" ref="N#N">
<struct name="A" ref="N::A#N::A" />
</namespace>
</index>

0 comments on commit 212d63a

Please sign in to comment.