Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » syntax validation not active when opening document
syntax validation not active when opening document [message #799350] Wed, 15 February 2012 19:34 Go to next message
Phil R is currently offline Phil RFriend
Messages: 99
Registered: September 2011
Member
Hi,

Is it normal that xtext does not check the syntax when a document is opened?
When the document is modified, the syntax checking happens. (all the errors appears)
Is it possible to turn syntax checking on immediately when the document opens?

Regards,
Phil
Re: syntax validation not active when opening document [message #799368 is a reply to message #799350] Wed, 15 February 2012 20:06 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13667
Registered: July 2009
Senior Member
Hi,

i cannot reproduce this. can you give some steps to reproduce it?

~Christian


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: syntax validation not active when opening document [message #799388 is a reply to message #799368] Wed, 15 February 2012 20:44 Go to previous messageGo to next message
Phil R is currently offline Phil RFriend
Messages: 99
Registered: September 2011
Member
ok, it's easy. open eclipse with the dsl plugin from xtext installed -> open an existing file -> no syntax check -> alter file content -> syntax checking happens..

I just checked it with a clean xtext project with the Hello World example.
create a file enter "Hello you ! errortext.." then the syntax error states "errortext.." unexpected
close the file and reopen and the error does not show anymore, when I modify the file the syntax error is displayed again.
Re: syntax validation not active when opening document [message #799393 is a reply to message #799388] Wed, 15 February 2012 20:53 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13667
Registered: July 2009
Senior Member
Hi,

still cannot reproduce this. at least if i add the xtext nature to the project?

~Christian


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: syntax validation not active when opening document [message #799405 is a reply to message #799393] Wed, 15 February 2012 21:18 Go to previous messageGo to next message
Phil R is currently offline Phil RFriend
Messages: 99
Registered: September 2011
Member
I create new empty project -> create file with the correct extension ("myDsl") -> xtext asks to add xtext nature to the project -> yes.. -> start using file etc ...

I'll try with a fresh xtext editor from itemis downloads

[Updated on: Wed, 15 February 2012 21:25]

Report message to a moderator

Re: syntax validation not active when opening document [message #799412 is a reply to message #799405] Wed, 15 February 2012 21:26 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13667
Registered: July 2009
Senior Member
this is exactly what i do
and it works of course you have to activate build automatically too

~Christian


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: syntax validation not active when opening document [message #799418 is a reply to message #799412] Wed, 15 February 2012 21:35 Go to previous messageGo to next message
Phil R is currently offline Phil RFriend
Messages: 99
Registered: September 2011
Member
ok, looks like my workspace is incorrupt. It works if I switch to a new empty workspace and create the "hello world" xtext project there
Re: syntax validation not active when opening document [message #799432 is a reply to message #799418] Wed, 15 February 2012 22:05 Go to previous messageGo to next message
Phil R is currently offline Phil RFriend
Messages: 99
Registered: September 2011
Member
TO add: it's probably my project, it doesn't work for my project and if an other project also is in the same workspace it gets the same problems. I'll try figuring it out. Thank you for your support!
Re: syntax validation not active when opening document [message #799437 is a reply to message #799432] Wed, 15 February 2012 22:18 Go to previous messageGo to next message
Phil R is currently offline Phil RFriend
Messages: 99
Registered: September 2011
Member
I wanted to add xtext nature automatically:

public class AutomaticAddXtextNature  extends AbstractDirtyStateAwareEditorCallback{
	@Inject
	private ToggleNature toggleNature;

	@Override
	public void afterCreatePartControl(XtextEditor editor) {
		super.afterCreatePartControl(editor);
		IResource resource = editor.getResource();
		if (resource!=null && !toggleNature.hasNature(resource.getProject()) && resource.getProject().isAccessible() && !resource.getProject().isHidden()) {
			toggleNature.toggleNature(resource.getProject());
		}
	}
}

and
@Override
	public Class<? extends org.eclipse.xtext.ui.editor.IXtextEditorCallback> bindIXtextEditorCallback() {
		return AutomaticAddXtextNature.class;
	}

and causes this the trouble? And then also if I check out this feature it could be that the problems are still active ?

So then I have used as a solution to use a project wizard where the xtext nature is automatically added. However the generated project wizard of xtext gives lots of extra's I don't need, like src folder, src-gen, generator, java libraries.. If the wizard is used then a clean project with only the xtext nature should be added
Regards,
Phil

[Updated on: Thu, 16 February 2012 10:59]

Report message to a moderator

Re: syntax validation not active when opening document [message #799895 is a reply to message #799437] Thu, 16 February 2012 12:51 Go to previous messageGo to next message
John J. Camilleri is currently offline John J. CamilleriFriend
Messages: 33
Registered: November 2011
Location: Göteborg
Member
I have experienced the same problem as Phil, with the validation not triggering when opening a file. The same also applies when Eclipse launches and automatically re-opens the files which were open in the previous session - I need to alter the file in order for validation to be triggered.

I do not have the Xtext nature enabled on my DSL projects, mainly because I cannot understand what value it adds. I turned off the prompt for adding the nature by binding to org.eclipse.xtext.ui.editor.IXtextEditorCallback, like so:

MyDSLUiModule.java
@Override
public Class<? extends org.eclipse.xtext.ui.editor.IXtextEditorCallback> bindIXtextEditorCallback() {
    return org.grammaticalframework.eclipse.ui.editor.MyEditorCallback.class;
}

MyEditorCallback
public class MyEditorCallback extends AbstractDirtyStateAwareEditorCallback {
    // empty!
}

I'll be honest, I'm not really sure why that works, but it does.

My question would be twofold:

  1. Is there a way to get this validation to trigger when opening a file, without having to resort to enabling the Xtext nature?
  2. What would be the purpose of enabling the Xtext nature on my DSL projects?


Thanks for all the great work in these forums, guys.

[Updated on: Thu, 16 February 2012 12:57]

Report message to a moderator

Re: syntax validation not active when opening document [message #849499 is a reply to message #799895] Thu, 19 April 2012 07:47 Go to previous messageGo to next message
John J. Camilleri is currently offline John J. CamilleriFriend
Messages: 33
Registered: November 2011
Location: Göteborg
Member
For anyone interested, I (think) I finally came across the answer. Put this in your UIModule file:
@Override
public Class<? extends org.eclipse.xtext.ui.editor.IXtextEditorCallback> bindIXtextEditorCallback() {
	return org.eclipse.xtext.ui.editor.validation.ValidatingEditorCallback.class;
}

It will prevent the prompts for Xtext nature & builder but preserve the validation properties of Xtext, i.e. your files will be validated as soon as they are opened.
Re: syntax validation not active when opening document [message #851045 is a reply to message #849499] Fri, 20 April 2012 15:40 Go to previous messageGo to next message
Phil R is currently offline Phil RFriend
Messages: 99
Registered: September 2011
Member
Thank you John J. Camilleri for sharing your solution! I recently got again trouble with this issue...
I'll check if your solution works Wink

[Updated on: Fri, 20 April 2012 15:41]

Report message to a moderator

Re: syntax validation not active when opening document [message #870366 is a reply to message #851045] Mon, 07 May 2012 19:38 Go to previous message
Phil R is currently offline Phil RFriend
Messages: 99
Registered: September 2011
Member
Hi John,

The Xtext Nature must be added to the project or bugs will occure. For example referencing to other resources (when scoping) will not work fully without xtext nature enabled.

Best Regards,
Phil

[Updated on: Mon, 07 May 2012 19:41]

Report message to a moderator

Previous Topic:using absolute path
Next Topic:Exception implementing refactoring
Goto Forum:
  


Current Time: Thu Dec 03 08:58:18 GMT 2020

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

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

Back to the top