-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor TMModel line token update and DocumentModelLines #403
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have much knowledge to judge this change but trust it is good ;)
I just did add an minor comment about the new method, but this is not a blocker.
public boolean isValid() { | ||
return !isInvalid; | ||
} | ||
|
||
public boolean isInvalid() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we remove isInvalid
then?
@@ -36,6 +36,10 @@ public List<TMToken> getTokens() { | |||
return tokens; | |||
} | |||
|
|||
public boolean isValid() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually don't like much the name isValid
here. Indeed, in such an approach, being "invalid" is semantically precise as "state is not ready", it's actually not the opposite of valid. So if we can avoid adding this method, I think it keeps things clearer for consumers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also thought about this. I think what invalid means is that the contained information is out of date / out of sync with the actual line in the editor. So we could change it to something like isOutdated / isSynced / isUpToDate, etc. any preference?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already have isInvalid()
which is pretty explicit. Do we need a negated variant at all? If yes, then I thing isUpToDate
is the closest meaning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no hard feelings for either getter. I can remove one. I just found line.isValid()
nicer to use than having to use !line.isInvalid()
which is a double negation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our software world abuse the "invalid" term so it's not really a negation but a precise description of an actual state unlike "valid" ;) But I'm totally fine with @angelozerr suggestion of renaming isInvalid
to isDirty
if it helps.
My only concern is more that I don't like isValid
.
What about isDirty? |
a24b19f
to
8bd9c51
Compare
I decided not to change the name of |
To be honest, I'm now much less familiar with this code than you are. I had a quick look at the general change here and think it's indeed a good one; so if you're confident enough with it and since tests are passing, feel free to merge. |
I refactored/simplified the way the TMModel handles line updates. Still seems to work as expected while needing less LoCs and I believe being easier to follow. Also it now makes use of the new Grammar's timeLimit feature.
Since this is a substantial change of the current logic. It would be great if you could also try it out before merging.