8026510: The name of com.sun.tools.javac.comp.Annotate.Annotator is confusing
Summary: A mostly automated rename Annotate.Annotator->Annotate.Worker and enterAnnotation->run.
Reviewed-by: emc, jjg
--- a/langtools/src/share/classes/com/sun/tools/javac/code/SymbolMetadata.java Tue Oct 15 21:12:33 2013 +0100
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/SymbolMetadata.java Tue Oct 15 22:15:35 2013 +0200
@@ -205,14 +205,14 @@
// Queue a pass that will replace Attribute.Placeholders
// with Attribute.Compound (made from synthesized containers).
- ctx.annotateRepeated(new Annotate.Annotator() {
+ ctx.annotateRepeated(new Annotate.Worker() {
@Override
public String toString() {
return "repeated annotation pass of: " + sym + " in: " + sym.owner;
}
@Override
- public void enterAnnotation() {
+ public void run() {
complete(ctx);
}
});
--- a/langtools/src/share/classes/com/sun/tools/javac/code/TypeAnnotations.java Tue Oct 15 21:12:33 2013 +0100
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/TypeAnnotations.java Tue Oct 15 22:15:35 2013 +0200
@@ -49,7 +49,7 @@
import com.sun.tools.javac.code.Symbol.VarSymbol;
import com.sun.tools.javac.code.Symbol.MethodSymbol;
import com.sun.tools.javac.comp.Annotate;
-import com.sun.tools.javac.comp.Annotate.Annotator;
+import com.sun.tools.javac.comp.Annotate.Worker;
import com.sun.tools.javac.comp.Attr;
import com.sun.tools.javac.comp.AttrContext;
import com.sun.tools.javac.comp.Env;
@@ -116,13 +116,13 @@
* This version only visits types in signatures and should be
* called from MemberEnter.
* The method takes the Annotate object as parameter and
- * adds an Annotator to the correct Annotate queue for
+ * adds an Annotate.Worker to the correct Annotate queue for
* later processing.
*/
public void organizeTypeAnnotationsSignatures(final Env<AttrContext> env, final JCClassDecl tree) {
- annotate.afterRepeated( new Annotator() {
+ annotate.afterRepeated( new Worker() {
@Override
- public void enterAnnotation() {
+ public void run() {
JavaFileObject oldSource = log.useSource(env.toplevel.sourcefile);
try {
@@ -135,9 +135,9 @@
}
public void validateTypeAnnotationsSignatures(final Env<AttrContext> env, final JCClassDecl tree) {
- annotate.validate(new Annotator() { //validate annotations
+ annotate.validate(new Worker() { //validate annotations
@Override
- public void enterAnnotation() {
+ public void run() {
JavaFileObject oldSource = log.useSource(env.toplevel.sourcefile);
try {
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Annotate.java Tue Oct 15 21:12:33 2013 +0100
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Annotate.java Tue Oct 15 22:15:35 2013 +0200
@@ -88,33 +88,33 @@
private int enterCount = 0;
- ListBuffer<Annotator> q = new ListBuffer<Annotator>();
- ListBuffer<Annotator> typesQ = new ListBuffer<Annotator>();
- ListBuffer<Annotator> repeatedQ = new ListBuffer<Annotator>();
- ListBuffer<Annotator> afterRepeatedQ = new ListBuffer<Annotator>();
- ListBuffer<Annotator> validateQ = new ListBuffer<Annotator>();
+ ListBuffer<Worker> q = new ListBuffer<Worker>();
+ ListBuffer<Worker> typesQ = new ListBuffer<Worker>();
+ ListBuffer<Worker> repeatedQ = new ListBuffer<Worker>();
+ ListBuffer<Worker> afterRepeatedQ = new ListBuffer<Worker>();
+ ListBuffer<Worker> validateQ = new ListBuffer<Worker>();
- public void earlier(Annotator a) {
+ public void earlier(Worker a) {
q.prepend(a);
}
- public void normal(Annotator a) {
+ public void normal(Worker a) {
q.append(a);
}
- public void typeAnnotation(Annotator a) {
+ public void typeAnnotation(Worker a) {
typesQ.append(a);
}
- public void repeated(Annotator a) {
+ public void repeated(Worker a) {
repeatedQ.append(a);
}
- public void afterRepeated(Annotator a) {
+ public void afterRepeated(Worker a) {
afterRepeatedQ.append(a);
}
- public void validate(Annotator a) {
+ public void validate(Worker a) {
validateQ.append(a);
}
@@ -134,32 +134,34 @@
enterCount++;
try {
while (q.nonEmpty()) {
- q.next().enterAnnotation();
+ q.next().run();
}
while (typesQ.nonEmpty()) {
- typesQ.next().enterAnnotation();
+ typesQ.next().run();
}
while (repeatedQ.nonEmpty()) {
- repeatedQ.next().enterAnnotation();
+ repeatedQ.next().run();
}
while (afterRepeatedQ.nonEmpty()) {
- afterRepeatedQ.next().enterAnnotation();
+ afterRepeatedQ.next().run();
}
while (validateQ.nonEmpty()) {
- validateQ.next().enterAnnotation();
+ validateQ.next().run();
}
} finally {
enterCount--;
}
}
- /** A client that has annotations to add registers an annotator,
- * the method it will use to add the annotation. There are no
- * parameters; any needed data should be captured by the
- * Annotator.
+ /** A client that needs to run during {@link #flush()} registers an worker
+ * into one of the queues defined in this class. The queues are: {@link #earlier(Worker)},
+ * {@link #normal(Worker)}, {@link #typeAnnotation(Worker)}, {@link #repeated(Worker)},
+ * {@link #afterRepeated(Worker)}, {@link #validate(Worker)}.
+ * The {@link Worker#run()} method will called inside the {@link #flush()}
+ * call. Queues are empties in the abovementioned order.
*/
- public interface Annotator {
- void enterAnnotation();
+ public interface Worker {
+ void run();
String toString();
}
@@ -204,12 +206,12 @@
}
/**
- * Queue the Annotator a on the repeating annotations queue of the
+ * Queue the Worker a on the repeating annotations queue of the
* Annotate instance this context belongs to.
*
- * @param a the Annotator to enqueue for repeating annotation annotating
+ * @param a the Worker to enqueue for repeating annotation annotating
*/
- public void annotateRepeated(Annotator a) {
+ public void annotateRepeated(Worker a) {
Annotate.this.repeated(a);
}
}
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java Tue Oct 15 21:12:33 2013 +0100
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java Tue Oct 15 22:15:35 2013 +0200
@@ -4085,13 +4085,13 @@
public void annotateType(final AnnotatedType type, final List<JCAnnotation> annotations) {
if (annotations.isEmpty())
return;
- annotate.typeAnnotation(new Annotate.Annotator() {
+ annotate.typeAnnotation(new Annotate.Worker() {
@Override
public String toString() {
return "annotate " + annotations + " onto " + type;
}
@Override
- public void enterAnnotation() {
+ public void run() {
List<Attribute.TypeCompound> compounds = fromAnnotations(annotations);
type.typeAnnotations = compounds;
}
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java Tue Oct 15 21:12:33 2013 +0100
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java Tue Oct 15 22:15:35 2013 +0200
@@ -202,7 +202,7 @@
}.importFrom(tsym);
// enter non-types before annotations that might use them
- annotate.earlier(new Annotate.Annotator() {
+ annotate.earlier(new Annotate.Worker() {
Set<Symbol> processed = new HashSet<Symbol>();
public String toString() {
@@ -228,7 +228,7 @@
}
}
}
- public void enterAnnotation() {
+ public void run() {
importFrom(tsym);
}
});
@@ -296,7 +296,7 @@
}.importFrom(tsym);
// enter non-types before annotations that might use them
- annotate.earlier(new Annotate.Annotator() {
+ annotate.earlier(new Annotate.Worker() {
Set<Symbol> processed = new HashSet<Symbol>();
boolean found = false;
@@ -326,7 +326,7 @@
}
}
}
- public void enterAnnotation() {
+ public void run() {
JavaFileObject prev = log.useSource(env.toplevel.sourcefile);
try {
importFrom(tsym);
@@ -841,14 +841,14 @@
if (s.kind != PCK) {
s.resetAnnotations(); // mark Annotations as incomplete for now
}
- annotate.normal(new Annotate.Annotator() {
+ annotate.normal(new Annotate.Worker() {
@Override
public String toString() {
return "annotate " + annotations + " onto " + s + " in " + s.owner;
}
@Override
- public void enterAnnotation() {
+ public void run() {
Assert.check(s.kind == PCK || s.annotationsPendingCompletion());
JavaFileObject prev = log.useSource(localEnv.toplevel.sourcefile);
DiagnosticPosition prevLintPos =
@@ -872,9 +872,9 @@
}
});
- annotate.validate(new Annotate.Annotator() { //validate annotations
+ annotate.validate(new Annotate.Worker() { //validate annotations
@Override
- public void enterAnnotation() {
+ public void run() {
JavaFileObject prev = log.useSource(localEnv.toplevel.sourcefile);
try {
chk.validateAnnotations(annotations, s);
@@ -946,7 +946,7 @@
void annotateDefaultValueLater(final JCExpression defaultValue,
final Env<AttrContext> localEnv,
final MethodSymbol m) {
- annotate.normal(new Annotate.Annotator() {
+ annotate.normal(new Annotate.Worker() {
@Override
public String toString() {
return "annotate " + m.owner + "." +
@@ -954,7 +954,7 @@
}
@Override
- public void enterAnnotation() {
+ public void run() {
JavaFileObject prev = log.useSource(localEnv.toplevel.sourcefile);
try {
enterDefaultValue(defaultValue, localEnv, m);
@@ -963,9 +963,9 @@
}
}
});
- annotate.validate(new Annotate.Annotator() { //validate annotations
+ annotate.validate(new Annotate.Worker() { //validate annotations
@Override
- public void enterAnnotation() {
+ public void run() {
JavaFileObject prev = log.useSource(localEnv.toplevel.sourcefile);
try {
// if default value is an annotation, check it is a well-formed
@@ -1264,13 +1264,13 @@
final DiagnosticPosition deferPos = this.deferPos;
- annotate.normal(new Annotate.Annotator() {
+ annotate.normal(new Annotate.Worker() {
@Override
public String toString() {
return "type annotate " + annotations + " onto " + sym + " in " + sym.owner;
}
@Override
- public void enterAnnotation() {
+ public void run() {
JavaFileObject prev = log.useSource(env.toplevel.sourcefile);
DiagnosticPosition prevLintPos = null;
--- a/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java Tue Oct 15 21:12:33 2013 +0100
+++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java Tue Oct 15 22:15:35 2013 +0200
@@ -1877,7 +1877,7 @@
}
}
- class AnnotationDefaultCompleter extends AnnotationDeproxy implements Annotate.Annotator {
+ class AnnotationDefaultCompleter extends AnnotationDeproxy implements Annotate.Worker {
final MethodSymbol sym;
final Attribute value;
final JavaFileObject classFile = currentClassFile;
@@ -1889,8 +1889,8 @@
this.sym = sym;
this.value = value;
}
- // implement Annotate.Annotator.enterAnnotation()
- public void enterAnnotation() {
+ // implement Annotate.Worker.run()
+ public void run() {
JavaFileObject previousClassFile = currentClassFile;
try {
// Reset the interim value set earlier in
@@ -1904,7 +1904,7 @@
}
}
- class AnnotationCompleter extends AnnotationDeproxy implements Annotate.Annotator {
+ class AnnotationCompleter extends AnnotationDeproxy implements Annotate.Worker {
final Symbol sym;
final List<CompoundAnnotationProxy> l;
final JavaFileObject classFile;
@@ -1917,8 +1917,8 @@
this.l = l;
this.classFile = currentClassFile;
}
- // implement Annotate.Annotator.enterAnnotation()
- public void enterAnnotation() {
+ // implement Annotate.Worker.run()
+ public void run() {
JavaFileObject previousClassFile = currentClassFile;
try {
currentClassFile = classFile;
@@ -1955,7 +1955,7 @@
}
@Override
- public void enterAnnotation() {
+ public void run() {
JavaFileObject previousClassFile = currentClassFile;
try {
currentClassFile = classFile;