Some while ago I started a plugin to easily add units to the uses clause just like you can do via quickfix in VisualStudio.
Some while ago I started a plugin to easily add units to the uses clause just like you can do via quickfix in VisualStudio.
I never actually polished it but since I felt it might be useful to others as well here it is (still beta - supported Delphi versions currently are 10, 10.1 and 10.2).
Just run the setup and install into a directory where the IDE will also have write access to (should be %localappdata% by default).
When you first start the IDE with the plugin it will index $(BDS)\source which should reasonably fast and you won't even notice it. You can then add additional directories via Options -> Third Party -> UsesHelper (or F6 -> UsesHelper). Just add any additional directories that should be indexed (recursively, only *.pas). Indexing will happen in the background. In the end it will save an index.dat file which it will only access when it gets changed or you restart the IDE.
Via shortcut (Shift+Alt+F10 - fix for now, might be configurable later) while in the editor on some symbol you can show the suggestion list for units that contain that symbol and add it to interface or implementation uses. What does not work yet is moving from one to the other if it already exists in either.
Let me know if there any issues and enjoy!
Oh, the download link:
https://1drv.ms/u/s!ArjIoB43KhwDg3Ju1tkHlJniN2WS
I never actually polished it but since I felt it might be useful to others as well here it is (still beta - supported Delphi versions currently are 10, 10.1 and 10.2).
Just run the setup and install into a directory where the IDE will also have write access to (should be %localappdata% by default).
When you first start the IDE with the plugin it will index $(BDS)\source which should reasonably fast and you won't even notice it. You can then add additional directories via Options -> Third Party -> UsesHelper (or F6 -> UsesHelper). Just add any additional directories that should be indexed (recursively, only *.pas). Indexing will happen in the background. In the end it will save an index.dat file which it will only access when it gets changed or you restart the IDE.
Via shortcut (Shift+Alt+F10 - fix for now, might be configurable later) while in the editor on some symbol you can show the suggestion list for units that contain that symbol and add it to interface or implementation uses. What does not work yet is moving from one to the other if it already exists in either.
Let me know if there any issues and enjoy!
Oh, the download link:
https://1drv.ms/u/s!ArjIoB43KhwDg3Ju1tkHlJniN2WS
Big hero :)
ReplyDelete/sub
ReplyDeleteOne bottle of vodka for you sir. 🙌
ReplyDeleteWow very cool!
ReplyDeleteYou beat me to it. That was on my list to combine the uses manager with the class browser.
ReplyDeletehttps://github.com/rfrezino/RFindUnit
ReplyDeleteJacek Laskowski I know that - not what I want. Why should I do some search when the plugin can already only suggest those units that have exactly the type under my cursor.
ReplyDeleteBy the way - I am indexing everything in the interface section of the units: all kinds of types including all values of enums, consts, variables, routines. So for example if you type mrOk and hit the shortcut it should show Dialogs and UITypes.
ReplyDeleteAttila Kovacs Yes, I am currently removing the common unit scope names (like System, Winapi, Vcl or Fmx) on purpose but I plan to make it an option which ones to omit.
Too bad its .pas based, won't work on Starter :(
ReplyDeleteSounds cool btw
Agustin Ortu The indexer is pas based. So if you produce the index.dat yourself or someone else shares it. It works =)
ReplyDeleteAttila Kovacs Not until you hit the button or change the directories to index :)
ReplyDeleteWell done. Thanks for sharing, Mr Stefan Glienke
ReplyDeleteStefan Glienke
ReplyDelete"while in the editor on some symbol you can show the suggestion" how?
Trying on Berlin free it dose not seem to work.
What am i expected to see?Mouse on symbol? Right mouse click?
Can we have the source?
shlomo abuisak I wrote the shortcut right before the part you quoted and also in the readme that shows after you install (if you did not uncheck that in the setup).
ReplyDeleteAnd no - with the amount of libraries, plugins and other things in the Delphi ecosystem people ask money for I think its fair enough if I don't open source every single piece of work I create. It will still be free though.
helo . Exists plugin to generate get set in editor Delphi Starter?
ReplyDeleteStefan Glienke The idea is good. Open source is of course nice but it is your decision.
ReplyDeleteWhat is the required version of Delphi ? Does it work with D2007 ?
/sub
ReplyDeleteRoland Bengtsson I am using features only available on XE and up.
ReplyDeleteStefan Glienke Please add config for shortcut. For me shift+alt+F10 is quite uncomfortable
ReplyDeleteStefan thank you: this is really great!
ReplyDeleteStefan, can you please add a config for shortcut?
ReplyDeleteStefan Glienke Thanks a lot for this.
ReplyDeleteI implemented unit scope as optional and config for shortcut. I will upload a new version in the next days.
ReplyDeleteAttila Kovacs If the unit is part of a project you don't need to add it to the global index as it will be indexed as part of a local index (all units in the project).
I had similar problems in the beginning like Attila. After having info on what is indexed i could change the options. First time AV. Next restart.
ReplyDeleteWow! It's working now. OMG this is brilliant:) THANKS!
FYI:
BTW: A path will get stored and handled as two paths is it exceeds the line length in the memo. I.e. linewrap is stored. Not 100% easy to notice when you Ctrl+V.
Dany Marmur I have to disable wordwrap then, thanks.
ReplyDeleteStefan Glienke if you are interested. Ever since installation i see a window "flashing". I cannot know if its the util of course. But it started then and it only happens in my dev vm when the ide is open. By "flashing" i mean a window is created, displayed and immediately hidden or destroyed. I speculate but it might be of help...
ReplyDeleteDo you plan to support older Delphi versions too?
ReplyDelete(Where "older" means Delphi 2007 in particular. ;-) )
Thomas Mueller I answered that question already: no. Code is using DelphiAST which only works on versions that know generics. Backporting that is not worth my time.
ReplyDeleteWhere can I download the last version of it?
ReplyDeleteHi Stefan Glienke do you released a new version of it? I am interested in some new changes you have told us, like disabled word-wrap, configurable shortcut etc. Thank you for this little jewel :-)
ReplyDeleteAttila Kovacs Me in that case, yes. I did not add those to the indexed symbols, will do for next version - probably around 2 weeks from now.
ReplyDeleteThank you Stefan Glienke!
ReplyDeleteI updated the plugin (link is still the same) - the default shortcut now is Ctrl+Shift+A (so it overrides the similar functionality from the IDE) but you can change it in the options.
ReplyDeleteAlso fixed the issues with not indexing some symbols and the wrong wordwrap in the index directories.
It also indexes the full qualified unit name. If you want to shorten some of them you can specify the scopes in the options (so if you add System for example the plugin adds SysUtils to the uses and not System.SysUtils).
Supported versions: 10.0, 10.1, 10.2
Stefan Glienke: thank you a lot!
ReplyDeleteNo
ReplyDeleteHi Stefan, how can I force a complete reindex after having added some directories to UsesHelper? I have pressed the reindex button in the Options, but nothing happened and when I press the shortcut on a symbol contained in one of the units contained in the directories I have added to the UsesHelper config, it give me an error "No unit found for identifier MyIdentifier". Any idea?
ReplyDeleteFabio VITALE I does the reindexing in the background and eventually finishes. It just does not give you a notification.
ReplyDeleteOk thanks Stefan Glienke! I will patiently wait the reindexing process
ReplyDeleteI will add a notification in the messages panel in the next version.
ReplyDeleteMaybe something wrong in my setup but I have noticed that the directory I have added to my config, where all my source files (*.pas) reside, did not get indexed. I also closed delphi, deleted the index.dat file and restarted delphi: nope, that directory is not indexed. I am short on ideas
ReplyDeleteFabio VITALE Did you properly enter the directory into the indexed directories list? No delimiter, just new lines for each directory.
ReplyDeleteIn the registry under the bds key there is the UsesHelper key with the value SearchPath. It contains the semicolon delimited directories.
Yes, all things seem to be correct. I've also restarted Delphi and now the UsesHelper shortcut is functional on symbols of the directory I've added to the config in Options . I do not know what was wrong with the indexing. Anyway thank you very much for your support!
ReplyDeleteAlso noticed that if you launch Rebuild Index and then exit Delphi, an access violation occours: this is kind of expected, I imagine, since maybe the reindex has not yet finished.
ReplyDeleteFabio VITALE Yes, I did not put any cancellation mechanism into that. It's simply an anonymous thread working in the background. I would fix that if I would charge money for the plugin, otherwise not worth the time ;) In your version it's also possible to fire it up multiple times which I fixed for the next version.
ReplyDeleteThank you very much! I will stay tuned for the new version.
ReplyDeleteIt is a nice, very nice product.
ReplyDeleteI love to use it, but now in 10.3 i miss it.
When will it be available in 10.3 (Rio) ?
thx