Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » XText -> Help Required
XText -> Help Required [message #1690901] Tue, 31 March 2015 20:16 Go to next message
Annamalai Mising name is currently offline Annamalai Mising nameFriend
Messages: 126
Registered: July 2009
Senior Member
Hello There

I am new to XText. I have an ecore model that is already present and
have a full fledged Form Editor available for it.

Now i am trying to create another Xtext Project which intends to use the
values of the above mentioned ecore model.

I followed the following tutorial.
1. Create my own ecore and generate the required genmodel and src for it.
2. Create a new Xtext Project and in the MyDSL.xtext i imported the
above ecore.
3. In the MyDSL.xtext i have also generated the ecore for the Grammar.
I have defined developers as ImportURI=STRING

I have attached the xtext for your reference. but when i run and in line
1 i type developer "My.orgchart" and followed by
task "TaskName" by and then try control space it doesnt work.
My.orgchart represents the instance of my 1st model.

Any help would be definitely appreciated.

Regards
Malai



grammar org.ancit.mydsl.Tasks with org.eclipse.xtext.common.Terminals

import "http://www.eclipse.org/emf/2002/Ecore" as ecore
import "platform:/resource/org.ancit.emf.model/model/orgchart.ecore" as company

generate tasks "http://www.ancit.org/mydsl/Tasks"

Tasks :
(developers+=Developers)*
(tasks+=Task)*;

Task: 'task' element=STRING
'by' developer=[company::ServiceSupervisor]
':' description=STRING;

Developers:
'developer' importURI=STRING;
  • Attachment: MyDsl.xtext
    (Size: 0.47KB, Downloaded 77 times)
Re: XText -> Help Required [message #1690904 is a reply to message #1690901] Tue, 31 March 2015 20:23 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13885
Registered: July 2009
Senior Member
Hi,

i am not sure if i got your question
if you want to reference non xtext but ecore stuff from xtext you need an iresourceserviceprovider.
you may have a look at https://christiandietrich.wordpress.com/2011/07/17/xtext-2-0-and-uml/


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: XText -> Help Required [message #1690905 is a reply to message #1690904] Tue, 31 March 2015 20:48 Go to previous messageGo to next message
Annamalai Mising name is currently offline Annamalai Mising nameFriend
Messages: 126
Registered: July 2009
Senior Member
On 4/1/2015 1:53 AM, Christian Dietrich wrote:
> Hi,
>
> i am not sure if i got your question
> if you want to reference non xtext but ecore stuff from xtext you need
> an iresourceserviceprovider.
> you may have a look at
> https://christiandietrich.wordpress.com/2011/07/17/xtext-2-0-and-uml/
Hello Christian

I did something further. Instead of using Xtext. I decided to achieve
the same using 2 Ecores.
So i created Ecore 1 and created a Dynamic Instance of the same
created Ecore 2 that references Ecore 1.
Then i created a Dynamic Instance of Ecore 2. in that Dynamic Instance,
i loaded the XMI resource that was created as the Dynamic Instance of
Ecore 1.

And this allows me to access the values from Ecore 1 into Ecore 2.

Now for Ecore 2 i decided to create a new XText Project from existing
ecore. And this is the xtext that i got for that ecore. Even this i am
not able to run coz i am not able to do Ctrl + Space to get items from
Ecore 1.

Attaching th 2 ecores and generated xtext for your reference.

Regards
Malai

// automatically generated by Xtext
grammar org.xtext.example.mydsl1.MyDsl with org.eclipse.xtext.common.Terminals

import "platform:/resource/org.ancit.emf.model2/model/ExtendedOrgChart.ecore"
import "platform:/resource/org.ancit.emf.model/model/orgchart.ecore" as orgchart
import "http://www.eclipse.org/emf/2002/Ecore" as ecore

Tasks returns Tasks:
{Tasks}
'Tasks'
'{'
('tasks' '{' tasks+=Task ( "," tasks+=Task)* '}' )?
'}';



Task returns Task:
{Task}
'Task'
name=EString
'{'
('supervisor' supervisor=[orgchart::ServiceSupervisor|EString])?
'}';

ServiceSupervisor returns orgchart::ServiceSupervisor:
'ServiceSupervisor'
name=EString
'{'
'servicetype' servicetype=EString
'}';

EString returns ecore::EString:
STRING | ID;
Re: XText -> Help Required [message #1690906 is a reply to message #1690905] Tue, 31 March 2015 20:49 Go to previous messageGo to next message
Annamalai Mising name is currently offline Annamalai Mising nameFriend
Messages: 126
Registered: July 2009
Senior Member
I tried to follow the article
http://jevopisdeveloperblog.blogspot.in/2010/01/quickn-dirty-tutorial-on-modelling-with.html

Regards
Malai

On 4/1/2015 2:18 AM, Annamalai wrote:
> On 4/1/2015 1:53 AM, Christian Dietrich wrote:
>> Hi,
>>
>> i am not sure if i got your question
>> if you want to reference non xtext but ecore stuff from xtext you need
>> an iresourceserviceprovider.
>> you may have a look at
>> https://christiandietrich.wordpress.com/2011/07/17/xtext-2-0-and-uml/
> Hello Christian
>
> I did something further. Instead of using Xtext. I decided to achieve
> the same using 2 Ecores.
> So i created Ecore 1 and created a Dynamic Instance of the same
> created Ecore 2 that references Ecore 1.
> Then i created a Dynamic Instance of Ecore 2. in that Dynamic Instance,
> i loaded the XMI resource that was created as the Dynamic Instance of
> Ecore 1.
>
> And this allows me to access the values from Ecore 1 into Ecore 2.
>
> Now for Ecore 2 i decided to create a new XText Project from existing
> ecore. And this is the xtext that i got for that ecore. Even this i am
> not able to run coz i am not able to do Ctrl + Space to get items from
> Ecore 1.
>
> Attaching th 2 ecores and generated xtext for your reference.
>
> Regards
> Malai
Re: XText -> Help Required [message #1690937 is a reply to message #1690906] Wed, 01 April 2015 05:54 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13885
Registered: July 2009
Senior Member
as i said:

if you want to reference from a textual model to a non textual model you need to create an iresourceserviceprovider for the non-textual (meta)model


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: XText -> Help Required [message #1690947 is a reply to message #1690937] Wed, 01 April 2015 08:24 Go to previous messageGo to next message
Annamalai Mising name is currently offline Annamalai Mising nameFriend
Messages: 126
Registered: July 2009
Senior Member
On 4/1/2015 11:24 AM, Christian Dietrich wrote:
> as i said:
>
> if you want to reference from a textual model to a non textual model you
> need to create an iresourceserviceprovider for the non-textual (meta)model
Hello Christian

I am still sitting with the problem. I did all the steps as per your
tutorial. Now i have a doubt on what is the getLanguageName() returning.
I am currently returning the id of my editor.

When i debug all these methods are called but when i do ctrl-space on my
task editor i am still getting nothing. Therefore it looks like some
linkage problem.

Any sort of help would be appreciated. :)

Regards
Malai
Re: XText -> Help Required [message #1690952 is a reply to message #1690947] Wed, 01 April 2015 09:03 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13885
Registered: July 2009
Senior Member
Hi,

to test if the resourceserviceprovider works: put the *.yournotxtextextension file to a model project (that has xtext nature) - e.g. next to the .yourdsl file.
if you have build automatically on and do a clean build on the project the files should be indexed.

you can find that out with the open model element dialog (Cmd + Shift + F3 on Mac)
now the elements should occur in this dialog


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: XText -> Help Required [message #1690954 is a reply to message #1690952] Wed, 01 April 2015 09:15 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13885
Registered: July 2009
Senior Member
P.S: if not: make sure you use the correct file extension (case sensitive) and have a proper name provider.

if yes then show us the latest version of the grammar


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: XText -> Help Required [message #1690957 is a reply to message #1690952] Wed, 01 April 2015 09:52 Go to previous messageGo to next message
Annamalai Mising name is currently offline Annamalai Mising nameFriend
Messages: 126
Registered: July 2009
Senior Member
On 4/1/2015 2:33 PM, Christian Dietrich wrote:
> Hi,
>
> to test if the resourceserviceprovider works: put the
> *.yournotxtextextension file to a model project (that has xtext nature)
> - e.g. next to the .yourdsl file.
> if you have build automatically on and do a clean build on the project
> the files should be indexed.
>
> you can find that out with the open model element dialog (Cmd + Shift +
> F3 on Mac)
> now the elements should occur in this dialog
When i do Ctrl + Shift + F3, i am able to see my nonxtext model instance
and when i select on it it opens in the emf reflective editor.
But i am not able to see it in my xtext dsl editor.

Attaching the complete workspace for your reference. I assume its some
issue with the languagename.

Regards
Malai

grammar org.ancit.xtext.tasks.Tasks with org.eclipse.xtext.common.Terminals

import "platform:/resource/org.ancit.emf.model/model/orgchart.ecore" as org

generate tasks "http://www.ancit.org/xtext/tasks/Tasks"

Model:
(tasks+=Task)*;


Task:
'task' name=ID 'by' supervisor=[org::ServiceSupervisor];
module org.ancit.xtext.tasks.GenerateTasks

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

var grammarURI = "classpath:/org/ancit/xtext/tasks/Tasks.xtext"
var fileExtensions = "task"
var projectName = "org.ancit.xtext.tasks"
var runtimeProject = "../${projectName}"
var generateXtendStub = true
var encoding = "UTF-8"

Workflow {
bean = StandaloneSetup {
scanClassPath = true
platformUri = "${runtimeProject}/.."

uriMap = {
from = "platform:/plugin/org.ancit.emf.model/model/orgchart.genmodel"
to = "platform:/resource/org.ancit.emf.model/model/orgchart.genmodel"
}
uriMap = {
from = "platform:/plugin/org.ancit.emf.model/model/orgchart.ecore"
to = "platform:/resource/org.ancit.emf.model/model/orgchart.ecore"
}

// The following two lines can be removed, if Xbase is not used.
registerGenModelFile = "platform:/resource/org.ancit.emf.model/model/orgchart.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 {}

// project wizard (optional)
// fragment = projectWizard.SimpleProjectWizardFragment auto-inject {
// generatorProjectName = "${projectName}"
// }

// 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: XText -> Help Required [message #1690958 is a reply to message #1690957] Wed, 01 April 2015 09:57 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13885
Registered: July 2009
Senior Member
Hi,

unfortunately there is not all i need attached. can you share a zip file?


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: XText -> Help Required [message #1690960 is a reply to message #1690952] Wed, 01 April 2015 10:02 Go to previous messageGo to next message
Annamalai Mising name is currently offline Annamalai Mising nameFriend
Messages: 126
Registered: July 2009
Senior Member
Hi

Attaching runtimemodule class screenshot.

Regards
Malai

4/1/2015 2:33 PM, Christian Dietrich wrote:
> Hi,
>
> to test if the resourceserviceprovider works: put the
> *.yournotxtextextension file to a model project (that has xtext nature)
> - e.g. next to the .yourdsl file.
> if you have build automatically on and do a clean build on the project
> the files should be indexed.
>
> you can find that out with the open model element dialog (Cmd + Shift +
> F3 on Mac)
> now the elements should occur in this dialog
Re: XText -> Help Required [message #1690961 is a reply to message #1690960] Wed, 01 April 2015 10:08 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13885
Registered: July 2009
Senior Member
Hi,

this will not help me to analyze. i dont think it is a problem with the language name.
thus did you check what i tould you to check?


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: XText -> Help Required [message #1691302 is a reply to message #1690961] Sun, 05 April 2015 04:42 Go to previous messageGo to next message
Annamalai Mising name is currently offline Annamalai Mising nameFriend
Messages: 126
Registered: July 2009
Senior Member
On 4/1/2015 3:38 PM, Christian Dietrich wrote:
> Hi,
>
> this will not help me to analyze. i dont think it is a problem with the
> language name.
> thus did you check what i tould you to check?

Hello Christian

I have uploaded it into my googledrive
https://drive.google.com/file/d/0BwQyPD9hEv4dR04zZjVDMlF6cmM/view?usp=sharing

Regards
Malai
Re: XText -> Help Required [message #1691317 is a reply to message #1691302] Sun, 05 April 2015 17:17 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13885
Registered: July 2009
Senior Member
Hi,

if you had a look at the open model element dialog you would have seen that the indexing works, but the naming is like MyCompany.PersonName and not
PersonName. Since xxx=[YYY] is short for xxx=[YYY|ID] (which means: reference a YYY and parse an ID) and ID prohibits dots (.) you dont get any proposals

=> either adapt the nameprovider of the resourceserviceprovider
or the grammar

Task:
	'task' name=ID 'by' supervisor=[org::ServiceSupervisor|FQN];
	
FQN:
	ID ('.' ID)*
;	


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
Previous Topic:Deriving from XBase
Next Topic:problems with Xtext 2.8 and Xcore 1.3.0
Goto Forum:
  


Current Time: Sat Apr 17 20:55:18 GMT 2021

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

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

Back to the top