|
@ -29,19 +29,19 @@ class ASTParser: |
|
|
else: |
|
|
else: |
|
|
return [c for c in cursor.get_children() if c.location.file and c.location.file.name == path] |
|
|
return [c for c in cursor.get_children() if c.location.file and c.location.file.name == path] |
|
|
|
|
|
|
|
|
def _parse(self, cursor, path, follow_includes=False): |
|
|
def _parse(self, cursor, path, follow_includes=False, parent_cursor=None): |
|
|
item = None |
|
|
item = None |
|
|
dont_recurse = False; |
|
|
dont_recurse = False; |
|
|
# dont parse excluded CursorKinds |
|
|
# dont parse excluded CursorKinds |
|
|
excluded_cursortypes = [CursorKind.INTEGER_LITERAL] |
|
|
excluded_cursortypes = [CursorKind.INTEGER_LITERAL] |
|
|
if not cursor.kind in excluded_cursortypes: |
|
|
if not cursor.kind in excluded_cursortypes: |
|
|
item = {"" |
|
|
item = {"" |
|
|
"tokens" : "", |
|
|
"tokens": "", |
|
|
"kind" : "", |
|
|
"kind": "", |
|
|
"name" : "", |
|
|
"name": "", |
|
|
"type" : "", |
|
|
"type": "", |
|
|
"file" : "", |
|
|
"file": "", |
|
|
"is_definition" : "", |
|
|
"is_definition": "", |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
# generic info for all CursorKinds |
|
|
# generic info for all CursorKinds |
|
@ -99,6 +99,11 @@ class ASTParser: |
|
|
if cursor.kind == CursorKind.TYPE_REF: |
|
|
if cursor.kind == CursorKind.TYPE_REF: |
|
|
item["utypekind"] = cursor.type.kind.spelling |
|
|
item["utypekind"] = cursor.type.kind.spelling |
|
|
|
|
|
|
|
|
|
|
|
if parent_cursor: |
|
|
|
|
|
if( not cursor.kind == CursorKind.TYPE_REF |
|
|
|
|
|
and parent_cursor.kind == CursorKind.FIELD_DECL): |
|
|
|
|
|
return None |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if not dont_recurse: |
|
|
if not dont_recurse: |
|
|
# get direct children |
|
|
# get direct children |
|
@ -106,7 +111,7 @@ class ASTParser: |
|
|
if len(child_cursors) > 0: |
|
|
if len(child_cursors) > 0: |
|
|
child_arr = [] |
|
|
child_arr = [] |
|
|
for child_cursor in child_cursors: |
|
|
for child_cursor in child_cursors: |
|
|
child_result = self._parse(child_cursor, path, follow_includes=follow_includes) |
|
|
child_result = self._parse(child_cursor, path, follow_includes=follow_includes, parent_cursor=cursor) |
|
|
if child_result: |
|
|
if child_result: |
|
|
child_arr.append(child_result) |
|
|
child_arr.append(child_result) |
|
|
|
|
|
|
|
|