3

我在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->format 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 格式化程序保持我的代码不变。我应该设置哪些设置?

4

1 回答 1

4

enclose the line you don't want eclipse to reformat between // @formatter:off and // @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
于 2012-12-27T17:54:24.703 回答