We are currently developing a Python script editor with IntelliSense functionality for a WPF application.
We would like the editor to support code completion equivalent to the `Python extension for Visual Studio Code` as much as possible.
Note that in this application, the Python standard module paths are not set in the SearchPaths of the Python project to allow operation regardless of whether Python is installed.
Question 1
Currently, when defining a Python script like the following, we are unable to display members defined by the type of `t` in the completion list for the loop variable ('t').
Is there any way to display members defined by the type of `t` in the completion list?
```py
# Defining a Class
class MyType:
def __init__(self, a):
self.propA = a
def set_propA(self, v):
self.propA = v
def get_propA(self):
return self.propA
# A list of instances of the defined class
myTypeList = [MyType(1), MyType(2), MyType(3)]
#Iterating over the elements of a list
for t in myTypeList:
# In VSCode (Python extension), when you type "t." here,
# the members of the MyType class appear in the completion list.
# However, in SyntaxEditor, the members of the MyType class are not displayed.
print(t.propA)
```
Question 2
Similar to Question 1, when defining a Python script like the following, we are unable to display members defined by the type of `t` in the completion list for the loop variable ('t').
Is it possible to display members defined by the element type in the completion list for loop variables even for custom collection types?
```py
from typing import Iterator
# Defining a Class
class MyType:
def __init__(self, a):
self.propA = a
def set_propA(self, v):
self.propA = v
def get_propA(self):
return self.propA
# Define a collection type of MyType
class MyTypeCollection:
def GetItem(self, index: int) -> MyType:
pass
def __iter__(self) -> Iterator[MyType]:
pass
# Create a collection
my_collection = MyTypeCollection()
#Iterating over the elements of a collection
for t in my_collection:
# In VSCode (Python extension), when you type "t" here,
# the members of the MyType class appear in the completion list.
# However, in SyntaxEditor, the members of the MyType class are not displayed.
print(t.propA)
```
Question 3
When defining classes with an inheritance relationship in a Python script like the following, we are unable to display parent class members in the completion list.
Is there any way to display parent class members in the completion list for elements of subclass types?
```py
# Define a base class
class BaseType:
propA = "value"
def execute(self):
pass
# Define a subclass
class SubType(BaseType):
propB = "value"
def can_execute(self):
return True
# Create an instance of a subclass
t = SubType()
# In VSCode (Python extension), if you type "t" here,
# members of the BaseType class will also appear in the completion list.
# However, in SyntaxEditor, members of the BaseType class are not displayed
# (members of the SubType class are displayed).
t.execute()
```
Thanks in advance!