com.sun.tools.javac.util.Options Java Examples
The following examples show how to use
com.sun.tools.javac.util.Options.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DocCommentParser.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
DocCommentParser(ParserFactory fac, DiagnosticSource diagSource, Comment comment) { this.fac = fac; this.diagSource = diagSource; this.comment = comment; names = fac.names; m = fac.docTreeMaker; Locale locale = (fac.locale == null) ? Locale.getDefault() : fac.locale; Options options = fac.options; boolean useBreakIterator = options.isSet("breakIterator"); if (useBreakIterator || !locale.getLanguage().equals(Locale.ENGLISH.getLanguage())) sentenceBreaker = BreakIterator.getSentenceInstance(locale); initTagParsers(); }
Example #2
Source File: LambdaToMethod.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 6 votes |
private LambdaToMethod(Context context) { context.put(unlambdaKey, this); diags = JCDiagnostic.Factory.instance(context); log = Log.instance(context); lower = Lower.instance(context); names = Names.instance(context); syms = Symtab.instance(context); rs = Resolve.instance(context); operators = Operators.instance(context); make = TreeMaker.instance(context); types = Types.instance(context); transTypes = TransTypes.instance(context); analyzer = new LambdaAnalyzerPreprocessor(); Options options = Options.instance(context); dumpLambdaToMethodStats = options.isSet("debug.dumpLambdaToMethodStats"); attr = Attr.instance(context); forceSerializable = options.isSet("forceSerializable"); }
Example #3
Source File: JavacProcessingEnvironment.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
private Map<String, String> initProcessorOptions(Context context) { Options options = Options.instance(context); Set<String> keySet = options.keySet(); Map<String, String> tempOptions = new LinkedHashMap<String, String>(); for(String key : keySet) { if (key.startsWith("-A") && key.length() > 2) { int sepIndex = key.indexOf('='); String candidateKey = null; String candidateValue = null; if (sepIndex == -1) candidateKey = key.substring(2); else if (sepIndex >= 3) { candidateKey = key.substring(2, sepIndex); candidateValue = (sepIndex < key.length()-1)? key.substring(sepIndex+1) : null; } tempOptions.put(candidateKey, candidateValue); } } return Collections.unmodifiableMap(tempOptions); }
Example #4
Source File: TestInferBinaryName.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
JavaFileManager getFileManager(String classpathProperty, boolean symFileKind, boolean zipFileIndexKind) throws IOException { Context ctx = new Context(); Options options = Options.instance(ctx); options.put("useOptimizedZip", Boolean.toString(zipFileIndexKind == USE_ZIP_FILE_INDEX)); if (symFileKind == IGNORE_SYMBOL_FILE) options.put("ignore.symbol.file", "true"); JavacFileManager fm = new JavacFileManager(ctx, false, null); List<File> path = getPath(System.getProperty(classpathProperty)); fm.setLocation(CLASS_PATH, path); return fm; }
Example #5
Source File: Enter.java From java-n-IDE-for-Android with Apache License 2.0 | 6 votes |
protected Enter(Context context) { context.put(enterKey, this); log = Log.instance(context); reader = ClassReader.instance(context); make = TreeMaker.instance(context); syms = Symtab.instance(context); chk = Check.instance(context); memberEnter = MemberEnter.instance(context); types = Types.instance(context); annotate = Annotate.instance(context); lint = Lint.instance(context); names = Names.instance(context); predefClassDef = make.ClassDef( make.Modifiers(PUBLIC), syms.predefClass.name, null, null, null, null); predefClassDef.sym = syms.predefClass; todo = Todo.instance(context); fileManager = context.get(JavaFileManager.class); Options options = Options.instance(context); pkginfoOpt = PkgInfo.get(options); }
Example #6
Source File: JavacProcessingEnvironment.java From javaide with GNU General Public License v3.0 | 6 votes |
private Map<String, String> initProcessorOptions(Context context) { Options options = Options.instance(context); Set<String> keySet = options.keySet(); Map<String, String> tempOptions = new LinkedHashMap<String, String>(); for(String key : keySet) { if (key.startsWith("-A") && key.length() > 2) { int sepIndex = key.indexOf('='); String candidateKey = null; String candidateValue = null; if (sepIndex == -1) candidateKey = key.substring(2); else if (sepIndex >= 3) { candidateKey = key.substring(2, sepIndex); candidateValue = (sepIndex < key.length()-1)? key.substring(sepIndex+1) : null; } tempOptions.put(candidateKey, candidateValue); } } return Collections.unmodifiableMap(tempOptions); }
Example #7
Source File: JavacProcessingEnvironment.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
private Map<String, String> initProcessorOptions(Context context) { Options options = Options.instance(context); Set<String> keySet = options.keySet(); Map<String, String> tempOptions = new LinkedHashMap<String, String>(); for(String key : keySet) { if (key.startsWith("-A") && key.length() > 2) { int sepIndex = key.indexOf('='); String candidateKey = null; String candidateValue = null; if (sepIndex == -1) candidateKey = key.substring(2); else if (sepIndex >= 3) { candidateKey = key.substring(2, sepIndex); candidateValue = (sepIndex < key.length()-1)? key.substring(sepIndex+1) : null; } tempOptions.put(candidateKey, candidateValue); } } return Collections.unmodifiableMap(tempOptions); }
Example #8
Source File: JavacProcessingEnvironment.java From java-n-IDE-for-Android with Apache License 2.0 | 6 votes |
private Map<String, String> initProcessorOptions(Context context) { Options options = Options.instance(context); Set<String> keySet = options.keySet(); Map<String, String> tempOptions = new LinkedHashMap<String, String>(); for(String key : keySet) { if (key.startsWith("-A") && key.length() > 2) { int sepIndex = key.indexOf('='); String candidateKey = null; String candidateValue = null; if (sepIndex == -1) candidateKey = key.substring(2); else if (sepIndex >= 3) { candidateKey = key.substring(2, sepIndex); candidateValue = (sepIndex < key.length()-1)? key.substring(sepIndex+1) : null; } tempOptions.put(candidateKey, candidateValue); } } return Collections.unmodifiableMap(tempOptions); }
Example #9
Source File: Analyzer.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
protected Analyzer(Context context) { context.put(analyzerKey, this); types = Types.instance(context); log = Log.instance(context); attr = Attr.instance(context); deferredAttr = DeferredAttr.instance(context); argumentAttr = ArgumentAttr.instance(context); make = TreeMaker.instance(context); names = Names.instance(context); Options options = Options.instance(context); String findOpt = options.get("find"); //parse modes Source source = Source.instance(context); allowDiamondWithAnonymousClassCreation = source.allowDiamondWithAnonymousClassCreation(); analyzerModes = AnalyzerMode.getAnalyzerModes(findOpt, source); }
Example #10
Source File: DocCommentParser.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
DocCommentParser(ParserFactory fac, DiagnosticSource diagSource, Comment comment) { this.fac = fac; this.diagSource = diagSource; this.comment = comment; names = fac.names; m = fac.docTreeMaker; Locale locale = (fac.locale == null) ? Locale.getDefault() : fac.locale; Options options = fac.options; boolean useBreakIterator = options.isSet("breakIterator"); if (useBreakIterator || !locale.getLanguage().equals(Locale.ENGLISH.getLanguage())) sentenceBreaker = BreakIterator.getSentenceInstance(locale); initTagParsers(); }
Example #11
Source File: StringConcat.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 6 votes |
private static StringConcat makeConcat(Context context) { Target target = Target.instance(context); String opt = Options.instance(context).get("stringConcat"); if (target.hasStringConcatFactory()) { if (opt == null) { opt = "inline";//"indyWithConstants"; } } else { if (opt != null && !"inline".equals(opt)) { Assert.error("StringConcatFactory-based string concat is requested on a platform that does not support it."); } opt = "inline"; } switch (opt) { case "inline": return new Inline(context); case "indy": return new IndyPlain(context); case "indyWithConstants": return new IndyConstants(context); default: Assert.error("Unknown stringConcat: " + opt); throw new IllegalStateException("Unknown stringConcat: " + opt); } }
Example #12
Source File: DocCommentParser.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
DocCommentParser(ParserFactory fac, DiagnosticSource diagSource, Comment comment) { this.fac = fac; this.diagSource = diagSource; this.comment = comment; names = fac.names; m = fac.docTreeMaker; Locale locale = (fac.locale == null) ? Locale.getDefault() : fac.locale; Options options = fac.options; boolean useBreakIterator = options.isSet("breakIterator"); if (useBreakIterator || !locale.getLanguage().equals(Locale.ENGLISH.getLanguage())) sentenceBreaker = BreakIterator.getSentenceInstance(locale); initTagParsers(); }
Example #13
Source File: DocCommentParser.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
DocCommentParser(ParserFactory fac, DiagnosticSource diagSource, Comment comment) { this.fac = fac; this.diagSource = diagSource; this.comment = comment; names = fac.names; m = fac.docTreeMaker; Locale locale = (fac.locale == null) ? Locale.getDefault() : fac.locale; Options options = fac.options; boolean useBreakIterator = options.isSet("breakIterator"); if (useBreakIterator || !locale.getLanguage().equals(Locale.ENGLISH.getLanguage())) sentenceBreaker = BreakIterator.getSentenceInstance(locale); initTagParsers(); }
Example #14
Source File: Lint.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 5 votes |
protected Lint(Context context) { // initialize values according to the lint options Options options = Options.instance(context); if (options.isSet(Option.XLINT) || options.isSet(Option.XLINT_CUSTOM, "all")) { // If -Xlint or -Xlint:all is given, enable all categories by default values = EnumSet.allOf(LintCategory.class); } else if (options.isSet(Option.XLINT_CUSTOM, "none")) { // if -Xlint:none is given, disable all categories by default values = EnumSet.noneOf(LintCategory.class); } else { // otherwise, enable on-by-default categories values = EnumSet.noneOf(LintCategory.class); Source source = Source.instance(context); if (source.compareTo(Source.JDK1_9) >= 0) { values.add(LintCategory.DEP_ANN); } values.add(LintCategory.REQUIRES_TRANSITIVE_AUTOMATIC); values.add(LintCategory.OPENS); values.add(LintCategory.MODULE); values.add(LintCategory.REMOVAL); } // Look for specific overrides for (LintCategory lc : LintCategory.values()) { if (options.isSet(Option.XLINT_CUSTOM, lc.option)) { values.add(lc); } else if (options.isSet(Option.XLINT_CUSTOM, "-" + lc.option)) { values.remove(lc); } } suppressedValues = EnumSet.noneOf(LintCategory.class); context.put(lintKey, this); augmentor = new AugmentVisitor(context); }
Example #15
Source File: Locations.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
void update(Options optionTable) { for (Option o: options) { String v = optionTable.get(o); if (v != null) { handleOption(o, v); } } }
Example #16
Source File: JNIWriter.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** Construct a class writer, given an options table. */ private JNIWriter(Context context) { context.put(jniWriterKey, this); fileManager = context.get(JavaFileManager.class); log = Log.instance(context); Options options = Options.instance(context); verbose = options.isSet(VERBOSE); checkAll = options.isSet("javah:full"); this.context = context; // for lazyInit() }
Example #17
Source File: JavaCompiler.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 5 votes |
static boolean explicitAnnotationProcessingRequested(Options options) { return options.isSet(PROCESSOR) || options.isSet(PROCESSOR_PATH) || options.isSet(PROCESSOR_MODULE_PATH) || options.isSet(PROC, "only") || options.isSet(XPRINT); }
Example #18
Source File: JavacProcessingEnvironment.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
protected JavacProcessingEnvironment(Context context) { this.context = context; context.put(JavacProcessingEnvironment.class, this); log = Log.instance(context); source = Source.instance(context); diags = JCDiagnostic.Factory.instance(context); options = Options.instance(context); printProcessorInfo = options.isSet(XPRINTPROCESSORINFO); printRounds = options.isSet(XPRINTROUNDS); verbose = options.isSet(VERBOSE); lint = Lint.instance(context).isEnabled(PROCESSING); if (options.isSet(PROC, "only") || options.isSet(XPRINT)) { JavaCompiler compiler = JavaCompiler.instance(context); compiler.shouldStopPolicyIfNoError = CompileState.PROCESS; } fatalErrors = options.isSet("fatalEnterError"); showResolveErrors = options.isSet("showResolveErrors"); werror = options.isSet(WERROR); platformAnnotations = initPlatformAnnotations(); // Initialize services before any processors are initialized // in case processors use them. filer = new JavacFiler(context); messager = new JavacMessager(context, this); elementUtils = JavacElements.instance(context); typeUtils = JavacTypes.instance(context); processorOptions = initProcessorOptions(context); unmatchedProcessorOptions = initUnmatchedProcessorOptions(); messages = JavacMessages.instance(context); taskListener = MultiTaskListener.instance(context); initProcessorClassLoader(); }
Example #19
Source File: JavacProcessingEnvironment.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
protected JavacProcessingEnvironment(Context context) { this.context = context; context.put(JavacProcessingEnvironment.class, this); log = Log.instance(context); source = Source.instance(context); diags = JCDiagnostic.Factory.instance(context); options = Options.instance(context); printProcessorInfo = options.isSet(XPRINTPROCESSORINFO); printRounds = options.isSet(XPRINTROUNDS); verbose = options.isSet(VERBOSE); lint = Lint.instance(context).isEnabled(PROCESSING); if (options.isSet(PROC, "only") || options.isSet(XPRINT)) { JavaCompiler compiler = JavaCompiler.instance(context); compiler.shouldStopPolicyIfNoError = CompileState.PROCESS; } fatalErrors = options.isSet("fatalEnterError"); showResolveErrors = options.isSet("showResolveErrors"); werror = options.isSet(WERROR); platformAnnotations = initPlatformAnnotations(); // Initialize services before any processors are initialized // in case processors use them. filer = new JavacFiler(context); messager = new JavacMessager(context, this); elementUtils = JavacElements.instance(context); typeUtils = JavacTypes.instance(context); processorOptions = initProcessorOptions(context); unmatchedProcessorOptions = initUnmatchedProcessorOptions(); messages = JavacMessages.instance(context); taskListener = MultiTaskListener.instance(context); initProcessorClassLoader(); }
Example #20
Source File: JNIWriter.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** Construct a class writer, given an options table. */ private JNIWriter(Context context) { context.put(jniWriterKey, this); fileManager = context.get(JavaFileManager.class); log = Log.instance(context); Options options = Options.instance(context); verbose = options.isSet(VERBOSE); checkAll = options.isSet("javah:full"); this.context = context; // for lazyInit() syms = Symtab.instance(context); lineSep = System.getProperty("line.separator"); }
Example #21
Source File: RemoveUnusedImports.java From google-java-format with Apache License 2.0 | 5 votes |
private static JCCompilationUnit parse(Context context, String javaInput) throws FormatterException { DiagnosticCollector<JavaFileObject> diagnostics = new DiagnosticCollector<>(); context.put(DiagnosticListener.class, diagnostics); Options.instance(context).put("--enable-preview", "true"); Options.instance(context).put("allowStringFolding", "false"); JCCompilationUnit unit; JavacFileManager fileManager = new JavacFileManager(context, true, UTF_8); try { fileManager.setLocation(StandardLocation.PLATFORM_CLASS_PATH, ImmutableList.of()); } catch (IOException e) { // impossible throw new IOError(e); } SimpleJavaFileObject source = new SimpleJavaFileObject(URI.create("source"), JavaFileObject.Kind.SOURCE) { @Override public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException { return javaInput; } }; Log.instance(context).useSource(source); ParserFactory parserFactory = ParserFactory.instance(context); JavacParser parser = parserFactory.newParser( javaInput, /*keepDocComments=*/ true, /*keepEndPos=*/ true, /*keepLineMap=*/ true); unit = parser.parseCompilationUnit(); unit.sourcefile = source; Iterable<Diagnostic<? extends JavaFileObject>> errorDiagnostics = Iterables.filter(diagnostics.getDiagnostics(), Formatter::errorDiagnostic); if (!Iterables.isEmpty(errorDiagnostics)) { // error handling is done during formatting throw FormatterException.fromJavacDiagnostics(errorDiagnostics); } return unit; }
Example #22
Source File: BaseFileManager.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Set the context for JavacPathFileManager. * @param context the context containing items to be associated with the file manager */ public void setContext(Context context) { log = Log.instance(context); options = Options.instance(context); classLoaderClass = options.get("procloader"); // Avoid initializing Lint boolean warn = options.isLintSet("path"); locations.update(log, warn, FSInfo.instance(context)); // Setting this option is an indication that close() should defer actually closing // the file manager until after a specified period of inactivity. // This is to accomodate clients which save references to Symbols created for use // within doclets or annotation processors, and which then attempt to use those // references after the tool exits, having closed any internally managed file manager. // Ideally, such clients should run the tool via the javax.tools API, providing their // own file manager, which can be closed by the client when all use of that file // manager is complete. // If the option has a numeric value, it will be interpreted as the duration, // in seconds, of the period of inactivity to wait for, before the file manager // is actually closed. // See also deferredClose(). String s = options.get("fileManager.deferClose"); if (s != null) { try { deferredCloseTimeout = (int) (Float.parseFloat(s) * 1000); } catch (NumberFormatException e) { deferredCloseTimeout = 60 * 1000; // default: one minute, in millis } } }
Example #23
Source File: TypeAnnotations.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
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); }
Example #24
Source File: Test.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
JavacFileManager createFileManager(boolean useOptimizedZip, boolean useSymbolFile) { Context c = new Context(); Options options = Options.instance(c); options.put("useOptimizedZip", Boolean.toString(useOptimizedZip)); if (!useSymbolFile) { options.put("ignore.symbol.file", "true"); } return new JavacFileManager(c, false, null); }
Example #25
Source File: Lint.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
protected Lint(Context context) { // initialize values according to the lint options Options options = Options.instance(context); values = EnumSet.noneOf(LintCategory.class); for (Map.Entry<String, LintCategory> e: map.entrySet()) { if (options.lint(e.getKey())) values.add(e.getValue()); } suppressedValues = EnumSet.noneOf(LintCategory.class); context.put(lintKey, this); augmentor = new AugmentVisitor(context); }
Example #26
Source File: JNIWriter.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** Construct a class writer, given an options table. */ private JNIWriter(Context context) { context.put(jniWriterKey, this); fileManager = context.get(JavaFileManager.class); log = Log.instance(context); Options options = Options.instance(context); verbose = options.isSet(VERBOSE); checkAll = options.isSet("javah:full"); this.context = context; // for lazyInit() syms = Symtab.instance(context); lineSep = System.getProperty("line.separator"); }
Example #27
Source File: T6877206.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
JavacFileManager createFileManager(boolean useSymbolFile) { Context ctx = new Context(); Options options = Options.instance(ctx); if (!useSymbolFile) { options.put("ignore.symbol.file", "true"); } return new JavacFileManager(ctx, false, null); }
Example #28
Source File: JavaParser.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
public JavaParser() { context = new Context(); diagnostics = new DiagnosticCollector<>(); context.put(DiagnosticListener.class, diagnostics); Options.instance(context).put("allowStringFolding", "false"); JavacFileManager fileManager = new JavacFileManager(context, true, UTF_8); try { fileManager.setLocation(StandardLocation.PLATFORM_CLASS_PATH, ImmutableList.<File>of()); } catch (IOException e) { // impossible canParse = false; } parserFactory = ParserFactory.instance(context); }
Example #29
Source File: Lint.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
protected Lint(Context context) { // initialize values according to the lint options Options options = Options.instance(context); values = EnumSet.noneOf(LintCategory.class); for (Map.Entry<String, LintCategory> e: map.entrySet()) { if (options.lint(e.getKey())) values.add(e.getValue()); } suppressedValues = EnumSet.noneOf(LintCategory.class); context.put(lintKey, this); augmentor = new AugmentVisitor(context); }
Example #30
Source File: TypeAnnotations.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
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); }