java代码美化_独立的Java代码格式化程序/美化工具/漂亮打印机?

根据对错误报告的错误理解,我的新理解是:https ://bugs.eclipse.org/bugs/show_bug.cgi ? id = 325289 OpenMRSFormatter.xml文件实际上必须是首选项文件,而不是XML文件。

您可以在这里找到这样的文件:https : //bugs.eclipse.org/bugs/attachment.cgi?id=178874

或使用以下格式转换任何XML导出的格式化程序文件:cat formatter.xml | grep设置| sed's / @@'> formatter.asprefs

谢谢米莎

这是我使用Eclipse 3.6 jar制作的。它是仅Java的命令行,并且应该跨平台兼容:

http://www.sendspace.com/file/nm4ptt

有一个使用捆绑的OpenMRSCodeFormatter.xml文件的Shell脚本。示例输出:

misha@misha-d630:~/openmrs-code-formatter$ cat ../Test.java

public class Test {

public a() {

System.out.println("! I did not format this right!");

}

}misha@misha-d630:~/openmrs-code-formatter$ ./format.sh ../Test.java

Configuration Name: OpenMRSFormatter.xml

Starting format job ...

Done.

cat ../misha@misha-d630:~/openmrs-code-formatter$ cat ../Test.java

public class Test {

public a() {

System.out.println("! I did not format this right!");

}

}misha@misha-d630:~/openmrs-code-formatter$

这是基于此处的帖子:http : //www.peterfriese.de/formatting-your-code-using-the-eclipse-code-formatter/

由于我不知道链接将保持多长时间,因此我将在下面描述内容。

这基于Eclipse 3.6 Helios发行版。我在Linux x86上使用了那个,但是它应该在任何版本上都可以使用,因为据我所知,我没有使用任何平台专用的JAR文件。

tar归档文件的内容为:

misha@misha-d630:~$ tar tvjf openmrs-code-formatter.tar.bz2  | sort

tar: Record size = 8 blocks

drwxr-xr-x misha/misha       0 2010-09-11 19:32 openmrs-code-formatter/plugins/

drwxr-xr-x misha/misha       0 2010-09-11 19:33 openmrs-code-formatter/configuration/org.eclipse.equinox.simpleconfigurator/

drwxr-xr-x misha/misha       0 2010-09-11 19:38 openmrs-code-formatter/configuration/

-rw-r--r-- misha/misha  101957 2010-09-11 19:03 openmrs-code-formatter/plugins/org.eclipse.equinox.common_3.6.0.v20100503.jar

-rw-r--r-- misha/misha  107210 2010-09-11 19:32 openmrs-code-formatter/plugins/org.eclipse.core.commands_3.6.0.I20100512-1500.jar

-rw-r--r-- misha/misha  111098 2010-09-11 19:06 openmrs-code-formatter/plugins/org.eclipse.equinox.preferences_3.3.0.v20100503.jar

-rw-r--r-- misha/misha 1147220 2010-09-11 18:45 openmrs-code-formatter/plugins/org.eclipse.osgi_3.6.0.v20100517.jar

-rw-r--r-- misha/misha    1812 2010-09-11 19:33 openmrs-code-formatter/configuration/org.eclipse.equinox.simpleconfigurator/bundles.info

-rw-r--r-- misha/misha  182596 2010-09-11 19:05 openmrs-code-formatter/plugins/org.eclipse.equinox.registry_3.5.0.v20100503.jar

-rw-r--r-- misha/misha  248071 2010-09-11 19:29 openmrs-code-formatter/plugins/org.eclipse.text_3.5.0.v20100601-1300.jar

-rw-r--r-- misha/misha     265 2010-09-11 19:21 openmrs-code-formatter/configuration/config.ini

-rw-r--r-- misha/misha   28554 2010-09-11 19:34 openmrs-code-formatter/OpenMRSFormatter.xml

-rw-r--r-- misha/misha   39331 2010-09-11 19:17 openmrs-code-formatter/plugins/org.eclipse.equinox.simpleconfigurator_1.0.200.v20100503.jar

-rw-r--r-- misha/misha 4504121 2010-09-11 19:27 openmrs-code-formatter/plugins/org.eclipse.jdt.core_3.6.0.v_A58.jar

-rw-r--r-- misha/misha   47023 2010-09-11 18:42 openmrs-code-formatter/plugins/org.eclipse.equinox.launcher_1.1.0.v20100507.jar

-rw-r--r-- misha/misha   52710 2010-09-11 19:29 openmrs-code-formatter/plugins/org.eclipse.core.filesystem_1.3.0.v20100526-0737.jar

-rw-r--r-- misha/misha 6451211 2010-09-11 19:32 openmrs-code-formatter/plugins/com.ibm.icu_4.2.1.v20100412.jar

-rw-r--r-- misha/misha   70928 2010-09-11 19:01 openmrs-code-formatter/plugins/org.eclipse.core.runtime_3.6.0.v20100505.jar

-rw-r--r-- misha/misha  769898 2010-09-11 19:29 openmrs-code-formatter/plugins/org.eclipse.core.resources_3.6.0.v20100526-0737.jar

-rw-r--r-- misha/misha   83817 2010-09-11 19:07 openmrs-code-formatter/plugins/org.eclipse.equinox.app_1.3.0.v20100512.jar

-rw-r--r-- misha/misha   86986 2010-09-11 19:31 openmrs-code-formatter/plugins/org.eclipse.core.expressions_3.4.200.v20100505.jar

-rw-r--r-- misha/misha   90837 2010-09-11 19:05 openmrs-code-formatter/plugins/org.eclipse.core.jobs_3.5.0.v20100515.jar

-rw-r--r-- misha/misha   91928 2010-09-11 19:06 openmrs-code-formatter/plugins/org.eclipse.core.contenttype_3.4.100.v20100505-1235.jar

-rwxr-xr-x misha/misha     111 2010-09-11 19:39 openmrs-code-formatter/format.sh

插件目录中的相关jar直接从Eclipse 3.6插件目录获取。

config.ini的内容是:

misha@misha-d630:~$ more openmrs-code-formatter/configuration/config.ini

osgi.bundles=reference\:file\:org.eclipse.equinox.simpleconfigurator_1.0.200.v20100503.jar@1\:start

org.eclipse.equinox.simpleconfigurator.configUrl=file\:org.eclipse.equinox.simpleconfigurator/bundles.info

eclipse.application=org.eclipse.jdt.core.JavaCodeFormatter

format.sh是:

misha@misha-d630:~$ more openmrs-code-formatter/format.sh

#!/bin/bash

java -jar plugins/org.eclipse.equinox.launcher_1.1.0.v20100507.jar -config OpenMRSFormatter.xml $*

和OpenMRSFormatter.xml可以在这里找到:http ://wiki.openmrs.org/download/attachments/3346087/OpenMRSFormatter.xml?version=1&modificationDate=1282168038000

我认为应该足以复制。

您可以在此处找到基于相同概念的有趣项目:http : //code.google.com/p/maven-java-formatter-plugin/

谢谢米莎

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值