Domanda

I have the following input:

 a: "a is {Foo foo}"

where foo is of type Foo; the business layer will eventually provide a value for the variable. After processing the input, two files will be generated: A properties file and a Java class:

 a=a is {0}

 public static I18nMessage a( Foo foo ) {
     return new I18nMessageBuilder().id( "a" ).args( foo ).build();
 }

The idea is that I assign each message an id which gives me a Java class that contains methods (where name == id) and which accepts typed parameters to complete the messages.

My question: How should I handle the text strings in my Xtext grammar? I would like to have code completion for the parameter types (Foo) but I have no idea how to handle the rest of the string which can contain spaces and any valid Unicode character.

Suggestions?

È stato utile?

Soluzione

I found a better solution which gives a pretty simple grammar and solves some other problems:

a(Foo foo): "a is " foo;

So the text message is a list of strings and parameters. This way, code completion is very simple and there is no need for escape sequences if you want to add formatters:

a(Date d): "Date is " d( "short" );
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top