Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 355391c

Browse filesBrowse files
michalcohenorenafek
authored andcommitted
After release! (before the 35th May presentation)
1 parent 81a9175 commit 355391c
Copy full SHA for 355391c

File tree

Expand file treeCollapse file tree

3 files changed

+113
-1
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+113
-1
lines changed

‎il.org.spartan.intellij-spartanizer/src/main/il/org/spartan/Leonidas/plugin/tippers/leonidas/EliminateTryBodyEmptyNoCatchesNoFinally.java

Copy file name to clipboardExpand all lines: il.org.spartan.intellij-spartanizer/src/main/il/org/spartan/Leonidas/plugin/tippers/leonidas/EliminateTryBodyEmptyNoCatchesNoFinally.java
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ public void matcher() {
2323
try {
2424
anyNumberOf(statement(0));
2525
} finally {
26-
2726
}
2827
/** end */
2928
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
package il.org.spartan.Leonidas.plugin.tippers;
2+
3+
import static spartanizer.SpartanizerUtils.eval;
4+
5+
/**
6+
* @author Michal Cohen
7+
* @since 12/01/17
8+
*/
9+
public class PluginTest35May {
10+
11+
int x;
12+
13+
public static void main(String[] args) {
14+
int x = 7;
15+
Integer z = 4;
16+
Integer y = eval(4).unless(x > 0); // replace with unless nano pattern
17+
18+
// remove braces
19+
if (x > 3)
20+
x++;
21+
22+
// remove braces
23+
while (!(x > 3))
24+
x++;
25+
26+
// remove double negation
27+
if (x > 4)
28+
System.out.print("banana");
29+
30+
// flip condition
31+
if (x > 2)
32+
x++;
33+
34+
// go fluent
35+
class Bloop {
36+
private int s;
37+
38+
Bloop setX(int ¢) {
39+
this.s = ¢;
40+
return this;
41+
}
42+
43+
int get() {
44+
return s;
45+
}
46+
}
47+
48+
// change to x++
49+
x++;
50+
51+
String s = "banana";
52+
// flip equals
53+
"split".equals(s);
54+
}
55+
56+
private static void foo(boolean ¢) {
57+
System.out.print(¢);
58+
}
59+
60+
// should change parameter to cent
61+
int f(int ¢) {
62+
¢ = ¢ + 5;
63+
return ¢ + 1;
64+
}
65+
}
66+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package il.org.spartan.Leonidas.plugin.tippers.spartanizer;
2+
3+
import java.util.List;
4+
import java.util.function.Function;
5+
6+
public class SpartanizerUtils {
7+
8+
public static <T> Eval<T> eval(T y) {
9+
return new Eval<T>(y);
10+
}
11+
12+
public static <T> T last(List<T> ts) {
13+
return ts.get(ts.size() - 1);
14+
}
15+
16+
public static <T, R> R nullConditional(T x, Function<T, R> f) {
17+
return x == null ? null : f.apply(x);
18+
}
19+
20+
public static <T> Defaults<T> defaults(T then) {
21+
return new Defaults<T>(then);
22+
}
23+
24+
public static class Eval<T> {
25+
T y;
26+
27+
public Eval(T y) {
28+
this.y = y;
29+
}
30+
31+
public T unless(boolean x) {
32+
return !x ? y : null;
33+
}
34+
}
35+
36+
public static class Defaults<T> {
37+
T then;
38+
39+
public Defaults(T then) {
40+
this.then = then;
41+
}
42+
43+
public T to(T else$) {
44+
return then != null ? then : else$;
45+
}
46+
}
47+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.