Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jdt-core-dev] APIs to remove redundant parenthesis

Hi all:

I am using JDT (latest version) to parse Java code in my research project. One particular issue
I met is how to use JDT to remove redundant parentheses. For example:

void rewriteTestConstructorExceptio
0() {
        try {
            {    // r - 1
                { / r -2
                    new CircularFifoBuffer(0);
                } //r - 2
            } //r-1
        } catch (NullPointerException ex) {
            return;
        }
    }


In the above example, parentheses r-1, r-2 and their corresponding matched ones are redundant.

A desirable output should be:

void rewriteTestConstructorExceptio0() {
        try {
                    new CircularFifoBuffer(0);
        } catch (NullPointerException ex) {
            return;
        }
    }



I am wondering could I use JDT to remove some redundant parentheses? either by using
existing implementations in JDT, or writing my owner code (e.g. vistitors). Could any one
kindly give me some hints and comments to do that? or please point some resources
to me.

Any comments are highly appreciated!

--

          Thanks

                    Sai

Back to the top