743 } 744 745 /** 746 * Print a representation of the elements to the given writer in 747 * the specified order. The main purpose of this method is for 748 * diagnostics. The exact format of the output is <em>not</em> 749 * specified and is subject to change. 750 * 751 * @param w the writer to print the output to 752 * @param elements the elements to print 753 */ 754 public void printElements(java.io.Writer w, Element... elements) { 755 for (Element element : elements) 756 (new PrintingProcessor.PrintingElementVisitor(w, this)).visit(element).flush(); 757 } 758 759 public Name getName(CharSequence cs) { 760 return names.fromString(cs.toString()); 761 } 762 763 /** 764 * Returns the tree node and compilation unit corresponding to this 765 * element, or null if they can't be found. 766 */ 767 private Pair<JCTree, JCCompilationUnit> getTreeAndTopLevel(Element e) { 768 Symbol sym = cast(Symbol.class, e); 769 Env<AttrContext> enterEnv = getEnterEnv(sym); 770 if (enterEnv == null) 771 return null; 772 JCTree tree = TreeInfo.declarationFor(sym, enterEnv.tree); 773 if (tree == null || enterEnv.toplevel == null) 774 return null; 775 return new Pair<JCTree,JCCompilationUnit>(tree, enterEnv.toplevel); 776 } 777 778 /** 779 * Returns the best approximation for the tree node and compilation unit 780 * corresponding to the given element, annotation and value. 781 * If the element is null, null is returned. 782 * If the annotation is null or cannot be found, the tree node and | 743 } 744 745 /** 746 * Print a representation of the elements to the given writer in 747 * the specified order. The main purpose of this method is for 748 * diagnostics. The exact format of the output is <em>not</em> 749 * specified and is subject to change. 750 * 751 * @param w the writer to print the output to 752 * @param elements the elements to print 753 */ 754 public void printElements(java.io.Writer w, Element... elements) { 755 for (Element element : elements) 756 (new PrintingProcessor.PrintingElementVisitor(w, this)).visit(element).flush(); 757 } 758 759 public Name getName(CharSequence cs) { 760 return names.fromString(cs.toString()); 761 } 762 763 @Override 764 public boolean isFunctionalInterface(TypeElement element) { 765 if (element.getKind() != ElementKind.INTERFACE) 766 return false; 767 else { 768 TypeSymbol tsym = cast(TypeSymbol.class, element); 769 return types.isFunctionalInterface(tsym); 770 } 771 } 772 773 /** 774 * Returns the tree node and compilation unit corresponding to this 775 * element, or null if they can't be found. 776 */ 777 private Pair<JCTree, JCCompilationUnit> getTreeAndTopLevel(Element e) { 778 Symbol sym = cast(Symbol.class, e); 779 Env<AttrContext> enterEnv = getEnterEnv(sym); 780 if (enterEnv == null) 781 return null; 782 JCTree tree = TreeInfo.declarationFor(sym, enterEnv.tree); 783 if (tree == null || enterEnv.toplevel == null) 784 return null; 785 return new Pair<JCTree,JCCompilationUnit>(tree, enterEnv.toplevel); 786 } 787 788 /** 789 * Returns the best approximation for the tree node and compilation unit 790 * corresponding to the given element, annotation and value. 791 * If the element is null, null is returned. 792 * If the annotation is null or cannot be found, the tree node and |