简体   繁体   English

在带有GWT的Eclipse中使用Google代码格式化程序

[英]Using Google code formatter in Eclipse with GWT

I would like to use the Google code style guidelines as an Eclipse code formatter. 我想将Google代码样式指南用作Eclipse代码格式化程序。 So, I imported this formatter XML definition file. 因此,我导入了此格式化程序 XML定义文件。

However, it disrupts GWT comments, which in my code start at the end of the line with /* -{ and continue on to multiple lines. 但是,它破坏了GWT注释,在我的代码中,注释从/* -{行的结尾开始,并继续到多行。 The formatter pushes all these lines to the right margin. 格式化程序将所有这些行推到右边距。

GWT评论推到右边

I set -{ }- as "on-off tags." 我将-{ }-设置为“开关标签”。

GWT评论标签

I also edited the formatter to not format any comments. 我还编辑了格式化程序以不格式化任何注释。

没有评论格式

However, this misformatting still occurs. 但是,这种格式错误仍然发生。

How can I use the Google code-style but still keep GWT comments as-is? 如何使用Google代码样式,但仍保持GWT注释不变?

You need to install the GWT Plugin for Eclipse (or the Google Plugin for Eclipse) and open Java source files with the GWT-aware editor. 您需要安装用于Eclipse的GWT插件(或用于Eclipse的Google插件),并使用支持GWT的编辑器打开Java源文件。 That way, JSNI is no longer seen as a simple comment and is formatted as JavaScript (using the JS formatter settings) 这样,JSNI不再被视为简单的注释,而是被格式化为JavaScript(使用JS Formatter设置)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM