我使用的格式不正確的現有代碼。 Eclipse格式化程序在格式化時失敗,我是配置格式化程序的新手。因此,經過一段時間的努力,我失敗了。內置模板不起作用。無論如何,我想使用Eclipse的格式化程序,而不是在一個插件。日食代碼格式化程序
我想獲得以下代碼...
/** Class A
*/
public class A
{
/** An int */
int i;
/** An A */
A(int i)
{ this.i = i;
}
/** Gets i */
int getI()
{ int b = i *2;
if(check())
{ try { doIt(); } catch (Exception e) {doIt();}
if (check())
{ if (check()) doIt();
else return i;
}
}
return b;
}
private void doIt() {}
private boolean check() {return false;}
}
...格式化成...
/**
* Class A
*/
public class A {
/**
* An int
*/
int i;
/**
* An A
*/
A(int i){
this.i = i;
}
/**
* Gets i
*/
int getI(){
int b = i *2;
if(check()){
try {
doIt();
} catch (Exception e) {
doIt();
}
if (check()){
if (check()){
doIt();
}else{
return i;
}
}
}
return b;
}
private void doIt() {}
private boolean check() {return false;}
}
有沒有辦法配置Formatter來處理我的問題?
任何幫助表示高度讚賞,因爲這是一個很大的代碼:-)
格式化程序在格式化時如何「失敗」?如果你有錯誤,你應該把它添加到你的問題。 – sharakan
-1實際上沒有指定出錯 –
嗯,我沒有指定錯誤,因爲沒有。代碼沒有按照需要格式化,就是這樣。無論如何,一個正確的答案已經發布。 – aboger