Skip to main content



      Home
Home » Modeling » TMF (Xtext) » [Formatter2] format action does nothing
[Formatter2] format action does nothing [message #1798146] Tue, 13 November 2018 05:24 Go to next message
Eclipse UserFriend
Hi all,

I have started to use Formatter2. I have checked that it binds correctly.

My problem is that Ctrl+Shift+F does absolutely nothing.

My mwe2 contains the following:
fragment = formatting.Formatter2Fragment2 {
	generateXtendStub = true
}


I have used the debugger and made sure that the bindIFormatter2 found in my AbstractMYDSLRuntimeModule.java method hits.

What else could I do?
Is there a specific thing that I should look for?
Re: [Formatter2] format action does nothing [message #1798147 is a reply to message #1798146] Tue, 13 November 2018 05:26 Go to previous messageGo to next message
Eclipse UserFriend
how does your implementation of the formatter class look like? is it called?
Re: [Formatter2] format action does nothing [message #1798148 is a reply to message #1798147] Tue, 13 November 2018 05:42 Go to previous messageGo to next message
Eclipse UserFriend
I left the generated stub for now. I have used the debugger to check and the implementation doesn't get called and the breakpoint is active(has the tick mark).

I have noticed something weird though.
When using
formatter = {
	generateXtendStub = true
}

the formatter class gets generated but doesn't get bound within the AbstractMYDSLRuntimeModule.java. I have to bind it myself adding a bindIFormatter2 method inside MYDSLRuntimeModule.java.

Using
fragment = formatting.Formatter2Fragment2 {
	generateXtendStub = true
}

adds the bind method as expected in AbstractMYDSLRuntimeModule.java.
Re: [Formatter2] format action does nothing [message #1798149 is a reply to message #1798148] Tue, 13 November 2018 05:48 Go to previous messageGo to next message
Eclipse UserFriend
ahh thats a pitfall

formatter = { generateStub = true }

generateXtendStub just decides if xtend or not
Re: [Formatter2] format action does nothing [message #1798150 is a reply to message #1798149] Tue, 13 November 2018 06:38 Go to previous messageGo to next message
Eclipse UserFriend
Christian Dietrich wrote on Tue, 13 November 2018 10:48
ahh thats a pitfall

formatter = { generateStub = true }

generateXtendStub just decides if xtend or not


This solves the binding issue right?
Re: [Formatter2] format action does nothing [message #1798151 is a reply to message #1798150] Tue, 13 November 2018 07:00 Go to previous messageGo to next message
Eclipse UserFriend
yes. then the formatter stub should be generated and called
Re: [Formatter2] format action does nothing [message #1798152 is a reply to message #1798146] Tue, 13 November 2018 07:09 Go to previous messageGo to next message
Eclipse UserFriend
Well my issue still persists.

ayman salah wrote on Tue, 13 November 2018 10:24

My problem is that Ctrl+Shift+F does absolutely nothing.


Re: [Formatter2] format action does nothing [message #1798155 is a reply to message #1798152] Tue, 13 November 2018 07:38 Go to previous messageGo to next message
Eclipse UserFriend
- which xtext version do you use?
- which os do you use
- did you debug into your formatter class?
Re: [Formatter2] format action does nothing [message #1798422 is a reply to message #1798155] Sun, 18 November 2018 06:49 Go to previous messageGo to next message
Eclipse UserFriend
I am using version 2.15 on Windows 7.
I tried to debug into my formatter class and the breakpoint is never hit.

I though noticed that when hitting Ctrl+Shift+F the mouse cursor becomes the busy icon (sand clock thing) for a second then nothing happens.
Re: [Formatter2] format action does nothing [message #1798423 is a reply to message #1798422] Sun, 18 November 2018 06:56 Go to previous messageGo to next message
Eclipse UserFriend
So I found that in my ui package plugin.xml file I had the following:
<extension
        point="org.eclipse.ui.activities">
     <activity
           id="com.test.mydsl.ui.Source"
           name="Source">
     </activity>
     <activityPatternBinding
           activityId="com.test.mydsl.ui.Source"
           pattern=".*/org.eclipse.xtext.ui.FormatAction">
     </activityPatternBinding>
  </extension>


When I removed that, the format option appeared in the menu that appears when right mouse click is hit inside the editor which is an improvement.

Guess what though, the format menu item is disabled for some reason.
Re: [Formatter2] format action does nothing [message #1798424 is a reply to message #1798149] Sun, 18 November 2018 07:03 Go to previous messageGo to next message
Eclipse UserFriend
Christian Dietrich wrote on Tue, 13 November 2018 10:48
ahh thats a pitfall

formatter = { generateStub = true }

generateXtendStub just decides if xtend or not


Doing this though didn't add bindIFormatter2() method to AbstractMYDSLUiModule. Has this moved to somewhere else or something?

I still manually added it to my MYDSLUiModule.java
Re: [Formatter2] format action does nothing [message #1798425 is a reply to message #1798424] Sun, 18 November 2018 07:06 Go to previous messageGo to next message
Eclipse UserFriend
ayman salah wrote on Sun, 18 November 2018 12:03
Christian Dietrich wrote on Tue, 13 November 2018 10:48
ahh thats a pitfall

formatter = { generateStub = true }

generateXtendStub just decides if xtend or not


Doing this though didn't add bindIFormatter2() method to AbstractMYDSLUiModule. Has this moved to somewhere else or something?

I still manually added it to my MYDSLUiModule.java


Never mind this, I thought it is in the UiModule not in the RuntimeModule. I have now removed it from the UiModule.
Re: [Formatter2] format action does nothing [message #1798426 is a reply to message #1798425] Sun, 18 November 2018 07:57 Go to previous message
Eclipse UserFriend
So umm,

I fixed my issue. I have had a class that overrides XtextSourceViewerConfiguration and it did override getContentFormatter and used to return null because I have had the formatter disabled before because the old formatter had loads of issues.

Now, the breakpoints inside the formatter class work.

And just for the record I have found that out by debugging XtextEditor.class createActions() method.

[Updated on: Sun, 18 November 2018 07:58] by Moderator

Previous Topic:Grammar and Color high light of Nested Variable Names
Next Topic:Unable to find mydsl package literals
Goto Forum:
  


Current Time: Fri Jun 20 16:47:20 EDT 2025

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

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

Back to the top