Xtend Code generation for RichStrings (FIXED) [message #1739070] |
Wed, 27 July 2016 10:29  |
Eclipse User |
|
|
|
Hi All,
In order to solve a problem, I need to understand how the code gets generated for RichString's. I have a very simple function - doPrint(StringConcatenationClient client). When I call this function with parameter '''Welcome «name»''' (name is a var), the following code gets generated.
StringConcatenationClient _client = new StringConcatenationClient() {
@Override
protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
_builder.append("Welcome ");
_builder.append(name, "");
}
};
With a bit of debugging, I was able to figure out the method "_toJavaStatement(RichString richString...)" in the class "XtendCompiler" that does most the job. What I didn't find was the code that generates the body of the appendTo method. To be specific, I am interested in the code that looks at '''Welcome «name»''' and generates the two "_builder.append" statements.
In the XtendLocationInFileProvider#getSignificantTextRegion(), I put a breakpoint inside "if (grammarAccess.getRICH_TEXT_INBETWEENRule() == ruleCall.getRule()) {", but it never got hit. I also spend some time going through classes - RichStringProcessor, AbstractRichTextValueConverter, RichTextInBetweenValueConverter, RichStringPrepareCompiler. But so far I haven't had much luck.
Am I missing something here ? Can someone please provide some pointers.
Tx in advance.
[Updated on: Fri, 29 July 2016 03:48] by Moderator Report message to a moderator
|
|
|
|
Re: Xtend Code generation for RichStrings [message #1739076 is a reply to message #1739071] |
Wed, 27 July 2016 12:07   |
Eclipse User |
|
|
|
Hi Christian,
Thanks for the prompt reply. Please find comments in-lined below
> did you have a look at org.eclipse.xtend.core.compiler.XtendCompiler.RichStringPrepareCompiler?
Yes, I did go through the RichStringPrepareCompiler class. I do not understand it completely so I might have missed something.
> what is the problem you try to solve in the first place?
We have extended the XBase language and added RichString support to it. To accommodate this change, a bit of infrastructure (around RichString) was taken from Xtend.
Now, for richstring like '''Welcome «name»''', this is the generated code - _builder.append("Welcome «name»"); I am trying to fix the behavior so that the generated code looks like this - _builder.append("Welcome "); _builder.append(name, "");
Tx
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02893 seconds