是否有人为 Eclipse IDE 创建了符合 Android 代码样式规则的 Java 代码格式化程序配置文件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2480596/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 14:33:06  来源:igfitidea点击:

Did anyone create the Java Code Formatter Profile for Eclipse IDE that conforms to the Android Code Style Rules?

androideclipsecoding-style

提问by yvolk

Android Code Style Guidedefines "Android Code Style Rules".
To conform to these rules one have to change quite a number of settings of the Java Code Formatter (Window->Preferences->Java->Code Style->Formatter) default profile (in Eclipse IDE).

Android Code Style Guide定义了“Android Code Style Rules”。
为了符合这些规则,必须更改 Java 代码格式化程序(Window->Preferences->Java->Code Style->Formatter)默认配置文件(在 Eclipse IDE 中)的大量设置。

Did anyone manage to configure the formatter to follow the "Android Code Style Rules" already?
If yes, please export the Formatter profile and publish to be used by community.

有没有人设法将格式化程序配置为遵循“Android 代码样式规则”?
如果是,请导出格式化程序配置文件并发布以供社区使用。

PS: I've tried to do this myself but I've found that there are too many formatter options available, and most of them are not mentioned in the Code Style Guide :-(

PS:我自己尝试过这样做,但我发现可用的格式化程序选项太多了,并且代码样式指南中没有提到其中的大部分:-(

回答by kroimon

There are pre-made formatter rules available from the platform/development.gitrepository (GitHub mirror, in folder /ide/eclipse).

platform/development.git存储库(GitHub 镜像,在文件夹/ide/eclipse 中)提供了预制的格式化程序规则。

So you can simply import android-formatting.xmland android.importorderas mentioned here.

所以你可以简单地导入android-formatting.xmlandroid.importorder这里提到的。

回答by Drew Dara-Abrams

On a related note, here's how developers around Google keep their various Eclipse instances all in agreement: Workspace Mechanic for Eclipse

在相关说明中,以下是 Google 周围的开发人员如何使他们的各种 Eclipse 实例保持一致:Workspace Mechanic for Eclipse

回答by omermuhammed

The link in kroimon's answer to android formatter rules is broken. Hereis the correct one.

kroimon 对 android 格式化程序规则的回答中的链接已损坏。是正确的。

回答by Viki

Sync the source code according to these instructions. The formatting guidelines are in the file development/ide/eclipse/android-formatting.xml. You can import it with Eclipse.

根据这些说明同步源代码。格式指南位于文件 development/ide/eclipse/android-formatting.xml 中。您可以使用 Eclipse 导入它。

Menu bar -> Window -> Preferences -> Java -> Code Style -> Formatter -> Import

菜单栏 -> 窗口 -> 首选项 -> Java -> 代码样式 -> 格式化程序 -> 导入

Point it to the path of the android-formatting.xml

将其指向 android-formatting.xml 的路径

回答by Moritz

I think personal or team preferences vary to much to globally enforce a coding style. So every body should deploy his project specific coding style.

我认为个人或团队的偏好差异很大,以在全球范围内强制实施编码风格。所以每个人都应该部署他的项目特定的编码风格。