|
Re: Use Formatter1 in Xtext 2.9 [message #1725232 is a reply to message #1725134] |
Tue, 01 March 2016 21:58   |
|
in gradle i get this error in test
java.lang.Error: Unresolved compilation problems:
getNameAssignment_1 cannot be resolved
getExclamationMarkKeyword_2 cannot be resolved
at org.xtext.example.mydsl9.MyDslFormatter.configureFormatting(MyDslFormatter.java:15)
at org.eclipse.xtext.formatting.impl.AbstractDeclarativeFormatter.getConfig(AbstractDeclarativeFormatter.java:93)
at org.eclipse.xtext.formatting.impl.AbstractDeclarativeFormatter.createFormatterStream(AbstractDeclarativeFormatter.java:75)
at org.eclipse.xtext.formatting.impl.DefaultNodeModelFormatter.format(DefaultNodeModelFormatter.java:84)
at org.xtext.example.mydsl9.tests.DummyTest.assertFormattedAs(DummyTest.java:50)
at org.xtext.example.mydsl9.tests.DummyTest.testIt(DummyTest.java:68)
this is cause the xtend-generation is not working properly
can you please file a ticket for that.
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: Use Formatter1 in Xtext 2.9 [message #1725234 is a reply to message #1725232] |
Tue, 01 March 2016 22:03   |
|
as a workaround you might give the xtend compiler some mode hints e.g
class MyDslFormatter extends AbstractDeclarativeFormatter {
@Inject
MyDslGrammarAccess ga
override protected configureFormatting(FormattingConfig config) {
val GreetingElements e = ga.getGreetingAccess()
format(config, e)
}
def private format(FormattingConfig config, GreetingElements e) {
config.setLinewrap().before(e.getNameAssignment_1())
config.setLinewrap().before(e.getExclamationMarkKeyword_2())
}
}
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: Use Formatter1 in Xtext 2.9 [message #1725263 is a reply to message #1725259] |
Wed, 02 March 2016 08:21   |
|
package org.xtext.example.mydsl.formatting
import com.google.inject.Inject
import org.eclipse.xtext.Assignment
import org.eclipse.xtext.formatting.impl.AbstractDeclarativeFormatter
import org.eclipse.xtext.formatting.impl.FormattingConfig
import org.xtext.example.mydsl.services.MyDslGrammarAccess
import org.xtext.example.mydsl.services.MyDslGrammarAccess.GreetingElements
class Formatter extends AbstractDeclarativeFormatter
{
@Inject
MyDslGrammarAccess ga
override protected configureFormatting(FormattingConfig config) {
val GreetingElements e = ga.getGreetingAccess()
format(config, e)
}
def private format(FormattingConfig config, GreetingElements e) {
val Assignment nameToGreet = e.getNameAssignment_1()
config.setNoSpace.after(nameToGreet)
}
}
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
|
|
|
|
Powered by
FUDForum. Page generated in 0.01834 seconds