My current attempt:
Find: (^$\n[\s]*.*\{|^$\n[\s]*.*@.*$)
Replace: /***/$1
Problem: works well except for the fact that the javadoc boilerplate is not indented.
What change would I implement to indent it accurately?
Input:
public class Main {
class innerClass {
int a;
int b;
@Override
private int goo() {
}
}
String a;
public static void main (String[] args) {
// blablabla
}
@Override
public int foo(int a) {
}
}
output:
/***/
public class Main {
/***/
class innerClass {
int a;
int b;
/***/
@Override
private int goo() {
}
}
String a;
/***/
public static void main (String[] args) {
// blablabla
}
/***/
@Override
public int foo(int a) {
}
}
Expected output:
/***/
public class Main {
/***/
class innerClass {
int a;
int b;
/***/
@Override
private int goo() {
}
}
String a;
/***/
public static void main (String[] args) {
// blablabla
}
/***/
@Override
public int foo(int a) {
}
}
You could try this regex
And replace it with
What it does is essentially finding all
{}
blocks without encountering a field(statements end with;
) and put the same length of indent within the same line of the open curly bracket and a/***/
before it.You may see the test cases here