add javadoc to Cursor#add and Cursor#addEol - #76
Conversation
| } | ||
|
|
||
| /** | ||
| * Inserts a token at the current position, pushing the current token (if any) forwards. |
There was a problem hiding this comment.
I understand why you might describe it this way but I prefer not to mention any "pushing". Perhaps change to:
Inserts a token at the current position which causes the cursor to advance by one (the cursor state remains as it was before, if it was at the end it will still be at the end. If it pointed to a token it will still point to that same token)
There was a problem hiding this comment.
I've had a look at the javadoc for java.util.List#add(int, T):
[...] Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).
How about that something like that?
|
Hi @quintesse, (Note: I do think it's important to mention that the current token is moved/shifted/pushed, because that was the primary point of confusion I had with this method initially) |
|
I'll accept, even though tokens don't actually have indices, so they won't actually increment. But I understandf what you mean and given a technically exact message will probably only make it longer without making it clearer. Again thanks! |
|
Ah yes, that part of the code has changed slightly. Would you mind updating your PR so I can merge it? |
# Conflicts: # src/main/java/org/codejive/properties/Cursor.java
|
Done :)
I don't understand. To me it seems they clearly do? public class Cursor {
private final List<PropertiesParser.Token> tokens; // <-- associates an index for each token
private void addToken(int index, PropertiesParser.Token token) {
if (hasToken(index)) {
tokens.add(index, token); // <-- increments the index of shifted tokens |
that's exactly the key here, it's But like I said, that distinction becomes very technical and explaining it in a way that is technically correct would probably mean having to make the text much longer and very likely not any clearer. (There is a reason why technical and legal texts are often long and boring 😄 ) |
|
Merged, thanks! |
|
tl;dr: I'll agree to disagree
I suspect this is a cultural/linguistical disagreement rather than a technical one. Importantly "has" != "contains" I would argue
Element instances do not contain their index. To mirror your wording: if you look inside the Class definitions for any element instance stored in a List, you won't find the index that the |
The current behaviour of
addis not intuitive and warrants documentation.