2525import java .io .InputStreamReader ;
2626import java .io .LineNumberReader ;
2727import java .io .Reader ;
28- import java .io .UncheckedIOException ;
2928import java .nio .file .Files ;
3029import java .util .ArrayList ;
3130import java .util .Collection ;
@@ -73,7 +72,7 @@ public class FileAnalyser {
7372 /**
7473 * The Locale of the files to analyze.
7574 */
76- private final Locale locale ;
75+ private final Locale sourceFileLocale ;
7776
7877 /**
7978 * The directories to analyze.
@@ -117,12 +116,14 @@ public class FileAnalyser {
117116 * @param tagClasses the array of tag classes to use for searching
118117 */
119118 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
120121 multipleLineCommentsOn = report .isMultipleLineComments ();
121122 emptyCommentsOn = report .isEmptyComments ();
122123 log = report .getLog ();
123124 sourceDirs = report .getSourceDirs ();
124125 encoding = report .getInputEncoding ();
125- locale = report .getLocale ();
126+ sourceFileLocale = report .getSourceFileLocale ();
126127 this .tagClasses = tagClasses ;
127128 this .includes = report .getIncludesCommaSeparated ();
128129 this .excludes = report .getExcludesCommaSeparated ();
@@ -133,7 +134,7 @@ public FileAnalyser(TagListReport report, List<TagClass> tagClasses) {
133134 *
134135 * @return a collection of TagReport objects.
135136 */
136- public Collection <TagReport > execute () {
137+ public Collection <TagReport > execute () throws IOException {
137138 List <File > fileList = findFilesToScan ();
138139
139140 for (File file : fileList ) {
@@ -156,15 +157,10 @@ public Collection<TagReport> execute() {
156157 *
157158 * @return a List of File objects.
158159 */
159- private List <File > findFilesToScan () {
160+ private List <File > findFilesToScan () throws IOException {
160161 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 ));
168164 }
169165 return filesList ;
170166 }
@@ -173,8 +169,8 @@ private List<File> findFilesToScan() {
173169 * Access an input reader that uses the current file encoding.
174170 *
175171 * @param file the file to open in the reader.
176- * @throws IOException the IO exception.
177172 * @return a reader with the current file encoding.
173+ * @throws IOException the IO exception.
178174 */
179175 private Reader getReader (File file ) throws IOException {
180176 InputStream in = Files .newInputStream (file .toPath ());
@@ -194,7 +190,7 @@ public void scanFile(File file) {
194190 int index ;
195191 // look for a tag on this line
196192 for (TagClass tagClass : tagClasses ) {
197- index = tagClass .tagMatchContains (currentLine , locale );
193+ index = tagClass .tagMatchContains (currentLine , sourceFileLocale );
198194 if (index != TagClass .NO_MATCH ) {
199195 // there's a tag on this line
200196 String commentType = extractCommentType (currentLine , index );
@@ -247,7 +243,7 @@ public void scanFile(File file) {
247243 // try to look if the next line is not a new tag
248244 boolean newTagFound = false ;
249245 for (TagClass tc : tagClasses ) {
250- if (tc .tagMatchStartsWith (currentComment , locale )) {
246+ if (tc .tagMatchStartsWith (currentComment , sourceFileLocale )) {
251247 newTagFound = true ;
252248 break ;
253249 }
0 commit comments