Tracking the line and column number

21 views
Skip to first unread message

Jesse Sightler

unread,
Mar 25, 2015, 8:23:22 PM3/25/15
to streamfly...@googlegroups.com
My code currently looks like this (also available here[1]):


ModificationFactory modFactory = new ModificationFactory(minimumLengthOfLookBehind, newNumberOfChars);
this.factory = new LineColumnAwareModificationFactory(modFactory);
this.matchProcessor = matchProcessor;
this.matcher = matcher;
this.newNumberOfChars = newNumberOfChars;

 
My issue is that factory.getLineNumber() and factory.getCurrentColumn() do not appear to be a usable way to find the current position of the match within the stream.

As you can see, I had a rather "creative" set of workarounds for this, but they only appear to work in a narrow set of circumstances. :)

Is what I am trying to do feasible? Do you have any guidance on accomplishing this task?

Thanks,
Jess


[1] https://github.com/windup/windup/blob/master/rules-base/api/src/main/java/org/jboss/windup/rules/files/condition/regex/StreamRegexMatcher.java

rw...@gmx.de

unread,
Mar 26, 2015, 12:08:04 PM3/26/15
to streamfly...@googlegroups.com
Hi Jess,

unfortunately, the comment for the parameter firstModifiableCharacterInBuffer in method Match.process() was wrong. The value for firstModifiableCharacterInBuffer must be fetched from somewhere else. Therefore, your code could not work. Sorry!

I just added a working example in the support module. Have a look at the latest source code version and let me know whether the code works for you.

Cheers
Rod
 

Jesse Sightler

unread,
Mar 26, 2015, 7:03:30 PM3/26/15
to streamfly...@googlegroups.com
Hi Rod,

Thank you for getting back to me. This does appear to improve things quite a bit, however, there still seems to be an error. Perhaps this is just an off by one error?

I have sent a PR with the issue highlighted here:
https://github.com/rwitzel/streamflyer/pull/4

Thanks,
Jess


--
You received this message because you are subscribed to the Google Groups "streamflyer-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to streamflyer-dis...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

rw...@gmx.de

unread,
Mar 27, 2015, 5:43:37 AM3/27/15
to streamfly...@googlegroups.com
Thank you, Jess. I will have a look on it but at the moment I cannot use GitHub due to the DDoS they are facing ( https://status.github.com/messages ).

rw...@gmx.de

unread,
Mar 27, 2015, 12:02:42 PM3/27/15
to streamfly...@googlegroups.com
I modified the example in the support module a bit. It looks as your problem had nothing to do with Streamflyer itself but rather with the correct way to find the position of a substring in a string.

Best Regards
Rod


On Friday, 27 March 2015 00:03:30 UTC+1, Jesse Sightler wrote:

Jesse Sightler

unread,
Mar 27, 2015, 1:19:57 PM3/27/15
to streamfly...@googlegroups.com
Hi Rod,

Thanks, and I agree that it is likely all of our problems are in the line/column calculation. Unfortunately this seems to be quite hard. I have updated our code with your approach and it mostly works. I still see of a few off by one errors on the column # in some tests, but I'm not sure how practical it is to work around that.

Thanks for your help!

--

rw...@gmx.de

unread,
Mar 28, 2015, 10:19:31 AM3/28/15
to streamfly...@googlegroups.com
Hi Jess,

I have just created an issue to make the tool you need part of the Streamflyer core: https://github.com/rwitzel/streamflyer/issues/6

In case you managed to find a solution, let us know. And it would be great if you could share more failing tests.

Thank you, Jess. Enjoy the weekend!


On Friday, 27 March 2015 18:19:57 UTC+1, Jesse Sightler wrote:
Hi Rod,

Thanks, and I agree that it is likely all of our problems are in the line/column calculation. Unfortunately this seems to be quite hard. I have updated our code with your approach and it mostly works. I still see of a few off by one errors on the column # in some tests, but I'm not sure how practical it is to work around that.

Thanks for your help!

Jesse Sightler

unread,
Mar 30, 2015, 3:24:54 PM3/30/15
to streamfly...@googlegroups.com
Hi Rod,

It turns out that I was incorrect. The column numbers are correct in my other test cases as well. It looks like your latest version works just fine!

Thanks for all your help with this!

Message has been deleted

rw...@gmx.de

unread,
Mar 31, 2015, 3:50:11 AM3/31/15
to streamfly...@googlegroups.com
Thank you for your feedback, Jess! I updated the description of the issue so that everybody knows they can rely on the code in the support module as long as it is not part of the core module yet.

Cheers
Rod

On Monday, 30 March 2015 21:24:54 UTC+2, Jesse Sightler wrote:
Hi Rod,

It turns out that I was incorrect. The column numbers are correct in my other test cases as well. It looks like your latest version works just fine!

Reply all
Reply to author
Forward
0 new messages