Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Compilation error inside the grammar access class when upgrading to Xtext 2.14
Compilation error inside the grammar access class when upgrading to Xtext 2.14 [message #1790666] Thu, 14 June 2018 07:54 Go to next message
Stéphane Galland is currently offline Stéphane GallandFriend
Messages: 123
Registered: July 2014
Location: Belfort, France
Senior Member
Dear all.

When trying to upgrade Xtext from 2.13 to 2.14, I'm encountering compilation errors within the generated code of my language grammar access class.

In the file SARLGrammarAccess.java (SARL is the name of my language), the following lines has an error:
        private final XtendGrammarAccess gaXtend;

	//MultiTypeReference types::JvmTypeReference:
	//	JvmTypeReference ({types::JvmSynonymTypeReference.references+=current} ('|' references+=JvmTypeReference)+)?;
	public XtendGrammarAccess.MultiTypeReferenceElements getMultiTypeReferenceAccess() {
		return gaXtend.getMultiTypeReferenceAccess();
	}


The error is: "The method getMultiTypeReferenceAccess() is undefined for the type XtendGrammarAccess".

My grammar has nothing special except I extends and reuse part of the Xtend grammar. The header of my grammar is:
grammar io.sarl.lang.SARL with org.eclipse.xtend.core.Xtend

generate sarl "http://www.sarl.io/lang/SARL"

import "http://www.eclipse.org/xtext/common/JavaVMTypes" as jvm
import "http://www.eclipse.org/xtext/xbase/Xbase" as xbase
import "http://www.eclipse.org/xtext/xbase/Xtype" as xtype
import "http://www.eclipse.org/xtend" as xtend


For generating the code, I use a MWE2 script that a part of is below :
 	component = XtextGenerator auto-inject {
		// Generation and configuration module for SARL
 		configuration = SarlGeneratorModule {
			// Project configuration
			project = StandardProjectConfig auto-inject {
				runtime = auto-inject {
					enabled = true
					name = runtimeProjectName
				}
				eclipsePlugin = auto-inject {
					enabled = true
					name = uiProjectName
				}
				genericIde = auto-inject {
					enabled = true
					name = uiProjectName
				}
				runtimeTest = auto-inject {
					enabled = true
					root = testProjectPath
				}
				eclipsePluginTest = auto-inject {
					enabled = true
					root = testUiProjectPath
				}
				mavenLayout = false
				createEclipseMetaData = true
			}
                }
		language = StandardLanguage auto-inject {
			// Set of resources
			resourceSet = XtextResourceSet : resourceSet {}
			// SARL depends on the Xtend model
			referencedResource = "platform:/resource/org.eclipse.xtend.core/model/Xtend.genmodel"
			// ID for SARL
			name = "io.sarl.lang.SARL"
			// Pointer to the SARL grammar
			grammarUri = "platform:/resource/${runtimeProjectName}/src/io/sarl/lang/SARL.xtext"
			// Definition of the file extensions for SARL
			fileExtensions = file.extensions
			// Specification of the injection that is used by MWE2 (not by the SARL compiler)
			guiceModule = SarlLanguageGeneratorModule {}

			// Specify the grammar access fragment			
			grammarAccess = auto-inject {
			}

			// Lexer
			parserGenerator = auto-inject {
				removeBacktrackingGuards = true
				lookaheadThreshold = '5'
				partialParsing = true
				debugGrammar = false
				options = auto-inject {
					//backtrack = true
				}
			}
			
			// EMF Generator
			emfGenerator = auto-inject {
				// Do not update the build.properties in order to avoid the path "model/generated"
				// within the "bin.includes" definition.
				updateBuildProperties = false
			}

			// SARL Validator
			validator = ValidatorFragment2 auto-inject {
    			composedCheck = "org.eclipse.xtend.core.validation.AnnotationValidation"
			}

			// SARL serializer
			serializer = auto-inject {
				generateStub = false
			}

			// Refactoring
			renameRefactoring = auto-inject {
				useJdtRefactoring = true
			}

    		// Generates the required bindings only if the grammar inherits from Xbase
			xbaseSupport = auto-inject {
				generateXtendInferrer = false
			}

    		// Testing infrastructure
			junitSupport = auto-inject {
				generateStub = false
			}
			
			// Content assist - Bug fixed for avoiding compilation error due to an
			// invalid qualified name for the XtendProposalProvider
			contentAssist = ContentAssistFragment2 auto-inject {
			}

			// Formatter - this fragment should be explicitly defined otherwise the SARLFormatter is not injected. Bug?
			formatter = auto-inject {	
				generateStub = true	
			}


One strange thing is that the "MultiTypeReference" exists in the Xtend grammar 2.14, but the XtendGrammarAccess has no reference to this element.

What is going wrong?

Stéphane.
Re: Compilation error inside the grammar access class when upgrading to Xtext 2.14 [message #1790668 is a reply to message #1790666] Thu, 14 June 2018 08:04 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
hmmm did not find getMultiTypeReferenceAccess in a quick browsing of the history.
can you lookup the commit that removed that?


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Compilation error inside the grammar access class when upgrading to Xtext 2.14 [message #1790685 is a reply to message #1790668] Thu, 14 June 2018 13:23 Go to previous messageGo to next message
Stéphane Galland is currently offline Stéphane GallandFriend
Messages: 123
Registered: July 2014
Location: Belfort, France
Senior Member
Seems that the getMultiTypeReferenceAccess function does not exist in version 2.13 too.
So that, the question should be: why the MWE2 tools generates a reference to this function?

The short answer may be: because the rule "MultiTypeReference" is defined within the Xtend grammar.
But in this case, why is it not declared within XtendGrammarAccess too.

It seems that this function was introduced due to a change within the Xtend grammar between 2.13 and 2.14.

The commit is: 85d02f719b2e558644058d3bc5e6021f54271b0b

Is it a problem of code generation from Xtend?

Stéphane.

[Updated on: Thu, 14 June 2018 13:29]

Report message to a moderator

Re: Compilation error inside the grammar access class when upgrading to Xtext 2.14 [message #1790687 is a reply to message #1790685] Thu, 14 June 2018 14:18 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
hi i have no idea on that.
could be a bug in the grammar access generator indeed.


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Compilation error inside the grammar access class when upgrading to Xtext 2.14 [message #1790690 is a reply to message #1790687] Thu, 14 June 2018 14:48 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

The problem is "grammar io.sarl.lang.SARL with org.eclipse.xtend.core.Xtend" whereby you declare that SARL is very tightly coupled to Xtend.

In an ideal world, the Xtext/Xtend developers would have infinite foresight and never ever need to evolve their APIs. Sadly they are only human; APIs evolve.

Sometimes as with EMF, there can be a run-time compatibility level so that newly generated functionality uses only old APIs. Xtext has not taken this approach, so every time anything significant changes compatibility may break. Some breaks are avoidable and have been retracted, others aren't. The parser/editor APIs are very diverse and so fragile. If Xtend changes you are almost guaranteed to need to rebuild a tightly coupled SARL. If SARL was self-standing you would only need to rebuild occasionally; For QVTd which extends OCL, a rebuild is needed everytime OCL changes, but an OCL rebuild is only needed occasionally; the Photon/Xtext 2.14 release of OCL runs on Xtext 2.9.1, but not 2.8. But this compatibility is only achieved by ensuring that the *.xtextbin files are not used; these broke most recently between Xtext 2.12 and 2.13. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=460978 for the (faster) solution.

Similarly with EMF, there are strong albeit informal guidelines: do not extend Ecore.ecore; reference it instead.

You need to review whether the benefits of extending Xtend directly justify the consequent tight coupling; this years' tightly-coupled SARL will not run on next year's Xtend/Xtext. You may need to rebuild and redistribute your SARL tooling every six months and maintain multiple versions if you have customers who upgrade slowly.

Regards

Ed Willink

Re: Compilation error inside the grammar access class when upgrading to Xtext 2.14 [message #1790696 is a reply to message #1790690] Thu, 14 June 2018 15:40 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
i had a look.
the problem is that xtend grammar and grammaraccess to match each other. means: the grammar access class shipped with 2.14 is outdated.
can you please create a ticket at xtext-xtend


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Compilation error inside the grammar access class when upgrading to Xtext 2.14 [message #1790745 is a reply to message #1790696] Fri, 15 June 2018 12:48 Go to previous messageGo to next message
Stéphane Galland is currently offline Stéphane GallandFriend
Messages: 123
Registered: July 2014
Location: Belfort, France
Senior Member
Dear Christian.
I have create the issue https://github.com/eclipse/xtext-xtend/issues/474.

Dear Ed.
Within SARL, a part of the grammar is dedicated to object-oriented programming, the other part is dedicated to agent-oriented programming. This latest part is the one on which we want to work hard.
We have decided to not code from scratch a OOP infrastructure since Xtend already provides one that could be extended.
SARL language's grammar inherits from the Xtend grammar and changes several specific rules for fixing the syntax philosophy that is different between Xtend and SARL (so that Xtend is hidden to SARL users).
In this we, we have benefit of all the code that is written for Xtend (jvm model inferrer, validator, ...) at a lower cost than an implementation from scratch.

Since the works done on Xtend are of a very good quality, we think that it is not a huge problem to inherits from it (and we have given a proof of concept with the previous version of Xtend) and update our code when some part of Xtend has changed.

All the best.
Stéphane.

[Updated on: Fri, 15 June 2018 12:58]

Report message to a moderator

Re: Compilation error inside the grammar access class when upgrading to Xtext 2.14 [message #1790746 is a reply to message #1790745] Fri, 15 June 2018 13:07 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
@Stephane did you try to override the broken parts in the grammar. does that help?
if not if you place a copy of the correct xtend.xtext next to your grammar which one will win?


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Compilation error inside the grammar access class when upgrading to Xtext 2.14 [message #1790750 is a reply to message #1790746] Fri, 15 June 2018 13:59 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi Stéphane

I had a quick think about SARL/QVTd referencing rather than extending Xtend/EssentialOCL and realized that it could be a bit hard. The tooling would need to flatten the extended functionality into the extending functionality to ensure that no usage of differently stable extended functionality was used. Perhaps Xtext's recent evolution to begin to support Grammar modules may support re-use behind a stable API. I'm afraid that I have not yet had time to study what is on offer beyond working around the consequent API breakage.

Regards

Ed Willink
Previous Topic:Mixin Xtext with other models
Next Topic:Keyword/name=ID conflicts
Goto Forum:
  


Current Time: Fri Apr 19 01:08:04 GMT 2024

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

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

Back to the top