Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Use spaces instead of tab in generated code [solved]
Use spaces instead of tab in generated code [solved] [message #1689583] Mon, 23 March 2015 21:56 Go to next message
Jimmy Lu is currently offline Jimmy LuFriend
Messages: 11
Registered: October 2014
Junior Member
I have a project created using EMF 2.9.2 where everything was working fine. Today I migrated it to EMF 2.10.1, and found the newly generated code uses tab indentation in many places (e.g. comments) instead of spaces. How can I fix this?

Note that I have already set my Preferences->Java->Code Style->Formatter->Indentation->Tab policy = Spaces only


Turns out to be a bug in Java Formatter Importer, that my imported change is not picked up until I manually change something and save it.

[Updated on: Mon, 23 March 2015 22:20]

Report message to a moderator

Re: Use spaces instead of tab in generated code comments [message #1689729 is a reply to message #1689583] Tue, 24 March 2015 07:42 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30541
Registered: July 2009
Senior Member
Jimmy,

Do you have the GenModel's Code Formatting property set to true and the
Comment Formatting set to false? If Code Formatting is set to true,
JDT should do the formatting, if it's set false, it should use the
preference's setting:

String tabCharacter =
options.get(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR);
if (JavaCore.TAB.equals(tabCharacter))
{
jControlModel.setLeadingTabReplacement("\t");
}
else
{
String spaces = "";
for (int i = Integer.parseInt(tabSize); i > 0; --i)
{
spaces += " ";
}
jControlModel.setLeadingTabReplacement(spaces);
}

Note that once it's messed up in the workspace, regenerating might not
fix it until you discard the local changes.

On 23/03/2015 10:56 PM, Jimmy Lu wrote:
> I have a project created using EMF 2.9.2 where everything was working
> fine. Today I migrated it to EMF 2.10.1, and found the newly
> generated code uses tab to indent the comments instead of spaces. How
> can I fix this?
>
> Note that I have already set my Preferences->Java->Code
> Style->Formatter->Indentation->Tab policy = Spaces only
Re: Use spaces instead of tab in generated code comments [message #1690191 is a reply to message #1689729] Wed, 25 March 2015 15:33 Go to previous message
Jimmy Lu is currently offline Jimmy LuFriend
Messages: 11
Registered: October 2014
Junior Member
Thank you for the help I resolved the problem. My
Code Formatting = false
Comment Formatting = false
And it should have picked up the settings in my preferences, but it did not until I change and save the preferences. I guess this is a minor bug here.

Ed Merks wrote on Tue, 24 March 2015 07:42
Jimmy,

Do you have the GenModel's Code Formatting property set to true and the
Comment Formatting set to false? If Code Formatting is set to true,
JDT should do the formatting, if it's set false, it should use the
preference's setting:

String tabCharacter =
options.get(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR);
if (JavaCore.TAB.equals(tabCharacter))
{
jControlModel.setLeadingTabReplacement("\t");
}
else
{
String spaces = "";
for (int i = Integer.parseInt(tabSize); i > 0; --i)
{
spaces += " ";
}
jControlModel.setLeadingTabReplacement(spaces);
}

Note that once it's messed up in the workspace, regenerating might not
fix it until you discard the local changes.

Previous Topic:Current Release Version of CDO
Next Topic:EMF : Error loading XMI file
Goto Forum:
  


Current Time: Mon Oct 14 18:46:28 GMT 2019

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

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

Back to the top