Sign in Join

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

Mailing lists / fpc-pascal / 2017-11

fcl-passrc: in which line a TPasElement ends?

5 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

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

Michael Fuchs

Hi,

a question to TPasElement of fcl-passrc:

To get the line in which the element starts I use the public SourceLinenumber field. But how do I get the last line of this element?

g
Michael

Michael Van Canneyt
to Michael Fuchs
Michael Fuchs wrote 6 lines
Hi, a question to TPasElement of fcl-passrc: To get the line in which the element starts I use the public SourceLinenumber field. But how do I get the last line of this element?

Currently this is not supported.

Michael.

Michael Fuchs
to Michael Van Canneyt

Sorry, some message were not sent to list, my fault:

Michael Van Canneyt wrote 5 lines
> Are there plans for a support in future? Or can you give me some > advices how I can implement this by myself? I'm afraid I am an > absolutly newbie in this part of of the FCL.> There are no plans to support this. I can't even imagine what you would need this for ?

I try to write a small tool for code analysis. I need for example to discover the line length of methods.

Show quoted text 7 lines
To implement this, you would need to heavily modify one of procedure TPasParser.ParseDeclarations(Declarations: TPasDeclarations); or function ParseType(Parent: TPasElement; const NamePos: TPasSourcePos; const TypeName: String = ''; Full: Boolean = false; GenericArgs: TFPList = nil): TPasType; depending on what you need

g
Michael

Michael Van Canneyt
to Michael Fuchs
Michael Fuchs wrote 12 lines
Sorry, some message were not sent to list, my fault: Am 03.11.2017 um 14:132 schrieb Michael Van Canneyt: >> Are there plans for a support in future? Or can you give me some >> advices how I can implement this by myself? I'm afraid I am an >> absolutly newbie in this part of of the FCL.> > There are no plans to support this. I can't even imagine what you > would need this for ? I try to write a small tool for code analysis. I need for example to discover the line length of methods.

In this case, you can probably simply use

TPasTreeContainer.FinishScope

to record the end of the method.

Michael.

Michael Fuchs
to Michael Van Canneyt
Michael Van Canneyt wrote
In this case, you can probably simply use TPasTreeContainer.FinishScope to record the end of the method.

Great, this is easy. I have created (and attached) a patch to add a SourceEndLinenummer for all elements.
Maybe it is useful for others or even for the trunk.

Thanks for the help.
Michael