![]() ![]() One of those jars isn’t needed, but I can’t remember which. We already tried to use External Code Formatter, but it didn't work on Intellij 9. They worked for my eclipse installation : With Eclipse 'alone' we used to have some exported configuration, and before anybody starts to work, the first step is just to import this configuration. Step 5: Now go to Settings > Other Settings > Eclipse Code formatter. Locate the directory you want to save it. Eclipse > Window > Preferences > Java > Code Style > Formatter: Choose Active Profile from the list. Step 4: After successful installation you can see a blue Eclipse Icon in the top pen. All you need is to export theses files before importing them. Select it and Click Install button in the right section. They may have different versions on your eclipse installation. Step 3: Type Eclipse Code Formatter in the search box. Here’s the list of jars I had to add to the classpath to get the code formatter to work : TextEdit te = cf.format(CodeFormatter.K_UNKNOWN, code, 0,code.length(),0,null) String code = "public class geo" ĬodeFormatter cf = new DefaultCodeFormatter() The Java > Code Style > Formatter preference page lets you manage your code formatter profiles for the Java code formatter. ![]() Public abstract TextEdit format(int kind, I was right.ĭefaultCodeFormatter implements the method : So, I started to search about classes derived from it, and so I found out about DefaultCodeFormatter, which I presumed was what I was looking for. Thanks to VonC‘s answer, I found out about the CodeFormatter class … and 10 jars and 2 hours later, I’ve got it working.ĬodeFormatter is an abstract class, which means you can’t instantiate it directly. However, it doesnt actually save the preference and the project continues to use the overall workspace setting. I was wondering if I could use the Eclipse Code Formatter from inside my code … so, the logical thing to do was to ask on stackoverflow, and see if anyone knew how to do that. UPDATE : I have since upgraded to Eclipse Luna (4.4) and things appeared to be better, in that having selected Configure Project Specific Settings and selected a project, you can now select a code formatter. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |