[Lazarus] How to get superuser rights

KrisztiƔn Nagy nkrisztian89 at gmail.com
Wed Jul 28 02:02:08 CEST 2010


On Tue, 27 Jul 2010 12:48:02 +0200
Bernd Kreuss <prof7bit at googlemail.com> wrote:

> Hi,
> 
> I am just playing around with the CodeTools and have the following:
> 
> >         P := node.CodePos.P;
> >         Tool := TStandardCodeTool(CodeToolBoss.GetCodeToolForSource(node.CodePos.Code, false, false));

That should be

Tool :=
TStandardCodeTool(CodeToolBoss.GetCodeToolForSource(node.CodePos.Code,
true, false));
if Tool=nil then exit;


> >         debugln(['identifier: ', Tool.ExtractIdentifier(P)]);
> 
> where node.CodePos.Code is the code of a unit and P is the starting
> position of something like
> 
> function foo(foobar: TSomething): TSomethingElse;
> 
> Tool.ExtractIdentifier() will now return the string "function". Isn't
> function a reserved word and not an Identifier? What is the codetool's
> understanding of an identifier and how do I search for the identifier?

An "identifier" is simply a valid pascal identifier (starting
with a letter, followed by some letters and numbers).
A 'keyword' is context sensitive. 
For example when doing identifier completion the following 'function'
is an identifier:

i:=function|

 
> The end result I am trying to achieve is to point it to somewhere and
> then have it return the *position* of the next Identifier (not just the
> next word). I know that ExtractIdentifier() won't help me with the
> position but I am just in the phase of some initial experimenting with
> it and it makes me wonder what the codetool's understanding of an
> "identifier" is and how to tell it that i am interested in the
> identifier of the declaration and not just the next word in the code.

I wrote an example in codebrowser.pas:
function TCodeBrowserView.GetCodeHelp

Mattias




More information about the Lazarus mailing list