[Solved] How can automatic library addition be done? lazarus / 9-Editor ---------------------------------------------------------------------- loaded · 2022-02-03 12:30 Hi All, I've fixed a lot of issues with the editor that I didn't know and did wrong until now. Another problem that has become very important to me now is the case of adding libraries. As follows; In android studio this can be handled easily. While working on the project, libraries that are not in the project can be added automatically with Alt+Enter. But so far; I waited a long time for this feature to come, but unfortunately I couldn't see it in 2.2. I don't know though!!! Is there a work around this in new versions? If there is no such study , how should we go about doing it ourselves ? Because ; While trying to run the codes I found in research, I am having a lot of trouble in this regard. I would be glad if you share your thoughts and ideas. Respects. ---------------------------------------------------------------------- Martin_fr · 2022-02-03 15:24 When you refer to "libraries" (in the context of android studio?), do you mean "packages"? Or do you mean libraries as in .dll or .so? Which would mean some "procedure ... external ... 'foo.dll'" kind of declaration? As for packages, try the "unit and identifier dictionary" (you need to install the package "cody" / then look in the "Source" menu). Though it starts out empty, it is self learning, and over time collects all the data you need. An overview of tools can be found here https://wiki.lazarus.freepascal.org/Lazarus_IDE_Tools A list of cool stuff https://wiki.lazarus.freepascal.org/New_IDE_features_since ---------------------------------------------------------------------- loaded · 2022-02-03 19:00 Martin_fr thank you very much for replying. Sorry I said library, but I should have said classroom. Its counterpart in Lazarus is unit. What I want is that the code to be written should automatically add it in whichever unit it is in. ---------------------------------------------------------------------- Martin_fr · 2022-02-03 19:33 Ok, it is probably still "View unit and identifier dictionary" from the cody package. (At least that is what I use, and I don't know if there is an other way). Menu Package > Install Package Add "Cody" and rebuild the IDE. Menu Tools > Options > Editor > Keymap Find "View unit and identifier dictionary" => add whatever key you want to use for it. As I said, it starts empty. But for me it did "learn" quite quick. I just restarted and created a new project... Type "TMap" in your code, and press the key for "View unit and identifier dictionary" => It should give you some options. Choose one, and it will add the unit. Well, it's not the same as in your example, it does not scan an its own for "unknown" identifiers. You have to invoke it yourself. But then it should work. As I said, it may take a bit before it has build it's data. But it will get there. https://wiki.lazarus.freepascal.org/Cody#Unit_.2F_Identifier_Dictionar y ---------------------------------------------------------------------- loaded · 2022-02-04 05:29 Yes, this is the closest solution to what I want! If we could modify it a bit and redesign it to auto-scan sources and use a Postgresql database, it would be number 10. Thank you very much Martin_fr for keeping us informed of this study. ---------------------------------------------------------------------- PascalDragon · 2022-02-04 14:56 Quote from: loaded on February 04, 2022, 06:29:53 amIf we could modify it a bit and redesign it to auto-scan sources and use a Postgresql database, it would be number 10. Having it set up a full blown database is waaaaaay to much overkill. ---------------------------------------------------------------------- loaded · 2022-02-04 16:07 Quote from: PascalDragon on February 04, 2022, 03:56:54 pmHaving it set up a full blown database is waaaaaay to much overkill. I think this is a situation directly proportional to the need, something unnecessary for you, a very severe need for me. ---------------------------------------------------------------------- Martin_fr · 2022-02-04 16:57 Quote from: loaded on February 04, 2022, 06:29:53 amYes, this is the closest solution to what I want! If we could modify it a bit and redesign it to auto-scan sources and use a Postgresql database, it would be number 10. Thank you very much Martin_fr for keeping us informed of this study. First, I haven't written that code. But... - the functionality it provides (e.g. currently not auto-scanning / not self-invoking) - the storage used behind the scene those are entirely separate things. I assume you mention Postgresql, in the hope it would be faster (or the fastest)? I doubt that. Well, as I said, I do not know the current implementation. Maybe the current way is not the fastest. But if there would be work on the speed of this, an internal implementation would definitely beat Postgresql. So, no, we do not need (nor want) Postgresql as a backend for this (Postgresql is a good tool, but it's not applicable here). For all else, as I said, I am not the author of this part of the IDE. So I am neither working on it (nor will I anytime soon), nor do I know what the current plans for it are. I do the the value in an "auto pop up" feature, but I have no idea if anyone currently has time and interest in working on this. There is an option somewhere, for the normal code-completion (after the dot / ctrl space) to pop up while you type (i.e. after you typed 2 or 3 letters, no dot needed)... You have to search Tools > Options... ---------------------------------------------------------------------- loaded · 2022-02-04 17:43 Quote from: Martin_fr on February 04, 2022, 05:57:01 pmFirst, I haven't written that code. My dear master Martin_fr, I know you didn't write the code. Therefore, be comfortable. I will not ask anything else from you. Because the information you have given above is like a shining star at night, guiding someone who knows where he wants to go. Quote from: loaded on February 04, 2022, 06:29:53 amIf we could modify it a bit and redesign it to auto-scan sources and use a Postgresql database, it would be number 10. I wrote down the ideas that flashed in my mind at that moment, that was the whole point.  Also, I'm not asking anyone to write any code. I gave this to myself as homework. I will work on this myself. But as always, I'm open to ideas and suggestions. Respects. ---------------------------------------------------------------------- Martin_fr · 2022-02-04 23:48 Quote from: loaded on February 04, 2022, 06:43:37 pmI wrote down the ideas that flashed in my mind at that moment, that was the whole point.  Also, I'm not asking anyone to write any code. I gave this to myself as homework. I will work on this myself. But as always, I'm open to ideas and suggestions. Respects. That's fair game. Ideas are welcome.  Questions too, should any arise. ---------------------------------------------------------------------- PascalDragon · 2022-02-05 13:20 Quote from: loaded on February 04, 2022, 05:07:19 pmQuote from: PascalDragon on February 04, 2022, 03:56:54 pmHaving it set up a full blown database is waaaaaay to much overkill. I think this is a situation directly proportional to the need, something unnecessary for you, a very severe need for me. In addition to what Martin_fr wrote that a specialized implementation will beat some database hands down it's also about dependencies. A PostgreSQL database is a huge behemoth comparable in size to Lazarus itself or even larger. The idea of Lazarus is that we simply don't have such strange third party requirements, especially not for something that might be considered a base package. ---------------------------------------------------------------------- loaded · 2022-02-05 18:39 Worth considering, Thank you very much PascalDragon for expressing your opinion ---------------------------------------------------------------------- loaded · 2022-02-13 07:18 Hi All, Currently, as I mentioned above, I wrote a component that can add the unit related to Alt+Enter, just like in Android Studio. It can find all functions, methods and features in Lcl, Fpc and Component folders. If it's accepted after a few minor fixes, I'll post it in the Online Package Manager. I wanted to inform you about a small development for you and a big one for me. Thank you to everyone who helped. Regards.  https://youtu.be/mIJbQjB_Gl8 ---------------------------------------------------------------------- marcov · 2022-02-13 13:04 Database engines are designed for when the data is disk based, with memory acting as a cache. Things like this that fit in memory are not really worth it. ---------------------------------------------------------------------- loaded · 2022-02-13 13:19 Thank you so much for expressing your opinion, marcov. Quote from: marcov on February 13, 2022, 02:04:15 pmDatabase engines are designed for when the data is disk based, with memory acting as a cache. Things like this that fit in memory are not really worth it. You are very right, as the masters stated above; You mean the same. So I did not use a database. I solved the problem just by doing simultaneous file scanning. For now, I have the code that needs some optimization, I have a few more ideas in mind, I will try them in a suitable time. Let's see what the result will be! I'm putting the package here. I would be very grateful if you would indicate your thoughts and suggestions at the point of review and development at a suitable time. Best regards.