Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Refering to UML elements
Refering to UML elements [message #1720461] Mon, 18 January 2016 18:36 Go to next message
Ernesto Posse is currently offline Ernesto PosseFriend
Messages: 381
Registered: March 2011
Senior Member
Hi. I'm developing a language that supports references to UML elements, but I'm having trouble building with Xtext 2.9.1.

The abstract syntax for the language is an Ecore model that has an EClass called "UMLProtocol" with a single 'collaboration' attribute that is a reference to a UML Collaboration.

The relevant parts of the Xtext grammar are the following:

grammar org.eclipse.papyrusrt.xtumlrt.xtext.Umlrt with org.eclipse.xtext.common.Terminals

import "http://www.eclipse.org/emf/2002/Ecore" as ecore
import "http://www.eclipse.org/papyrusrt/xtumlrt/common"
import "http://www.eclipse.org/papyrusrt/xtumlrt/umlrt"
import "http://www.eclipse.org/uml2/5.0.0/UML" as uml   // (1)

Import returns AbstractImport:
    'import' 'ns' {Import} importedNamespace=QualifiedName ('.*')?
    | 'import' 'uri' {URIImport} importURI=STRING
;

QualifiedName:
    ID ('.' ID)*
;

// ...

fragment ProtocolReferenceFragment returns RTPort:
    ':' type=[Protocol | QualifiedName]
    | ':' 'uml' type=[UMLProtocol | QualifiedName]
;


The workflow is this:

module org.eclipse.papyrusrt.xtumlrt.xtext.GenerateTumlrt

import org.eclipse.xtext.xtext.generator.*
import org.eclipse.xtext.xtext.generator.model.project.*

var rootPath = ".."

Workflow {
	
	component = XtextGenerator {
		configuration = {
			project = StandardProjectConfig {
				baseName = "org.eclipse.papyrusrt.xtumlrt.xtext"
				rootPath = rootPath
				runtimeTest = {
					enabled = true
				}
				eclipsePlugin = {
					enabled = true
				}
				eclipsePluginTest = {
					enabled = true
				}
				createEclipseMetaData = true
			}
			code = {
				encoding = "UTF-8"
				fileHeader = "/*\n * generated by Xtext \${version}\n */"
			}
		}
		language = StandardLanguage {
			name = "org.eclipse.papyrusrt.xtumlrt.xtext.Tumlrt"
			fileExtensions = "umlrt"
			referencedResource = "platform:/resource/org.eclipse.papyrusrt.xtumlrt.umlrt.model/model/umlrt.genmodel"
			referencedResource = "platform:/resource/org.eclipse.papyrusrt.xtumlrt.common.model/model/common.genmodel"
			
			fragment = ecore2xtext.Ecore2XtextValueConverterServiceFragment2 auto-inject {}

			fragment = org.eclipse.xtext.generator.adapter.FragmentAdapter {
				fragment = org.eclipse.xtext.generator.ecore2xtext.FormatterFragment {}
			}

			serializer = {
				generateStub = false
			}
			validator = {
				// composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
			}
		}
	}
}


but when running it I get this:

0    [main] INFO  text.xtext.generator.XtextGenerator  - Initializing Xtext generator
9    [main] INFO  lipse.emf.mwe.utils.StandaloneSetup  - Adding generated EPackage 'org.eclipse.xtext.common.types.TypesPackage'
209  [main] INFO  lipse.emf.mwe.utils.StandaloneSetup  - Registering project org.eclipse.papyrusrt.xtumlrt.xtext at 'file:/Users/epp/Development/PapyrusRT/git/org.eclipse.papyrus-rt/plugins/xtumlrt/xtext/org.eclipse.papyrusrt.xtumlrt.xtext/'
209  [main] INFO  lipse.emf.mwe.utils.StandaloneSetup  - Registering project org.eclipse.papyrusrt.xtumlrt.xtext.tests at 'file:/Users/epp/Development/PapyrusRT/git/org.eclipse.papyrus-rt/plugins/xtumlrt/xtext/org.eclipse.papyrusrt.xtumlrt.xtext.tests/'
209  [main] INFO  lipse.emf.mwe.utils.StandaloneSetup  - Registering project org.eclipse.papyrusrt.xtumlrt.xtext.ide at 'file:/Users/epp/Development/PapyrusRT/git/org.eclipse.papyrus-rt/plugins/xtumlrt/xtext/org.eclipse.papyrusrt.xtumlrt.xtext.ide/'
209  [main] INFO  lipse.emf.mwe.utils.StandaloneSetup  - Registering project org.eclipse.papyrusrt.xtumlrt.xtext.ui at 'file:/Users/epp/Development/PapyrusRT/git/org.eclipse.papyrus-rt/plugins/xtumlrt/xtext/org.eclipse.papyrusrt.xtumlrt.xtext.ui/'
209  [main] INFO  lipse.emf.mwe.utils.StandaloneSetup  - Registering project org.eclipse.papyrusrt.xtumlrt.xtext.ui.tests at 'file:/Users/epp/Development/PapyrusRT/git/org.eclipse.papyrus-rt/plugins/xtumlrt/xtext/org.eclipse.papyrusrt.xtumlrt.xtext.ui.tests/'
224  [main] INFO  lipse.emf.mwe.utils.StandaloneSetup  - Using resourceSet registry. The registered Packages will not be registered in the global EPackage.Registry.INSTANCE!
583  [main] INFO  clipse.emf.mwe.utils.GenModelHelper  - Registered GenModel 'http://www.eclipse.org/Xtext/Xbase/XAnnotations' from 'platform:/resource/org.eclipse.xtext.xbase/model/Xbase.genmodel'
588  [main] INFO  clipse.emf.mwe.utils.GenModelHelper  - Registered GenModel 'http://www.eclipse.org/xtext/xbase/Xtype' from 'platform:/resource/org.eclipse.xtext.xbase/model/Xbase.genmodel'
614  [main] INFO  clipse.emf.mwe.utils.GenModelHelper  - Registered GenModel 'http://www.eclipse.org/xtext/xbase/Xbase' from 'platform:/resource/org.eclipse.xtext.xbase/model/Xbase.genmodel'
614  [main] INFO  clipse.emf.mwe.utils.GenModelHelper  - Registered GenModel 'http://www.eclipse.org/xtext/common/JavaVMTypes' from 'platform:/resource/org.eclipse.xtext.common.types/model/JavaVMTypes.genmodel'
712  [main] INFO  clipse.emf.mwe.utils.GenModelHelper  - Registered GenModel 'http://www.eclipse.org/papyrusrt/xtumlrt/umlrt' from 'platform:/resource/org.eclipse.papyrusrt.xtumlrt.umlrt.model/model/umlrt.genmodel'
712  [main] INFO  clipse.emf.mwe.utils.GenModelHelper  - Registered GenModel 'http://www.eclipse.org/papyrusrt/xtumlrt/common' from 'platform:/resource/org.eclipse.papyrusrt.xtumlrt.common.model/model/common.genmodel'
713  [main] ERROR xt.generator.XtextGeneratorLanguage  - Error loading 'platform:/plugin/org.eclipse.uml2.uml/model/UML.genmodel'
713  [main] ERROR xt.generator.XtextGeneratorLanguage  - Error loading 'platform:/plugin/org.eclipse.uml2.types/model/Types.genmodel'
713  [main] ERROR xt.generator.XtextGeneratorLanguage  - Error loading 'platform:/plugin/org.eclipse.emf.ecore/model/Ecore.genmodel'
1325 [main] ERROR xt.generator.XtextGeneratorLanguage  - [XtextLinkingDiagnostic: null:7 Couldn't resolve reference to EPackage 'http://www.eclipse.org/uml2/5.0.0/UML'., TransformationDiagnostic: null:27 Cannot find compatible feature importURI in sealed EClass URIImport from imported package http://www.eclipse.org/papyrusrt/xtumlrt/umlrt: The existing attribute 'importURI' has an incompatible type 'null'. The expected type is 'EString' [java.lang.String]. (ErrorCode: CannotCreateTypeInSealedMetamodel)]
1328 [main] ERROR mf.mwe2.launch.runtime.Mwe2Launcher  - Problems running workflow org.eclipse.papyrusrt.xtumlrt.xtext.GenerateTumlrt: Problem parsing 'file:/Users/epp/Development/PapyrusRT/git/org.eclipse.papyrus-rt/plugins/xtumlrt/xtext/org.eclipse.papyrusrt.xtumlrt.xtext/../org.eclipse.papyrusrt.xtumlrt.xtext/src/org/eclipse/papyrusrt/xtumlrt/xtext/Tumlrt.xtext':
XtextLinkingDiagnostic: null:7 Couldn't resolve reference to EPackage 'http://www.eclipse.org/uml2/5.0.0/UML'.
TransformationDiagnostic: null:27 Cannot find compatible feature importURI in sealed EClass URIImport from imported package http://www.eclipse.org/papyrusrt/xtumlrt/umlrt: The existing attribute 'importURI' has an incompatible type 'null'. The expected type is 'EString' [java.lang.String]. (ErrorCode: CannotCreateTypeInSealedMetamodel)
java.lang.RuntimeException: Problems running workflow org.eclipse.papyrusrt.xtumlrt.xtext.GenerateTumlrt: Problem parsing 'file:/Users/epp/Development/PapyrusRT/git/org.eclipse.papyrus-rt/plugins/xtumlrt/xtext/org.eclipse.papyrusrt.xtumlrt.xtext/../org.eclipse.papyrusrt.xtumlrt.xtext/src/org/eclipse/papyrusrt/xtumlrt/xtext/Tumlrt.xtext':
XtextLinkingDiagnostic: null:7 Couldn't resolve reference to EPackage 'http://www.eclipse.org/uml2/5.0.0/UML'.
TransformationDiagnostic: null:27 Cannot find compatible feature importURI in sealed EClass URIImport from imported package http://www.eclipse.org/papyrusrt/xtumlrt/umlrt: The existing attribute 'importURI' has an incompatible type 'null'. The expected type is 'EString' [java.lang.String]. (ErrorCode: CannotCreateTypeInSealedMetamodel)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:104)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:62)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:52)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.run(Mwe2Launcher.java:78)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.main(Mwe2Launcher.java:36)
Caused by: java.lang.IllegalStateException: Problem parsing 'file:/Users/epp/Development/PapyrusRT/git/org.eclipse.papyrus-rt/plugins/xtumlrt/xtext/org.eclipse.papyrusrt.xtumlrt.xtext/../org.eclipse.papyrusrt.xtumlrt.xtext/src/org/eclipse/papyrusrt/xtumlrt/xtext/Tumlrt.xtext':
XtextLinkingDiagnostic: null:7 Couldn't resolve reference to EPackage 'http://www.eclipse.org/uml2/5.0.0/UML'.
TransformationDiagnostic: null:27 Cannot find compatible feature importURI in sealed EClass URIImport from imported package http://www.eclipse.org/papyrusrt/xtumlrt/umlrt: The existing attribute 'importURI' has an incompatible type 'null'. The expected type is 'EString' [java.lang.String]. (ErrorCode: CannotCreateTypeInSealedMetamodel)
	at org.eclipse.xtext.xtext.generator.XtextGeneratorLanguage.initialize(XtextGeneratorLanguage.java:280)
	at org.eclipse.xtext.xtext.generator.StandardLanguage.initialize(StandardLanguage.java:166)
	at org.eclipse.xtext.xtext.generator.XtextGenerator.initialize(XtextGenerator.java:176)
	at org.eclipse.xtext.xtext.generator.XtextGenerator.checkConfigurationInternal(XtextGenerator.java:120)
	at org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent2.checkConfiguration(AbstractWorkflowComponent2.java:21)
	at org.eclipse.emf.mwe.core.lib.Mwe2Bridge.preInvoke(Mwe2Bridge.java:65)
	at org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent.preInvoke(AbstractWorkflowComponent.java:197)
	at org.eclipse.emf.mwe2.runtime.workflow.AbstractCompositeWorkflowComponent.preInvoke(AbstractCompositeWorkflowComponent.java:29)
	at org.eclipse.emf.mwe2.runtime.workflow.Workflow.run(Workflow.java:18)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:102)
	... 4 more



Now, I do not have org.eclipse.uml2.uml as a project in my workspace but it is installed, Xtext recognizes it to be a registered package and I expect it to be available in the target platform.

Furthermore, I have installed the latest UML2, which is 5.1.0. It would seem like an error in line (1) in the grammar where I use 'import "http://www.eclipse.org/uml2/5.0.0/UML" as uml', but it turns out that the Ns URI declared in UML.ecore is "http://www.eclipse.org/uml2/5.0.0/UML". (If I change that line to 5.1.0, the Xtext editor points an error, with 5.0.0 it only shows a warning saying that the package contains references to elements in the package registry and not in the workspace)

Why is it complaining about not finding the package if I have it installed? I have checked and both UML.ecore and UML.genmodel are included in the jar file under the 'model' folder.

Given the warning message, is it not possible to have references to elements that are not in the workspace? Would I have to import org.eclipse.uml2.uml as a project in the workspace for it to work?

I tried adding

			referencedResource = "platform:/plugin/org.eclipse.uml2.uml/model/UML.genmodel"


to the StandardLanguage configuration, but then it fails when registering the packages saying that it doesn't recognize the 'platform' protocol.

I thought it could be dealt with by adding a URI map, as it used to be possible with the old workflow, but I can't find how to add URI maps in the new configuration style.

It's also complaining about the type importURI attribute, but the type is set to EString in the model.

Any help is appreciated.

Thanks.
Re: Refering to UML elements [message #1728670 is a reply to message #1720461] Wed, 06 April 2016 11:39 Go to previous messageGo to next message
Sven Schuster is currently offline Sven SchusterFriend
Messages: 1
Registered: April 2016
Junior Member
Hey,

did you, by any chance, solve your problem? I'm having a very similar issue right now. Thanks!

Best, Sven
Re: Refering to UML elements [message #1729983 is a reply to message #1728670] Wed, 20 April 2016 16:21 Go to previous message
Ernesto Posse is currently offline Ernesto PosseFriend
Messages: 381
Registered: March 2011
Senior Member
No, I haven't. If you are able to solve yours, could you share your findings?

Thanks.
Previous Topic:How to add underline to my textStyle
Next Topic:Remove items in Preferences
Goto Forum:
  


Current Time: Sat Nov 16 01:25:26 GMT 2019

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

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

Back to the top