platform text: DSL model/document reconciling [message #329321] |
Wed, 18 June 2008 14:41  |
Eclipse User |
|
|
|
My editor for a DSL maintains a DOM that is updated by a MonoReconciler
with my own reconciling strategy to reparse the document. Frequently the
DOM is out of date while the user is editing. My problem is that my
content assist processing relies on it to be up to date, and I can't see
how best to achieve this. As it is, if the user types fast and hits
ctrl-space the reconciler either doesn't get started because of its 500ms
delay, or it hasn't yet finished reconciling. I can imagine also that
refactoring would want to work with an up-to-date model.
What is the best way for me to get my content assist processor to wait
until the model is in sync with the document? I see that buried within
AbstractReconciler.BackgroundThread is a method suspendCallerWhileDirty()
which would be really handy, but the fact that it isn't exposed through
API makes me wonder if my thinking is somehow wrong.
I've considered having each DOM node maintain its offset and length in a
Position so that the document will at least automatically adjust all the
DOM nodes to reflect document changes. But this seems heavy weight and
still doesn't really sync the model - it merely reduces the harm of being
out of sync.
In order to save memory, my DOM doesn't actually store within it the
textual content of leaf nodes, so it isn't independent of the document.
I'm beginning to think this was a mistake - that I should make it
independent so that at least I can still have a consistent complete DOM
even after the document has changed. Just for the sake of
content-assistance this seems overkill, though, and for refactoring it
seems insufficient given that whitespace might still be important during
refactoring and it really seems overkill to capture whitespace in DOM
nodes.
So all that brings me back to just wanting the content-assist
processor(and whatever would be reponsible for refactoring) to be able to
ask the reconciler simply to finish up any outstanding reconciling and
wait for that to complete before creating any completion proposals. I
could get this by copying the code from the default reconcilers and
exposing the functionality I need, but the Java editor and Ant editors
don't seem to need to do this.
I feel like I must be missing some obvious simple solution. Is there
anyone who can point me in the right direction?
Thanks,
Ian Graham
|
|
|
Re: platform text: DSL model/document reconciling [message #329350 is a reply to message #329321] |
Fri, 20 June 2008 05:59  |
Eclipse User |
|
|
|
Ian Graham wrote:
> My editor for a DSL maintains a DOM that is updated by a
> MonoReconciler with my own reconciling strategy to reparse the
> document. Frequently the DOM is out of date while the user is
> editing. My problem is that my content assist processing relies on it
> to be up to date, and I can't see how best to achieve this. As it is,
> if the user types fast and hits ctrl-space the reconciler either
> doesn't get started because of its 500ms delay, or it hasn't yet
> finished reconciling. I can imagine also that refactoring would want
> to work with an up-to-date model.
>
> What is the best way for me to get my content assist processor to wait
> until the model is in sync with the document? I see that buried
> within AbstractReconciler.BackgroundThread is a method
> suspendCallerWhileDirty() which would be really handy, but the fact
> that it isn't exposed through API makes me wonder if my thinking is
> somehow wrong.
>
> I've considered having each DOM node maintain its offset and length in
> a Position so that the document will at least automatically adjust all
> the DOM nodes to reflect document changes. But this seems heavy
> weight and still doesn't really sync the model - it merely reduces the
> harm of being out of sync.
>
> In order to save memory, my DOM doesn't actually store within it the
> textual content of leaf nodes, so it isn't independent of the
> document. I'm beginning to think this was a mistake - that I should
> make it independent so that at least I can still have a consistent
> complete DOM even after the document has changed. Just for the sake
> of content-assistance this seems overkill, though, and for refactoring
> it seems insufficient given that whitespace might still be important
> during refactoring and it really seems overkill to capture whitespace
> in DOM nodes.
>
> So all that brings me back to just wanting the content-assist
> processor(and whatever would be reponsible for refactoring) to be able
> to ask the reconciler simply to finish up any outstanding reconciling
> and wait for that to complete before creating any completion
> proposals. I could get this by copying the code from the default
> reconcilers and exposing the functionality I need, but the Java editor
> and Ant editors don't seem to need to do this.
>
> I feel like I must be missing some obvious simple solution. Is there
> anyone who can point me in the right direction?
Hi Ian,
if your content assist needs the full model update and DOM then you're
basically doomed because each time the user invokes code assist he will
have to wait for the DOM to be computed and invoking code assist happens
almost as frequently than just typing. If possible you should rework
your code so that code assist can be computed using a faster parser
based solution i.e. make it independent of reconciling the mode.
Dani
>
> Thanks,
> Ian Graham
|
|
|
Powered by
FUDForum. Page generated in 0.02579 seconds