我怎样才能更改我的eclipse源格式化程序设置来处理以下示例?

时间:2012-12-27 17:48:50

标签: java eclipse

我在eclipse中写了这段代码

protected void createTables(SQLiteDatabase db) {
        db.execSQL(
                                          "create table " + CUSTOMERS_TABLE +" (" +                     
                        CustomerId + " text primary key," +
                        FirstName + " text," +
                        MiddleName + " text," +
                        LastName + " text," +
                        Portrait + " BLOB," +
                        Gender + " integer," +
                        Age + " integer," +
                        Passed + " integer"+
                ");"

但是当我使用source->格式化我的代码时,eclipse使它们像这样

protected void createTables(SQLiteDatabase db) {
        db.execSQL("create table " + CUSTOMERS_TABLE + " (" + CustomerId
                + " text primary key," + FirstName + " text," + MiddleName
                + " text," + LastName + " text," + Portrait + " BLOB," + Gender
                + " integer," + Age + " integer,"
                + Passed
                + " integer" +");"

我希望eclipse格式化程序保留我的代码。我应该设置哪些设置?

1 个答案:

答案 0 :(得分:4)

将您不希望eclipse的行包含在// @formatter:off// @formatter:on之间重新格式化:

protected void createTables(SQLiteDatabase db) {
    // @formatter:off
    db.execSQL(
                                      "create table " + CUSTOMERS_TABLE +" (" +                     
                    CustomerId + " text primary key," +
                    FirstName + " text," +
                    MiddleName + " text," +
                    LastName + " text," +
                    Portrait + " BLOB," +
                    Gender + " integer," +
                    Age + " integer," +
                    Passed + " integer"+
            ");"
    // @formatter:on