| 9 | |
| 10 | |
| 11 | class JavaParser(LanguageParser): |
| 12 | |
| 13 | FILTER_PATHS = ('test', 'tests') |
| 14 | |
| 15 | BLACKLISTED_FUNCTION_NAMES = ['toString', 'hashCode', 'equals', 'finalize', 'notify', 'notifyAll', 'clone'] |
| 16 | |
| 17 | @staticmethod |
| 18 | def get_docstring_node(node): |
| 19 | """ |
| 20 | Get docstring node from it parent node. Expect return list have length==1 |
| 21 | |
| 22 | Args: |
| 23 | node (tree_sitter.Node): parent node (usually function node) to get its docstring |
| 24 | Return: |
| 25 | List: list of docstring nodes |
| 26 | """ |
| 27 | docstring_node = [] |
| 28 | |
| 29 | if node.prev_sibling: |
| 30 | prev_node = node.prev_sibling |
| 31 | if prev_node.type == 'block_comment' or prev_node.type == 'line_comment': |
| 32 | docstring_node.append(prev_node) |
| 33 | |
| 34 | return docstring_node |
| 35 | |
| 36 | @staticmethod |
| 37 | def get_docstring(node, blob=None): |
| 38 | """ |
| 39 | Get docstring description for node |
| 40 | |
| 41 | Args: |
| 42 | node (tree_sitter.Node) |
| 43 | blob (str): original source code which parse the `node` |
| 44 | Returns: |
| 45 | str: docstring |
| 46 | """ |
| 47 | if blob: |
| 48 | logger.info('From version `0.0.6` this function will update argument in the API') |
| 49 | docstring_node = JavaParser.get_docstring_node(node) |
| 50 | |
| 51 | docstring = '' |
| 52 | if docstring_node: |
| 53 | docstring = get_node_text(docstring_node[0]) |
| 54 | return docstring |
| 55 | |
| 56 | @staticmethod |
| 57 | def get_comment_node(function_node): |
| 58 | """ |
| 59 | Return all comment node inside a parent node |
| 60 | Args: |
| 61 | node (tree_sitter.Node) |
| 62 | Return: |
| 63 | List: list of comment nodes |
| 64 | """ |
| 65 | comment_node = get_node_by_kind(function_node, kind=['line_comment']) |
| 66 | return comment_node |
| 67 | |
| 68 | @staticmethod |
nothing calls this directly
no outgoing calls
no test coverage detected