Skip to content
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

Merged
merged 1 commit into from
May 31, 2022

Conversation

sebthom
Copy link
Member

@sebthom sebthom commented May 24, 2022

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.

Copy link
Contributor

@mickaelistria mickaelistria left a 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() {
Copy link
Contributor

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() {
Copy link
Contributor

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.

Copy link
Member Author

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?

Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Contributor

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.

@angelozerr
Copy link
Contributor

What about isDirty?

@sebthom sebthom marked this pull request as draft May 24, 2022 21:39
@sebthom sebthom force-pushed the patch-10 branch 2 times, most recently from a24b19f to 8bd9c51 Compare May 30, 2022 20:49
@sebthom
Copy link
Member Author

sebthom commented May 30, 2022

I decided not to change the name of ModelLine.isInvalid to anything else for now. However now I also did some changes to the org.eclipse.tm4e.ui.internal.model to reduce the number of reparsings and thus editor refreshes/repaintings to 1 on multi-line edits. Until now for each multi-line change two separate line invalidation events were send to the Tokenizer thread. This should speed up working on larger documents.

@sebthom sebthom marked this pull request as ready for review May 30, 2022 20:58
@sebthom sebthom changed the title Refactor TMModel line token update Refactor TMModel line token update and DocumentModelLines May 30, 2022
@mickaelistria
Copy link
Contributor

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.

@sebthom sebthom merged commit 3276cde into eclipse-tm4e:master May 31, 2022
@sebthom sebthom deleted the patch-10 branch May 31, 2022 10:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants