Tue, 15 Oct 2013 22:15:35 +0200
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
1 /*
2 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
26 package com.sun.tools.javac.parser;
28 import java.nio.CharBuffer;
30 import com.sun.tools.javac.code.Source;
31 import com.sun.tools.javac.util.Context;
32 import com.sun.tools.javac.util.Log;
33 import com.sun.tools.javac.util.Names;
36 /**
37 * A factory for creating scanners.
38 *
39 * <p><b>This is NOT part of any supported API.
40 * If you write code that depends on this, you do so at your own
41 * risk. This code and its internal interfaces are subject to change
42 * or deletion without notice.</b>
43 */
44 public class ScannerFactory {
45 /** The context key for the scanner factory. */
46 public static final Context.Key<ScannerFactory> scannerFactoryKey =
47 new Context.Key<ScannerFactory>();
49 /** Get the Factory instance for this context. */
50 public static ScannerFactory instance(Context context) {
51 ScannerFactory instance = context.get(scannerFactoryKey);
52 if (instance == null)
53 instance = new ScannerFactory(context);
54 return instance;
55 }
57 final Log log;
58 final Names names;
59 final Source source;
60 final Tokens tokens;
62 /** Create a new scanner factory. */
63 protected ScannerFactory(Context context) {
64 context.put(scannerFactoryKey, this);
65 this.log = Log.instance(context);
66 this.names = Names.instance(context);
67 this.source = Source.instance(context);
68 this.tokens = Tokens.instance(context);
69 }
71 public Scanner newScanner(CharSequence input, boolean keepDocComments) {
72 if (input instanceof CharBuffer) {
73 CharBuffer buf = (CharBuffer) input;
74 if (keepDocComments)
75 return new Scanner(this, new JavadocTokenizer(this, buf));
76 else
77 return new Scanner(this, buf);
78 } else {
79 char[] array = input.toString().toCharArray();
80 return newScanner(array, array.length, keepDocComments);
81 }
82 }
84 public Scanner newScanner(char[] input, int inputLength, boolean keepDocComments) {
85 if (keepDocComments)
86 return new Scanner(this, new JavadocTokenizer(this, input, inputLength));
87 else
88 return new Scanner(this, input, inputLength);
89 }
90 }