Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Today's Messages (on)  | Unanswered Messages (off)

Forum: TMF (Xtext)
 Topic: Add my var in Quick Reference
Re: Add my var in Quick Reference [message #1060707 is a reply to message #1060693] Tue, 28 May 2013 03:02
Christian Dietrich is currently offline Christian Dietrich
Messages: 4444
Registered: July 2009
Senior Member
Hmmm this term for cross references is new for me Wink
 Topic: XbaseScopeProvider in Xtext 2.4
Re: XbaseScopeProvider in Xtext 2.4 [message #1060732 is a reply to message #1028715] Tue, 28 May 2013 05:37
Victor Noël is currently offline Victor Noël
Messages: 56
Registered: June 2010
Member
Hi, any news about that?
 Topic: Maven errors question
Maven errors question [message #1060731] Tue, 28 May 2013 05:30
Mårten Carlzon is currently offline Mårten Carlzon
Messages: 60
Registered: March 2013
Location: Sweden
Member

Hello folks

I was wondering if I could get some help with my maven setup?
I have been using this example as my base for building my maven setup, but since I only need the jar file and not a compilation I have modded the mydsl pom file.

When I extract it in eclipse as runnable jar with the option "Package required libraries into generated Jar" everything works fine, but when I build and run the jar with maven I get the following errors:

----------------------ERROR--------------------------------------
log4j:WARN No appenders could be found for logger (org.eclipse.xtext.parser.antlr.AbstractInternalAntlrParser).
log4j:WARN Please initialize the log4j system properly.


Exception in thread "main" org.eclipse.emf.common.util.WrappedException: java.lang.StringIndexOutOfBoundsException:
String index out of range: 369
at org.eclipse.xtext.linking.lazy.LazyLinkingResource.getEObject(LazyLinkingResource.java:182)
at org.eclipse.xtext.linking.lazy.LazyLinkingResource.resolveLazyCrossReference(LazyLinkingResource.java:135
)
at org.eclipse.xtext.linking.lazy.LazyLinkingResource.resolveLazyCrossReferences(LazyLinkingResource.java:11
4)
at org.eclipse.xtext.EcoreUtil2.resolveLazyCrossReferences(EcoreUtil2.java:510)
at org.eclipse.xtext.validation.ResourceValidatorImpl.resolveProxies(ResourceValidatorImpl.java:154)
at org.eclipse.xtext.validation.ResourceValidatorImpl.validate(ResourceValidatorImpl.java:67)
at idainfront.iipax.dsl.generator.Generator.runGenerator(Generator.java:42)
at idainfront.iipax.dsl.generator.Main.main(Main.java:32)
Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: 369
at java.lang.String.substring(Unknown Source)
at org.eclipse.xtext.nodemodel.impl.AbstractNode.getText(AbstractNode.java:95)
at org.eclipse.xtext.nodemodel.util.NodeModelUtils.getTokenText(NodeModelUtils.java:373)
at org.eclipse.xtext.linking.impl.LinkingHelper.getCrossRefNodeAsString(LinkingHelper.java:51)
at org.eclipse.xtext.linking.impl.DefaultLinkingService.getCrossRefNodeAsString(DefaultLinkingService.java:1
39)
at org.eclipse.xtext.linking.impl.DefaultLinkingService.getLinkedObjects(DefaultLinkingService.java:115)
at org.eclipse.xtext.linking.lazy.LazyLinkingResource.getEObject(LazyLinkingResource.java:198)
at org.eclipse.xtext.linking.lazy.LazyLinkingResource.getEObject(LazyLinkingResource.java:175)
... 7 more

I don't really know what files may help you I thought atleast I might post the pom for this file and the mydsl (which is iidsl for me) projects.

Generator pom

IiDSL pom



Hmm... might as well ask, but since I only want to compile a jar file from my main class which turns my dsl file into an xml file by using the generator, do I need to build all the projects they have in the xtext-maven-example or can I simplify it?
(Cinda new to maven Smile )

Thanks for any help

Write you later / Mårten
Re: Maven errors question [message #1060735 is a reply to message #1060731] Tue, 28 May 2013 05:40
Christian Dietrich is currently offline Christian Dietrich
Messages: 4444
Registered: July 2009
Senior Member
Hi,

did you make sure you did not stumbe over http://www.eclipse.org/forums/index.php/m/1022283/?srch=xtext-maven-examples#msg_1022283
Re: Maven errors question [message #1060737 is a reply to message #1060735] Tue, 28 May 2013 05:49
Mårten Carlzon is currently offline Mårten Carlzon
Messages: 60
Registered: March 2013
Location: Sweden
Member

Hi,

I should probably have mentioned it. But I did stumble over it, fell quite hard and no wiser when I got up Smile
I tried to remove the log4j and repackage them in the standalone but it didn't seem to help.
I guess I missed something so will look into it again.

Well, sorry for taking your time if the answer already was here Smile
Write you later / Mårten
Re: Maven errors question [message #1060740 is a reply to message #1060737] Tue, 28 May 2013 06:02
Christian Dietrich is currently offline Christian Dietrich
Messages: 4444
Registered: July 2009
Senior Member
HI,

i fear you have to do some further digging on that place
Re: Maven errors question [message #1060741 is a reply to message #1060740] Tue, 28 May 2013 06:09
Mårten Carlzon is currently offline Mårten Carlzon
Messages: 60
Registered: March 2013
Location: Sweden
Member

Hi,

meh! Sorry for taking up your time. Seems I forgot to fix in the repackage.xml file.
Now I only have the log4j warning but... since it compiles I will take that when I have more time Smile

Sorry again, its like when you ask the teacher about something and just as you ask you find the answer.
Well, at least people here have good patience with me Very Happy

Have a good day

Write you later / Mårten
 Topic: New Target Language
Re: New Target Language [message #1060751 is a reply to message #1060642] Tue, 28 May 2013 07:06
anduril elendil is currently offline anduril elendil
Messages: 4
Registered: May 2013
Junior Member
Hi,

do you have a link for a tutorial or something else? I wrote my first small grammer and would like to translate it to a xml file. But I can't find anything about how to do this. The only thing I found was XSD and XPAND in the documentation of Eclipse Indigo. How Can I do this with Xtend or do I have to use something else? Currently I use Eclipse Juno.

Thx
Re: New Target Language [message #1060756 is a reply to message #1060751] Tue, 28 May 2013 07:23
Claudio Heeg is currently offline Claudio Heeg
Messages: 57
Registered: April 2013
Member
http://www.eclipse.org/Xtext/documentation.html#TutorialCodeGeneration
should give you a nice starting point, I reckon?
It is java based but you can see the static and dynamic parts of the code to be generated, it should be pretty straightforward for other languages.
And, just to prove that other languages are indeed possible:
http://christiandietrich.wordpress.com/2013/04/12/xtext-model-visualization-with-plantuml/

[Updated on: Tue, 28 May 2013 07:32]

Report message to a moderator

Re: New Target Language [message #1060757 is a reply to message #1060751] Tue, 28 May 2013 07:25
Christian Dietrich is currently offline Christian Dietrich
Messages: 4444
Registered: July 2009
Senior Member
Have a look at the 15 mins example extended from the docs

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de
Re: New Target Language [message #1060758 is a reply to message #1060594] Tue, 28 May 2013 07:38
anduril elendil is currently offline anduril elendil
Messages: 4
Registered: May 2013
Junior Member
ok thank you, I'll work that through
 Topic: Correct Indentation
Correct Indentation [message #1060727] Tue, 28 May 2013 05:11
Andrea Sindico is currently offline Andrea Sindico
Messages: 257
Registered: November 2010
Senior Member

Is there a way to provide a service for automatic correction of the indentation like the one provided in the Java editor (i.e. Ctrl+i)?

Follow me on Twitter @andreasindico

Re: Correct Indentation [message #1060730 is a reply to message #1060727] Tue, 28 May 2013 05:27
Alexander Nittka is currently offline Alexander Nittka
Messages: 1085
Registered: July 2009
Senior Member
Hi,

you can configure a formatter. Shift-Ctrl-f invokes the formatter in the editor.

Alex


Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext@itemis.de
Re: Correct Indentation [message #1060780 is a reply to message #1060730] Tue, 28 May 2013 08:25
Andrea Sindico is currently offline Andrea Sindico
Messages: 257
Registered: November 2010
Senior Member

I have uncommented the three lines suggested in the default implementation of the AbstractDeclarativeFormatter

	c.setLinewrap(0, 1, 2).before(getGrammarAccess().getSL_COMMENTRule());
		c.setLinewrap(0, 1, 2).before(getGrammarAccess().getML_COMMENTRule());
		c.setLinewrap(0, 1, 1).after(getGrammarAccess().getML_COMMENTRule());


but it says the getSL_COMMENTRule and getML_COMMENTRule() methods are undefined

am I missing something?


Follow me on Twitter @andreasindico

Re: Correct Indentation [message #1060783 is a reply to message #1060780] Tue, 28 May 2013 08:28
Christian Dietrich is currently offline Christian Dietrich
Messages: 4444
Registered: July 2009
Senior Member
Hi you have to downcast get grammar access to YourDslGrammarAccess

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de
Re: Correct Indentation [message #1060784 is a reply to message #1060783] Tue, 28 May 2013 08:32
Andrea Sindico is currently offline Andrea Sindico
Messages: 257
Registered: November 2010
Senior Member

Hi Christian,
thank you it works


Follow me on Twitter @andreasindico

Re: Correct Indentation [message #1060786 is a reply to message #1060783] Tue, 28 May 2013 08:37
Claudio Heeg is currently offline Claudio Heeg
Messages: 57
Registered: April 2013
Member
Christian Dietrich wrote on Tue, 28 May 2013 14:28
Hi you have to downcast get grammar access to YourDslGrammarAccess

Makes me wonder - shouldn't that be listed as a bug, i.e. should that example not be working as is?

https://bugs.eclipse.org/bugs/show_bug.cgi?id=329996 - Nevermind me.

[Updated on: Tue, 28 May 2013 08:39]

Report message to a moderator

Re: Correct Indentation [message #1060790 is a reply to message #1060786] Tue, 28 May 2013 08:41
Christian Dietrich is currently offline Christian Dietrich
Messages: 4444
Registered: July 2009
Senior Member
Feel free to do so

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de
 Topic: Automatically adding Xtext nature to project
Automatically adding Xtext nature to project [message #1060791] Tue, 28 May 2013 08:46
Phil H is currently offline Phil H
Messages: 70
Registered: November 2012
Member
Hi,

I'm using a GMF editor with xtext. In order to get xtext running corectly, it's necessary to add the xtext nature to the project. Is there way to do this automatically when I create a new gmf diagram. Therefor I'm using the following creation wizard:

<extension point="org.eclipse.ui.newWizards" id="creation-wizard">
    <category
        id="org.eclipse.ui.PLDev"
        name="Prod">
     </category>
     <wizard
       name="Prod"
       icon="icons/PldWizard.png"
       category="org.eclipse.ui.PLDev"
       class="pld.diagram.part.PldCreationWizard"
       id="pld.diagram.part.PldCreationWizardID">
       <description>Creates a new Productline</description>
      </wizard>
   </extension>


Is there a chance to extend the creation wizard in order to add a xtext nature to the project?
Re: Automatically adding Xtext nature to project [message #1060796 is a reply to message #1060791] Tue, 28 May 2013 08:54
Claudio Heeg is currently offline Claudio Heeg
Messages: 57
Registered: April 2013
Member
I'm a little confused as to what you want to achieve precisely, but as far as programmatically adding the nature to a project goes, this thread came to mind:
http://www.eclipse.org/forums/index.php/m/718205/
Especially the two lines mentioned during the last post may be of interest?

From what I understand you have both a textual Xtext file and a graphical representation of it. Where and when do you want to add the nature now, automatically?
Re: Automatically adding Xtext nature to project [message #1060799 is a reply to message #1060791] Tue, 28 May 2013 08:56
Alexander Nittka is currently offline Alexander Nittka
Messages: 1085
Registered: July 2009
Senior Member
Hi,

in the PldCreationWizard class, you should be able to obtain the project, inspect its natures and add the Xtext nature if necessary.

Alex


Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext@itemis.de
 Topic: grammar ignore until next keyword
Re: grammar ignore until next keyword [message #1060827 is a reply to message #1060684] Tue, 28 May 2013 10:37
Henrik Lindberg is currently offline Henrik Lindberg
Messages: 2431
Registered: July 2009
Senior Member
On 2013-27-05 20:37, Stella Levin wrote:
> Hi Henrik, great thanks for reply. The problem is that the full grammar
> is VERY complicated, the statements are multi-line. I just want to
> create simplified editor, with basic keyword coloring and outline view.
> Why is it usually a very bad idea to state keywords as terminals? Why
> "terminal NOT_KWD" doesn't work as expected? Thanks again. Stella

You have overlapping terminals. You will probably never trigger NOT_KWD
terminal rule, because there are other terminal rules with higher
precedence.

Keywords work differently than terminals in the lexer; for rules such as
ID, if it matches a keyword the keyword token will be emitted. That will
not happen if you have the keyword as a terminal on its own. There are
also functionality tied to being a keyword as opposed to other types of
punctuation tokens. I.e. rule of thumb "do not use terminals for keywords".

If you want to be able to create a model (to show in the outline) you
naturally need to parse enough of the syntax. One way this can be done
is to write an external lexer that simplifies the task in the grammar.

Hope that helps.

Regards
- henrik
 Topic: How to define a 'synchronized' method using the model inferrer
How to define a 'synchronized' method using the model inferrer [message #1060821] Tue, 28 May 2013 10:05
Oren Mishali is currently offline Oren Mishali
Messages: 11
Registered: March 2013
Junior Member
Hi all,
I'm using the model inferrer in order to map elements in a model into Java methods. E.g., I have this code:

...
members += model.toMethod("foo", model.newTypeRef(Void::TYPE)) [
body = [ append('''...''') ]
...


Is it possible to define the above Java method as 'synchronized'? I hope it is...

Thanks!
Oren

Re: How to define a 'synchronized' method using the model inferrer [message #1060831 is a reply to message #1060821] Tue, 28 May 2013 10:48
Lorenzo Bettini is currently offline Lorenzo Bettini
Messages: 1128
Registered: July 2009
Senior Member
On 05/28/2013 04:05 PM, Oren Mishali wrote:
> Hi all,
> I'm using the model inferrer in order to map elements in a model into
> Java methods. E.g., I have this code:
>
>
> ..
> members += model.toMethod("foo", model.newTypeRef(Void::TYPE)) [
> body = [ append('''...''') ]
> ..
>
>
> Is it possible to define the above Java method as 'synchronized'? I hope
> it is...

Just inspect the JvmOperation and you can see the get/setSynchronized :)

members += model.toMethod("foo", model.newTypeRef(Void::TYPE)) [
body = [ append('''...''') ]
synchronized = true


--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
HOME: http://www.lorenzobettini.it
 Topic: xtext project creation programmatically
xtext project creation programmatically [message #1060872] Tue, 28 May 2013 15:06
Vincent De Bry is currently offline Vincent De Bry
Messages: 5
Registered: May 2013
Junior Member
Hello,

I would like to create Xtext projects (base + ui) programmatically.
I took a look at xtext project wizard but I cannot figure out which methods of which classes have to be used.

Do someone already had the same need and could provide me with an implementation example ?

Thanks
 Topic: Dependency injection in objects instantiated in custom code
Dependency injection in objects instantiated in custom code [message #1060866] Tue, 28 May 2013 14:28
Erick Fonseca is currently online Erick Fonseca
Messages: 26
Registered: December 2011
Junior Member
My question is mostly related to Google Guice. In my GlobalScopeProvider, I need to instantiate an XtextResource.

myResource = new XtextResource(myUri);


Is there a way I can take advantage of all bindings defined in my DSL module in order to populate XtextResource fields?
Re: Dependency injection in objects instantiated in custom code [message #1060871 is a reply to message #1060866] Tue, 28 May 2013 15:02
Alexander Nittka is currently offline Alexander Nittka
Messages: 1085
Registered: July 2009
Senior Member
Hi,

the whole point of dependency injection is not to use constructors... How about injecting IResourceFactory (bound in DefaultRuntimeModule)? Going back one step, I'd ask, why do you need a new XtextResource in the GlobalScopeProvider - what do you want to achieve?


Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext@itemis.de
Re: Dependency injection in objects instantiated in custom code [message #1060874 is a reply to message #1060871] Tue, 28 May 2013 15:15
Erick Fonseca is currently online Erick Fonseca
Messages: 26
Registered: December 2011
Junior Member
I'm new to dependency injection, still getting the hang of it. I will try that.

Actually, I'm trying to treat imports for files outside the current project or even the workspace. It seems to me that creating a Resource objects for these files might help.
 Topic: Xtext Save Action
Re: Xtext Save Action [message #1060703 is a reply to message #1060333] Tue, 28 May 2013 02:52
junior developer is currently offline junior developer
Messages: 159
Registered: January 2013
Senior Member
Hi Christian,

I want to create field automatically,
When I create an element,ist default fields are created automatically.Which class is used for this.How can I do ?

Best Regrads,
Re: Xtext Save Action [message #1060705 is a reply to message #1060703] Tue, 28 May 2013 02:57
Christian Dietrich is currently offline Christian Dietrich
Messages: 4444
Registered: July 2009
Senior Member
Sorry i cant follow you.
Re: Xtext Save Action [message #1060710 is a reply to message #1060705] Tue, 28 May 2013 03:54
junior developer is currently offline junior developer
Messages: 159
Registered: January 2013
Senior Member
Hi Christian,

I understand you,I search it but I do not find a solution:( I have no idea which class is used . How can I solved this problem.
Re: Xtext Save Action [message #1060715 is a reply to message #1060710] Tue, 28 May 2013 04:24
Christian Dietrich is currently offline Christian Dietrich
Messages: 4444
Registered: July 2009
Senior Member
I don't know your problem. I don't understand it.

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de
Re: Xtext Save Action [message #1060718 is a reply to message #1060715] Tue, 28 May 2013 04:44
junior developer is currently offline junior developer
Messages: 159
Registered: January 2013
Senior Member
I want to do Create an element,its default fields are created automatically such as my grammar :
ContentType returns ContentType:
'ContentType'
name=QualifiedName
'{'
'guID' '=' guID=STRING
'displayName' '=' displayName=STRING
('description' '=' description=STRING)?
('group' '=' group=STRING)?
('parent' '=' parentContentType=[ContentType|QualifiedName])?
(ownedField+=Field (ownedField+=Field)*)?
'}';

Field returns Field:
LookUp | BooleanField | TextField | NumberField;

TextField returns TextField:
'Text' name=QualifiedName '{'
'guID' '=' guID=STRING
'displayName' '=' displayName=STRING
('required' '=' required=EBoolean)?
('unlimitedLenghtInDocumentLibraries' '=' unlimitedLenghtInDocumentLibraries=EBoolean)?
('description' '=' description=STRING)?
('group' '=' group=STRING)?
('default' '=' default=STRING)?
('displaySize' '=' displaySize=INT)?
('maxLength' '=' maxLength=INT)?
'}';


My grammar is below.When I create a contenttype ,ContentType's Fields are created automatically:ownedField+=Field (ownedField+=Field)*)?
When I create ContentType below Text Field is created automatically in the Xtext Editor.User may change its property onlly.I hope ,I can explain my problem.

Text text {
guID = "guID"
displayName="bollty u" required = true unlimitedLenghtInDocumentLibraries= false default = "Default"


}

[Updated on: Tue, 28 May 2013 04:45]

Report message to a moderator

Re: Xtext Save Action [message #1060720 is a reply to message #1060718] Tue, 28 May 2013 04:49
Christian Dietrich is currently offline Christian Dietrich
Messages: 4444
Registered: July 2009
Senior Member
My question still is: do you need that derived element explicitly in
the file

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de
Re: Xtext Save Action [message #1060721 is a reply to message #1060720] Tue, 28 May 2013 04:56
junior developer is currently offline junior developer
Messages: 159
Registered: January 2013
Senior Member
hi,

I I can understand derived element explicitly in the file correctly.no I do not derived elements.I will give own value in the Field's properties.I do not call other elemets .
Re: Xtext Save Action [message #1060724 is a reply to message #1060721] Tue, 28 May 2013 05:00
Christian Dietrich is currently offline Christian Dietrich
Messages: 4444
Registered: July 2009
Senior Member
Sorry if it happens automatically it is derived

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de
Re: Xtext Save Action [message #1060725 is a reply to message #1060721] Tue, 28 May 2013 05:02
Christian Dietrich is currently offline Christian Dietrich
Messages: 4444
Registered: July 2009
Senior Member
BTW why don't you try the hook I proposed (xtextdoxumentprovider it
was I think - the editor callback might be the wrong place

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de
Re: Xtext Save Action [message #1060736 is a reply to message #1060710] Tue, 28 May 2013 05:42
Christian Dietrich is currently offline Christian Dietrich
Messages: 4444
Registered: July 2009
Senior Member
Still the question: did you try to move your code to
XtextDocumentProvider.doSaveDocument

(document may be an XtextDocument)
Re: Xtext Save Action [message #1060752 is a reply to message #1060736] Tue, 28 May 2013 07:09
junior developer is currently offline junior developer
Messages: 159
Registered: January 2013
Senior Member
Hi Christian,

I understand ,it is drived.I do not try XtextDocumentProvider.doSaveDocument.
I wrote code in the
public class EditorCallback extends NatureAddingEditorCallback {
public class EditorCallback extends NatureAddingEditorCallback {
@Override

I solved internal name and Displayname.When I save editor,qualifiedname is wrote in the displayname field and if qualifiedname has emtpt ,remove blanked and then rewrite fullname, and first blanked name is written in the displayname field.I solved my problem .All changes manupulation on the editor .I written my code in the
public void afterSave(XtextEditor editor) .

Now ,I want to drived process (create default field in the right place on the editor when one element is created).I may use XtextDocumentProvider.doSaveDocument.Hence when Xtextdocument is saved ,I will create default elements.Do you have offered an example?
Re: Xtext Save Action [message #1060755 is a reply to message #1060752] Tue, 28 May 2013 07:15
Christian Dietrich is currently offline Christian Dietrich
Messages: 4444
Registered: July 2009
Senior Member
No. Simple downcast and call your code on the xtextdocument

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de
Pages (2): [1  2    »]


Current Time: Tue May 28 17:03:21 EDT 2013

Powered by FUDForum. Page generated in 0.08667 seconds