Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Import and use Ecore model using importURI
Import and use Ecore model using importURI [message #1386881] Sun, 22 June 2014 06:01 Go to next message
Eclipse UserFriend
Hi,

some things changed since my last topic and now I need a little help again.

I want to be able to import some Ecore files in my DSL and use classes of these specified files.

Example DSL:
grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals

generate myDsl "ht tp://www.xtext.org/example/mydsl/MyDsl"

import "ht tp://www.eclipse.org/emf/2002/Ecore" as ecore

Model:
	imports+=Import*
	selection=Selection;

Import: 'import' importURI=STRING;

Selection:
	'selection' name=ID '{'
		selected+=Select*
	'}';

Select:
	'select' classref=[ecore::EClass] name=ID;



It should look like this:
import "org/test/MyEcoreModel.ecore"

selection test {
	select MyClass mc // MyClass is an EClass in MyEcoreModel.ecore
}


But this does not seem to work. The classref=[ecore::EClass] part does not find the classes in the ecore model file. I guess this is a problem of the ScopeProvider, but how do I get into the importURI in the ScopeProvider? Or is there another problem?

Thanks for any suggestions,
Florian
Re: Import and use Ecore model using importURI [message #1386884 is a reply to message #1386881] Sun, 22 June 2014 07:43 Go to previous messageGo to next message
Eclipse UserFriend
Hi,
aaa=[BBB] is short for aaa=[BBB|ID] => an ID Will be parsed. the eclass name is packagename.classname.

a . is not allowed in ID

Select:
	'select' classref=[ecore::EClass|FQN] name=ID;

FQN: ID ("." ID)*;
Re: Import and use Ecore model using importURI [message #1386886 is a reply to message #1386884] Sun, 22 June 2014 09:25 Go to previous messageGo to next message
Eclipse UserFriend
Oh I am so dumb.. you already told me this in that other topic..

Ok but this does only half the trick, as I can select all models in my project now. But I only want to select those from my import section. How can I apply a filter like this?
Re: Import and use Ecore model using importURI [message #1386890 is a reply to message #1386886] Sun, 22 June 2014 11:25 Go to previous messageGo to next message
Eclipse UserFriend
Sure you did the workflow config right?
Re: Import and use Ecore model using importURI [message #1386910 is a reply to message #1386890] Mon, 23 June 2014 00:56 Go to previous messageGo to next message
Eclipse UserFriend
Here is an example how to restrict the scope, perhaps it works for your situation as well.

reducing cross reference to current DSL file [message #1229358] at
https://www.eclipse.org/forums/index.php/t/635607/
Re: Import and use Ecore model using importURI [message #1389056 is a reply to message #1386910] Fri, 27 June 2014 05:10 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

I checked the workflow over and over again, but I can not find anything that causes this.. What am I looking for?


@Uli: Yes I was trying to restrict the scope, but I can not find a way to refer and read the imported files. I want only the EClasses in the files listed in the import section to show up.


My Workflow looks like this:
module org.xtext.example.mydsl.GenerateMyDsl

import org.eclipse.emf.mwe.utils.*
import org.eclipse.xtext.generator.*
import org.eclipse.xtext.ui.generator.*

var grammarURI = "classpath:/org/xtext/example/mydsl/MyDsl.xtext"
var fileExtensions = "mydsl"
var projectName = "org.xtext.example.mydsl"
var runtimeProject = "../${projectName}"
var generateXtendStub = true
var encoding = "UTF-8"

Workflow {
    bean = StandaloneSetup {
    	scanClassPath = true
    	platformUri = "${runtimeProject}/.."
    	// The following two lines can be removed, if Xbase is not used.
    	registerGeneratedEPackage = "org.eclipse.xtext.xbase.XbasePackage"
    	registerGenModelFile = "platform:/resource/org.eclipse.xtext.xbase/model/Xbase.genmodel"
    	// Ecore
    	registerGeneratedEPackage = "org.eclipse.emf.ecore.EcorePackage"
    	registerGenModelFile = "platform:/resource/org.eclipse.emf.ecore/model/Ecore.genmodel"
    }
    
    component = DirectoryCleaner {
    	directory = "${runtimeProject}/src-gen"
    }
    
    component = DirectoryCleaner {
    	directory = "${runtimeProject}/model"
    }
    
    component = DirectoryCleaner {
    	directory = "${runtimeProject}.ui/src-gen"
    }
    
    component = DirectoryCleaner {
    	directory = "${runtimeProject}.tests/src-gen"
    }
    
    component = Generator {
    	pathRtProject = runtimeProject
    	pathUiProject = "${runtimeProject}.ui"
    	pathTestProject = "${runtimeProject}.tests"
    	projectNameRt = projectName
    	projectNameUi = "${projectName}.ui"
    	encoding = encoding
    	language = auto-inject {
    		uri = grammarURI
    
    		// Java API to access grammar elements (required by several other fragments)
    		fragment = grammarAccess.GrammarAccessFragment auto-inject {}
    
    		// generates Java API for the generated EPackages
    		fragment = ecore.EMFGeneratorFragment auto-inject {}
    
    		// the old serialization component
    		// fragment = parseTreeConstructor.ParseTreeConstructorFragment auto-inject {}    
    
    		// serializer 2.0
    		fragment = serializer.SerializerFragment auto-inject {
    			generateStub = false
    		}
    
    		// a custom ResourceFactory for use with EMF
    		fragment = resourceFactory.ResourceFactoryFragment auto-inject {}
    
    		// The antlr parser generator fragment.
    		fragment = parser.antlr.XtextAntlrGeneratorFragment auto-inject {
    		//  options = {
    		//      backtrack = true
    		//  }
    		}
    
    		// Xtend-based API for validation
    		fragment = validation.ValidatorFragment auto-inject {
    		    composedCheck = "org.eclipse.xtext.validation.ImportUriValidator"
    		    composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
    		}
    
    		// old scoping and exporting API
    		// fragment = scoping.ImportURIScopingFragment auto-inject {}
    		// fragment = exporting.SimpleNamesFragment auto-inject {}
    
    		// scoping and exporting API
    		fragment = scoping.ImportNamespacesScopingFragment auto-inject {}
    		fragment = exporting.QualifiedNamesFragment auto-inject {}
    		fragment = builder.BuilderIntegrationFragment auto-inject {}
    
    		// generator API
    		fragment = generator.GeneratorFragment auto-inject {}
    
    		// formatter API
    		fragment = formatting.FormatterFragment auto-inject {}
    
    		// labeling API
    		fragment = labeling.LabelProviderFragment auto-inject {}
    
    		// outline API
    		fragment = outline.OutlineTreeProviderFragment auto-inject {}
    		fragment = outline.QuickOutlineFragment auto-inject {}
    
    		// quickfix API
    		fragment = quickfix.QuickfixProviderFragment auto-inject {}
    
    		// content assist API
    		fragment = contentAssist.ContentAssistFragment auto-inject {}
    
    		// generates a more lightweight Antlr parser and lexer tailored for content assist
    		fragment = parser.antlr.XtextAntlrUiGeneratorFragment auto-inject {}
    
    		// generates junit test support classes into Generator#pathTestProject
    		fragment = junit.Junit4Fragment auto-inject {}
    
    		// rename refactoring
    		fragment = refactoring.RefactorElementNameFragment auto-inject {}
    
    		// provides the necessary bindings for java types integration
    		fragment = types.TypesGeneratorFragment auto-inject {}
    
    		// generates the required bindings only if the grammar inherits from Xbase
    		fragment = xbase.XbaseGeneratorFragment auto-inject {}
    
    		// provides a preference page for template proposals
    		fragment = templates.CodetemplatesGeneratorFragment auto-inject {}
    
    		// provides a compare view
    		fragment = compare.CompareFragment auto-inject {}
    	}
    }
}
Re: Import and use Ecore model using importURI [message #1393903 is a reply to message #1389056] Fri, 04 July 2014 08:58 Go to previous messageGo to next message
Eclipse UserFriend
Any other suggestions? Sad
Re: Import and use Ecore model using importURI [message #1393980 is a reply to message #1393903] Fri, 04 July 2014 11:27 Go to previous message
Eclipse UserFriend
your workflow is not configured to support import uri

  		// old scoping and exporting API
    		// fragment = scoping.ImportURIScopingFragment auto-inject {} //Bad
    		// fragment = exporting.SimpleNamesFragment auto-inject {} //Bad
    
    		// scoping and exporting API
    		fragment = scoping.ImportNamespacesScopingFragment auto-inject {} //Bad
    		fragment = exporting.QualifiedNamesFragment auto-inject {} //Bad
    		fragment = builder.BuilderIntegrationFragment auto-inject {}
fragment = types.TypesGeneratorFragment auto-inject {} //Bad
    
    		// generates the required bindings only if the grammar inherits from Xbase
    		fragment = xbase.XbaseGeneratorFragment auto-inject {} //Bad
Previous Topic:XCore 1.1.2 not any more on updatesite
Next Topic:Mac OS X very slow
Goto Forum:
  


Current Time: Sun Jul 06 01:56:34 EDT 2025

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

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

Back to the top