mirror of
https://github.com/tiennm99/lombok.git
synced 2026-10-13 22:16:11 +00:00
Do not use reflection to check if annotation is present
This commit is contained in:
1 parent
fe2117e779
commit
763b384a16
3 files changed
+14
-1
No files matched your search
@@ -36,6 +36,9 @@ import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
|
||||
* has been implemented with an empty body. Override whichever methods you need.
|
||||
*/
|
||||
public abstract class EclipseASTAdapter implements EclipseASTVisitor {
|
||||
|
||||
private final boolean deferUntilPostDiet = getClass().isAnnotationPresent(DeferUntilPostDiet.class);
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public void visitCompilationUnit(EclipseNode top, CompilationUnitDeclaration unit) {}
|
||||
|
||||
@@ -98,4 +101,8 @@ public abstract class EclipseASTAdapter implements EclipseASTVisitor {
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public void endVisitStatement(EclipseNode statementNode, Statement statement) {}
|
||||
|
||||
public boolean isDeferUntilPostDiet() {
|
||||
return deferUntilPostDiet ;
|
||||
}
|
||||
}
|
||||
@@ -416,5 +416,11 @@ public interface EclipseASTVisitor {
|
||||
int end = node.get().sourceEnd();
|
||||
return String.format(" [%d, %d]", start, end);
|
||||
}
|
||||
|
||||
public boolean isDeferUntilPostDiet() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
boolean isDeferUntilPostDiet();
|
||||
}
|
||||
@@ -53,7 +53,7 @@ public class EclipseNode extends lombok.core.LombokNode<EclipseAST, EclipseNode,
|
||||
* Visits this node and all child nodes depth-first, calling the provided visitor's visit methods.
|
||||
*/
|
||||
public void traverse(EclipseASTVisitor visitor) {
|
||||
if (!this.isCompleteParse() && visitor.getClass().isAnnotationPresent(DeferUntilPostDiet.class)) return;
|
||||
if (visitor.isDeferUntilPostDiet() && !isCompleteParse()) return;
|
||||
|
||||
switch (getKind()) {
|
||||
case COMPILATION_UNIT:
|
||||
|
||||
Reference in new issue
Block a user