How can i deny an unit from deactivating Code Insigth in Firemonkey? - delphi

I want to import an unit to save ini files with this unit from Github, but, as soon as i import it, code insight stops working - instead of opening itself doesn't even open anymore. It isn't a change in the IDE options, as it works in every unit/project in which i don't use it. So, the line
Uses: [...], FMX.IniFile;
Seems to deactivate Code Insight. I use Rad Studio 10.3. Is this a known issue or does a solution already exists?
Thanks
Edit: In order to use the file correctly, i need to import the files for android and Apple as well, which are in the same directory as the main FMX.IniFile.Pas, these might cause the problem as well

Sorry, I just tried what you describe in your q and code completion continues to work fine.
Here's exactly what I did:
Created a new multi-platform application.
Saved the default new Form1 unit the IDE creates and the project.
Created a new unit and cut and pasted the source of FMX.IniFile into it.
Saved the new unit in the project's folder under the name FMX.IniFile.Pas
Added FMX.IniFile to Form1's unit's Uses clause.
Added a TButton to Form1 and did a Save All
Created a `Button1Click' event on Form1.
Switched from the form editor to the code editor and, in the Button1Click handler skeleton and started to type
Self.c
and the IDE immediately offered the various properties of Form1 beginning with c as code-completion possibilities.
I'm using Delphi 10.2.3 on Windows 10 Pro 64-bit.

Related

Delphi 11 Alexandria LSP code completion problem

Is there any way to solve the problem when you add a new unit to a project and LSP Code Completion doesn't recognize the new functions/procedures? Sometimes I have to close and reopen the IDE for it to recognize them.
I have a project with more than 300 units, and sometimes it doesn't recognize uses that I add, and I try to use functions or procedures. It only works if I close the IDE.
I don't have such problems in Delphi 10.3.
If you are referring to a brand new unit that does not yet exist on disk, then that is a known limitation of Code Completion. Once the unit has been saved to disk, then it should work as expected.
I believe this was stated in the launch webinar by David Millington and is referenced in the "Items to be aware of" section of a RAD Studio 11 wiki page.
https://github.com/ideasawakened/DelphiKB/wiki/D28.ALEXANDRIA.11.1.0.0

Why when we add an android service to an app, delphi automatically include in the dpr of the app the unit of the datamodule of the service?

When i create a new service, then this service will have a main datamodule (DM), and when i add this service to an already existing app, then delphi automatically add to the dpr (in the uses clauses) of this app the unit of the datamodule:
uses ...
...
myService_mainunit;
why ? it's also make after not possible to compile under IOS ...
The IDE has absolutely no idea what your intentions are. It has no clue that you only want to use this for Android, regardless of if it's Android-specific code or not. You have to write the code which tells it this, such as using conditionals.
When you created a new Android Service, the IDE set up a pre-made template for you. This template just happens to use a Data Module to do its work. But when you add the Data Module to a project, the IDE simply does not know why you want to add it. It's just doing its job, it does this for any and every unit you add to your project, regardless of what that unit's purpose is. In fact, there is no such thing as adding a unit to your project and not being in the DPR uses.
"it's also make after not possible to compile under IOS"
Again, this is easily resolved by wrapping platform conditionals around it. Of course, the IDE "takes control" of the DPR file, so perhaps not that easily, as the IDE could malform your code. It is however very possible by not including this Data Module in your project, but place it in a location where your project can find it.

Is there a more productive way to build and test components?

I would like to know how everyone else is writing their components and testing them out?
The way I am doing it seems to be taking too long, so I hope someone could maybe point something obvious that I might have overlooked or could do instead to make the whole process of building my own components more enjoyable and not such a dogged lengthy task.
This is along the lines of what I am doing with one of my current components (with the package open as the project, and the component already installed in the IDE):
Make changes to the component code.
Build with Shift+F9.
If adding a new published property to my component I uninstall / reinstall the component again.
Add a new Form.
Drop my recently built component on the form.
Check at design time to see if the properties can be correctly changed and the control is painted correctly (also see if new published properties show in Object Inspector). Also check for any errors in the component.
If at design time everything seems ok, I save the package and close it then create a new Application.
Then I add again my component to the new Form of the new Application project and run it to see how it works at run time.
Some further modifications to the component can be changed without opening the package again, ie if it is a paint procedure of my component I can just open the source unit of the component, change it and re run the Application to see the changes.
Any other modifications and I usually need to close the whole project again, and reopen the package and repeat all the steps above.
I am constantly switching between the component package and new application project to make changes, there has to be a much more efficient way of doing this and I bet there is but I cannot see it!
I will accept the answer to the person who can save me a lot of time and cut out most of the steps above if it is possible:)
Why do you need to perform the steps from 4. more than once?
I generally create a program group and add the following to it:
A runtime package that contains all the runtime units.
A designtime package that installs the component and implements any design time editors.
A demo project that allows properties of the component to be changed via a GUI.
When I make changes to the component I simply rebuild the demo project and run it. If I make changes to the properties of the component I rebuild the runtime package then install the design time package. After doing this, display the demo form again and the Delphi IDE will warn you of any missing components. No need to recreate anything.
If you want to see an example, take a look at my TChromeTabs source.
Oh. I never thoght that component developement will require that much operatins.
My common workflow looks like that:
Open Project group with my component packages (run-time and design-time) and test programs
Modify component code
Rebuild component package
Switch to test program's form with that component to see if it looks ok in Design-time
Run test program from IDE to see if it works in Run-time
And, occasionally I run a batch file that compiles my component and all the test programs in a clean environment (without using all the precompiled .dcu files) for each Delphi version that I have. Just to test that component can be compiled correctly in both Delphi 6 and Delphi 2010 (which are used in our company).
I use Lazy Delphi Builder to make a "clean compile" (compile without using full Delphi Library path). A separate LazyDBP profile for each IDE. And a .bat file that runs them all.

Adding a unit automatically to the project

I am working on a component in Delphi 7 and Delphi 2006, where I am using a unit which I need to add to the .dpr file of the project on which the component is dropped automatically.
Like the way Eureka Log automatically adds the unit 'ExceptionLog' to the project file:
Can anyone tell me how to programmatically add a unit to the project file when I drop my component on any form in the project?
You most likely have to use the Open Tools API for that.
Also it might require to write a TSelectionEditor for your component to trigger the adding of the unit (I would try the RequiresUnit method).
While there is an easy way to just add a unit to the active project (code below) this just works for the active project which might not be the project the form belongs to you are adding the component to. Also it adds the unit at the end of the uses clause.
uses
ToolsAPI;
var
currentProject: IOTAProject;
begin
currentProject := GetActiveProject();
currentProject.AddFile('MyUnit.pas', True);
You can check the GExperts source code because it contains a class (TUsesManager) that can parse units and modify the uses clause.
Odd.
I used to set my default dpr to contain next to nothing as a result my toolbox was very empty. So if it was in my toolbox it was in the dpr - what are you having problems with - normally if its in the toolbox, its already in the dpr.
go Project > Eurekalog Options and disable Eurekalog.

One project in Delphi 2007 doesn't show procedure name in the IDE Obj Inspector's Events

I have a Delphi project in 2007 that doesn't show the procedure names in the Object Inspector's Events such as Form OnClose, OnCreate or OnShow in the IDE. The code is there and if you click on OnCreate (for example) you are taken to the code and the IDE fills in the name of procedure. However on reload, the procedures are missing from the IDE again.
This same project causes various error messages when Delphi closes also, but I am not sure if this is related (no other project developed under this Delphi does but this one is the largest app and uses several 3rd party add-in libraries).
I have moved this app to various Delphi 2007 installations and it reacts the same, so it isn't a corrupt Delphi situation. Is there any way to rebuild or fix a corrupt project like this? Any help would be appreciated.
I would try to remove all the files and keep only the dpr and the pas/dfm files in case it's a corrupted project file.
I would also double check if there is any Form inheritance mess, as I have seen somewhat similar issues with the inherited event handlers. (look at the dfm files directly)
Try delete all the .DCU's, close Delphi, restart Delphi then rebuild your project.
Delphi's IDE takes several liberties with your code without warning you.
In particular : if you have a callback (eg: "TMyForm.FormCreate") linked in the dfm, and the IDE detects that the function's body is empty, when you save your unit, the ide removes the declaration and the implementation before saving your file.
Adding anything (even a simple "//") in the function's body prevents this : try typing some code or some comment in your function before closing your Delphi.
As for errors when Delphi closes, there can be so many reasons.
Do you have any third-party components or experts installed ?
Have you tried installing IDEFixpack for D2007 ?

Resources