Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Formating with Xtend
Formating with Xtend [message #1053646] Tue, 07 May 2013 06:46 Go to next message
junior developer is currently offline junior developerFriend
Messages: 354
Registered: January 2013
Senior Member
Hi all,

I update Xtext framework .but I have problem.I written pure java code previosly but now Formatting class is a xtend class.

My code for formating :
public class FilesystemFormatter extends AbstractDeclarativeFormatter {
	
	
// It's usually a good idea to activate the following three statements.
// They will add and preserve newlines around comments
//		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());
		@Override
		protected void configureFormatting(FormattingConfig c) {
			FilesystemGrammarAccess f = (FilesystemGrammarAccess) getGrammarAccess();

			c.setAutoLinewrap(120);
			//c.setLinewrap(1).after(f.getFileAccess().getSemicolonKeyword_0_2_1());
			
			//c.setWrappedLineIndentation(f.getFileAccess().getSemicolonKeyword_0_2_1()) ;
			c.setLinewrap(1, 2, 3).around(f.getFilesystemRule());
			c.setLinewrap(1, 2, 3).around(f.getDriveRule());
			c.setLinewrap(1, 1, 2).around(f.getSyncRule());
			c.setLinewrap(1,1,2).around(f.getObjectRule());
			
			List<Pair<Keyword,Keyword>> pairs = f.findKeywordPairs("{", "}");
			for (Pair<Keyword, Keyword> pair : pairs) {
				c.setIndentation(pair.getFirst(), pair.getSecond());
			}
			
			c.setLinewrap(0, 1, 2).before(f.getSL_COMMENTRule());
			c.setLinewrap(0, 1, 2).before(f.getML_COMMENTRule());
			c.setLinewrap(0, 1, 1).after(f.getML_COMMENTRule());
			
		}
		
	
	}



My problem :

FilesystemGrammarAccess f = (FilesystemGrammarAccess) getGrammarAccess(); is not defined in the xtend class.

I want to change this code with Xtend code Sad
Re: Formating with Xtend [message #1053648 is a reply to message #1053646] Tue, 07 May 2013 07:05 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi,

casts are written like this in Xtend:

val FilesystemGrammarAccces f = getGrammarAccess() as
FileSystemGrammarAccess

or even shorter

val f = grammarAccess as FileSystemGrammarAccess

Regards,
Sebastian
--
Looking for professional support for Xtext, Xtend or Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 07.05.13 08:46, schrieb junior developer:
> Hi all,
>
> I update Xtext framework .but I have problem.I written pure java code
> previosly but now Formatting class is a xtend class.
>
> My code for formating :
>
> public class FilesystemFormatter extends AbstractDeclarativeFormatter {
>
>
> // It's usually a good idea to activate the following three statements.
> // They will add and preserve newlines around comments
> // 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());
> @Override
> protected void configureFormatting(FormattingConfig c) {
> FilesystemGrammarAccess f = (FilesystemGrammarAccess)
> getGrammarAccess();
>
> c.setAutoLinewrap(120);
>
> //c.setLinewrap(1).after(f.getFileAccess().getSemicolonKeyword_0_2_1());
>
>
> //c.setWrappedLineIndentation(f.getFileAccess().getSemicolonKeyword_0_2_1())
> ;
> c.setLinewrap(1, 2, 3).around(f.getFilesystemRule());
> c.setLinewrap(1, 2, 3).around(f.getDriveRule());
> c.setLinewrap(1, 1, 2).around(f.getSyncRule());
> c.setLinewrap(1,1,2).around(f.getObjectRule());
>
> List<Pair<Keyword,Keyword>> pairs = f.findKeywordPairs("{",
> "}");
> for (Pair<Keyword, Keyword> pair : pairs) {
> c.setIndentation(pair.getFirst(), pair.getSecond());
> }
>
> c.setLinewrap(0, 1, 2).before(f.getSL_COMMENTRule());
> c.setLinewrap(0, 1, 2).before(f.getML_COMMENTRule());
> c.setLinewrap(0, 1, 1).after(f.getML_COMMENTRule());
>
> }
>
>
> }
>
>
>
> My problem :
>
> FilesystemGrammarAccess f = (FilesystemGrammarAccess)
> getGrammarAccess(); is not defined in the xtend class.
>
> I want to change this code with Xtend code :(
Re: Formating with Xtend [message #1053664 is a reply to message #1053648] Tue, 07 May 2013 08:08 Go to previous messageGo to next message
junior developer is currently offline junior developerFriend
Messages: 354
Registered: January 2013
Senior Member
Hi Sebastian,

I want to use my code that is written in the previosly version, in the Xtext's new version .

I have been written pure java code in the previous Xtext version,now I want to use these code in new Xtext version.is it possible ? because every generated class (such as for Validation,Formating) is a Xtend class .I want to use new version but I want to write pure java code .

must I write xtend code for this version?
Re: Formating with Xtend [message #1053665 is a reply to message #1053664] Tue, 07 May 2013 08:09 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi,

in Xtend you cast as

val f = grammarAccess as FilesystemGrammarAccess


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Formating with Xtend [message #1053666 is a reply to message #1053665] Tue, 07 May 2013 08:11 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
P.S:you can switch back to java for most components shitching the flag in the workflow

var generateXtendStub = false



Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Formating with Xtend [message #1053671 is a reply to message #1053666] Tue, 07 May 2013 08:23 Go to previous messageGo to next message
junior developer is currently offline junior developerFriend
Messages: 354
Registered: January 2013
Senior Member
Hi Christian,

Thank you for your help .
I try var generateXtendStub = false ,but MyDslValidator is still Xtend .can I change this class with java class?
Re: Formating with Xtend [message #1053674 is a reply to message #1053671] Tue, 07 May 2013 08:29 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi, this is a bug/non feature

you may use validation.Java..Valid...Fragment in the workflow instead


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Formating with Xtend [message #1053677 is a reply to message #1053674] Tue, 07 May 2013 08:35 Go to previous messageGo to next message
Claudio Heeg is currently offline Claudio HeegFriend
Messages: 75
Registered: April 2013
Member
You can also just create the Java class (MyDslValidator) there manually and delete the Xtend file.
Same for the generator.

[Updated on: Tue, 07 May 2013 08:37]

Report message to a moderator

Re: Formating with Xtend [message #1053684 is a reply to message #1053674] Tue, 07 May 2013 08:43 Go to previous messageGo to next message
junior developer is currently offline junior developerFriend
Messages: 354
Registered: January 2013
Senior Member
Hi Christian ,

How can I use fragment in the workflow .How can I use MyDSLjavaValidator.java class ?
sorry I don t understand



Christian Dietrich wrote on Tue, 07 May 2013 04:29
Hi, this is a bug/non feature

you may use validation.Java..Valid...Fragment in the workflow instead
Re: Formating with Xtend [message #1053686 is a reply to message #1053684] Tue, 07 May 2013 08:44 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Simply replace the other validation fragment with it ?!?

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Formating with Xtend [message #1053688 is a reply to message #1053677] Tue, 07 May 2013 08:48 Go to previous messageGo to next message
junior developer is currently offline junior developerFriend
Messages: 354
Registered: January 2013
Senior Member

Hi Claudio ,

I create a MydslValidator.java but I regenerate the grammar ,occur MydslValidator.xtend
again
Claudio Heeg wrote on Tue, 07 May 2013 04:35
You can also just create the Java class (MyDslValidator) there manually and delete the Xtend file.
Same for the generator.
Re: Formating with Xtend [message #1053711 is a reply to message #1053688] Tue, 07 May 2013 10:57 Go to previous messageGo to next message
junior developer is currently offline junior developerFriend
Messages: 354
Registered: January 2013
Senior Member
Hi Christian,

My problem is solved with created java class.

Thanks a lots ,
Re: Formating with Xtend [message #1053729 is a reply to message #1053664] Tue, 07 May 2013 12:10 Go to previous messageGo to next message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 760
Registered: July 2009
Location: Hamburg
Senior Member
In the mwe2 workflow, set the variable generateXtendStub to false and
replace the fragments

validation.ValidatorFragment
with
validation.JavaValidatorFragment

and
contentAssist.ContentAssistFragment
with
contentAssist.JavaBasedContentAssistFragment

This will restore the generation of Java stubs and their bindings.

Am 07.05.13 10:08, schrieb junior developer:
> Hi Sebastian,
>
> I want to use my code that is written in the previosly version, in the
> Xtext's new version .
>
> I have been written pure java code in the previous Xtext version,now I
> want to use these code in new Xtext version.is it possible ? because
> every generated class (such as for Validation,Formating) is a Xtend
> class .I want to use new version but I want to write pure java code .
>
> must I write xtend code for this version?


--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com


---
Get professional support from the Xtext committers at www.typefox.io
Re: Formating with Xtend [message #1053821 is a reply to message #1053729] Tue, 07 May 2013 17:36 Go to previous message
junior developer is currently offline junior developerFriend
Messages: 354
Registered: January 2013
Senior Member
Hi Jan,

My problem is solved with replace the fragment .but Do I encounter any problems at a later time.thank you for help,

BEst regrads


Jan Kohnlein wrote on Tue, 07 May 2013 08:10
In the mwe2 workflow, set the variable generateXtendStub to false and
replace the fragments

validation.ValidatorFragment
with
validation.JavaValidatorFragment

and
contentAssist.ContentAssistFragment
with
contentAssist.JavaBasedContentAssistFragment

This will restore the generation of Java stubs and their bindings.

Am 07.05.13 10:08, schrieb junior developer:
> Hi Sebastian,
>
> I want to use my code that is written in the previosly version, in the
> Xtext's new version .
>
> I have been written pure java code in the previous Xtext version,now I
> want to use these code in new Xtext version.is it possible ? because
> every generated class (such as for Validation,Formating) is a Xtend
> class .I want to use new version but I want to write pure java code .
>
> must I write xtend code for this version?


--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
Previous Topic:strange behavior of XImportSection
Next Topic:How can I infer jvm type which has super type which is derived from part of domain model
Goto Forum:
  


Current Time: Thu Mar 28 10:22:04 GMT 2024

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

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

Back to the top