Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2014-02

Getting help for a type if its unit is not in uses

28 messages · 9 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Sven Barth

Hello together!

On the German Delphi-Forum Delphi-PRAXiS there was the question in which unit the type TObjectList resided in Lazarus. Besides the obvious answer "contnrs" there was also the suggestion to use F1 on the TObjectList identifier to let the help find it for you. (For those that can read German, here is the thread:
http://www.delphipraxis.net/178892-lazarus-kennt-keine-tobjectlist.html )

Now the problem is that this won't work in Lazarus which will return a error message "Hilfeschl?sselwort "FPCKeyword_TObjectList" nciht[sic!] gefunden." ("Help keyword "FPCKeyword_TObjectList" not found") [plus another, in my opinion needless, error message afterwards with (in my case) "No help found for "project1.lpr" at (13,16)"] and the user is none the wiser... This is at least the case in 1.0.12 on win64, I didn't check for any changes here in 1.2/1.3...

Are there any ideas for improving this situation for people that know that there is an identifier in the RTL, FCL, whatever, but don't know which unit it resides in? E.g. Lazarus did scan the FPC sources, couldn't it keep an identifier->unit index? Also could the error message be improved a bit? E.g. kick out that second error and use "TObjectList" instead of "FPCKeyword_TObjectList" in the error message?

Regards,
Sven

Reply by email

Xiangrong Fang
to Sven Barth

This is a great feature suggestion. If implemented I think it should also work with constants. For example, it cost me some 10+ minutes to figure out VK_ESCAPE is defined in LCLTypes.

Thanks!

2014-02-05 Sven Barth :

Show quoted text 33 lines
Hello together! On the German Delphi-Forum Delphi-PRAXiS there was the question in which unit the type TObjectList resided in Lazarus. Besides the obvious answer "contnrs" there was also the suggestion to use F1 on the TObjectList identifier to let the help find it for you. (For those that can read German, here is the thread: http://www.delphipraxis.net/ 178892-lazarus-kennt-keine-tobjectlist.html ) Now the problem is that this won't work in Lazarus which will return a error message "Hilfeschl?sselwort "FPCKeyword_TObjectList" nciht[sic!] gefunden." ("Help keyword "FPCKeyword_TObjectList" not found") [plus another, in my opinion needless, error message afterwards with (in my case) "No help found for "project1.lpr" at (13,16)"] and the user is none the wiser... This is at least the case in 1.0.12 on win64, I didn't check for any changes here in 1.2/1.3... Are there any ideas for improving this situation for people that know that there is an identifier in the RTL, FCL, whatever, but don't know which unit it resides in? E.g. Lazarus did scan the FPC sources, couldn't it keep an identifier->unit index? Also could the error message be improved a bit? E.g. kick out that second error and use "TObjectList" instead of "FPCKeyword_TObjectList" in the error message? Regards, Sven -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20140205/745699a2/attachment.html>

Reply by email

Mattias Gaertner
to Sven Barth: Hello together! On the German Delphi-Forum Delphi-PRAXiS there was the question in which…
Show quoted text 5 lines
[...] On the German Delphi-Forum Delphi-PRAXiS there was the question in which unit the type TObjectList resided in Lazarus. Besides the obvious answer "contnrs" there was also the suggestion to use F1 on the TObjectList identifier to let the help find it for you.

(For those that can read

Show quoted text 8 lines
German, here is the thread: http://www.delphipraxis.net/178892-lazarus-kennt-keine-tobjectlist.html ) Now the problem is that this won't work in Lazarus which will return a error message "Hilfeschl?sselwort "FPCKeyword_TObjectList" nciht[sic!] gefunden." ("Help keyword "FPCKeyword_TObjectList" not found") [plus another, in my opinion needless, error message afterwards with (in my case)

The above message is now omitted. The hint is now in the debug log.

Show quoted text 8 lines
"No help found for "project1.lpr" at (13,16)"] and the user is none the wiser... This is at least the case in 1.0.12 on win64, I didn't check for any changes here in 1.2/1.3... Are there any ideas for improving this situation for people that know that there is an identifier in the RTL, FCL, whatever, but don't know which unit it resides in? E.g. Lazarus did scan the FPC sources, couldn't it keep an identifier->unit index?

It only scanned the directories for file names. This alone can take minutes on slow disks/networks.
There are currently two identifier->unit indices.

Code Browser:
- built in the IDE
- scans current project or IDE and all currently used packages
- does not save index to disk
- does not show identifiers of other packages (not used by project/IDE)

Cody Identifier Dictionary
- installed when Cody is installed
- keeps track of all scanned identifiers
- stores index to disk
- shows identifiers of other packages (if you used them once)
- if you used several copies of a unit on your disk, it will show all of them
- can be confusing when you renamed files or worked cross platform.

Basically you can use the Code Browser to update the dictionary. Both show only top level identifiers, not sub identifiers or parameters.

When an identifier was not found it now starts the code browser, so TObjectList of contnrs is now shown.

Also could the error message be improved a bit? E.g. kick out that second error and use "TObjectList" instead of "FPCKeyword_TObjectList" in the error message?

You now get the codebrowser. There you can search for packages, units and identifiers.

Mattias

Reply by email

Sven Barth
to Mattias Gaertner
Mattias Gaertner wrote 8 lines
On Wed, 05 Feb 2014 09:03:32 +0100 Sven Barth wrote: > Now the problem is that this won't work in Lazarus which will return a > error message "Hilfeschl?sselwort "FPCKeyword_TObjectList" nciht[sic!] > gefunden." ("Help keyword "FPCKeyword_TObjectList" not found") [plus > another, in my opinion needless, error message afterwards with (in my > case) The above message is now omitted. The hint is now in the debug log.

Great. :)

[snip]

Show quoted text 7 lines
When an identifier was not found it now starts the code browser, so TObjectList of contnrs is now shown. > Also could the error message > be improved a bit? E.g. kick out that second error and use "TObjectList" > instead of "FPCKeyword_TObjectList" in the error message? You now get the codebrowser. There you can search for packages, units and identifiers.

Great! Let's see how good that will work. :) Any chance this could still be in 1.2?

Regards,
Sven

Reply by email

Sven Barth
to Mattias Gaertner
Mattias Gaertner wrote 12 lines
On Wed, 05 Feb 2014 12:32:55 +0100 Sven Barth wrote: > Am 05.02.2014 12:25, schrieb Mattias Gaertner: > [...] >> You now get the codebrowser. There you can search for packages, units >> and identifiers. > Great! Let's see how good that will work. :) Any chance this could still > be in 1.2? Well, there is the risk that it breaks F1 on identifiers. I need testers.

It seems to still work correctly.

Is it normal though that the "select help entry" dialog shows duplicates? This happens e.g. when using F1 on "var" (contents "Pascal keyword "var"" and "Pascal keyword "var" (2)") and on "TObjectList" with "contnrs" in uses clause (contents: "FCL - Free Pascal Component Library Units ( type TObjectList in
e:\fpc\svn\packages\fcl-base\src\contnrs.pp)" (twice!) [sidenote: a horizontal scrollbar would be nice here as well, although I know that the window can be resized...]).

Also how should one select an identifier in the Code Browser to get the help entry? Double clicking the entry opens the class' declaration inside the editor, but I'd like to get the help...

Regards,
Sven

Reply by email

Mattias Gaertner
to Reimar Grabowski
On Wed, 5 Feb 2014 12:25:18 +0100 Mattias Gaertner wrote: Can we hope to someday get the feature that Lazarus adds the unit where a type/function/whatever is defined automatically to the uses clause when it is used for the first time (just like Eclipse does for Java imports)?

Please define "automatically".

Mattias

Reply by email

Juha Manninen
to Mattias Gaertner
> Can we hope to someday get the feature that Lazarus adds the unit where a type/function/whatever is defined automatically to the uses clause when it is used for the first time (just like Eclipse does for Java imports)? Please define "automatically".

MS Visual Studio has the red error marker and a popup menu that gives options to fix the code. Adding a missing unit dependency is just one of the corrections. This would be a nice goal.
Eclipse does about the same thing, although Visual Studio may be the best in this respect.
My knowledge may be a little outdated. I should evaluate the top IDEs again.

But yes, a way to add a missing unit reference would be very important.

Juha

Reply by email

Mattias Gaertner
to Juha Manninen
Show quoted text 5 lines
>> Can we hope to someday get the feature that Lazarus adds the unit where a type/function/whatever is defined automatically to the uses clause when it is used for the first time (just like Eclipse does for Java imports)? > > Please define "automatically". MS Visual Studio has the red error marker and a popup menu that gives

Something has to generate these markers.
The compiler is the most reliable tool for that, but it would fail if a required unit fails to compile and it should not write to disk, so it needs temporary output directories.

Mattias

Reply by email

Flávio Etrusco
to Reimar Grabowski: On Wed, 5 Feb 2014 12:25:18 +0100 Can we hope to someday get the feature that Lazarus…
Reimar Grabowski wrote 6 lines
On Wed, 5 Feb 2014 12:25:18 +0100 Mattias Gaertner wrote: Can we hope to someday get the feature that Lazarus adds the unit where a type/function/whatever is defined automatically to the uses clause when it is used for the first time (just like Eclipse does for Java imports)? R.

FWIW if you get an "identifier not found" error while compiling, the context menu in the Message View has a "Search identifier" command. It opens the Code Browser (which also could be much cleaner) and searches the class. Then you can open the context menu for the unit found and select "Use unit FOO in unit BAR".

-Fl?vio

Reply by email

Reimar Grabowski
to Juha Manninen: MS Visual Studio has the red error marker and a popup menu that gives options to fix the…
>> Can we hope to someday get the feature that Lazarus adds the unit where a type/function/whatever is defined automatically to the uses clause when it is used for the first time (just like Eclipse does for Java imports)? > > Please define "automatically".

Available types (Java standard, user defined or belonging to 'libs' in your class path) are shown in the code completion popup, also the package name where this type is defined. When choosing a type the corresponding import is added to your code.

MS Visual Studio has the red error marker and a popup menu that gives options to fix the code. Adding a missing unit dependency is just one of the corrections.

That's available in Eclipse, too, via 'quick fixes'. But I am more interested in the first one, which I use a lot in Eclipse.

R.

Reply by email

Mattias Gaertner
to Reimar Grabowski: On Wed, 5 Feb 2014 21:55:07 +0200 Available types (Java standard, user defined or…
Show quoted text 7 lines
On Wed, 5 Feb 2014 21:55:07 +0200 Juha Manninen wrote: > >> Can we hope to someday get the feature that Lazarus adds the unit where a type/function/whatever is defined automatically to the uses clause when it is used for the first time (just like Eclipse does for Java imports)? > > > > Please define "automatically". Available types (Java standard, user defined or belonging to 'libs' in your class path) are shown in the code completion popup, also the package name where this type is defined. When choosing a type the corresponding import is added to your code.

Can you give an example how this should work in Lazarus?

Mattias

Reply by email

Sven Barth
to Flávio Etrusco: FWIW if you get an "identifier not found" error while compiling, the context menu in the…
Fl?vio Etrusco wrote 12 lines
On Wed, Feb 5, 2014 at 4:50 PM, Reimar Grabowski wrote: > On Wed, 5 Feb 2014 12:25:18 +0100 > Mattias Gaertner wrote: > > Can we hope to someday get the feature that Lazarus adds the unit where a type/function/whatever is defined automatically to the uses clause when it is used for the first time (just like Eclipse does for Java imports)? > > R. FWIW if you get an "identifier not found" error while compiling, the context menu in the Message View has a "Search identifier" command. It opens the Code Browser (which also could be much cleaner) and searches the class. Then you can open the context menu for the unit found and select "Use unit FOO in unit BAR".

In 1.0.12 you need to switch from "Project" to "Lazarus-IDE" to have it find e.g. "TObjectList". In 1.3 this works without the switch. Does someone know whether this is the case in 1.2 as well?

And is it by intension that one needs to select a node before the correct context menu is shown? (win32) E.g. doing a right click on the "type TObjectList = class(TList)" node without having selected any node shows the menu containing solely the various expand/collapse menu items (and the export entry).

Regards,
Sven

Reply by email

Flávio Etrusco
to Sven Barth
Sven Barth wrote 22 lines
Am 05.02.2014 23:24, schrieb Fl?vio Etrusco: > On Wed, Feb 5, 2014 at 4:50 PM, Reimar Grabowski wrote: >> >> On Wed, 5 Feb 2014 12:25:18 +0100 >> Mattias Gaertner wrote: >> >> Can we hope to someday get the feature that Lazarus adds the unit where a >> type/function/whatever is defined automatically to the uses clause when it >> is used for the first time (just like Eclipse does for Java imports)? >> >> R. > > FWIW if you get an "identifier not found" error while compiling, the > context menu in the Message View has a "Search identifier" command. It > opens the Code Browser (which also could be much cleaner) and searches > the class. Then you can open the context menu for the unit found and > select "Use unit FOO in unit BAR". In 1.0.12 you need to switch from "Project" to "Lazarus-IDE" to have it find e.g. "TObjectList". In 1.3 this works without the switch. Does someone know whether this is the case in 1.2 as well?

In 1.2RC2 it works correctly ("Project" is selected and "With required packages" is checked).

Show quoted text 5 lines
And is it by intension that one needs to select a node before the correct context menu is shown? (win32) E.g. doing a right click on the "type TObjectList = class(TList)" node without having selected any node shows the menu containing solely the various expand/collapse menu items (and the export entry).

Yeah, we definitely should enable eoRightClickSelect there. Not to mention some other way cleaner dialog (or switchable tweaks in CB), or better yet (as others already said), inline marking with smarts in the codetools parser ;-) And indexing.

Regards, Sven

Best regards,
Fl?vio

Reply by email

Flávio Etrusco
to Flávio Etrusco
Fl?vio Etrusco wrote 16 lines
On Thu, Feb 6, 2014 at 6:04 AM, Sven Barth wrote: > Am 05.02.2014 23:24, schrieb Fl?vio Etrusco: >> >> FWIW if you get an "identifier not found" error while compiling, the >> context menu in the Message View has a "Search identifier" command. It >> opens the Code Browser (which also could be much cleaner) and searches >> the class. Then you can open the context menu for the unit found and >> select "Use unit FOO in unit BAR". > > And is it by intension that one needs to select a node before the correct > context menu is shown? (win32) E.g. doing a right click on the "type > TObjectList = class(TList)" node without having selected any node shows the > menu containing solely the various expand/collapse menu items (and the > export entry). Yeah, we definitely should enable eoRightClickSelect there.

(And should it be the default for the component, if not for compatibility :-/ ) As long as we are at it, may I ask to reset the progress bar after the search is completed? :) Thanks.

Best regards,
Fl?vio

Reply by email

Mattias Gaertner
to Sven Barth: In 1.0.12 you need to switch from "Project" to "Lazarus-IDE" to have it find e.g.…
Show quoted text 6 lines
[...] And is it by intension that one needs to select a node before the correct context menu is shown? (win32) E.g. doing a right click on the "type TObjectList = class(TList)" node without having selected any node shows the menu containing solely the various expand/collapse menu items (and the export entry).

right clicks select is now enabled.

Mattias

Reply by email

Sven Barth
to Mattias Gaertner: On Thu, 06 Feb 2014 09:04:10 +0100 right clicks select is now enabled. Mattias
Mattias Gaertner wrote 11 lines
On Thu, 06 Feb 2014 09:04:10 +0100 Sven Barth wrote: > [...] > And is it by intension that one needs to select a node before the > correct context menu is shown? (win32) E.g. doing a right click on the > "type TObjectList = class(TList)" node without having selected any node > shows the menu containing solely the various expand/collapse menu items > (and the export entry). right clicks select is now enabled.

Great :)

Regards,
Sven

Reply by email

Marco van de Voort
to Mattias Gaertner: On Wed, 05 Feb 2014 09:03:32 +0100 (For those that can read The above message is now…
Mattias Gaertner wrote 8 lines
> Are there any ideas for improving this situation for people that know > that there is an identifier in the RTL, FCL, whatever, but don't know > which unit it resides in? E.g. Lazarus did scan the FPC sources, > couldn't it keep an identifier->unit index? It only scanned the directories for file names. This alone can take minutes on slow disks/networks. There are currently two identifier->unit indices.

You could also try to lookup in CHM index. Lookup symbol, and then parse path of the html to get the unit (due to fpdoc structure)

Since the CHM indices are already sorted, this should be doable quickly after the initial decompression.

Reply by email

Graeme Geldenhuys
to Sven Barth: Hello together! On the German Delphi-Forum Delphi-PRAXiS there was the question in which…
Sven Barth wrote
Are there any ideas for improving this situation for people that know that there is an identifier in the RTL, FCL, whatever, but don't know which unit it resides in?

Yes, simply use DocView and make sure you specified a help directory where INF help files are located, or concatenate the RTL, FCL and LCL inf help files as a command line parameter. DocView searches are instant, so don't worry about speed by concatenating help files.

For DocView integration in Lazarus IDE (no need for a IDE recompile) follow this link.

http://fpgui.sourceforge.net/docview_ide_integration.shtml

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/

Reply by email

Michael Schnell
to Graeme Geldenhuys
Graeme Geldenhuys wrote
Yes, simply use DocView ...

Been there. Loved it.

But I never was able to generate the files for DocView from the current revisions of the SVNs.

(Here, multiple files are necessary (language definition,. RTL, LCL, "Help on Help" .... you name it. )

- Michael

Reply by email

Graeme Geldenhuys
to Michael Schnell
Michael Schnell wrote
But I never was able to generate the files for DocView from the current revisions of the SVNs.

Last time I tried (a couple months back) the LCL docs wasn't in a state that could be built - or it was a fpdoc bug not yet resolve. I'll update to the latest and see if things are better now. They should be.

(Here, multiple files are necessary (language definition,. RTL, LCL, "Help on Help" .... you name it. )

Simply run:

docview <file1>+<file2+<file_n>
or
docview <path_to_INF_docs>
or
docview <ENV_variable_of_path_or_files>

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/

Reply by email

Michael Schnell
to Graeme Geldenhuys
Graeme Geldenhuys wrote 7 lines
Simply run: docview <file1>+<file2+<file_n> or docview <path_to_INF_docs> or docview <ENV_variable_of_path_or_files>

I was trying o use Docview integrated in in the Lazarus IDE. This is fact worked rather nicely with multiple files. I seem to remember that there were some issues (AFAIR, you intended to solve some of them :-) )

-Michael

Reply by email

Marco van de Voort
to Graeme Geldenhuys: Last time I tried (a couple months back) the LCL docs wasn't in a state that could be…
Graeme Geldenhuys wrote 6 lines
> But I never was able to generate the files for DocView from the current > revisions of the SVNs. Last time I tried (a couple months back) the LCL docs wasn't in a state that could be built - or it was a fpdoc bug not yet resolve. I'll update to the latest and see if things are better now. They should be.

I routinely build lcl.chm a couple a times an year, but usually have to run the script to generate some XML files because the LCL build scripts use wildcards to generate the fpdoc cmdline.

IOW, new pas files without docs break the build out of the box.

Reply by email