[Feature request] Add Python support for global search (Ctrl+.)
Currently, the global search feature (Ctrl+.) doesn't work with Python codebases (function or class names are not found). After discussing with @chergert on the mailing list, the root cause is because there are currently no Python plugins that implement the IdeCodeIndexer
interface.
I came up with a python_symbol_parser.py that runs through a Python codebase and returns a list of symbols (classes and definitions) found in every python files. This could be use as the first step to write a Python implementation of the IdeCodeIndexer
interface.
Note: the script itself is compatible with both Python 2.7 and Python 3.x, but since it's using the Abstract Tree Syntax Python module (ast
), it will need to be called using the same Python interpreter as the code it's parsing.
Example:
$ python3 python_symbol_parser.py ~/dev/requests
[{'begin_line': 14,
'begin_line_offset': 0,
'file': '/home/pierre/dev/requests/setup.py',
'kind': 'class',
'name': 'PyTest'},
{'begin_line': 17,
'begin_line_offset': 4,
'file': '/home/pierre/dev/requests/setup.py',
'kind': 'function',
'name': 'initialize_options'},
(...)
{'begin_line': 115,
'begin_line_offset': 4,
'file': '/home/pierre/dev/requests/tests/testserver/server.py',
'kind': 'function',
'name': '__exit__'},
{'begin_line': 7,
'begin_line_offset': 0,
'file': '/home/pierre/dev/requests/docs/_themes/flask_theme_support.py',
'kind': 'class',
'name': 'FlaskyStyle'}]