|
|
Re: Incremental updates on editor models [message #1836306 is a reply to message #1836290] |
Mon, 28 December 2020 19:48   |
Ed Willink Messages: 7597 Registered: July 2009 |
Senior Member |
|
|
Hi
The Xtext semantic model that you see is updated from the node model and you are instructed to expect that the semantic model is regenerated between IUnitOfWork accesses, however in practice unchanged parts are often re-used. This gets you closer to being able to use EMF change tracking, But...
If you run your incremental update analysis very frequently you may have only one editor action to synchronize using some form of semantic identity to correlate old and new. But this will make the editor unacceptably sluggish since the user will have to drop their typing speed. And some actions such as quick fixes / pastes may involve substantial chnages. Worse, considering Java, if the user is adding a for(){} loop and makes a mess of the punctuation the editor may spend a significant time struggling to make sense of the {} mismatches. (It would be much better if the editor partitioned the source text into a hierarchy of {} delimited sections, and avoided detailed parse while the sectioning is bad. Once good, onlky changed sections need be reparsed, but it may be a bugger change.)
The node model and semantic model could be maintained incrementally, but one of the Xtext developers very sensibly observed that such a manually coded incremental conversion was just too hard. You would need a fundamentally incremental tool such as perhaps EMF-IncQuery today or QVTd tomorrow.
Comparison of models to determine incremental changes is really hard and explains why two different Eclipse projects EMF Compare and EMF Diff/Merge offer contrasting approaches, neither of which may be suitable for a model for which you have significant domain insight.
And even when you can compare what is a change? Consider the Java
int before[] = new int[]{1,2,3};
long after[] = new long[]{2,3,1};
Is it a total delete / create? Is it a retype+rename+(a 3 value recreate or a 2-value rotate plus 1-valuedelete/add)?
Or just consider the GIT Merge panes. Sometimes they're pretty good, but other times particularly if you reorder some functions they are very disappointing.
Once you have decided what you want to treat as a change, you can design a per semantic model element semantic identity computation that maximizes the equality for semantically unchanged elements and then allows you to start to decide whether unmatched elements are create/delete or evolve.
(For different reasons Eclipse OCL has a LUSSID class (Locally Unique Semantically Sensitive ID) that enables compact stable xmi:ids to be auto-generated. This might give you some ideas wrt hierarchical computations but it treats a hierarchical name change as delete/create - no evolution.)
Regards
Ed Willink
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02194 seconds