Skip to main content



      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 14:34 Go to next message
Eclipse UserFriend
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 15:06 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

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

~Christian
Re: syntax validation not active when opening document [message #799388 is a reply to message #799368] Wed, 15 February 2012 15:44 Go to previous messageGo to next message
Eclipse UserFriend
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 15:53 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

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

~Christian
Re: syntax validation not active when opening document [message #799405 is a reply to message #799393] Wed, 15 February 2012 16:18 Go to previous messageGo to next message
Eclipse UserFriend
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 16:25] by Moderator

Re: syntax validation not active when opening document [message #799412 is a reply to message #799405] Wed, 15 February 2012 16:26 Go to previous messageGo to next message
Eclipse UserFriend
this is exactly what i do
and it works of course you have to activate build automatically too

~Christian
Re: syntax validation not active when opening document [message #799418 is a reply to message #799412] Wed, 15 February 2012 16:35 Go to previous messageGo to next message
Eclipse UserFriend
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 17:05 Go to previous messageGo to next message
Eclipse UserFriend
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 17:18 Go to previous messageGo to next message
Eclipse UserFriend
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 05:59] by Moderator

Re: syntax validation not active when opening document [message #799895 is a reply to message #799437] Thu, 16 February 2012 07:51 Go to previous messageGo to next message
Eclipse UserFriend
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 07:57] by Moderator

Re: syntax validation not active when opening document [message #849499 is a reply to message #799895] Thu, 19 April 2012 03:47 Go to previous messageGo to next message
Eclipse UserFriend
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 11:40 Go to previous messageGo to next message
Eclipse UserFriend
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 11:41] by Moderator

Re: syntax validation not active when opening document [message #870366 is a reply to message #851045] Mon, 07 May 2012 15:38 Go to previous message
Eclipse UserFriend
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 15:41] by Moderator

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


Current Time: Mon Jul 14 09:57:34 EDT 2025

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

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

Back to the top