Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » How to force the editor to parse the entire editor content
How to force the editor to parse the entire editor content [message #1776163] Mon, 13 November 2017 10:21 Go to next message
Markus Holzem is currently offline Markus HolzemFriend
Messages: 7
Registered: November 2017
Junior Member
Hello,

I created a COBOL like syntax with Xtext. I got the syntax and an adapted lexer to handle COBOL's comment and numbering areas (column 1-6, 73-80) and the COBOL comment marker "*" on column 7. Everything is fine until I start to edit the file.

Taking the following COBOL code as an example:

      * Comment
        linkage section.
        01 parameter PIC X(20).
        procedure division using parameter.


When I start to edit e.g. the 3rd line the lexer receives only

01 parameter PIC X(20).
        procedure division using parameter.


to be parsed. After that the first few columns are interpreted as comments by my lexer and the highlighting is wrong. The reduced call seems to be used only to do the styling of the text in the editor. Afterwards a check is processed on the entire document for syntax checking.

Is there a possibility to force the editor parse the entire document instead of the part beginning with the modified line?

Kind regards,
Markus
Re: How to force the editor to parse the entire editor content [message #1776196 is a reply to message #1776163] Mon, 13 November 2017 15:44 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 12325
Registered: July 2009
Senior Member
Hi,
id have a look at org.eclipse.xtext.parser.impl.PartialParsingHelper.reparse(IParser, IParseResult, ReplaceRegion) respectively org.eclipse.xtext.parser.AbstractParser.reparse(IParseResult, ReplaceRegion)


Need professional support for Xtext, Xpand, EMF?
Go to: https://xtext.itemis.com
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Mon, 13 November 2017 15:44]

Report message to a moderator

Re: How to force the editor to parse the entire editor content [message #1776224 is a reply to message #1776196] Tue, 14 November 2017 06:58 Go to previous messageGo to next message
Markus Holzem is currently offline Markus HolzemFriend
Messages: 7
Registered: November 2017
Junior Member
Thanks for the hint, but unfortunately the process does not pass PartialParsingHelper.reparse.

While editing my stack trace looks like

Thread [main] (Suspended)	
	DocumentTokenSource.computeDamageRegion(DocumentEvent) line: 286	
	DocumentTokenSource.updateStructure(DocumentEvent) line: 249	
	XtextDocument.fireDocumentChanged(DocumentEvent) line: 700	
	XtextDocument(AbstractDocument).replace(int, int, String, long) line: 1102	
	XtextDocument(AbstractDocument).replace(int, int, String) line: 1120	
	ProjectionTextStore.replace(int, int, String) line: 103	
	ProjectionDocument(AbstractDocument).replace(int, int, String, long) line: 1095	
	ProjectionDocument(AbstractDocument).replace(int, int, String) line: 1120	
	ProjectionDocument.replace(int, int, String) line: 625	
	DefaultDocumentAdapter.replaceTextRange(int, int, String) line: 233	
	StyledText.modifyContent(Event, boolean) line: 7355	
	...


The DocumentEvent holds the XtextDocument and an offset starting at the position where I type in the editor.

I think I have to override org.eclipse.xtext.ui.editor.model.DocumentTokenSource.getRepairEntryData(DocumentEvent) to achieve what I want.

Markus

Re: How to force the editor to parse the entire editor content [message #1776226 is a reply to message #1776224] Tue, 14 November 2017 07:16 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 12325
Registered: July 2009
Senior Member
but where is the parser involved?

Need professional support for Xtext, Xpand, EMF?
Go to: https://xtext.itemis.com
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How to force the editor to parse the entire editor content [message #1776243 is a reply to message #1776226] Tue, 14 November 2017 11:51 Go to previous messageGo to next message
Markus Holzem is currently offline Markus HolzemFriend
Messages: 7
Registered: November 2017
Junior Member
The only place to get access to line and character position in line is the lexer.
The adapted lexer can be configured in the ???RuntimeModule class (overriding bindLexer, etc.)
The adapted lexer is accessed in DocumentTokenSource.getRepairEntryData using DocumentTokenSource.createTokenSource. This is where the string containing the document(part) is provided to the lexer.

On further investigation I found BacktrackingLexerDocumentTokenSource doing exactly what I need. But how do I provide an object of BacktrackingLexerDocumentTokenSource instead of DocumentTokenSource while XtextDocument is created?

I simply cannot find the piece of code where and how to define the binding. Could you help me there?

Markus
Re: How to force the editor to parse the entire editor content [message #1776250 is a reply to message #1776243] Tue, 14 November 2017 13:20 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 12325
Registered: July 2009
Senior Member
sry have no idea on that

Need professional support for Xtext, Xpand, EMF?
Go to: https://xtext.itemis.com
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How to force the editor to parse the entire editor content [message #1776251 is a reply to message #1776243] Tue, 14 November 2017 13:22 Go to previous message
Markus Holzem is currently offline Markus HolzemFriend
Messages: 7
Registered: November 2017
Junior Member
Got it:

class ...UiModule extends AbstractApiUiModule {
  ...
  def Class<? extends DocumentTokenSource> bindDocumentTokenSource() {
    return typeof(BacktrackingLexerDocumentTokenSource);
  }
  ...


solves the problem.

Markus
Previous Topic:Content Assist for external information
Next Topic:[DELETE PLEASE] Configurable issue code is not registered - check binding for...
Goto Forum:
  


Current Time: Tue Oct 23 16:32:20 GMT 2018

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

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

Back to the top