Skip to main content



      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 05:21 Go to next message
Eclipse UserFriend
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 10:44 Go to previous messageGo to next message
Eclipse UserFriend
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)

[Updated on: Mon, 13 November 2017 10:44] by 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 01:58 Go to previous messageGo to next message
Eclipse UserFriend
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 02:16 Go to previous messageGo to next message
Eclipse UserFriend
but where is the parser involved?
Re: How to force the editor to parse the entire editor content [message #1776243 is a reply to message #1776226] Tue, 14 November 2017 06:51 Go to previous messageGo to next message
Eclipse UserFriend
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 08:20 Go to previous messageGo to next message
Eclipse UserFriend
sry have no idea on that
Re: How to force the editor to parse the entire editor content [message #1776251 is a reply to message #1776243] Tue, 14 November 2017 08:22 Go to previous message
Eclipse UserFriend
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: Wed Jul 23 13:43:50 EDT 2025

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

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

Back to the top