Eclipse C ++格式化程序在方法标识符之前放置新行 [英] Eclipse C++ formatter puts new line before method identifiers

查看:125
本文介绍了Eclipse C ++格式化程序在方法标识符之前放置新行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了Eclipse格式化程序的问题。在声明中声明方法时,它不会正确格式化我的代码。它在方法的返回类型之后放置一条新行。



我已经导出了样式xml文件并检查了其中的设置,但是没有任何设置与这个问题和Eclipse中的设置编辑器在方法声明的示例代码中没有显示相同的问题。



这是一个代码示例,想要发生:

  class MyClass 
{
public:
MyClass();
void myMethod();
};

但是,这是我得到的:

  class MyClass 
{
public:
MyClass();
void
myMethod();
};

再次,在样式编辑器中,代码没有这个问题,看起来只是我想要它在,但在实际的代码中,故事是不同的。



我使用的是3.8.0版本。任何帮助都不胜感激。



编辑:我删除了格式不正确的源文件(将代码格式化多次后无效),并将其替换为相同文件使用相同的方法,相同的结构等。我这次格式化代码,它的工作。这可能是一个错误,但是我将它留下来,以防万一遇到类似的问题,或者有一个解决方案来避免这个问题。首先,

  .metadata\。这两个文件:

>

 文件1:org.eclipse.cdt.core.prefs,将此行从insert更改为不要插入
org.eclipse.cdt.core.formatter.insert_new_line_before_identifier_in_function_declaration =不插入


文件2:org.eclipse.cdt.ui.prefs,
扫描此文件为 insert_new_line_before_identifier_in_function_declaration,并从插入方式做一个类似的改变,不要在其旁插入,应该很明显

注意我在靛蓝和朱诺看到这个问题,上面描述的修复是在juno。


I ran into a problem with the Eclipse formatter. It won't format my code correctly when declaring methods within a class declaration. It puts a new line after the method's return type.

I already exported the style xml file and examined the settings in it, but none of the settings have any apparent connection to this problem, and the settings editor in Eclipse didn't show the same problem happening in it's sample code for method declarations.

Here is an example bit of code for what I want to have happen:

class MyClass
{
    public:
        MyClass();
        void myMethod();
};

However, this is what I get:

class MyClass
{
    public:
        MyClass();
        void
        myMethod();
};

Again, in the styles editor, the code doesn't have this problem and looks just how I want it to, but in the actual code, the story is different.

I'm using version 3.8.0. Any help is appreciated.

Edit: I deleted those source files that were formatted incorrectly (after formatting the code several times to no avail) and replaced them with "identical" files with the same methods, same structure, etc. I formatted the code this time and it worked. This is probably a bug, but I'm leaving it up just in case anyone else encounters a similar problem or has a solution to avoiding this problem in the first place.

解决方案

I hand edited two files under the main eclipse projects directory

.metadata\.plugins\org.eclipse.core.runtime\.settings

The two files:

file 1: org.eclipse.cdt.core.prefs, change this line from "insert" to "do not insert"
 org.eclipse.cdt.core.formatter.insert_new_line_before_identifier_in_function_declaration=do not insert


file 2: org.eclipse.cdt.ui.prefs,
scan this file for "insert_new_line_before_identifier_in_function_declaration" and make a similar change from insert to do not insert next to it, should be obvious

Note I seen this problem on indigo and juno, the fix described above was in juno.

这篇关于Eclipse C ++格式化程序在方法标识符之前放置新行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆