[java formatter] c style comments formatting supported. Note, only single line comments or comments with each line starting with asterisks will be formatted, since by using /* and */ you

This commit is contained in:
yarik
2017-06-16 11:08:53 +03:00
parent c4cfcf98b6
commit ced545552a
34 changed files with 272 additions and 87 deletions
@@ -12,7 +12,7 @@ public class Main {
BinaryOperator<Integer> min = Math::min;
String foo = "xyz";
/*check*/
/*check*/
boolean b = selector.andThen(Collections.singleton(/* "xyz" here */ "xyz")::contains).apply(/* foo here */ foo);
}
}
@@ -3,8 +3,8 @@ import java.util.List;
public class Main {
public static void test(List<CharSequence> list) {
/*before dot*/
/*after dot*/
/*before dot*/
/*after dot*/
list.stream()
/*before dot2*/./*after dot2*/map(cs -> /*length!!!*/ cs.subSequence(/*subsequence*/1, 5).length()).forEach(System.out::println);
}
@@ -3,7 +3,7 @@ import java.util.List;
public class Main {
public static void test(List<CharSequence> list) {
/*out of body*/
/*out of body*/
list.stream().map(cs -> cs/*in body*/.subSequence(1, 5).length()).forEach(System.out::println);
}
}
@@ -2,10 +2,10 @@
import java.util.stream.Stream;
class Test {
void foo(Stream<String> stringStream ) {
stringStream.filter(name -> name.startsWith("A") && name.//comment2
length() > 1//comment
/*comment1*/
).findAny();
}
void foo(Stream<String> stringStream ) {
stringStream.filter(name -> name.startsWith("A") && name.//comment2
length() > 1//comment
/*comment1*/
).findAny();
}
}
@@ -2,9 +2,9 @@
import java.util.stream.Stream;
class Test {
void foo(Stream<String> stringStream ) {
stringStream.filt<caret>er(name -> name.startsWith("A"))//comment
.filter(a -> a.//comment2
length() > 1 /*comment1*/).findAny();
}
void foo(Stream<String> stringStream ) {
stringStream.filt<caret>er(name -> name.startsWith("A"))//comment
.filter(a -> a.//comment2
length() > 1 /*comment1*/).findAny();
}
}
@@ -11,10 +11,10 @@ public class Main {
}
public Number testOptionalComments(Optional<MyList> strList) {
/* optional is present */
/*return something */
/* optional is absent */
/* return null*/
/* optional is present */
/*return something */
/* optional is absent */
/* return null*/
return strList.map(myList -> myList.size() > /*too big*/ 1 ? myList.get(1) : 1.0).orElse(null);
}
}
@@ -8,11 +8,11 @@ class T {
}
else if (s.startsWith("@")) {
return s.substring(1); // return comment
/* inline 1 *//* inline 2 */
/* inline 1 *//* inline 2 */
}
else if (s.startsWith("#")) {
return "#"; // return comment
/* inline */
/* inline */
}
return s; // return comment
}
@@ -21,7 +21,7 @@ public class Main {
}
public static List<String> testUseName() {
/*limit*/
/*limit*/
List<String> list = new ArrayList<>();
long limit = 20;
for (String x = ""; ; x = x /* add "a" */ + "a") {
@@ -10,7 +10,7 @@ public class Test {
// comment2
System.out.println("hello");
/*in return */
/*in return */
String s = "foo" + //inline
"bar";
}
@@ -4,8 +4,8 @@ import java.util.function.Function;
public class Test {
public static void main(String[] args) {
/* bar */
/* who-hoo */
/* bar */
/* who-hoo */
String s = "foo";
}
}
@@ -4,7 +4,7 @@ import java.util.function.Function;
public class Test {
public static void main(String[] args) {
/* bar */
/* bar */
String s = ("a" +/* who-hoo */ "x") + "foo";
}
}
@@ -2,7 +2,7 @@
class Test {
public int test(String s1, String s2) {
return Integer.compare(s1.length(), s2.length());
/*otherwise bigger*/
/*otherwise bigger*/
}
public int test2(String s1, String s2) {
@@ -3,9 +3,9 @@ public class Test {
public void test(String s1, String s2) {
System.out.println(Integer.compare(s1.length(), s2.length()));
System.out.println(Integer.compare(s2.length(), s1.length()));
/*greater!*/
/*less!*/
/*equal!*/
/*greater!*/
/*less!*/
/*equal!*/
System.out.println(Integer.compare(s1.length(), s2.length()));
System.out.println(Integer.compare(s2.length(), s1.length()));
System.out.println(Integer.compare(s2.length(), s1.length()));