Closed anderskaplan closed 1 year ago
@pbodnar Please disregard the test coverage check, it's a false alarm caused by deleting one line of "tested" code.
Another thought: What about instead of replacing the existing anchor/reset methods making them stacked (a simple list would probably suffice for the stored anchors)? Would that make sense to you?
Also, we should expect that some could use the existing methods in their custom tokens, so that is another reason for not removing them right away.
Another thought: What about instead of replacing the existing anchor/reset methods making them stacked (a simple list would probably suffice for the stored anchors)? Would that make sense to you?
Yes, I did consider that option, I even tried implementing it :) However, that option assumes that a push is always followed by a pop, and that is not the case here. Sure, one could force the calling code to clean up (i.e. pop) after itself, but that becomes more complex and error prone than just letting the calling code keep track of the stored position.
Also, we should expect that some could use the existing methods in their custom tokens, so that is another reason for not removing them right away.
It could happen, but I'd guess that the risk is rather small. Imho this is one of those band-aids that just need to be pulled. We could keep the anchor/reset methods for now, though, and mark them as deprecated. Which do you prefer?
Another thought: What about instead of replacing the existing anchor/reset methods making them stacked (a simple list would probably suffice for the stored anchors)? Would that make sense to you?
Yes, I did consider that option, I even tried implementing it :) However, that option assumes that a push is always followed by a pop, and that is not the case here. Sure, one could force the calling code to clean up (i.e. pop) after itself, but that becomes more complex and error prone than just letting the calling code keep track of the stored position.
OK, I would expect that push and pop would by always stacked (nested). But anyway yes, it is definitely easier this way, even if we need to introduce a new variable (anchor
) in every such block.
Also, we should expect that some could use the existing methods in their custom tokens, so that is another reason for not removing them right away.
It could happen, but I'd guess that the risk is rather small. Imho this is one of those band-aids that just need to be pulled. We could keep the anchor/reset methods for now, though, and mark them as deprecated. Which do you prefer?
I prefer to keep them and mark them as deprecated, please. :)
Issue found during implementation of #166, when checking for the start of
Table
tokens.When checking if a table starts on a line, one needs to scan multiple lines without consuming any content. The way to do this is with the anchor/reset methods on the
FileWrapper
class. However, this breaks the parsing ofList
tokens, because these also use anchor/reset, and the anchor set byList
gets overwritten by the one set inTable
.The proposed solution is to not store the anchor position on the
FileWrapper
, but instead move that responsibility to the parsing method. This way, recursive parsing can hold multiple anchors at the same time, without any interference.