25
25
import java .io .InputStreamReader ;
26
26
import java .io .LineNumberReader ;
27
27
import java .io .Reader ;
28
- import java .io .UncheckedIOException ;
29
28
import java .nio .file .Files ;
30
29
import java .util .ArrayList ;
31
30
import java .util .Collection ;
@@ -73,7 +72,7 @@ public class FileAnalyser {
73
72
/**
74
73
* The Locale of the files to analyze.
75
74
*/
76
- private final Locale locale ;
75
+ private final Locale sourceFileLocale ;
77
76
78
77
/**
79
78
* The directories to analyze.
@@ -117,12 +116,14 @@ public class FileAnalyser {
117
116
* @param tagClasses the array of tag classes to use for searching
118
117
*/
119
118
public FileAnalyser (TagListReport report , List <TagClass > tagClasses ) {
119
+ // TODO - direct class TagListReport should not be used,
120
+ // we can add a separate args or new class/interface for group of args
120
121
multipleLineCommentsOn = report .isMultipleLineComments ();
121
122
emptyCommentsOn = report .isEmptyComments ();
122
123
log = report .getLog ();
123
124
sourceDirs = report .getSourceDirs ();
124
125
encoding = report .getInputEncoding ();
125
- locale = report .getLocale ();
126
+ sourceFileLocale = report .getSourceFileLocale ();
126
127
this .tagClasses = tagClasses ;
127
128
this .includes = report .getIncludesCommaSeparated ();
128
129
this .excludes = report .getExcludesCommaSeparated ();
@@ -133,7 +134,7 @@ public FileAnalyser(TagListReport report, List<TagClass> tagClasses) {
133
134
*
134
135
* @return a collection of TagReport objects.
135
136
*/
136
- public Collection <TagReport > execute () {
137
+ public Collection <TagReport > execute () throws IOException {
137
138
List <File > fileList = findFilesToScan ();
138
139
139
140
for (File file : fileList ) {
@@ -156,15 +157,10 @@ public Collection<TagReport> execute() {
156
157
*
157
158
* @return a List of File objects.
158
159
*/
159
- private List <File > findFilesToScan () {
160
+ private List <File > findFilesToScan () throws IOException {
160
161
List <File > filesList = new ArrayList <>();
161
- try {
162
- for (String sourceDir : sourceDirs ) {
163
- filesList .addAll (FileUtils .getFiles (new File (sourceDir ), includes , excludes ));
164
- }
165
- } catch (IOException e ) {
166
- // TODO - fix with Doxia 2.x - canGenerateReport will have a checked exception
167
- throw new UncheckedIOException ("Error while trying to find the files to scan." , e );
162
+ for (String sourceDir : sourceDirs ) {
163
+ filesList .addAll (FileUtils .getFiles (new File (sourceDir ), includes , excludes ));
168
164
}
169
165
return filesList ;
170
166
}
@@ -173,8 +169,8 @@ private List<File> findFilesToScan() {
173
169
* Access an input reader that uses the current file encoding.
174
170
*
175
171
* @param file the file to open in the reader.
176
- * @throws IOException the IO exception.
177
172
* @return a reader with the current file encoding.
173
+ * @throws IOException the IO exception.
178
174
*/
179
175
private Reader getReader (File file ) throws IOException {
180
176
InputStream in = Files .newInputStream (file .toPath ());
@@ -194,7 +190,7 @@ public void scanFile(File file) {
194
190
int index ;
195
191
// look for a tag on this line
196
192
for (TagClass tagClass : tagClasses ) {
197
- index = tagClass .tagMatchContains (currentLine , locale );
193
+ index = tagClass .tagMatchContains (currentLine , sourceFileLocale );
198
194
if (index != TagClass .NO_MATCH ) {
199
195
// there's a tag on this line
200
196
String commentType = extractCommentType (currentLine , index );
@@ -247,7 +243,7 @@ public void scanFile(File file) {
247
243
// try to look if the next line is not a new tag
248
244
boolean newTagFound = false ;
249
245
for (TagClass tc : tagClasses ) {
250
- if (tc .tagMatchStartsWith (currentComment , locale )) {
246
+ if (tc .tagMatchStartsWith (currentComment , sourceFileLocale )) {
251
247
newTagFound = true ;
252
248
break ;
253
249
}
0 commit comments