[QScintilla] Object type-sensitive Scintilla prompts
Phil Thompson
phil at riverbankcomputing.com
Sun Mar 25 10:49:25 BST 2012
On Sat, 24 Mar 2012 16:22:01 -0500, Jack Cosgrove <jackcosgrove at gmail.com>
wrote:
> Just a quick question:
>
> Since Python is not strongly typed it isn't possible to filter the
> methods available in a Scintilla prompt based upon the object type,
> right? So upon typing the '.' operator for an object of type MyClass,
> you cannot immediately be presented with MyMethod1(), MyMethod2() simply
> because those are methods of class MyClass? Even if you were to keep
> track of variable names and types, objects of different types can have
> the same name at different times in a program.
Python is strongly typed, I think you mean that it is not statically
typed.
A lexer is just that, it's not a parser so QScintilla doesn't know
anything about the type of objects. A dynamically typed language like
Python means that a parser wouldn't help either in a lot of cases.
What QScintilla does do is remember the type of the current object if you
tell it (by choosing a particular entry from the auto-completion list) and
will use that to limit the choices in later lists. As soon as you move the
cursor away from the current object then it forgets everything that it has
learnt.
For example if your API list contains "Type1.foo.bar", "Type1.foo.bat" and
"Type2.foo.baz" and you type "self.foo." then you will get a list with all
three entries. If you pick "Type1.foo.bar" then QScintilla knows that self
has type "Type1". If you then continue so that you now have "self.foo.b"
then QScintilla will only offer the first two entries. (Note that I'm
guessing a bit about exactly what will be shown - but the principle is
correct.)
Phil
More information about the QScintilla
mailing list