fcl-passrc: in which line a TPasElement ends?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

fcl-passrc: in which line a TPasElement ends?

Michael Fuchs-5
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
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: fcl-passrc: in which line a TPasElement ends?

Michael Van Canneyt


On Fri, 3 Nov 2017, Michael Fuchs wrote:

> 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.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: fcl-passrc: in which line a TPasElement ends?

Michael Fuchs-5
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.


> 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
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: fcl-passrc: in which line a TPasElement ends?

Michael Van Canneyt


On Fri, 3 Nov 2017, Michael Fuchs wrote:

> 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.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: fcl-passrc: in which line a TPasElement ends?

Michael Fuchs-6
Am 03.11.2017 um 15:31 schrieb Michael Van Canneyt:
> 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

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

endlinenumber.diff (1K) Download Attachment