8268352: Rename javadoc Messager class to JavadocLog
Reviewed-by: prappo
This commit is contained in:
parent
b568e87947
commit
fafc4d9764
@ -165,7 +165,7 @@ public class ElementsTable {
|
||||
private final List<Location> locations;
|
||||
private final Modules modules;
|
||||
private final ToolOptions options;
|
||||
private final Messager messager;
|
||||
private final JavadocLog log;
|
||||
private final JavaCompiler compiler;
|
||||
|
||||
private final Map<String, Entry> entries = new LinkedHashMap<>();
|
||||
@ -210,7 +210,7 @@ public class ElementsTable {
|
||||
this.fm = toolEnv.fileManager;
|
||||
this.modules = Modules.instance(context);
|
||||
this.options = options;
|
||||
this.messager = Messager.instance0(context);
|
||||
this.log = JavadocLog.instance0(context);
|
||||
this.compiler = JavaCompiler.instance(context);
|
||||
Source source = Source.instance(context);
|
||||
|
||||
@ -370,19 +370,19 @@ public class ElementsTable {
|
||||
return;
|
||||
|
||||
if (moduleNames.size() > 1) {
|
||||
String text = messager.getText("main.cannot_use_sourcepath_for_modules",
|
||||
String text = log.getText("main.cannot_use_sourcepath_for_modules",
|
||||
String.join(", ", moduleNames));
|
||||
throw new ToolException(CMDERR, text);
|
||||
}
|
||||
|
||||
String foundModule = getModuleName(StandardLocation.SOURCE_PATH);
|
||||
if (foundModule == null) {
|
||||
String text = messager.getText("main.module_not_found_on_sourcepath", moduleNames.get(0));
|
||||
String text = log.getText("main.module_not_found_on_sourcepath", moduleNames.get(0));
|
||||
throw new ToolException(CMDERR, text);
|
||||
}
|
||||
|
||||
if (!moduleNames.get(0).equals(foundModule)) {
|
||||
String text = messager.getText("main.sourcepath_does_not_contain_module", moduleNames.get(0));
|
||||
String text = log.getText("main.sourcepath_does_not_contain_module", moduleNames.get(0));
|
||||
throw new ToolException(CMDERR, text);
|
||||
}
|
||||
}
|
||||
@ -399,7 +399,7 @@ public class ElementsTable {
|
||||
}
|
||||
}
|
||||
} catch (IOException ioe) {
|
||||
String text = messager.getText("main.file.manager.list", location);
|
||||
String text = log.getText("main.file.manager.list", location);
|
||||
throw new ToolException(SYSERR, text, ioe);
|
||||
}
|
||||
return null;
|
||||
@ -413,7 +413,7 @@ public class ElementsTable {
|
||||
for (String m : modules) {
|
||||
List<Location> moduleLocations = getModuleLocation(locations, m);
|
||||
if (moduleLocations.isEmpty()) {
|
||||
String text = messager.getText("main.module_not_found", m);
|
||||
String text = log.getText("main.module_not_found", m);
|
||||
throw new ToolException(CMDERR, text);
|
||||
}
|
||||
if (moduleLocations.contains(StandardLocation.SOURCE_PATH)) {
|
||||
@ -520,7 +520,7 @@ public class ElementsTable {
|
||||
try {
|
||||
return fm.list(location, packagename, kinds, recurse);
|
||||
} catch (IOException ioe) {
|
||||
String text = messager.getText("main.file.manager.list", packagename);
|
||||
String text = log.getText("main.file.manager.list", packagename);
|
||||
throw new ToolException(SYSERR, text, ioe);
|
||||
}
|
||||
}
|
||||
@ -567,7 +567,7 @@ public class ElementsTable {
|
||||
if (!isMandated(mdle, rd) && onlyTransitive == rd.isTransitive()) {
|
||||
if (!haveModuleSources(dep)) {
|
||||
if (!warnedNoSources.contains(dep)) {
|
||||
messager.printWarningUsingKey(dep, "main.module_source_not_found", dep.getQualifiedName());
|
||||
log.printWarningUsingKey(dep, "main.module_source_not_found", dep.getQualifiedName());
|
||||
warnedNoSources.add(dep);
|
||||
}
|
||||
}
|
||||
@ -759,7 +759,7 @@ public class ElementsTable {
|
||||
if (pkg != null) {
|
||||
packlist.add(pkg);
|
||||
} else {
|
||||
messager.printWarningUsingKey("main.package_not_found", modpkg.toString());
|
||||
log.printWarningUsingKey("main.package_not_found", modpkg.toString());
|
||||
}
|
||||
});
|
||||
specifiedPackageElements = Collections.unmodifiableSet(packlist);
|
||||
@ -780,7 +780,7 @@ public class ElementsTable {
|
||||
for (String className : classArgList) {
|
||||
TypeElement te = toolEnv.loadClass(className);
|
||||
if (te == null) {
|
||||
String text = messager.getText("javadoc.class_not_found", className);
|
||||
String text = log.getText("javadoc.class_not_found", className);
|
||||
throw new ToolException(CMDERR, text);
|
||||
} else {
|
||||
addAllClasses(classes, te, true);
|
||||
@ -796,7 +796,7 @@ public class ElementsTable {
|
||||
toolEnv.notice("main.Loading_source_files_for_package", modpkg.toString());
|
||||
List<JavaFileObject> files = getFiles(modpkg, recurse);
|
||||
if (files.isEmpty()) {
|
||||
String text = messager.getText("main.no_source_files_for_package",
|
||||
String text = log.getText("main.no_source_files_for_package",
|
||||
modpkg.toString());
|
||||
throw new ToolException(CMDERR, text);
|
||||
} else {
|
||||
@ -909,7 +909,7 @@ public class ElementsTable {
|
||||
try {
|
||||
return fm.getLocationForModule(location, msymName);
|
||||
} catch (IOException ioe) {
|
||||
String text = messager.getText("main.doclet_could_not_get_location", msymName);
|
||||
String text = log.getText("main.doclet_could_not_get_location", msymName);
|
||||
throw new ToolException(ERROR, text, ioe);
|
||||
}
|
||||
}
|
||||
@ -956,9 +956,9 @@ public class ElementsTable {
|
||||
}
|
||||
} catch (CompletionFailure e) {
|
||||
if (e.getMessage() != null)
|
||||
messager.printWarning(e.getMessage());
|
||||
log.printWarning(e.getMessage());
|
||||
else
|
||||
messager.printWarningUsingKey("main.unexpected.exception", e);
|
||||
log.printWarningUsingKey("main.unexpected.exception", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2001, 2021, 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
|
||||
@ -61,24 +61,24 @@ public class JavadocEnter extends Enter {
|
||||
|
||||
protected JavadocEnter(Context context) {
|
||||
super(context);
|
||||
messager = Messager.instance0(context);
|
||||
log = JavadocLog.instance0(context);
|
||||
toolEnv = ToolEnvironment.instance(context);
|
||||
compiler = JavaCompiler.instance(context);
|
||||
}
|
||||
|
||||
final Messager messager;
|
||||
final JavadocLog log;
|
||||
final ToolEnvironment toolEnv;
|
||||
final JavaCompiler compiler;
|
||||
|
||||
@Override
|
||||
public void main(List<JCCompilationUnit> trees) {
|
||||
// cache the error count if we need to convert Enter errors as warnings.
|
||||
int nerrors = messager.nerrors;
|
||||
int nerrors = log.nerrors;
|
||||
super.main(trees);
|
||||
compiler.enterDone();
|
||||
if (toolEnv.ignoreSourceErrors) {
|
||||
messager.nwarnings += (messager.nerrors - nerrors);
|
||||
messager.nerrors = nerrors;
|
||||
log.nwarnings += (log.nerrors - nerrors);
|
||||
log.nerrors = nerrors;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -123,7 +123,7 @@ import com.sun.tools.javac.util.Log;
|
||||
* @see java.util.ResourceBundle
|
||||
* @see java.text.MessageFormat
|
||||
*/
|
||||
public class Messager extends Log implements Reporter {
|
||||
public class JavadocLog extends Log implements Reporter {
|
||||
/** The overall context for the documentation run. */
|
||||
private final Context context;
|
||||
|
||||
@ -138,22 +138,22 @@ public class Messager extends Log implements Reporter {
|
||||
*/
|
||||
private final LinkedHashMap<JavaFileObject, SoftReference<DiagnosticSource>> diagSourceCache;
|
||||
|
||||
/** Get the current messager, which is also the compiler log. */
|
||||
public static Messager instance0(Context context) {
|
||||
/** Get the current javadoc log, which is also the compiler log. */
|
||||
public static JavadocLog instance0(Context context) {
|
||||
Log instance = context.get(logKey);
|
||||
if (!(instance instanceof Messager m))
|
||||
throw new InternalError("no messager instance!");
|
||||
return m;
|
||||
if (!(instance instanceof JavadocLog l))
|
||||
throw new InternalError("no JavadocLog instance!");
|
||||
return l;
|
||||
}
|
||||
|
||||
public static void preRegister(Context context,
|
||||
final String programName) {
|
||||
context.put(logKey, (Factory<Log>)c -> new Messager(c, programName));
|
||||
context.put(logKey, (Factory<Log>)c -> new JavadocLog(c, programName));
|
||||
}
|
||||
|
||||
public static void preRegister(Context context, final String programName,
|
||||
final PrintWriter outWriter, final PrintWriter errWriter) {
|
||||
context.put(logKey, (Factory<Log>)c -> new Messager(c, programName, outWriter, errWriter));
|
||||
context.put(logKey, (Factory<Log>)c -> new JavadocLog(c, programName, outWriter, errWriter));
|
||||
}
|
||||
|
||||
final String programName;
|
||||
@ -176,7 +176,7 @@ public class Messager extends Log implements Reporter {
|
||||
* Constructor
|
||||
* @param programName Name of the program (for error messages).
|
||||
*/
|
||||
public Messager(Context context, String programName) {
|
||||
public JavadocLog(Context context, String programName) {
|
||||
// use the current values of System.out, System.err, in case they have been redirected
|
||||
this(context, programName,
|
||||
createPrintWriter(System.out, false),
|
||||
@ -189,7 +189,7 @@ public class Messager extends Log implements Reporter {
|
||||
* @param outWriter Stream for notices etc.
|
||||
* @param errWriter Stream for errors and warnings
|
||||
*/
|
||||
public Messager(Context context, String programName, PrintWriter outWriter, PrintWriter errWriter) {
|
||||
public JavadocLog(Context context, String programName, PrintWriter outWriter, PrintWriter errWriter) {
|
||||
super(context, outWriter, errWriter);
|
||||
messages = JavacMessages.instance(context);
|
||||
messages.add(locale -> ResourceBundle.getBundle("jdk.javadoc.internal.tool.resources.javadoc",
|
@ -70,7 +70,7 @@ import static jdk.javadoc.internal.tool.Main.Result.*;
|
||||
public class JavadocTool extends com.sun.tools.javac.main.JavaCompiler {
|
||||
ToolEnvironment toolEnv;
|
||||
|
||||
final Messager messager;
|
||||
final JavadocLog log;
|
||||
final ClassFinder javadocFinder;
|
||||
final DeferredCompletionFailureHandler dcfh;
|
||||
final Enter javadocEnter;
|
||||
@ -82,7 +82,7 @@ public class JavadocTool extends com.sun.tools.javac.main.JavaCompiler {
|
||||
*/
|
||||
protected JavadocTool(Context context) {
|
||||
super(context);
|
||||
messager = Messager.instance0(context);
|
||||
log = JavadocLog.instance0(context);
|
||||
javadocFinder = JavadocClassFinder.instance(context);
|
||||
dcfh = DeferredCompletionFailureHandler.instance(context);
|
||||
javadocEnter = JavadocEnter.instance(context);
|
||||
@ -101,7 +101,7 @@ public class JavadocTool extends com.sun.tools.javac.main.JavaCompiler {
|
||||
* Construct a new javadoc tool.
|
||||
*/
|
||||
public static JavadocTool make0(Context context) {
|
||||
Messager messager = null;
|
||||
JavadocLog log = null;
|
||||
try {
|
||||
// force the use of Javadoc's class finder
|
||||
JavadocClassFinder.preRegister(context);
|
||||
@ -115,13 +115,13 @@ public class JavadocTool extends com.sun.tools.javac.main.JavaCompiler {
|
||||
// force the use of Javadoc's own todo phase
|
||||
JavadocTodo.preRegister(context);
|
||||
|
||||
// force the use of Messager as a Log
|
||||
messager = Messager.instance0(context);
|
||||
// force the use of Javadoc's subtype of Log
|
||||
log = JavadocLog.instance0(context);
|
||||
|
||||
return new JavadocTool(context);
|
||||
} catch (CompletionFailure ex) {
|
||||
assert messager != null;
|
||||
messager.error(Position.NOPOS, ex.getMessage());
|
||||
assert log != null;
|
||||
log.error(Position.NOPOS, ex.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -142,11 +142,11 @@ public class JavadocTool extends com.sun.tools.javac.main.JavaCompiler {
|
||||
// If -Xclasses is set, the args should be a list of class names
|
||||
for (String arg: javaNames) {
|
||||
if (!isValidPackageName(arg)) { // checks
|
||||
String text = messager.getText("main.illegal_class_name", arg);
|
||||
String text = log.getText("main.illegal_class_name", arg);
|
||||
throw new ToolException(CMDERR, text);
|
||||
}
|
||||
}
|
||||
if (messager.hasErrors()) {
|
||||
if (log.hasErrors()) {
|
||||
return null;
|
||||
}
|
||||
etable.setClassArgList(javaNames);
|
||||
@ -171,14 +171,14 @@ public class JavadocTool extends com.sun.tools.javac.main.JavaCompiler {
|
||||
packageNames.add(arg);
|
||||
} else if (arg.endsWith(".java")) {
|
||||
if (fm == null) {
|
||||
String text = messager.getText("main.assertion.error", "fm == null");
|
||||
String text = log.getText("main.assertion.error", "fm == null");
|
||||
throw new ToolException(ABNORMAL, text);
|
||||
} else {
|
||||
String text = messager.getText("main.file_not_found", arg);
|
||||
String text = log.getText("main.file_not_found", arg);
|
||||
throw new ToolException(ERROR, text);
|
||||
}
|
||||
} else {
|
||||
String text = messager.getText("main.illegal_package_name", arg);
|
||||
String text = log.getText("main.illegal_package_name", arg);
|
||||
throw new ToolException(CMDERR, text);
|
||||
}
|
||||
}
|
||||
@ -191,7 +191,7 @@ public class JavadocTool extends com.sun.tools.javac.main.JavaCompiler {
|
||||
.scanSpecifiedItems();
|
||||
|
||||
// abort, if errors were encountered during modules initialization
|
||||
if (messager.hasErrors()) {
|
||||
if (log.hasErrors()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -202,7 +202,7 @@ public class JavadocTool extends com.sun.tools.javac.main.JavaCompiler {
|
||||
modules.newRound();
|
||||
modules.initModules(allTrees.toList());
|
||||
|
||||
if (messager.hasErrors()) {
|
||||
if (log.hasErrors()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -210,7 +210,7 @@ public class JavadocTool extends com.sun.tools.javac.main.JavaCompiler {
|
||||
toolEnv.notice("main.Building_tree");
|
||||
javadocEnter.main(allTrees.toList());
|
||||
|
||||
if (messager.hasErrors()) {
|
||||
if (log.hasErrors()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -232,17 +232,17 @@ public class JavadocTool extends com.sun.tools.javac.main.JavaCompiler {
|
||||
} catch (CompletionFailure cf) {
|
||||
throw new ToolException(ABNORMAL, cf.getMessage(), cf);
|
||||
} catch (Abort abort) {
|
||||
if (messager.hasErrors()) {
|
||||
if (log.hasErrors()) {
|
||||
// presumably a message has been emitted, keep silent
|
||||
throw new ToolException(ABNORMAL, "", abort);
|
||||
} else {
|
||||
String text = messager.getText("main.internal.error");
|
||||
String text = log.getText("main.internal.error");
|
||||
Throwable t = abort.getCause() == null ? abort : abort.getCause();
|
||||
throw new ToolException(ABNORMAL, text, t);
|
||||
}
|
||||
}
|
||||
|
||||
if (messager.hasErrors())
|
||||
if (log.hasErrors())
|
||||
return null;
|
||||
|
||||
toolEnv.docEnv = new DocEnvImpl(toolEnv, etable);
|
||||
|
@ -84,7 +84,7 @@ public class Start {
|
||||
|
||||
private static final String ProgramName = "javadoc";
|
||||
|
||||
private Messager messager;
|
||||
private JavadocLog log;
|
||||
|
||||
private final String docletName;
|
||||
|
||||
@ -94,7 +94,7 @@ public class Start {
|
||||
|
||||
private Doclet doclet;
|
||||
|
||||
// used to determine the locale for the messager
|
||||
// used to determine the locale for the log
|
||||
private Locale locale;
|
||||
|
||||
/**
|
||||
@ -120,9 +120,9 @@ public class Start {
|
||||
String docletName, ClassLoader classLoader) {
|
||||
this.context = context == null ? new Context() : context;
|
||||
String pname = programName == null ? ProgramName : programName;
|
||||
this.messager = (outWriter == null && errWriter == null)
|
||||
? new Messager(this.context, pname)
|
||||
: new Messager(this.context, pname, outWriter, errWriter);
|
||||
this.log = (outWriter == null && errWriter == null)
|
||||
? new JavadocLog(this.context, pname)
|
||||
: new JavadocLog(this.context, pname, outWriter, errWriter);
|
||||
this.docletName = docletName;
|
||||
this.classLoader = classLoader;
|
||||
this.docletClass = null;
|
||||
@ -140,13 +140,13 @@ public class Start {
|
||||
this.locale = Locale.getDefault();
|
||||
|
||||
Log log = context.get(Log.logKey);
|
||||
if (log instanceof Messager m){
|
||||
messager = m;
|
||||
if (log instanceof JavadocLog l){
|
||||
this.log = l;
|
||||
} else {
|
||||
PrintWriter out = context.get(Log.errKey);
|
||||
messager = (out == null)
|
||||
? new Messager(context, ProgramName)
|
||||
: new Messager(context, ProgramName, out, out);
|
||||
this.log = (out == null)
|
||||
? new JavadocLog(context, ProgramName)
|
||||
: new JavadocLog(context, ProgramName, out, out);
|
||||
}
|
||||
|
||||
options = getToolOptions();
|
||||
@ -183,7 +183,7 @@ public class Start {
|
||||
}
|
||||
}
|
||||
};
|
||||
return new ToolOptions(context, messager, helper);
|
||||
return new ToolOptions(context, log, helper);
|
||||
}
|
||||
|
||||
private Runtime.Version toolVersion() {
|
||||
@ -195,7 +195,7 @@ public class Start {
|
||||
}
|
||||
|
||||
private void showUsage(String headerKey, ToolOption.Kind kind, String footerKey) {
|
||||
messager.noticeUsingKey(headerKey);
|
||||
log.noticeUsingKey(headerKey);
|
||||
showToolOptions(kind);
|
||||
|
||||
// let doclet print usage information
|
||||
@ -205,11 +205,11 @@ public class Start {
|
||||
: Option.Kind.STANDARD);
|
||||
}
|
||||
if (footerKey != null)
|
||||
messager.noticeUsingKey(footerKey);
|
||||
log.noticeUsingKey(footerKey);
|
||||
}
|
||||
|
||||
private void showVersion(String labelKey, String value) {
|
||||
messager.noticeUsingKey(labelKey, messager.programName, value);
|
||||
log.noticeUsingKey(labelKey, log.programName, value);
|
||||
}
|
||||
|
||||
private void showToolOptions(ToolOption.Kind kind) {
|
||||
@ -238,11 +238,11 @@ public class Start {
|
||||
|| primaryName.equals(ToolOptions.AT)
|
||||
|| primaryName.equals(ToolOptions.J)
|
||||
? "" : " ";
|
||||
parameters = sep + option.getParameters(messager);
|
||||
parameters = sep + option.getParameters(log);
|
||||
} else {
|
||||
parameters = "";
|
||||
}
|
||||
String description = option.getDescription(messager);
|
||||
String description = option.getDescription(log);
|
||||
showOption(names, parameters, description);
|
||||
}
|
||||
|
||||
@ -252,7 +252,7 @@ public class Start {
|
||||
if (options.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
messager.noticeUsingKey("main.doclet.usage.header", name);
|
||||
log.noticeUsingKey("main.doclet.usage.header", name);
|
||||
|
||||
Comparator<Doclet.Option> comp = new Comparator<Doclet.Option>() {
|
||||
final Collator collator = Collator.getInstance(Locale.US);
|
||||
@ -307,22 +307,22 @@ public class Start {
|
||||
if (synopses.length() < DEFAULT_SYNOPSIS_WIDTH
|
||||
&& !description.contains("\n")
|
||||
&& (SMALL_INDENT.length() + DEFAULT_SYNOPSIS_WIDTH + 1 + description.length() <= DEFAULT_MAX_LINE_LENGTH)) {
|
||||
messager.notice(String.format(COMPACT_FORMAT, synopses, description));
|
||||
log.notice(String.format(COMPACT_FORMAT, synopses, description));
|
||||
return;
|
||||
}
|
||||
|
||||
// If option synopses fit on a single line of reasonable length, show that;
|
||||
// otherwise, show 1 per line
|
||||
if (synopses.length() <= DEFAULT_MAX_LINE_LENGTH) {
|
||||
messager.notice(SMALL_INDENT + synopses);
|
||||
log.notice(SMALL_INDENT + synopses);
|
||||
} else {
|
||||
for (String name: names) {
|
||||
messager.notice(SMALL_INDENT + name + parameters);
|
||||
log.notice(SMALL_INDENT + name + parameters);
|
||||
}
|
||||
}
|
||||
|
||||
// Finally, show the description
|
||||
messager.notice(LARGE_INDENT + description.replace("\n", "\n" + LARGE_INDENT));
|
||||
log.notice(LARGE_INDENT + description.replace("\n", "\n" + LARGE_INDENT));
|
||||
}
|
||||
|
||||
|
||||
@ -372,7 +372,7 @@ public class Start {
|
||||
} catch (ToolException te) {
|
||||
if (!te.result.isOK()) {
|
||||
if (te.message != null) {
|
||||
messager.printError(te.message);
|
||||
log.printError(te.message);
|
||||
}
|
||||
Throwable t = te.getCause();
|
||||
dumpStack(t == null ? te : t);
|
||||
@ -380,7 +380,7 @@ public class Start {
|
||||
return te.result;
|
||||
} catch (OptionException oe) {
|
||||
if (oe.message != null) {
|
||||
messager.printError(oe.message);
|
||||
log.printError(oe.message);
|
||||
}
|
||||
oe.m.run();
|
||||
Throwable t = oe.getCause();
|
||||
@ -397,7 +397,7 @@ public class Start {
|
||||
// It would be even better to rethrow this as IllegalArgumentException
|
||||
// when invoked via the API.
|
||||
// See javac Arguments.error(InvalidValueException) for an example
|
||||
messager.printRawLines(e.getMessage());
|
||||
log.printRawLines(e.getMessage());
|
||||
Throwable t = e.getCause();
|
||||
dumpStack(t == null ? e : t);
|
||||
return ERROR;
|
||||
@ -406,7 +406,7 @@ public class Start {
|
||||
// when invoked via the API.
|
||||
// See javac Arguments.error(InvalidValueException) for an example
|
||||
if (oe.message != null)
|
||||
messager.printError(oe.message);
|
||||
log.printError(oe.message);
|
||||
|
||||
oe.m.run();
|
||||
Throwable t = oe.getCause();
|
||||
@ -414,7 +414,7 @@ public class Start {
|
||||
return oe.result;
|
||||
} catch (ToolException exc) {
|
||||
if (exc.message != null) {
|
||||
messager.printError(exc.message);
|
||||
log.printError(exc.message);
|
||||
}
|
||||
Throwable t = exc.getCause();
|
||||
if (result == ABNORMAL) {
|
||||
@ -441,10 +441,10 @@ public class Start {
|
||||
fileManager.close();
|
||||
} catch (IOException ignore) {}
|
||||
}
|
||||
if (this.options.rejectWarnings() && messager.hasWarnings()) {
|
||||
if (this.options.rejectWarnings() && log.hasWarnings()) {
|
||||
error("main.warnings.Werror");
|
||||
}
|
||||
boolean haveErrors = messager.hasErrors();
|
||||
boolean haveErrors = log.hasErrors();
|
||||
if (!result.isOK() && !haveErrors) {
|
||||
// the doclet failed, but nothing reported, flag it!.
|
||||
error("main.unknown.error");
|
||||
@ -452,14 +452,14 @@ public class Start {
|
||||
if (haveErrors && result.isOK()) {
|
||||
result = ERROR;
|
||||
}
|
||||
messager.printErrorWarningCounts();
|
||||
messager.flush();
|
||||
log.printErrorWarningCounts();
|
||||
log.flush();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private void reportInternalError(Throwable t) {
|
||||
messager.printErrorUsingKey("doclet.internal.report.bug");
|
||||
log.printErrorUsingKey("doclet.internal.report.bug");
|
||||
dumpStack(true, t);
|
||||
}
|
||||
|
||||
@ -493,10 +493,10 @@ public class Start {
|
||||
arguments.init(ProgramName);
|
||||
arguments.allowEmpty();
|
||||
|
||||
doclet.init(locale, messager);
|
||||
int beforeCount = messager.nerrors;
|
||||
doclet.init(locale, log);
|
||||
int beforeCount = log.nerrors;
|
||||
boolean success = parseArgs(argList, javaNames);
|
||||
int afterCount = messager.nerrors;
|
||||
int afterCount = log.nerrors;
|
||||
if (!success && beforeCount == afterCount) { // if there were failures but they have not been reported
|
||||
return CMDERR;
|
||||
}
|
||||
@ -505,8 +505,8 @@ public class Start {
|
||||
// Arguments does not always increase the error count in the
|
||||
// case of errors, so increment the error count only if it has
|
||||
// not been updated previously, preventing complaints by callers
|
||||
if (!messager.hasErrors() && !messager.hasWarnings())
|
||||
messager.nerrors++;
|
||||
if (!log.hasErrors() && !log.hasWarnings())
|
||||
log.nerrors++;
|
||||
return CMDERR;
|
||||
}
|
||||
|
||||
@ -514,8 +514,8 @@ public class Start {
|
||||
// Arguments does not always increase the error count in the
|
||||
// case of errors, so increment the error count only if it has
|
||||
// not been updated previously, preventing complaints by callers
|
||||
if (!messager.hasErrors() && !messager.hasWarnings())
|
||||
messager.nerrors++;
|
||||
if (!log.hasErrors() && !log.hasWarnings())
|
||||
log.nerrors++;
|
||||
return CMDERR;
|
||||
}
|
||||
|
||||
@ -534,7 +534,7 @@ public class Start {
|
||||
if (options.modules().isEmpty()) {
|
||||
if (options.subpackages().isEmpty()) {
|
||||
if (javaNames.isEmpty() && isEmpty(fileObjects)) {
|
||||
String text = messager.getText("main.No_modules_packages_or_classes_specified");
|
||||
String text = log.getText("main.No_modules_packages_or_classes_specified");
|
||||
throw new ToolException(CMDERR, text);
|
||||
}
|
||||
}
|
||||
@ -560,7 +560,7 @@ public class Start {
|
||||
// We're done.
|
||||
if (options.verbose()) {
|
||||
long elapsedMillis = (System.nanoTime() - startNanos) / 1_000_000;
|
||||
messager.noticeUsingKey("main.done_in", Long.toString(elapsedMillis));
|
||||
log.noticeUsingKey("main.done_in", Long.toString(elapsedMillis));
|
||||
}
|
||||
|
||||
return returnStatus;
|
||||
@ -610,7 +610,7 @@ public class Start {
|
||||
if (argVal != null) {
|
||||
switch (opt.getArgumentCount()) {
|
||||
case 0:
|
||||
text = messager.getText("main.unnecessary_arg_provided", argBase);
|
||||
text = log.getText("main.unnecessary_arg_provided", argBase);
|
||||
throw new OptionException(ERROR, this::showUsage, text);
|
||||
case 1:
|
||||
if (!opt.process(arg, Collections.singletonList(argVal))) {
|
||||
@ -618,12 +618,12 @@ public class Start {
|
||||
}
|
||||
break;
|
||||
default:
|
||||
text = messager.getText("main.only_one_argument_with_equals", argBase);
|
||||
text = log.getText("main.only_one_argument_with_equals", argBase);
|
||||
throw new OptionException(ERROR, this::showUsage, text);
|
||||
}
|
||||
} else {
|
||||
if (args.size() - idx - 1 < opt.getArgumentCount()) {
|
||||
text = messager.getText("main.requires_argument", arg);
|
||||
text = log.getText("main.requires_argument", arg);
|
||||
throw new OptionException(ERROR, this::showUsage, text);
|
||||
}
|
||||
if (!opt.process(arg, args.subList(idx + 1, idx + 1 + opt.getArgumentCount()))) {
|
||||
@ -636,7 +636,7 @@ public class Start {
|
||||
}
|
||||
// check if arg is accepted by the tool before emitting error
|
||||
if (!isToolOption) {
|
||||
text = messager.getText("main.invalid_flag", arg);
|
||||
text = log.getText("main.invalid_flag", arg);
|
||||
throw new OptionException(ERROR, this::showUsage, text);
|
||||
}
|
||||
return m * idx;
|
||||
@ -686,7 +686,7 @@ public class Start {
|
||||
throw new IllegalArgumentException("More than one doclet specified (" +
|
||||
userDocletName + " and " + argv.get(i) + ").");
|
||||
}
|
||||
String text = messager.getText("main.more_than_one_doclet_specified_0_and_1",
|
||||
String text = log.getText("main.more_than_one_doclet_specified_0_and_1",
|
||||
userDocletName, argv.get(i));
|
||||
throw new ToolException(CMDERR, text);
|
||||
}
|
||||
@ -695,7 +695,7 @@ public class Start {
|
||||
throw new IllegalArgumentException("More than one doclet specified (" +
|
||||
docletName + " and " + argv.get(i) + ").");
|
||||
}
|
||||
String text = messager.getText("main.more_than_one_doclet_specified_0_and_1",
|
||||
String text = log.getText("main.more_than_one_doclet_specified_0_and_1",
|
||||
docletName, argv.get(i));
|
||||
throw new ToolException(CMDERR, text);
|
||||
}
|
||||
@ -730,7 +730,7 @@ public class Start {
|
||||
throw new IllegalArgumentException("Could not set location for " +
|
||||
userDocletPath, ioe);
|
||||
}
|
||||
String text = messager.getText("main.doclet_could_not_set_location",
|
||||
String text = log.getText("main.doclet_could_not_set_location",
|
||||
userDocletPath);
|
||||
throw new ToolException(CMDERR, text, ioe);
|
||||
}
|
||||
@ -743,7 +743,7 @@ public class Start {
|
||||
|
||||
+ userDocletPath);
|
||||
}
|
||||
String text = messager.getText("main.doclet_no_classloader_found",
|
||||
String text = log.getText("main.doclet_no_classloader_found",
|
||||
userDocletName);
|
||||
throw new ToolException(CMDERR, text);
|
||||
}
|
||||
@ -757,7 +757,7 @@ public class Start {
|
||||
}
|
||||
|
||||
if (Doclet.class.isAssignableFrom(docletClass)) {
|
||||
messager.setLocale(Locale.getDefault()); // use default locale for console messages
|
||||
log.setLocale(Locale.getDefault()); // use default locale for console messages
|
||||
try {
|
||||
Object o = docletClass.getConstructor().newInstance();
|
||||
doclet = (Doclet) o;
|
||||
@ -765,11 +765,11 @@ public class Start {
|
||||
if (apiMode) {
|
||||
throw new ClientCodeException(exc);
|
||||
}
|
||||
String text = messager.getText("main.could_not_instantiate_class", docletClass.getName());
|
||||
String text = log.getText("main.could_not_instantiate_class", docletClass.getName());
|
||||
throw new ToolException(ERROR, text);
|
||||
}
|
||||
} else {
|
||||
String text = messager.getText("main.not_a_doclet", docletClass.getName());
|
||||
String text = log.getText("main.not_a_doclet", docletClass.getName());
|
||||
throw new ToolException(ERROR, text);
|
||||
}
|
||||
return doclet;
|
||||
@ -782,7 +782,7 @@ public class Start {
|
||||
if (apiMode) {
|
||||
throw new IllegalArgumentException("Cannot find doclet class " + docletName);
|
||||
}
|
||||
String text = messager.getText("main.doclet_class_not_found", docletName);
|
||||
String text = log.getText("main.doclet_class_not_found", docletName);
|
||||
throw new ToolException(CMDERR, text, cnfe);
|
||||
}
|
||||
}
|
||||
@ -842,13 +842,13 @@ public class Start {
|
||||
*/
|
||||
private void checkOneArg(List<String> args, int index) throws OptionException {
|
||||
if ((index + 1) >= args.size() || args.get(index + 1).startsWith("-d")) {
|
||||
String text = messager.getText("main.requires_argument", args.get(index));
|
||||
String text = log.getText("main.requires_argument", args.get(index));
|
||||
throw new OptionException(CMDERR, this::showUsage, text);
|
||||
}
|
||||
}
|
||||
|
||||
void error(String key, Object... args) {
|
||||
messager.printErrorUsingKey(key, args);
|
||||
log.printErrorUsingKey(key, args);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -865,7 +865,7 @@ public class Start {
|
||||
// Ensure that a non-empty language is available for the <HTML lang=...> element
|
||||
return (l.getLanguage().isEmpty()) ? Locale.ENGLISH : l;
|
||||
} catch (IllformedLocaleException e) {
|
||||
String text = messager.getText("main.malformed_locale_name", localeName);
|
||||
String text = log.getText("main.malformed_locale_name", localeName);
|
||||
throw new ToolException(CMDERR, text);
|
||||
}
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ public class ToolEnvironment {
|
||||
return instance;
|
||||
}
|
||||
|
||||
final Messager messager;
|
||||
final JavadocLog log;
|
||||
|
||||
/** Predefined symbols known to the compiler. */
|
||||
public final Symtab syms;
|
||||
@ -137,7 +137,7 @@ public class ToolEnvironment {
|
||||
context.put(ToolEnvKey, this);
|
||||
this.context = context;
|
||||
|
||||
messager = Messager.instance0(context);
|
||||
log = JavadocLog.instance0(context);
|
||||
syms = Symtab.instance(context);
|
||||
finder = JavadocClassFinder.instance(context);
|
||||
enter = JavadocEnter.instance(context);
|
||||
@ -199,7 +199,7 @@ public class ToolEnvironment {
|
||||
if (quiet) {
|
||||
return;
|
||||
}
|
||||
messager.noticeUsingKey(key);
|
||||
log.noticeUsingKey(key);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -212,7 +212,7 @@ public class ToolEnvironment {
|
||||
if (quiet) {
|
||||
return;
|
||||
}
|
||||
messager.noticeUsingKey(key, a1);
|
||||
log.noticeUsingKey(key, a1);
|
||||
}
|
||||
|
||||
TreePath getTreePath(JCCompilationUnit tree) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2021, 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
|
||||
@ -168,9 +168,9 @@ public class ToolOptions {
|
||||
private final OptionHelper compilerOptionHelper;
|
||||
|
||||
/**
|
||||
* The messager to be used to report diagnostics..
|
||||
* The log to be used to report diagnostics..
|
||||
*/
|
||||
private final Messager messager;
|
||||
private final JavadocLog log;
|
||||
|
||||
/**
|
||||
* The helper for help and version options
|
||||
@ -181,10 +181,10 @@ public class ToolOptions {
|
||||
* Creates an object to handle tool options.
|
||||
*
|
||||
* @param context the context used to find other tool-related components
|
||||
* @param messager the messager to be used to report diagnostics
|
||||
* @param log the log to be used to report diagnostics
|
||||
*/
|
||||
ToolOptions(Context context, Messager messager, ShowHelper showHelper) {
|
||||
this.messager = messager;
|
||||
ToolOptions(Context context, JavadocLog log, ShowHelper showHelper) {
|
||||
this.log = log;
|
||||
this.showHelper = showHelper;
|
||||
compOpts = Options.instance(context);
|
||||
fileManagerOpts = new LinkedHashMap<>();
|
||||
@ -200,7 +200,7 @@ public class ToolOptions {
|
||||
compOpts = null;
|
||||
compilerOptionHelper = null;
|
||||
fileManagerOpts = null;
|
||||
messager = null;
|
||||
log = null;
|
||||
showHelper = null;
|
||||
}
|
||||
|
||||
@ -646,14 +646,14 @@ public class ToolOptions {
|
||||
return names;
|
||||
}
|
||||
|
||||
String getParameters(Messager messager) {
|
||||
String getParameters(JavadocLog log) {
|
||||
return (hasArg || primaryName.endsWith(":"))
|
||||
? messager.getText(getKey(primaryName, ".arg"))
|
||||
? log.getText(getKey(primaryName, ".arg"))
|
||||
: null;
|
||||
}
|
||||
|
||||
String getDescription(Messager messager) {
|
||||
return messager.getText(getKey(primaryName, ".desc"));
|
||||
String getDescription(JavadocLog log) {
|
||||
return log.getText(getKey(primaryName, ".desc"));
|
||||
}
|
||||
|
||||
private String getKey(String optionName, String suffix) {
|
||||
@ -833,7 +833,7 @@ public class ToolOptions {
|
||||
* @return the exception
|
||||
*/
|
||||
private IllegalOptionValue illegalOptionValue(String arg) {
|
||||
return new IllegalOptionValue(showHelper::usage, messager.getText("main.illegal_option_value", arg));
|
||||
return new IllegalOptionValue(showHelper::usage, log.getText("main.illegal_option_value", arg));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -864,7 +864,7 @@ public class ToolOptions {
|
||||
* @return the helper
|
||||
*/
|
||||
private OptionHelper getOptionHelper() {
|
||||
return new OptionHelper.GrumpyHelper(messager) {
|
||||
return new OptionHelper.GrumpyHelper(log) {
|
||||
@Override
|
||||
public String get(com.sun.tools.javac.main.Option option) {
|
||||
return compOpts.get(option);
|
||||
|
@ -227,7 +227,7 @@ public class CheckResourceKeys {
|
||||
}
|
||||
|
||||
// special handling for code strings synthesized in
|
||||
// jdk.javadoc.internal.tool.Messager
|
||||
// jdk.javadoc.internal.tool.JavadocLog
|
||||
results.add("javadoc.error.msg");
|
||||
results.add("javadoc.note.msg");
|
||||
results.add("javadoc.note.pos.msg");
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2021, 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
|
||||
@ -46,7 +46,7 @@ import javax.tools.ToolProvider;
|
||||
import com.sun.tools.javac.file.JavacFileManager;
|
||||
import com.sun.tools.javac.util.Context;
|
||||
import jdk.javadoc.internal.api.JavadocTaskImpl;
|
||||
import jdk.javadoc.internal.tool.Messager;
|
||||
import jdk.javadoc.internal.tool.JavadocLog;
|
||||
|
||||
/**
|
||||
* Misc tests for JavacTaskImpl.
|
||||
@ -81,7 +81,7 @@ public class JavadocTaskImplTest extends APITest {
|
||||
JavaFileObject srcFile = createSimpleJavaFileObject();
|
||||
Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
|
||||
Context c = new Context();
|
||||
Messager.preRegister(c, "javadoc");
|
||||
JavadocLog.preRegister(c, "javadoc");
|
||||
try (StandardJavaFileManager fm = new JavacFileManager(c, true, null)) {
|
||||
File outDir = getOutDir();
|
||||
fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
|
||||
@ -99,7 +99,7 @@ public class JavadocTaskImplTest extends APITest {
|
||||
JavaFileObject srcFile = null; // error, provokes NPE
|
||||
Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
|
||||
Context c = new Context();
|
||||
Messager.preRegister(c, "javadoc");
|
||||
JavadocLog.preRegister(c, "javadoc");
|
||||
try (StandardJavaFileManager fm = new JavacFileManager(c, true, null)) {
|
||||
File outDir = getOutDir();
|
||||
fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
|
||||
|
Loading…
x
Reference in New Issue
Block a user