Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Spell checking for custom construct - DocumentPartitioner is confused
Spell checking for custom construct - DocumentPartitioner is confused [message #895957] Mon, 16 July 2012 16:15 Go to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
Hi,

after happily migrating to Xtext 2.3 and enjoying the compatibility with Eclipse 3.7.2 I added support for spell checking into my tool.

Since I need spellchecking for a custom syntax element (none of the predefined COMMENT rules) I had to apply some tweaks which now cause the DocumentPartitioner to log this error
ERROR org.eclipse.xtext.ui.editor.model.DocumentPartitioner  - Detected unexpected state in document partitioner. Please file a bug with the following information attached:
Document content after the event was applied:
>>> content of my file
<<<
Document event: offset: 375, length: 1, timestamp: 3
text:><


Is this a bug in xtext or is that caused by one of my customizations?
Basically I did 3 things:

1. write and bind my own AntlrTokenToAttributeIdMapper, copied mainly from DefaultAntlrTokenToAttributeIdMapper and adding my elements to calculateId()

2. let the same class implement ITokenTypeToPartitionTypeMapper and bind it for this type, too.
-- getPartitionType() has the same implementation as TerminalsTokenTypeToPartitionMapper
-- getSupportedPartitionTypes() returns an array of only two elements: the id of the element where spell-checking should be supported and IDocument.DEFAULT_CONTENT_TYPE

3. write my own SpellingReconcileStrategy extends XtextSpellingReconcileStrategy and override shouldProcess()
-- bind this directly plus a factory that creates instances of it.

Effect:
- syntax highlighting for this element works OK
- spell checking works exactly as desired.
- error is logged as shown.

Should I worry? Should I file a bug? Should I change my customization (how?)?

cheers,
Stephan
Re: Spell checking for custom construct - DocumentPartitioner is confused [message #896432 is a reply to message #895957] Wed, 18 July 2012 11:42 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Stephan,

this is a diagnostic message that tries to identify a long standing bug
with dangling error markers in Xtext editors. We spotted some suspicious
code in the document partitioner and decided to log a messages as soon
as this code is executed. It was simply to late in the Juno train to
change that crucial component.
I'd say a ticket would be helpful but otherwise you may ignore the
logged error.

Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 16.07.12 18:15, schrieb Stephan Herrmann:
> Hi,
>
> after happily migrating to Xtext 2.3 and enjoying the compatibility with
> Eclipse 3.7.2 I added support for spell checking into my tool.
>
> Since I need spellchecking for a custom syntax element (none of the
> predefined COMMENT rules) I had to apply some tweaks which now cause the
> DocumentPartitioner to log this error
>
> ERROR org.eclipse.xtext.ui.editor.model.DocumentPartitioner - Detected
> unexpected state in document partitioner. Please file a bug with the
> following information attached:
> Document content after the event was applied:
>>>> content of my file
> <<<
> Document event: offset: 375, length: 1, timestamp: 3
> text:><
>
>
> Is this a bug in xtext or is that caused by one of my customizations?
> Basically I did 3 things:
>
> 1. write and bind my own AntlrTokenToAttributeIdMapper, copied mainly
> from DefaultAntlrTokenToAttributeIdMapper and adding my elements to
> calculateId()
>
> 2. let the same class implement ITokenTypeToPartitionTypeMapper and bind
> it for this type, too. -- getPartitionType() has the same implementation
> as TerminalsTokenTypeToPartitionMapper
> -- getSupportedPartitionTypes() returns an array of only two elements:
> the id of the element where spell-checking should be supported and
> IDocument.DEFAULT_CONTENT_TYPE
>
> 3. write my own SpellingReconcileStrategy extends
> XtextSpellingReconcileStrategy and override shouldProcess()
> -- bind this directly plus a factory that creates instances of it.
>
> Effect:
> - syntax highlighting for this element works OK
> - spell checking works exactly as desired.
> - error is logged as shown.
>
> Should I worry? Should I file a bug? Should I change my customization
> (how?)?
>
> cheers,
> Stephan
>
Re: Spell checking for custom construct - DocumentPartitioner is confused [message #897101 is a reply to message #896432] Sat, 21 July 2012 19:44 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
Sebastian Zarnekow wrote on Wed, 18 July 2012 13:42
...I'd say a ticket would be helpful ...



See https://bugs.eclipse.org/385667

During isolation of the bug I found
- a way to avoid the error
- that this was not directly connected to spell checking

cheers,
Stephan
Re: Spell checking for custom construct - DocumentPartitioner is confused [message #897189 is a reply to message #897101] Mon, 23 July 2012 06:13 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Thanks for the detailled bug report!

Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 21.07.12 21:44, schrieb Stephan Herrmann:
> Sebastian Zarnekow wrote on Wed, 18 July 2012 13:42
>> ...I'd say a ticket would be helpful ...
>
>
>
> See https://bugs.eclipse.org/385667
>
> During isolation of the bug I found
> - a way to avoid the error
> - that this was not directly connected to spell checking
>
> cheers,
> Stephan
Re: Spell checking for custom construct - DocumentPartitioner is confused [message #991073 is a reply to message #897189] Mon, 17 December 2012 09:56 Go to previous message
Charles Bonneau is currently offline Charles BonneauFriend
Messages: 32
Registered: February 2010
Location: Belgium
Member
Hello,
I encountered the same kind of error with a very simple test case.
My grammar start with a simple entry point:
Container:
	'Container' (id=STRING)? '{'
        [...]
	'}';

But when one guy from the test team entered :
Container "Hello World //without ending double quote and neither parenthesis

and hit the back space key, he got this error
org.eclipse.xtext.ui.editor.model.DocumentPartitioner  - Detected unexpected state in document partitioner. Please file a bug with the following information attached:
Document content after the event was applied:
>>>Container "Hello Worl<<<
Document event: offset: 21, length: 1, timestamp: 20
text:><

The test case is very tricky to reproduce mainly because by default the Xtext Editor automatically add the closing double quote (with both double quotes there is no Error Log entry).

I understand that I should ignore this issue and this is definitely not blocking, but I would like, at least, to hide it so the test team doesn't complain about it anymore.

Any advice/thoughts ?

Should I add my test case to the existing ticket ?

BR,

Charles Bonneau
Previous Topic:Scoping for variables
Next Topic:Handling of computed values in transient attributes in AST - your suggestions and experience please
Goto Forum:
  


Current Time: Fri Apr 19 00:34:11 GMT 2024

Powered by FUDForum. Page generated in 0.01976 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top