|
|
Home » Developing U++ » U++ Developers corner » Assist for include files
Assist for include files [message #31016] |
Tue, 01 February 2011 11:06 |
raxvan
Messages: 60 Registered: December 2009
|
Member |
|
|
Hello,
I'm working to add to the ide a new feature similar to visual studio 2010. When the user types include and the the key < or " the window will PopUp having all the appropriate files in it.
I use as a reference the assist used to displaying function names.
So far so good, but i'm having some issues.
1. Apparently i can't figure out why normal assist will close when pressing Escape and my assist will not. Also i can't find any code related to that. I could just add a statement to take care of that but i don't know what other side effects this might have.
2. What would be the best approach: having the files scanned when the assist will open? or to scan the files in advance (when the package is loaded) and just fill the assist with already existent data.
3. What is the Key code for '"'? because i can't figure it this out with the debugger.
4. Are there any hidden issues i have to address?
Thanks,
Raxvan.
92b48bf94855483bb4cec8bcc8c0c933
|
|
|
Re: Assist for include files [message #31043 is a reply to message #31016] |
Wed, 02 February 2011 10:17 |
|
Hi Raxvan
raxvan wrote on Tue, 01 February 2011 11:06 | I'm working to add to the ide a new feature similar to visual studio 2010. When the user types include and the the key < or " the window will PopUp having all the appropriate files in it.
I use as a reference the assist used to displaying function names.
So far so good, but i'm having some issues.
|
Good idea, although I have to warn you that it might not be as easy as it seems. I did attempt something similar once (showing annotation in the editor), but failed. AssistEditor code is quite a jungle
raxvan wrote on Tue, 01 February 2011 11:06 | 1. Apparently i can't figure out why normal assist will close when pressing Escape and my assist will not. Also i can't find any code related to that. I could just add a statement to take care of that but i don't know what other side effects this might have.
| The assist is handled at many different places, e.g. in AssistEditor::LeftDown() it is closed when you click in the editor. I guess (don't see the code right now) that closing on esc might be handled similarly. Anyway, I think it might be easy to actually extend current Assist behavior to do this than write a new one...
raxvan wrote on Tue, 01 February 2011 11:06 | 2. What would be the best approach: having the files scanned when the assist will open? or to scan the files in advance (when the package is loaded) and just fill the assist with already existent data.
| Depends on what exactly you want to show. If you restrict to files from packages in current project (which would be just fine IMHO), you can process this information very fast because it is already stored within theide. If you wan't to scan for files on disk than some clever pre-reading might be needed. Or you can cheat and suggest user some fixed set of standard system headers + the files in packages
raxvan wrote on Tue, 01 February 2011 11:06 | 3. What is the Key code for '"'? because i can't figure it this out with the debugger.
| It's \x22 (or 34 in decimal) or you can just write '\"'. Neat trick: In theide press Ctrl+E to show calculator, type '"' and press enter
raxvan wrote on Tue, 01 February 2011 11:06 | 4. Are there any hidden issues i have to address?
| Nothing I am aware of right now, as long as it behaves like regular assist, it should be fine. In case you will be searching for files on disk, you should make sure it is very fast - slow dialogs are annoying for users
Also if you want to take part in theide development, you should probably ask Mirek for a Redmine account and create a feature issue in the issue tracker we just recently started to use
Best regards,
Honza
|
|
|
Re: Assist for include files [message #31047 is a reply to message #31043] |
Wed, 02 February 2011 11:30 |
raxvan
Messages: 60 Registered: December 2009
|
Member |
|
|
Hello,
dolik.rce wrote on Wed, 02 February 2011 10:17 |
Good idea, although I have to warn you that it might not be as easy as it seems. I did attempt something similar once (showing annotation in the editor), but failed. AssistEditor code is quite a jungle
|
I can see , but i find the ide code really easy to understand.
dolik.rce wrote on Wed, 02 February 2011 10:17 |
The assist is handled at many different places, e.g. in AssistEditor::LeftDown() it is closed when you click in the editor. I guess (don't see the code right now) that closing on esc might be handled similarly. Anyway, I think it might be easy to actually extend current Assist behavior to do this than write a new one...
|
I have that fixed now, the file assist opens and closes properly.
The next step left is populating the popup with proper stuff.
dolik.rce wrote on Wed, 02 February 2011 10:17 |
Depends on what exactly you want to show. If you restrict to files from packages in current project (which would be just fine IMHO), you can process this information very fast because it is already stored within theide. If you wan't to scan for files on disk than some clever pre-reading might be needed. Or you can cheat and suggest user some fixed set of standard system headers + the files in packages
|
I want to show the files in all the assembly paths from the current project. Also the files from include directories. I'm thinking to do a scan in advance but in this case i have to handle all the changes (add file, remove file, etc).
dolik.rce wrote on Wed, 02 February 2011 10:17 |
It's \x22 (or 34 in decimal) or you can just write '\"'. Neat trick: In theide press Ctrl+E to show calculator, type '"' and press enter
|
Fixed , the problem was in some other place , actually the key was equal to '"' but the code was busted.
dolik.rce wrote on Wed, 02 February 2011 10:17 |
Also if you want to take part in theide development, you should probably ask Mirek for a Redmine account and create a feature issue in the issue tracker we just recently started to use
|
Will do , once i have a working beta of this.
Thanks,
Raxvan.
92b48bf94855483bb4cec8bcc8c0c933
|
|
|
Re: Assist for include files [message #31048 is a reply to message #31047] |
Wed, 02 February 2011 12:21 |
|
raxvan wrote on Wed, 02 February 2011 11:30 |
dolik.rce wrote on Wed, 02 February 2011 10:17 | Good idea, although I have to warn you that it might not be as easy as it seems. I did attempt something similar once (showing annotation in the editor), but failed. AssistEditor code is quite a jungle
| I can see , but i find the ide code really easy to understand.
| Yes, once you *find* what you are looking for, then it is really easy to read
raxvan wrote on Wed, 02 February 2011 11:30 | I want to show the files in all the assembly paths from the current project. Also the files from include directories. I'm thinking to do a scan in advance but in this case i have to handle all the changes (add file, remove file, etc).
|
Is there some point to suggest non-project packages from assemblies? In 99% of cases you have to add the package to make any use of the headers inside. The files from include directories are different situation of course, and it makes sense to suggest them. I'd personally prefer creating a list at the start of theide and check for changes only on request (on Assist -> Rescan code). You will see how fast you can write it, if it would delay starting too much, you would have to do some trickery e.g. creating the list in a background task (can be done using callbacks).
Actually it would be nice if some of the present scanning was rewritten into separate threads... That would speed things nicely, since the disk I/O heavy task (including yours) could be done in background, while user could already work.
Honza
|
|
|
Re: Assist for include files [message #31050 is a reply to message #31048] |
Wed, 02 February 2011 13:55 |
raxvan
Messages: 60 Registered: December 2009
|
Member |
|
|
dolik.rce wrote on Wed, 02 February 2011 12:21 |
Is there some point to suggest non-project packages from assemblies? In 99% of cases you have to add the package to make any use of the headers inside. The files from include directories are different situation of course, and it makes sense to suggest them. I'd personally prefer creating a list at the start of theide and check for changes only on request (on Assist -> Rescan code).
|
You are right, the only files you *should* use should already be in a package in current project. Therefore i will stick, for now, with these files only.
I think in visual studio the files are scanned on request based on the current path. This system allows the user to see files from paths such as "../../Folder/etc". I personally believe this should not be allowed because paths like these are confusing. Therefore i will not implement something like this.
Raxvan.
92b48bf94855483bb4cec8bcc8c0c933
|
|
|
Re: Assist for include files [message #31071 is a reply to message #31016] |
Thu, 03 February 2011 19:06 |
raxvan
Messages: 60 Registered: December 2009
|
Member |
|
|
Hello,
Here is a simple image with the work i have done.
The method chosen to scan the files is mixed. Some files are stored in a Vector and the rest of the files are scanned on demand.
The scanning is performed using the class CoWork (I suggest including this CoWork class into the main Ide class so other heavy operations, such as FindInFiles and Assist Code Scanner, to work in background).
The behavior is exactly like normal assist and ~95 % of it is already implemented/working/tested.
I have one question:
What type (or what methods) has a class to implement in order to work as a row in ArrayCtrl? Because now i use AttrText and when i insert i can only use the current row in the ArrayCtrl.
I would like to have some extra data associated with each row in order to finish this.
I used Windows to develop this, but i think it should work fine with linux too.
Thanks,
Raxvan.
-
Attachment: demo.PNG
(Size: 45.68KB, Downloaded 292 times)
92b48bf94855483bb4cec8bcc8c0c933
[Updated on: Thu, 03 February 2011 19:08] Report message to a moderator
|
|
|
Re: Assist for include files [message #31073 is a reply to message #31071] |
Thu, 03 February 2011 19:32 |
|
That looks great
One hint: I believe that for the quoted style includes, only files from current package should be suggested. IIRC the gcc search for the file relatively to the current file, so if the other package was in different assembly, it might cause problem. Also it is IMHO a good coding style to use #include "file.h" only for "local" files.
Have you tested how the CoWork solution works on single core processor? (Or when you set affinity of the process to single core...).
Unfortunately, I can't answer the question about ArrayCtrl, as I don't know answer...
Looking forward to see the code
Honza
|
|
|
|
Re: Assist for include files [message #31075 is a reply to message #31074] |
Thu, 03 February 2011 21:58 |
|
raxvan wrote on Thu, 03 February 2011 19:50 | When the include assist uses quotes ('"') the current file is taken (theide->editfile) and a search is performed. I can see that 'editfile' variable holds the entire path to the current edited file , therefore i extract the path from that and i perform a search based on that path. This will give only "local" files/folders.
| I guess it is more of a philosophical question Or matter of taste. My point of view is this: If I wan't to include something from other packages, I should include them first (so I don't forget to do it later ). Secondly, if I wan't to include something from other package, I will always use <pkg/file.h> for a simple reason that another user might have different setup of assemblies (e.g. two nest from non-neighboring directories) and then "pkg/file.h" might not make sense. From this follows that a) only local package files can be shown when '"' is pressed and b) only files from loaded packages can be suggested. Both of these cases save you scanning disk, since those files are already accessible through ide.IdeWorkspace(). So the only thing that is IMHO really needed to be looked up on disk are the system headers from include directories and those doesn't change very often, so it might be even possible to cache the list in a single file to have it ready at start and check if it is up to date later (e.g. when the application is idle). That way you wouldn't even have to worry about speed. But that is all just my opinion, if you think you will need more files suggested or something else, you are free to do it
raxvan wrote on Thu, 03 February 2011 19:50 | I can't test CoWork anywhere because i have no single core machines . CoWork is very simple to use (just Do(THISBACK(...)), and don't care how the function will run.) and i never encountered problems with this system. There will be more extensive testing later.
Using this required me to modify the current build configuration for the Ide to be multithreaded.
The "Loading..." message is there for a very short amount of time (~0.1 seconds or less) but i will keep it there in case of some existing heavy disk operations.
| You can test by instructing the process to use only single core using Task manager (there should be Set Affinity in context menu for each process on Processes tab) but if it is under 1 second it is probably OK even if it was executed in serial.
Honza
|
|
|
Re: Assist for include files [message #31082 is a reply to message #31016] |
Fri, 04 February 2011 09:15 |
raxvan
Messages: 60 Registered: December 2009
|
Member |
|
|
Hello,
I have created a rar file with the source files of the ide so everyone can test it. The code is not final, as you will see the path dose not support `../` and deleting a `/` will close the assist.
For fix these issues with a nice solution requires some thinking. This might delay the final product with 2-3 days.
My only concern is about linux (i haven't had any time to try it out) and filenames containing special characters. FindFile will only return a String not a WString.
http://dl.dropbox.com/u/9887398/ide.rar
Raxvan.
92b48bf94855483bb4cec8bcc8c0c933
|
|
|
|
|
|
|
|
|
|
|
|
|
Goto Forum:
Current Time: Thu Apr 18 23:15:39 CEST 2024
Total time taken to generate the page: 0.03915 seconds
|
|
|