diff options
author | Philippe Charles <charphi@users.noreply.github.com> | 2018-08-22 09:54:00 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-22 09:54:00 +0200 |
commit | 3ffac6642456e2c7d32952c62df8a565e2d4728b (patch) | |
tree | b0a28ac208dcb8af9add494c4caffe4f11bb287b /src/core/lombok/eclipse/HandlerLibrary.java | |
parent | 35c7c6bda2e71da2e6e06cec5b0fb012c348f694 (diff) | |
parent | 769185e123dfd4a073161eafb58ce50bb79d6201 (diff) | |
download | lombok-3ffac6642456e2c7d32952c62df8a565e2d4728b.tar.gz lombok-3ffac6642456e2c7d32952c62df8a565e2d4728b.tar.bz2 lombok-3ffac6642456e2c7d32952c62df8a565e2d4728b.zip |
Merge branch 'master' into master
Diffstat (limited to 'src/core/lombok/eclipse/HandlerLibrary.java')
-rw-r--r-- | src/core/lombok/eclipse/HandlerLibrary.java | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/src/core/lombok/eclipse/HandlerLibrary.java b/src/core/lombok/eclipse/HandlerLibrary.java index 07c6f97b..0e72fb38 100644 --- a/src/core/lombok/eclipse/HandlerLibrary.java +++ b/src/core/lombok/eclipse/HandlerLibrary.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2014 The Project Lombok Authors. + * Copyright (C) 2009-2018 The Project Lombok Authors. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -212,21 +212,25 @@ public class HandlerLibrary { * @param ast The Compilation Unit that contains the Annotation AST Node. * @param annotationNode The Lombok AST Node representing the Annotation AST Node. * @param annotation 'node.get()' - convenience parameter. + * @param priority current prioritiy + * @return the priority we want to run - MAX_VALUE means never */ - public void handleAnnotation(CompilationUnitDeclaration ast, EclipseNode annotationNode, org.eclipse.jdt.internal.compiler.ast.Annotation annotation, long priority) { + public long handleAnnotation(CompilationUnitDeclaration ast, EclipseNode annotationNode, org.eclipse.jdt.internal.compiler.ast.Annotation annotation, long priority) { TypeResolver resolver = new TypeResolver(annotationNode.getImportList()); TypeReference rawType = annotation.type; - if (rawType == null) return; + if (rawType == null) return Long.MAX_VALUE; String fqn = resolver.typeRefToFullyQualifiedName(annotationNode, typeLibrary, toQualifiedName(annotation.type.getTypeName())); - if (fqn == null) return; + if (fqn == null) return Long.MAX_VALUE; AnnotationHandlerContainer<?> container = annotationHandlers.get(fqn); - if (container == null) return; - if (priority != container.getPriority()) return; + if (container == null) return Long.MAX_VALUE; + + if (priority < container.getPriority()) return container.getPriority(); // we want to run at this priority + if (priority > container.getPriority()) return Long.MAX_VALUE; // it's over- we do not want to run again if (!annotationNode.isCompleteParse() && container.deferUntilPostDiet()) { if (needsHandling(annotation)) container.preHandle(annotation, annotationNode); - return; + return Long.MAX_VALUE; } try { @@ -236,13 +240,16 @@ public class HandlerLibrary { } catch (Throwable t) { error(ast, String.format("Lombok annotation handler %s failed", container.handler.getClass()), t); } + return Long.MAX_VALUE; } /** * Will call all registered {@link EclipseASTVisitor} instances. */ - public void callASTVisitors(EclipseAST ast, long priority, boolean isCompleteParse) { + public long callASTVisitors(EclipseAST ast, long priority, boolean isCompleteParse) { + long nearestPriority = Long.MAX_VALUE; for (VisitorContainer container : visitorHandlers) { + if (priority < container.getPriority()) nearestPriority = Math.min(container.getPriority(), nearestPriority); if (!isCompleteParse && container.deferUntilPostDiet()) continue; if (priority != container.getPriority()) continue; try { @@ -252,5 +259,6 @@ public class HandlerLibrary { String.format("Lombok visitor handler %s failed", container.visitor.getClass()), t); } } + return nearestPriority; } } |