[Qt-creator] Scripting plugin

Nicolas Arnaud-Cormos nicolas.arnaud-cormos at kdab.com
Fri Mar 2 01:05:47 CET 2012


On Wednesday 29 February 2012 23:06:15 you wrote:
> # psudo code (in python, sure js can do similar) - find unused defines.
> ^ import qtcreator
> ^ prj = qtcreator.projects.active
> ^ for file in prj.files:
> ^     if file.type in {'C', 'C++'}:
> ^         for dec in file.defines:
> ^             if not dec.id.startswith("_"):
> ^                 if len(dec.find_users()) == 0:
> ^                     print("%s: %s:%d - has no users" % (dec.id,
> file.filepath, dec.lineno))

I totally expect this kind of things to be possible.
I want to give access to the project manager, projects... the file.defines 
part will need a bit more time, I definitely would like to give access to the 
AST, I just don't know how (well, from a C++ point of view, I can find, it's 
jsut the interface).

> Other things that should be possible with a scripting API.
> 
> * find out if a function always takes the same constant value for an
> argument. 
> * find out if functions return values which are never used.
> * check if there are functions that could be made static (defined but
> not used in any other files).

Giving access to the "Find Usage" method should give you all that.

> Will this kind of thing be possible?

I don't see why not. Definitely something I want to do.

On another subject, I wonder if javascript is the right choice, maybe QML 
would be nice, for 2 reasons:
 * support of QtScript in Qt 5.0
 * you can still do some javascripts
 * it opens the door to awesomeness
At the same time, those scripts will be by nature imperative... I have this 
idea in my mind for some time now, I need to experiment. I probably need an 
example to convince myself.

Nicolas

-- 
Nicolas Arnaud-Cormos | nicolas.arnaud-cormos at kdab.com | Senior Software 
Engineer
KDAB (France) S.A.S., a KDAB Group company
Tel. France +33 (0)4 90 84 08 53, Sweden (HQ) +46-563-540090
KDAB - Qt Experts - Platform-independent software solutions



More information about the Qt-creator mailing list