Package com.sun.tools.javac.util

Examples of com.sun.tools.javac.util.Options


   */
  public static RootDoc createJavadoc(File sourcedir, ListBuffer<String> javaNames, ListBuffer<String> subPackages, Map<String,String> simpleOptions) throws Exception{

    Context context = new Context();
   
      Options options = Options.instance(context);
    options.put(OptionName.SOURCEPATH, sourcedir.getAbsolutePath());
    // TODO make the encoding more flexible
    String encoding = IoBoostUtils.UTF_8;
    if (!options.isSet(OptionName.ENCODING))
      options.put(OptionName.ENCODING, encoding);

      ListBuffer<String[]> optionList = new ListBuffer<String[]>();
    optionList.append(new String[] { OptionName.SOURCEPATH.toString(),
        sourcedir.getAbsolutePath() });

View Full Code Here


                resetProperties = true;
            }

            Context c = new Context();
            if (!useSymbolFile) {
                Options options = Options.instance(c);
                options.put("ignore.symbol.file", "true");
            }

            return new JavacFileManager(c, false, null);
        } finally {
            if (resetProperties) {
View Full Code Here

        }

        setDocletInvoker(argv);
        ListBuffer<String> subPackages = new ListBuffer<String>();
        ListBuffer<String> excludedPackages = new ListBuffer<String>();
        Options compOpts = Options.instance(context);
        boolean docClasses = false;

        // Parse arguments
        for (int i = 0 ; i < argv.length ; i++) {
            String arg = argv[i];
            if (arg.equals("-subpackages")) {
                oneArg(argv, i++);
                addToList(subPackages, argv[i]);
            } else if (arg.equals("-exclude")){
                oneArg(argv, i++);
                addToList(excludedPackages, argv[i]);
            } else if (arg.equals("-verbose")) {
                setOption(arg);
                compOpts.put("-verbose", "");
            } else if (arg.equals("-encoding")) {
                oneArg(argv, i++);
                encoding = argv[i];
                compOpts.put("-encoding", argv[i]);
            } else if (arg.equals("-breakiterator")) {
                breakiterator = true;
                setOption("-breakiterator");
            } else if (arg.equals("-quiet")) {
                quiet = true;
                setOption("-quiet");
            } else if (arg.equals("-help")) {
                usage();
                exit();
            } else if (arg.equals("-Xclasses")) {
                setOption(arg);
                docClasses = true;
            } else if (arg.equals("-Xwerror")) {
                setOption(arg);
                rejectWarnings = true;
            } else if (arg.equals("-private")) {
                setOption(arg);
                setFilter(ModifierFilter.ALL_ACCESS);
            } else if (arg.equals("-package")) {
                setOption(arg);
                setFilter(PUBLIC | PROTECTED |
                          ModifierFilter.PACKAGE );
            } else if (arg.equals("-protected")) {
                setOption(arg);
                setFilter(PUBLIC | PROTECTED );
            } else if (arg.equals("-public")) {
                setOption(arg);
                setFilter(PUBLIC);
            } else if (arg.equals("-source")) {
                oneArg(argv, i++);
                if (compOpts.get("-source") != null) {
                    usageError("main.option.already.seen", arg);
                }
                compOpts.put("-source", argv[i]);
            } else if (arg.equals("-prompt")) {
                compOpts.put("-prompt", "-prompt");
                messager.promptOnError = true;
            } else if (arg.equals("-sourcepath")) {
                oneArg(argv, i++);
                if (compOpts.get("-sourcepath") != null) {
                    usageError("main.option.already.seen", arg);
                }
                compOpts.put("-sourcepath", argv[i]);
            } else if (arg.equals("-classpath")) {
                oneArg(argv, i++);
                if (compOpts.get("-classpath") != null) {
                    usageError("main.option.already.seen", arg);
                }
                compOpts.put("-classpath", argv[i]);
            } else if (arg.equals("-sysclasspath")) {
                oneArg(argv, i++);
                if (compOpts.get("-bootclasspath") != null) {
                    usageError("main.option.already.seen", arg);
                }
                compOpts.put("-bootclasspath", argv[i]);
            } else if (arg.equals("-bootclasspath")) {
                oneArg(argv, i++);
                if (compOpts.get("-bootclasspath") != null) {
                    usageError("main.option.already.seen", arg);
                }
                compOpts.put("-bootclasspath", argv[i]);
            } else if (arg.equals("-extdirs")) {
                oneArg(argv, i++);
                if (compOpts.get("-extdirs") != null) {
                    usageError("main.option.already.seen", arg);
                }
                compOpts.put("-extdirs", argv[i]);
            } else if (arg.equals("-overview")) {
                oneArg(argv, i++);
            } else if (arg.equals("-doclet")) {
                i++;  // handled in setDocletInvoker
            } else if (arg.equals("-docletpath")) {
                i++;  // handled in setDocletInvoker
            } else if (arg.equals("-locale")) {
                if (i != 0)
                    usageError("main.locale_first");
                oneArg(argv, i++);
                docLocale = argv[i];
            } else if (arg.startsWith("-XD")) {
                String s = arg.substring("-XD".length());
                int eq = s.indexOf('=');
                String key = (eq < 0) ? s : s.substring(0, eq);
                String value = (eq < 0) ? s : s.substring(eq+1);
                compOpts.put(key, value);
            }
            // call doclet for its options
            // other arg starts with - is invalid
            else if ( arg.startsWith("-") ) {
                int optionLength;
                optionLength = docletInvoker.optionLength(arg);
                if (optionLength < 0) {
                    // error already displayed
                    exit();
                } else if (optionLength == 0) {
                    // option not found
                    usageError("main.invalid_flag", arg);
                } else {
                    // doclet added option
                    if ((i + optionLength) > argv.length) {
                        usageError("main.requires_argument", arg);
                    }
                    ListBuffer<String> args = new ListBuffer<String>();
                    for (int j = 0; j < optionLength-1; ++j) {
                        args.append(argv[++i]);
                    }
                    setOption(arg, args.toList());
                }
            } else {
                javaNames.append(arg);
            }
        }

        if (javaNames.isEmpty() && subPackages.isEmpty()) {
            usageError("main.No_packages_or_classes_specified");
        }

        if (!docletInvoker.validOptions(options.toList())) {
            // error message already displayed
            exit();
        }

        JavadocTool comp = JavadocTool.make0(context);
        if (comp == null) return false;

        if (showAccess == null) {
            setFilter(defaultFilter);
        }

        LanguageVersion languageVersion = docletInvoker.languageVersion();
        RootDocImpl root = comp.getRootDocImpl(
                docLocale, encoding, showAccess,
                javaNames.toList(), options.toList(), breakiterator,
                subPackages.toList(), excludedPackages.toList(),
                docClasses,
                // legacy?
                languageVersion == null || languageVersion == LanguageVersion.JAVA_1_1, quiet);

        // pass off control to the doclet
        boolean ok = root != null;
        if (ok) ok = docletInvoker.start(root);

        // We're done.
        if (compOpts.get("-verbose") != null) {
            tm = System.currentTimeMillis() - tm;
            messager.notice("main.done_in", Long.toString(tm));
        }

        return ok;
View Full Code Here

                resetProperties = true;
            }

            Context c = new Context();
            if (!useSymbolFile) {
                Options options = Options.instance(c);
                options.put("ignore.symbol.file", "true");
            }

            return new JavacFileManager(c, false, null);
        } finally {
            if (resetProperties) {
View Full Code Here

        // uugh, ugly back door, should be cleaned up, someday
        if (zipFileIndexKind == USE_ZIP_FILE_INDEX)
            System.clearProperty("useJavaUtilZip");
        else
            System.setProperty("useJavaUtilZip", "true");
        Options options = Options.instance(ctx);
        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;
    }
View Full Code Here

    }

    static void test(boolean genEndPos) throws IOException {
        Context context = new Context();

        Options options = Options.instance(context);
        options.put("diags", "%b:%s/%o/%e:%_%t%m|%p%m");

        Log log = Log.instance(context);
        log.multipleErrors = true;

        JavacFileManager.preRegister(context);
View Full Code Here

                                       Iterable<String> options)
    {
        if (options == null)
            return;

        Options optionTable = Options.instance(context);

        JavacOption[] recognizedOptions =
            RecognizedOptions.getJavacToolOptions(new GrumpyHelper());
        Iterator<String> flags = options.iterator();
        while (flags.hasNext()) {
View Full Code Here

                                       Iterable<String> options)
    {
        if (options == null)
            return;

        Options optionTable = Options.instance(context);

        JavacOption[] recognizedOptions =
            RecognizedOptions.getJavacToolOptions(new GrumpyHelper());
        Iterator<String> flags = options.iterator();
        while (flags.hasNext()) {
View Full Code Here

    private static Map<String, LintCategory> map = new HashMap<String,LintCategory>();


    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);
View Full Code Here


    protected Lint(Context context) {
        DEBUG.P(this,"Lint(1)");
    // initialize values according to the lint options
    Options options = Options.instance(context);
    DEBUG.P("options.keySet()="+options.keySet());
   
    //建立一个空的(没有元素的)枚举类型的集合,
    //集合元素的类型为“LintCategory"(LintCategory是一个枚举类,看下面)
    values = EnumSet.noneOf(LintCategory.class);
   
    //注:map是static的,它的值已在构造枚举类LintCategory时加入
    DEBUG.P("map.size()="+map.size());
    DEBUG.P("map="+map);
    for (Map.Entry<String, LintCategory> e: map.entrySet()) {
      if (options.lint(e.getKey()))
        values.add(e.getValue());
    }
    DEBUG.P("values="+values);
    /*如在javac命令行中加入“-Xlint”选项时,表示启用所有的警告(11项)
    map.size()=11
 
View Full Code Here

TOP

Related Classes of com.sun.tools.javac.util.Options

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.