This project is read-only.

Getting line numbers for the nodes

Topics: Developer Forum
Mar 6, 2007 at 2:12 PM

I'm trying out your parser for use in a VS add-in. I have a question, though. Is there, currently, any good way to get the line number of a node (e.g. a field node or the first line of a namespace node)? I need to know where in the file I am after I have run the parser and I am traversing the nodes.
Mar 8, 2007 at 11:02 AM
Edited Mar 8, 2007 at 11:47 AM
I agree.

What do you think if i add the corresponding token in the node ?

( the token struct has two fields : the line and the column of his position )
Mar 8, 2007 at 8:49 PM
Ok, i did the implementation.

Now, each node has a new public field -> RelatedToken.

This is the token from which the node was created. The Token structur has the line and the column in the source code.

Maybe you will find some errors like a wrong line number or a wrong column number. In this case let know where :).

Mar 9, 2007 at 7:33 AM
Thank you. Great!
I will try the new feature out this weekend.
On another note, I saw that the latest source code imports a DotNetZen library, however it does not seem to be used anywhere. Is it just an old remain?
Mar 10, 2007 at 1:19 AM
It's a part of an ongoing development to create ToCodeDom functionality. The library adds access to abstractions over CodeDom that would otherwise take a long time to implement manually.