1
1
/*
2
- * Copyright (c) 2016, 2020 , Oracle and/or its affiliates. All rights reserved.
2
+ * Copyright (c) 2016, 2021 , Oracle and/or its affiliates. All rights reserved.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* This code is free software; you can redistribute it and/or modify it
26
26
27
27
import javax .lang .model .element .Element ;
28
28
import javax .tools .Diagnostic ;
29
+ import javax .tools .FileObject ;
29
30
30
31
import com .sun .source .util .DocTreePath ;
31
32
import jdk .javadoc .doclet .Reporter ;
@@ -76,8 +77,8 @@ public Resources getResources() {
76
77
/**
77
78
* Reports an error message to the doclet's reporter.
78
79
*
79
- * @param key the name of a resource containing the message to be printed
80
- * @param args optional arguments to be replaced in the message.
80
+ * @param key the name of a resource containing the message to be printed
81
+ * @param args optional arguments to be replaced in the message
81
82
*/
82
83
public void error (String key , Object ... args ) {
83
84
report (ERROR , resources .getText (key , args ));
@@ -86,22 +87,35 @@ public void error(String key, Object... args) {
86
87
/**
87
88
* Reports an error message to the doclet's reporter.
88
89
*
89
- * @param path a path identifying the position to be included with
90
- * the message
91
- * @param key the name of a resource containing the message to be printed
92
- * @param args optional arguments to be replaced in the message.
90
+ * @param path a path identifying the position to be included with the message
91
+ * @param key the name of a resource containing the message to be printed
92
+ * @param args optional arguments to be replaced in the message
93
93
*/
94
94
public void error (DocTreePath path , String key , Object ... args ) {
95
95
report (ERROR , path , resources .getText (key , args ));
96
96
}
97
97
98
+ /**
99
+ * Reports an error message to the doclet's reporter.
100
+ *
101
+ * @param fo the file object to be associated with the message
102
+ * @param start the start of a range of characters to be associated with the message
103
+ * @param pos the position to be associated with the message
104
+ * @param end the end of a range of characters to be associated with the message
105
+ * @param key the name of a resource containing the message to be printed
106
+ * @param args optional arguments to be replaced in the message
107
+ */
108
+ public void error (FileObject fo , int start , int pos , int end , String key , Object ... args ) {
109
+ report (ERROR , fo , start , pos , end , resources .getText (key , args ));
110
+ }
111
+
98
112
// ***** Warnings *****
99
113
100
114
/**
101
115
* Reports a warning message to the doclet's reporter.
102
116
*
103
- * @param key the name of a resource containing the message to be printed
104
- * @param args optional arguments to be replaced in the message.
117
+ * @param key the name of a resource containing the message to be printed
118
+ * @param args optional arguments to be replaced in the message
105
119
*/
106
120
public void warning (String key , Object ... args ) {
107
121
report (WARNING , resources .getText (key , args ));
@@ -110,10 +124,9 @@ public void warning(String key, Object... args) {
110
124
/**
111
125
* Reports a warning message to the doclet's reporter.
112
126
*
113
- * @param path a path identifying the position to be included with
114
- * the message
115
- * @param key the name of a resource containing the message to be printed
116
- * @param args optional arguments to be replaced in the message.
127
+ * @param path a path identifying the position to be included with the message
128
+ * @param key the name of a resource containing the message to be printed
129
+ * @param args optional arguments to be replaced in the message
117
130
*/
118
131
public void warning (DocTreePath path , String key , Object ... args ) {
119
132
if (configuration .showMessage (path , key )) {
@@ -124,28 +137,43 @@ public void warning(DocTreePath path, String key, Object... args) {
124
137
/**
125
138
* Reports a warning message to the doclet's reporter.
126
139
*
127
- * @param e an element identifying the declaration whose position should
128
- * to be included with the message
129
- * @param key the name of a resource containing the message to be printed
130
- * @param args optional arguments to be replaced in the message.
140
+ * @param e an element identifying the position to be included with the message
141
+ * @param key the name of a resource containing the message to be printed
142
+ * @param args optional arguments to be replaced in the message
131
143
*/
132
144
public void warning (Element e , String key , Object ... args ) {
133
145
if (configuration .showMessage (e , key )) {
134
146
report (WARNING , e , resources .getText (key , args ));
135
147
}
136
148
}
137
149
150
+ /**
151
+ * Reports a warning message to the doclet's reporter.
152
+ *
153
+ * @param fo the file object to be associated with the message
154
+ * @param start the start of a range of characters to be associated with the message
155
+ * @param pos the position to be associated with the message
156
+ * @param end the end of a range of characters to be associated with the message
157
+ * @param key the name of a resource containing the message to be printed
158
+ * @param args optional arguments to be replaced in the message
159
+ */
160
+ public void warning (FileObject fo , int start , int pos , int end , String key , Object ... args ) {
161
+ report (WARNING , fo , start , pos , end , resources .getText (key , args ));
162
+ }
163
+
138
164
// ***** Notices *****
139
165
140
166
/**
141
167
* Reports an informational notice to the doclet's reporter.
168
+ * The message is written directly to the reporter's diagnostic stream.
142
169
*
143
- * @param key the name of a resource containing the message to be printed
144
- * @param args optional arguments to be replaced in the message.
170
+ * @param key the name of a resource containing the message to be printed
171
+ * @param args optional arguments to be replaced in the message
145
172
*/
146
173
public void notice (String key , Object ... args ) {
147
174
if (!configuration .getOptions ().quiet ()) {
148
- report (NOTE , resources .getText (key , args ));
175
+ // Note: we do not use report(NOTE, ...) which would prefix the output with "Note:"
176
+ reporter .getDiagnosticWriter ().println (resources .getText (key , args ));
149
177
}
150
178
}
151
179
@@ -162,4 +190,8 @@ private void report(Diagnostic.Kind k, DocTreePath p, String msg) {
162
190
private void report (Diagnostic .Kind k , Element e , String msg ) {
163
191
reporter .print (k , e , msg );
164
192
}
193
+
194
+ private void report (Diagnostic .Kind k , FileObject fo , int start , int pos , int end , String msg ) {
195
+ reporter .print (k , fo , start , pos , end , msg );
196
+ }
165
197
}
0 commit comments