All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jdk.javadoc.internal.tool.Start Maven / Gradle / Ivy

There is a newer version: 9-dev-r4023-3
Show newest version
/*
 * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 only, as
 * published by the Free Software Foundation.  Oracle designates this
 * particular file as subject to the "Classpath" exception as provided
 * by Oracle in the LICENSE file that accompanied this code.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 * or visit www.oracle.com if you need additional information or have any
 * questions.
 */

package jdk.javadoc.internal.tool;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.PrintWriter;
import java.nio.file.Path;
import java.text.BreakIterator;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.Objects;
import java.util.Set;
import static javax.tools.DocumentationTool.Location.*;
import javax.tools.JavaFileManager;
import javax.tools.JavaFileObject;
import javax.tools.StandardJavaFileManager;
import javax.tools.StandardLocation;

import com.sun.tools.javac.api.JavacTrees;
import com.sun.tools.javac.file.BaseFileManager;
import com.sun.tools.javac.file.JavacFileManager;
import com.sun.tools.javac.main.CommandLine;
import com.sun.tools.javac.platform.PlatformDescription;
import com.sun.tools.javac.platform.PlatformUtils;
import com.sun.tools.javac.util.ClientCodeException;
import com.sun.tools.javac.util.Context;
import com.sun.tools.javac.util.Log;
import com.sun.tools.javac.util.Options;

import jdk.javadoc.doclet.Doclet;
import jdk.javadoc.doclet.Doclet.Option;
import jdk.javadoc.doclet.DocletEnvironment;

import static com.sun.tools.javac.main.Option.*;
/**
 * Main program of Javadoc.
 * Previously named "Main".
 *
 *  

This is NOT part of any supported API. * If you write code that depends on this, you do so at your own risk. * This code and its internal interfaces are subject to change or * deletion without notice. * * @author Robert Field * @author Neal Gafter (rewrite) */ public class Start extends ToolOption.Helper { /** Context for this invocation. */ private final Context context; private static final String ProgramName = "javadoc"; // meaning we allow all visibility of PROTECTED and PUBLIC private static final String defaultModifier = "protected"; private Messager messager; private final String docletName; private final ClassLoader classLoader; private Class docletClass; private Doclet doclet; // used to determine the locale for the messager private Locale locale; /** * In API mode, exceptions thrown while calling the doclet are * propagated using ClientCodeException. */ private boolean apiMode; private JavaFileManager fileManager; Start() { this(null, null, null, null, null); } Start(PrintWriter writer) { this(null, null, writer, null, null); } Start(Context context, String programName, PrintWriter writer, String docletName, ClassLoader classLoader) { this.context = context == null ? new Context() : context; String pname = programName == null ? ProgramName : programName; this.messager = writer == null ? new Messager(this.context, pname) : new Messager(this.context, pname, writer, writer); this.docletName = docletName; this.classLoader = classLoader; this.docletClass = null; this.locale = Locale.getDefault(); } public Start(Context context) { this.docletClass = null; this.context = Objects.requireNonNull(context); this.apiMode = true; this.docletName = null; this.classLoader = null; this.locale = Locale.getDefault(); } void initMessager() { if (!apiMode) return; if (messager == null) { Log log = context.get(Log.logKey); if (log instanceof Messager) { messager = (Messager) log; } else { PrintWriter out = context.get(Log.outKey); messager = (out == null) ? new Messager(context, ProgramName) : new Messager(context, ProgramName, out, out); } } } /** * Usage */ @Override void usage() { usage(true); } void usage(boolean exit) { usage("main.usage", "-help", null, exit); } @Override void Xusage() { Xusage(true); } void Xusage(boolean exit) { usage("main.Xusage", "-X", "main.Xusage.foot", exit); } private void usage(String main, String option, String foot, boolean exit) { messager.notice(main); // let doclet print usage information (does nothing on error) if (docletClass != null) { String name = doclet.getName(); Set





© 2015 - 2024 Weber Informatics LLC | Privacy Policy