Code Insight
nielsie95
2010-02-27 15:29:25
Hey,
Today I worked on code completion again; I added include caching. There are a few downsides: a file will be cached for the entire time the program is running, this means that unused includes will also stay cached (caching full SRL takes about 4 mb, so it's no biggy I think). If a file is changed after it's cached it will use the cached version. The only thing I can think of is checking at an interval to see if there's an updated file available? On the other hand, caching has had a good impact on the speed: parsing the whole SRL include takes about 250ms. Every other parse takes between 0 and 15 ms (big scripts may take 30ms?), so that's nice.
I believe everything still works and I'm pretty happy with it. I don't know if I posted this somewhere, but here it goes:
It supports delphi/lazarus/scar/simba files. Pretty much everything is parsed: defines, functions, variables, types, comments and statements. The base of the code insight is also done, which means that it can find the place where a variable or function is stored (supports classes/records, with statements and forwarded functions). Params should work too for functions (and variables!).
The next thing is to show all the information above. I don't think Lazarus has (easy) components for completion in SynEdit, so I'll probably whip something up myself.
mastaraymond
2010-02-27 17:17:56
Now we're talkin'! :)
And no it doesn't has any 'easy' components, however you can just rip off the code completion Lazarus uses.. That's what I did for Cogat atleast.
Gu3st...
2010-02-27 18:24:37
*sigh* another big thingy I don't understand what does :(
nielsie95
2010-02-27 20:26:51

Updated the attachment in the first post.
mastaraymond
2010-02-27 20:38:45
From: nielsie95

Updated the attachment in the first post.
That looks fricking awesome!!
Gu3st...
2010-02-28 03:03:41
Wow that is awesome! :D
Good job :)
Widget
2010-02-28 04:39:59
After taking a minute to figure out that picture, I must say I'm very impressed :D
Only thing I can think of is that semicolons are screaming to be there, especially since Simba really needs them now :p
mastaraymond
2010-02-28 05:30:51
From: Widget
After taking a minute to figure out that picture, I must say I'm very impressed :D
Only thing I can think of is that semicolons are screaming to be there, especially since Simba really needs them now :p
Not more than SCAR ;)
nielsie95
2010-02-28 14:59:29
Updated the first post again, fixed some errors and added control click (find declaration).
mastaraymond
2010-02-28 17:29:57
How/Does this work with (imported) classes?
nielsie95
2010-02-28 17:40:29
At the moment it doesn't support imported classes (they should work inside inside files though).
nielsie95
2010-03-02 12:27:27
Updated the first post. I added the very base for param completion.
What do you think would be a good way to import functions/classes? Does Pascal Script has that debug/dump unit in Lazarus too? Or would a more general solution, like XML files, be better?
mastaraymond
2010-03-02 12:52:45
From: nielsie95
Updated the first post. I added the very base for param completion.
What do you think would be a good way to import functions/classes? Does Pascal Script has that debug/dump unit in Lazarus too? Or would a more general solution, like XML files, be better?
Not so sure about that "debug" file.. I think a general XML-file might be better
nielsie95
2010-03-06 10:20:15
Updated the first post again.
I need to find a good way to manage the focus on the popup, currently it forgets to redirect the character to the editor every now and then. I also need to find a good way to handle the resize of the form (but that's not of very high priority). I think ctrl+space should work now, though :)
mastaraymond
2010-03-06 13:43:32
From: nielsie95
Updated the first post again.
I need to find a good way to manage the focus on the popup, currently it forgets to redirect the character to the editor every now and then. I also need to find a good way to handle the resize of the form (but that's not of very high priority). I think ctrl+space should work now, though :)
iirc, in Lazarus itself the focus is just on the SynEdit and the ProcessCommand event is used to redirect keys to the popup
nielsie95
2010-03-09 15:11:32
But the Lazarus one doesn't work that good for me… I can't resize it and I can't select anything with my mouse.
I've revamped the extension unit from Pascal Script (the unit that SCAR uses to fill the code completion - I now know why it doesn't work too well in SCAR ;)) to dump all the classes/types/procedures/etc. The downside of this is that we'll need another solution for the other interpreter (CPascal?).
Wizzup doesn't like his param hints to pop up over the editor, but he would rather like to see them in a separate panel or the status bar. Does anyone else like it better this way (or another way)?
Also, should there be a function list? If so, what should it look like? Treeview/list/tabs? What should it display?
Wizzup?
2010-03-09 15:35:27
From: nielsie95
But the Lazarus one doesn't work that good for me… I can't resize it and I can't select anything with my mouse.
I've revamped the extension unit from Pascal Script (the unit that SCAR uses to fill the code completion - I now know why it doesn't work too well in SCAR ;)) to dump all the classes/types/procedures/etc. The downside of this is that we'll need another solution for the other interpreter (CPascal?).
I don't think CPascal should be a point of interest just yet. It isn't really function-complete. So I don't think this is an issue for now.
From: nielsie95
Wizzup doesn't like his param hints to pop up over the editor, but he would rather like to see them in a separate panel or the status bar. Does anyone else like it better this way (or another way)?
Well, I don't think it would be a bad idea as you can give a more detailed overview of the current procedure/function. With stuff like FindDeformedRotatedBitmapIn the hints in SCAR often went out of my monitor or out of the application, and that is really ugly IMO.
From: nielsie95
Also, should there be a function list? If so, what should it look like? Treeview/list/tabs? What should it display?
I quite like the one simba currently has, but it definitely lacks. :)
What is does OK, IMO:
- It is a tree.
- It is searchable.
- Allows dragging a function in the script
- Shows the declaration (in types).
What is lacks:
- Jumping to declaration.
- Probably something else I cannot think of ATM.
- Documentation per function? (nothing to worry about atm)
I don't think we need tabs / list. Tree is more easy to work with as you can easily collapse / search in a specific tree.
mastaraymond
2010-03-09 15:37:00
From: Wizzup?
I don't think CPascal should be a point of interest just yet. It isn't really function-complete. So I don't think this is an issue for now.
Well, I don't think it would be a bad idea as you can give a more detailed overview of the current procedure/function. With stuff like FindDeformedRotatedBitmapIn the hints in SCAR often went out of my monitor or out of the application, and that is really ugly IMO.
I quite like the one simba currently has, but it definitely lacks. :)
What is does OK, IMO:
- It is a tree.
- It is searchable.
- Allows dragging a function in the script
- Shows the declaration (in types).
What is lacks:
- Jumping to declaration.
- Probably something else I cannot think of ATM.
- Documentation per function? (nothing to worry about atm)
I don't think we need tabs / list. Tree is more easy to work with as you can easily collapse / search in a specific tree.
It does jump to declaration..
Nava2
2010-03-09 21:23:48
Right click jumps.
Uhm, I think that perhaps having part of the debug box sectioned for function descriptions would be really cool.
I like how IDE's like Eclipse show more than just parameters, but also show the full information about the function/procedure.
Just a thought, this also might make the RAM blow up with information. Perhaps there might be a way to load it etc so it doesn't stick in RAM all the time?
nielsie95
2010-03-10 07:58:23
What do you mean by the full information?
mormonman
2010-03-10 08:51:53
From: nielsie95
What do you mean by the full information?
nielsie95
2010-03-10 13:03:09
Ah, that's pretty cool :)
Personally, I'm not in favour of a TreeView because it'll be harder to read with a lot of items.
Nava2
2010-03-10 16:49:38
I was thinking put that information at the bottom in a tabbed setup. Then just have the old school code hints with the cursor.
I think tree view works great. But, as we add more and more levels, it does get squished. I do like how there are dividers…
But also filling in the bottom information when clicking on the function list would be great :)
Wizzup?
2010-03-10 17:34:49
From: Nava2
I was thinking put that information at the bottom in a tabbed setup. Then just have the old school code hints with the cursor.
I think tree view works great. But, as we add more and more levels, it does get squished. I do like how there are dividers…
But also filling in the bottom information when clicking on the function list would be great :)
How would you ever add more levels to the treeview? Do you have files in files in files?
Tabs doesn't sound like a good idea IMO.
I don't see how TreeView is harder to read with more items. It is definitely MORE readable than a ItemsList because you can collapse certain groups.
Nava2
2010-03-10 19:21:54
From: Wizzup?
How would you ever add more levels to the treeview? Do you have files in files in files?
Files in Folders in Folders in Folders..
Wizzup?
2010-03-11 12:00:40
From: Nava2
Files in Folders in Folders in Folders..
You don't get my point I think. I mean that a script can include other files, but that doesn't really mean they'd have to be in a separate collapsible node… Hmm… Perhaps that is a good idea… ;)
Unless I don't get it… Is nielsies
function list going to show SRLs functions in it's entirety?
If so, even more the reason to use a Tree…
nielsie95
2010-03-11 12:19:59
I'm not even sure yet if I'm going to make a function list. It could show SRL's function in its entirety, but it could also also show SRL's functions (including params), variables, constants and types in its entirety or it could merely show the functions in the current document..
With tabs you could have the engine functions, the script functions and the include functions in separate tabs. In a list you can easily add columns to sort (name, position) and in a tree you can display a lot of information in a hierarchic kind of view.
I believe Virtual TreeView supports a mix of list/tree and it's very fast too.
Wizzup?
2010-03-11 15:46:42
From: nielsie95
I'm not even sure yet if I'm going to make a function list. It could show SRL's function in its entirety, but it could also also show SRL's functions (including params), variables, constants and types in its entirety or it could merely show the functions in the current document..
With tabs you could have the engine functions, the script functions and the include functions in separate tabs. In a list you can easily add columns to sort (name, position) and in a tree you can display a lot of information in a hierarchic kind of view.
I believe Virtual TreeView supports a mix of list/tree and it's very fast too.
Tabs for a list of functions is so… unnatural IMO… Much easier to make it a branch of a tree, but that's just MO I guess. Sorting a Tree is pretty easy too. But a list is perhaps ok too, although I think groups aren't as cool as branches of a tree. :>
Nava2
2010-03-11 17:11:30
I like the idea for having tabs, but I would say vertical tabs over horizontal. One for script engine, one for included files, one for the current script.
Perhaps we could allow addition of more tabs, allowing for dragging of the descriptions so you could essentially organize it how you like?
By the way, treeview is nice. very nice.
nielsie95
2010-03-13 14:47:20
I've committed the sources to the simba git and attached an executable to the first post.
nielsie95
2010-03-28 09:33:24
Currently code completion (ctrl + space) and find declaration (ctrl + click) are in the repository, so it will be in the next version. Could use some testing :)