Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Xtend Code generation for RichStrings (FIXED)(RichString and StringConcatenationClient)
Xtend Code generation for RichStrings (FIXED) [message #1739070] Wed, 27 July 2016 10:29 Go to next message
Neeraj Bhusare is currently offline Neeraj BhusareFriend
Messages: 177
Registered: July 2009
Location: Canada
Senior Member
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.


Twitter : @NeerajBhusare
Blog : https://nbhusare.github.io/
Best regards, Neeraj

[Updated on: Fri, 29 July 2016 03:48]

Report message to a moderator

Re: Xtend Code generation for RichStrings [message #1739071 is a reply to message #1739070] Wed, 27 July 2016 10:58 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
did you have a look at org.eclipse.xtend.core.compiler.XtendCompiler.RichStringPrepareCompiler?
what is the problem you try to solve in the first place?


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtend Code generation for RichStrings [message #1739076 is a reply to message #1739071] Wed, 27 July 2016 12:07 Go to previous messageGo to next message
Neeraj Bhusare is currently offline Neeraj BhusareFriend
Messages: 177
Registered: July 2009
Location: Canada
Senior Member
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


Twitter : @NeerajBhusare
Blog : https://nbhusare.github.io/
Best regards, Neeraj
Re: Xtend Code generation for RichStrings [message #1739081 is a reply to message #1739076] Wed, 27 July 2016 12:33 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Sry I fear you have to digg yourself

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtend Code generation for RichStrings (FIXED) [message #1739255 is a reply to message #1739081] Fri, 29 July 2016 03:46 Go to previous message
Neeraj Bhusare is currently offline Neeraj BhusareFriend
Messages: 177
Registered: July 2009
Location: Canada
Senior Member
I could fix the issue. The solution was to - A) Override the "XLiteral" rule. This made sure the "XStringLiteral" rule from my language got called, B) Fix some inconsistencies in the terminal rules for Rich text.



Twitter : @NeerajBhusare
Blog : https://nbhusare.github.io/
Best regards, Neeraj

[Updated on: Fri, 29 July 2016 03:47]

Report message to a moderator

Previous Topic:[SOLVED] Invalid modifiers for dirty types in content assist
Next Topic:[SOLVED] Could we generate code for existing resources without xtext.builder.participant?
Goto Forum:
  


Current Time: Sat Apr 20 04:47:18 GMT 2024

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

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

Back to the top