public static Annotate instance(Context context) { Annotate instance = context.get(annotateKey); if (instance == null) instance = new Annotate(context); return instance; }
annotate.earlier(new Annotate.Annotator() { Set<Symbol> processed = new HashSet<Symbol>();
Attribute.TypeCompound enterTypeAnnotation(JCAnnotation a, Type expected, Env<AttrContext> env) { return (Attribute.TypeCompound) enterAnnotation(a, expected, env, true); }
/** Completion for classes to be loaded. Before a class is loaded * we make sure its enclosing class (if any) is loaded. */ private void complete(Symbol sym) throws CompletionFailure { if (sym.kind == TYP) { ClassSymbol c = (ClassSymbol)sym; c.members_field = new Scope.ErrorScope(c); // make sure it's always defined annotate.enterStart(); try { completeOwners(c.owner); completeEnclosing(c); } finally { // The flush needs to happen only after annotations // are filled in. annotate.enterDoneWithoutFlush(); } fillIn(c); } else if (sym.kind == PCK) { PackageSymbol p = (PackageSymbol)sym; try { fillIn(p); } catch (IOException ex) { throw new CompletionFailure(sym, ex.getLocalizedMessage()).initCause(ex); } } if (!filling) annotate.flush(); // finish attaching annotations }
protected TypeAnnotations(Context context) { context.put(typeAnnosKey, this); names = Names.instance(context); log = Log.instance(context); syms = Symtab.instance(context); annotate = Annotate.instance(context); attr = Attr.instance(context); Options options = Options.instance(context); }
/** Called after the Enter phase completes. */ public void enterDone() { enterCount--; flush(); }
annotate.enterStart(); ListBuffer<ClassSymbol> prevUncompleted = uncompleted; if (memberEnter.completionEnabled) uncompleted = new ListBuffer<ClassSymbol>(); annotate.enterDone();
} else { try { annotate.enterStart(); memberEnter.memberEnter(tree, env); } finally { annotate.enterDone(); annotate.flush();
buf.append(enterAttributeValue(types.elemtype(expected), l.head, env)); enterAttributeValue(syms.errType, l.head, env); return enterAnnotation((JCAnnotation)tree, expected, env); } else { log.error(tree.pos(), "annotation.value.must.be.annotation"); if (!expected.isErroneous()) log.error(tree.pos(), "annotation.not.valid.for.type", expected); enterAnnotation((JCAnnotation)tree, syms.errType, env); return new Attribute.Error(((JCAnnotation)tree).annotationType.type);
/** Enter a default value for an attribute method. */ private void enterDefaultValue(final JCExpression defaultValue, final Env<AttrContext> localEnv, final MethodSymbol m) { m.defaultValue = annotate.enterAttributeValue(m.type.getReturnType(), defaultValue, localEnv); }
Type currentContainerType = getContainingType(currentAnno, ctx.pos.get(currentAnno), reportError); if (currentContainerType == null) { continue; targetContainerType = currentContainerType; containerValueSymbol = validateContainer(targetContainerType, origAnnoType, ctx.pos.get(currentAnno)); log.error(annoTree.pos(), "duplicate.annotation.invalid.repeated", origAnnoType); c = enterAnnotation(annoTree, targetContainerType, ctx.env); c.setSynthesized(true);
/** * Separate type annotations from declaration annotations and * determine the correct positions for type annotations. * This version only visits types in signatures and should be * called from MemberEnter. * The method takes the Annotate object as parameter and * 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 Worker() { @Override public void run() { JavaFileObject oldSource = log.useSource(env.toplevel.sourcefile); try { new TypeAnnotationPositions(true).scan(tree); } finally { log.useSource(oldSource); } } } ); }
protected TypeAnnotations(Context context) { context.put(typeAnnosKey, this); names = Names.instance(context); log = Log.instance(context); syms = Symtab.instance(context); annotate = Annotate.instance(context); attr = Attr.instance(context); Options options = Options.instance(context); }
/** Called after the Enter phase completes. */ public void enterDone() { enterCount--; flush(); }
annotate.enterStart(); ListBuffer<ClassSymbol> prevUncompleted = uncompleted; if (memberEnter.completionEnabled) uncompleted = new ListBuffer<ClassSymbol>(); annotate.enterDone();
isFirst = false; try { annotate.enterStart(); for (JCExpression impl : tree.implementing) typeAnnotate(impl, baseEnv, sym, tree.pos()); annotate.flush(); annotate.enterDone();
buf.append(enterAttributeValue(types.elemtype(expected), l.head, env)); enterAttributeValue(syms.errType, l.head, env); return enterAnnotation((JCAnnotation)tree, expected, env); } else { log.error(tree.pos(), "annotation.value.must.be.annotation"); if (!expected.isErroneous()) log.error(tree.pos(), "annotation.not.valid.for.type", expected); enterAnnotation((JCAnnotation)tree, syms.errType, env); return new Attribute.Error(((JCAnnotation)tree).annotationType.type);
/** Completion for classes to be loaded. Before a class is loaded * we make sure its enclosing class (if any) is loaded. */ private void complete(Symbol sym) throws CompletionFailure { if (sym.kind == TYP) { ClassSymbol c = (ClassSymbol)sym; c.members_field = new Scope.ErrorScope(c); // make sure it's always defined annotate.enterStart(); try { completeOwners(c.owner); completeEnclosing(c); } finally { // The flush needs to happen only after annotations // are filled in. annotate.enterDoneWithoutFlush(); } fillIn(c); } else if (sym.kind == PCK) { PackageSymbol p = (PackageSymbol)sym; try { fillIn(p); } catch (IOException ex) { throw new CompletionFailure(sym, ex.getLocalizedMessage()).initCause(ex); } } if (!filling) annotate.flush(); // finish attaching annotations }
/** Enter a default value for an attribute method. */ private void enterDefaultValue(final JCExpression defaultValue, final Env<AttrContext> localEnv, final MethodSymbol m) { m.defaultValue = annotate.enterAttributeValue(m.type.getReturnType(), defaultValue, localEnv); }
Type currentContainerType = getContainingType(currentAnno, ctx.pos.get(currentAnno), reportError); if (currentContainerType == null) { continue; targetContainerType = currentContainerType; containerValueSymbol = validateContainer(targetContainerType, origAnnoType, ctx.pos.get(currentAnno)); log.error(annoTree.pos(), "duplicate.annotation.invalid.repeated", origAnnoType); c = enterAnnotation(annoTree, targetContainerType, ctx.env); c.setSynthesized(true);