[QScintilla] AutoCompletion for object based languages...is it possible?

Phil Thompson phil at riverbankcomputing.com
Mon Oct 27 17:45:56 GMT 2008


On Mon, 27 Oct 2008 12:40:46 -0400, "Eric Fontana"
<eric at carbondesignsystems.com> wrote:
> Well; I've been experimenting with the AutoComplete (QsciAPIs) api and
> got
> 
> it working, however its not that useful without the next step;
> 
>  
> 
> I have an embedded QtScript object in my app, I registered a global
> 
> property "Project" to access it from the Script.
> 
>  
> 
> When you type "Project" (dot) "Project." the autocomplete pops up
> 
> and I can select a method name ,that works great.
> 
>  
> 
> Howerver, if a method returns an object, lets say for example:
> 
>  
> 
> var x = Project.Color;
> 
>  
> 
> If color was a QObject which had a name property I can type
> 
> 
> 
> x.name
> 
>  
> 
> However, since "x" isn't known to the autocomplete api, it's not known.
> 
>  
> 
> Is there a way to know when "x" is defined "var x = ..." easily?
> 
>  
> 
> I also noticed that the load() method doesn't support a return type
> 
> from the loader file.
> 
>  
> 
> Has anyone done this before?

QsciAPIs requires the user to provide enough information to know what to
do. If you entered "x.set" then the autocompletion list will contain all
API words starting with "set".

If two types have a method called "set" then both will appear in the list
and the type will also be shown. If the user selects, say, the "set
(Project.Color)" entry then it infers that the type of "x" is Project.Color
and uses that to restrict what is shown in later autocompletion and call
tip lists. This information isn't cached, so if you move to a different
line and back again then it forgets the type.

The alternative is to provide your own QsciAbstractAPIs subclass that
extracts the API information using whatever means is appropriate to the
language being edited. For example with a dynamic language you might be
able to create the "x" object and introspect it. With a static language you
might be able to parse it and get the type of "x" from the parse tree.

Phil


More information about the QScintilla mailing list