sqlparse icon indicating copy to clipboard operation
sqlparse copied to clipboard

Track positions of tokens

Open sjoerdjob opened this issue 8 years ago • 8 comments

In some cases (error reporting, syntax highlighting), it might be desired to know the location of the tokens w.r.t. the original input.

sjoerdjob avatar Jun 13 '16 19:06 sjoerdjob

Coverage Status

Coverage decreased (-0.06%) to 93.333% when pulling 3514252c5be9d7c6ada40784c5ba196299b722b4 on sjoerdjob:track_positions into 2936f9756aaea2e0f5b4cbb578a25c4fe07bcdf1 on andialbrecht:master.

coveralls avatar Jun 13 '16 19:06 coveralls

would it be simpler to build the token during the lexing process and assign the row/col values then? then you are only yielding/refering 1 object instead of 4 related ones

vmuriart avatar Jun 14 '16 04:06 vmuriart

Yes. That would be a lot simpler. I was just trying to keep the diff as simple as possible.

sjoerdjob avatar Jun 14 '16 04:06 sjoerdjob

I was going to change into that behavior in the near future. Unless there is any particular reason not to, I think it would be better to go ahead with it. But you are correct, it would increase the diff since there would be changes needed in other section of the code simply for that change.

We can always go back and do it later though. Haven't fully reviewed this code yet.

vmuriart avatar Jun 14 '16 04:06 vmuriart

Yes, going ahead with moving to tokens earlier would be a wise move. It's a bit confusing when it's uncertain if you're iterating over tuples or over Tokens.

sjoerdjob avatar Jun 14 '16 05:06 sjoerdjob

Haven't forgotten about this. I'll merge it in after the 0.2.0 release.

vmuriart avatar Jun 15 '16 01:06 vmuriart

Hi! Any update on this? I'd want to use the feature of line:col.

I see that there is a merge conflict here. If there is no developer to update the patch, I can try.

segoon avatar Apr 28 '22 08:04 segoon

@segoon : I myself no longer have any interest in carrying this patch forward, so you're free to continue where this left off.

sjoerdjob avatar Jun 04 '22 21:06 sjoerdjob