mirror of
https://github.com/tiennm99/lombok.git
synced 2026-10-14 18:18:48 +00:00
9 files changed
+55
-4
No files matched your search
@@ -40,6 +40,7 @@ import com.sun.tools.javac.tree.JCTree.JCCase;
|
||||
import com.sun.tools.javac.tree.JCTree.JCClassDecl;
|
||||
import com.sun.tools.javac.tree.JCTree.JCExpression;
|
||||
import com.sun.tools.javac.tree.JCTree.JCIdent;
|
||||
import com.sun.tools.javac.tree.JCTree.JCMethodDecl;
|
||||
import com.sun.tools.javac.tree.JCTree.JCMethodInvocation;
|
||||
import com.sun.tools.javac.tree.JCTree.JCStatement;
|
||||
import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
|
||||
@@ -61,12 +62,14 @@ public class HandleHelper extends JavacAnnotationHandler<Helper> {
|
||||
private List<JCStatement> getStatementsFromJcNode(JCTree tree) {
|
||||
if (tree instanceof JCBlock) return ((JCBlock) tree).stats;
|
||||
if (tree instanceof JCCase) return ((JCCase) tree).stats;
|
||||
if (tree instanceof JCMethodDecl) return ((JCMethodDecl) tree).body.stats;
|
||||
return null;
|
||||
}
|
||||
|
||||
private void setStatementsOfJcNode(JCTree tree, List<JCStatement> statements) {
|
||||
if (tree instanceof JCBlock) ((JCBlock) tree).stats = statements;
|
||||
else if (tree instanceof JCCase) ((JCCase) tree).stats = statements;
|
||||
else if (tree instanceof JCMethodDecl) ((JCMethodDecl) tree).body.stats = statements;
|
||||
else throw new IllegalArgumentException("Can't set statements on node type: " + tree.getClass());
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
class HelperTest {
|
||||
public class HelperInInitializationBlock {
|
||||
{
|
||||
final int z = 5;
|
||||
if (Boolean.TRUE) {
|
||||
@@ -0,0 +1,13 @@
|
||||
public class HelperInMethod {
|
||||
int someMethod(int arg1) {
|
||||
final int localVar = 5;
|
||||
|
||||
class Helpers {
|
||||
int helperMethod(int arg) {
|
||||
return arg + localVar;
|
||||
}
|
||||
}
|
||||
final Helpers $Helpers = new Helpers();
|
||||
return $Helpers.helperMethod(10);
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
import lombok.experimental.Helper;
|
||||
class HelperTest {
|
||||
public class HelperInInitializationBlock {
|
||||
{
|
||||
final int z = 5;
|
||||
if (Boolean.TRUE)
|
||||
@@ -24,7 +24,7 @@ class HelperTest {
|
||||
}
|
||||
}
|
||||
}
|
||||
HelperTest() {
|
||||
public HelperInInitializationBlock() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import lombok.experimental.Helper;
|
||||
public class HelperInMethod {
|
||||
public HelperInMethod() {
|
||||
super();
|
||||
}
|
||||
int someMethod(int arg1) {
|
||||
final int localVar = 5;
|
||||
@Helper class Helpers {
|
||||
Helpers() {
|
||||
super();
|
||||
}
|
||||
int helperMethod(int arg) {
|
||||
return (arg + localVar);
|
||||
}
|
||||
}
|
||||
final Helpers $Helpers = new Helpers();
|
||||
return $Helpers.helperMethod(10);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import lombok.experimental.Helper;
|
||||
|
||||
class HelperTest {
|
||||
public class HelperInInitializationBlock {
|
||||
{
|
||||
final int z = 5;
|
||||
if (Boolean.TRUE) {
|
||||
@@ -0,0 +1,16 @@
|
||||
import lombok.experimental.Helper;
|
||||
|
||||
public class HelperInMethod {
|
||||
int someMethod(int arg1) {
|
||||
final int localVar = 5;
|
||||
|
||||
@Helper
|
||||
class Helpers {
|
||||
int helperMethod(int arg) {
|
||||
return arg + localVar;
|
||||
}
|
||||
}
|
||||
|
||||
return helperMethod(10);
|
||||
}
|
||||
}
|
||||
File renamed without changes.
Reference in new issue
Block a user