I’m developing a small python package that uses auto-generated code in way that resembles python’s ctypes package usage.
>>> class Point(Structure):
... _fields_ = [Field("name", str),
... Field("x", (int, long)),
... Field("y", (int, long))]
... p = Point("p1", 10, 20)
... assert p.name.startswith("p") and p.x == 10
I wish to write a plugin that allows the IDE to understand these structures and provide:
* Auto-complete of the generated members (for the class / instances) – i.e. name, x and y
* Auto-complete for the generated-member’s members themselves (by resolving each member’s type) – i.e. startswith for name as a string
* Go-To-Def functionality for those members to their field descriptors.
* Hide the "unresolved attribute references..."
* Constructor’s parameters tool-tip.
I started addressing the first item on my list (successfully using CompletionContributor) and I think that it might cause a slight (unwanted) delay opening the auto-complete session.
I am wondering whether I’m going this the wrong way, and instead of handling each issue alone; I might want to allow PyCharm to recognize these structures while parsing the code (and generating "stub-fields" there) thus allowing the already provided capabilities of the IDE to do their magic. (I know that this doesn’t address the last issue, which will have to be dealt with separately…)
What is the correct way to address this feature?