[Lazarus] CodeTools: what is an "identifier"

Bernd Kreuss prof7bit at googlemail.com
Wed Jul 28 23:26:47 CEST 2010


[sending this a second time because I got a strange error from the list
server]

Mattias Gaertner wrote:

> I didn't test the code much.
> I just saw that codebrowser stores file positions, not clean positions.
> Makes sense.
> I fixed GetCodeHelp.

Ok, It works now. BTW: The explanation about the codetools in the wiki
is already quite helpful, I don't know why I didn't find this text
earlier, It would have saved me some time.

The GetCodeHelp() function is now working as expected but I discovered
something else and this is currently also visible in the code editor in
the svn version:

consider the following small program:

program foo;

type
  TAnswer = Integer; // represents an answer

var
  Answer : TAnswer; // in this global variable we store the answer

{call this to find the answer for everything}
procedure FindAnswer;
begin
  Answer := 42;
end;

begin
  FindAnswer;
  Writeln(Answer);
end.

if you have lazarus running from the console so that you can see the
debug messages and move the mouse around in the above program over the
various occurrences of the identifiers you will observe that whenever
you are over the *declaration* it will raise (and gracefully catch) an
exception and at the same time the hint window will miss the part for
chhoSmartHint (the part with full declaration, filename and line/column)
and only show the comment help (and fpdoc if available).

If you move the mouse over the actual usage of these names then it will
show all 3 parts of the hint and not throw the exception. The Exception
happens somewhere deep within TFindDeclarationTool.FindSmartHint() or
.FindDeclaration() and is probably because it is already sitting at the
declaration and cant find a declaration for the declaration itself.

This impacts the use in the CodeBrowser since we point them all directly
at the declarations and so it will never give a smarthint and cannot
fully replace the old default hint from the code browser. I'm sure this
is only a little forgotten IF ELSE somewhere in FindSmartHint() that
would do the trick but I can't easily find the spot where (how) to do this.

Bernd






More information about the Lazarus mailing list