Recent

Author Topic: [Solved] How can automatic library addition be done?  (Read 5447 times)

loaded

  • Hero Member
  • *****
  • Posts: 859
[Solved] How can automatic library addition be done?
« on: February 03, 2022, 01:30:55 pm »
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.
« Last Edit: February 04, 2022, 06:30:06 am by loaded »
Check out  loaded on Strava
https://www.strava.com/athletes/109391137

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 11036
  • Debugger - SynEdit - and more
    • wiki
Re: How can automatic library addition be done?
« Reply #1 on: February 03, 2022, 04:24:45 pm »
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

  • Hero Member
  • *****
  • Posts: 859
Re: How can automatic library addition be done?
« Reply #2 on: February 03, 2022, 08:00:42 pm »
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.
Check out  loaded on Strava
https://www.strava.com/athletes/109391137

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 11036
  • Debugger - SynEdit - and more
    • wiki
Re: How can automatic library addition be done?
« Reply #3 on: February 03, 2022, 08:33:05 pm »
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_Dictionary


loaded

  • Hero Member
  • *****
  • Posts: 859
Re: How can automatic library addition be done?
« Reply #4 on: February 04, 2022, 06:29:53 am »
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.
Check out  loaded on Strava
https://www.strava.com/athletes/109391137

PascalDragon

  • Hero Member
  • *****
  • Posts: 5938
  • Compiler Developer
Re: How can automatic library addition be done?
« Reply #5 on: February 04, 2022, 03:56:54 pm »
If 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

  • Hero Member
  • *****
  • Posts: 859
Re: How can automatic library addition be done?
« Reply #6 on: February 04, 2022, 05:07:19 pm »
Having 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.
« Last Edit: February 04, 2022, 05:09:39 pm by loaded »
Check out  loaded on Strava
https://www.strava.com/athletes/109391137

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 11036
  • Debugger - SynEdit - and more
    • wiki
Re: How can automatic library addition be done?
« Reply #7 on: February 04, 2022, 05:57:01 pm »
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.

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...
« Last Edit: February 04, 2022, 06:03:24 pm by Martin_fr »

loaded

  • Hero Member
  • *****
  • Posts: 859
Re: How can automatic library addition be done?
« Reply #8 on: February 04, 2022, 06:43:37 pm »
First, 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.

If 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.
Check out  loaded on Strava
https://www.strava.com/athletes/109391137

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 11036
  • Debugger - SynEdit - and more
    • wiki
Re: How can automatic library addition be done?
« Reply #9 on: February 05, 2022, 12:48:37 am »
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.

That's fair game. Ideas are welcome.  Questions too, should any arise.


PascalDragon

  • Hero Member
  • *****
  • Posts: 5938
  • Compiler Developer
Re: How can automatic library addition be done?
« Reply #10 on: February 05, 2022, 02:20:07 pm »
Having 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

  • Hero Member
  • *****
  • Posts: 859
Re: [Solved] How can automatic library addition be done?
« Reply #11 on: February 05, 2022, 07:39:38 pm »
Worth considering, Thank you very much PascalDragon for expressing your opinion
Check out  loaded on Strava
https://www.strava.com/athletes/109391137

loaded

  • Hero Member
  • *****
  • Posts: 859
Re: [Solved] How can automatic library addition be done?
« Reply #12 on: February 13, 2022, 08:18:06 am »
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
Check out  loaded on Strava
https://www.strava.com/athletes/109391137

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12156
  • FPC developer.
Re: [Solved] How can automatic library addition be done?
« Reply #13 on: February 13, 2022, 02:04:15 pm »
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

  • Hero Member
  • *****
  • Posts: 859
Re: [Solved] How can automatic library addition be done?
« Reply #14 on: February 13, 2022, 02:19:47 pm »
Thank you so much for expressing your opinion, marcov.
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.
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.
« Last Edit: February 13, 2022, 03:05:17 pm by loaded »
Check out  loaded on Strava
https://www.strava.com/athletes/109391137

 

TinyPortal © 2005-2018