Skip to content

Commit

Permalink
Addresses #81
Browse files Browse the repository at this point in the history
  • Loading branch information
sylvainhalle committed Aug 6, 2019
1 parent d66af27 commit b70d4fe
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
24 changes: 21 additions & 3 deletions Source/Core/src/ca/uqac/lif/textidote/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public class Main
/**
* A version string
*/
public static final String VERSION_STRING = "0.8";
public static final String VERSION_STRING = "0.8.1";

/**
* The name of the Aspell dictionary file to look for in a folder
Expand Down Expand Up @@ -508,6 +508,7 @@ else if (output_method.compareToIgnoreCase("json") == 0)
Queue<String> filename_queue = new ArrayDeque<String>();
Set<String> processed_filenames = new HashSet<String>();
filename_queue.addAll(filenames);
String top_level_filename = null;
while (!filename_queue.isEmpty())
{
String filename = filename_queue.remove();
Expand All @@ -516,6 +517,11 @@ else if (output_method.compareToIgnoreCase("json") == 0)
continue;
}
processed_filenames.add(filename);
if (top_level_filename == null || cmd_filenames.contains(filename))
{
// This is a top level filename
top_level_filename = filename;
}
Scanner scanner = null;
try
{
Expand Down Expand Up @@ -608,7 +614,15 @@ else if (output_method.compareToIgnoreCase("json") == 0)
List<Advice> all_advice = linter.evaluateAll(last_string);
renderer.addAdvice(filename, last_string, all_advice);
num_advice += all_advice.size();
addInnerFilesToQueue(c_cleaner.getInnerFiles(), processed_filenames, filename_queue, filename);
int added = addInnerFilesToQueue(c_cleaner.getInnerFiles(), processed_filenames, filename_queue, top_level_filename);
if (added > 0 && cmd_filenames.size() > 1)
{
// Corner case where file checking does not work
stderr.println("Warning: one of the input files refers to sub-files, and");
stderr.println("more than one file is specified on the command line. When");
stderr.println("using sub-files, you should provide a single root document.");
return -5;
}
}
catch (LinterException e)
{
Expand Down Expand Up @@ -845,10 +859,12 @@ protected static void printMap(PrintStream ps, Map<Range,Range> map)
* This object is modified by the current method (new filenames can be
* added to it).
* @param current_filename The name of the file currently being processed
* @return The number of new files added to the queue
*/
protected static void addInnerFilesToQueue(List<String> inner_files, Set<String> processed_filenames,
protected static int addInnerFilesToQueue(List<String> inner_files, Set<String> processed_filenames,
Queue<String> file_queue, String current_filename)
{
int added = 0;
File f = new File(current_filename);
String parent_path = f.getParent();
if (parent_path == null)
Expand All @@ -869,7 +885,9 @@ protected static void addInnerFilesToQueue(List<String> inner_files, Set<String>
if (!processed_filenames.contains(filename))
{
file_queue.add(parent_path + filename);
added++;
}
}
return added;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<hr/>
Output produced by TeXtidote v0.8, &copy; 2018-2019 Sylvain Hall&eacute; - All rights reserved.<br/>
Output produced by TeXtidote v0.8.1, &copy; 2018-2019 Sylvain Hall&eacute; - All rights reserved.<br/>
See the <a href="https://sylvainhalle.github.io/sylvainhalle/textidote">TeXtidote website</a> for more information.
</body>
</html>
2 changes: 1 addition & 1 deletion config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<author>Sylvain Hall&#233;</author>

<!-- The project's version number -->
<version>0.8</version>
<version>0.8.1</version>

<!-- The project's main class -->
<mainclass>ca.uqac.lif.textidote.Main</mainclass>
Expand Down

0 comments on commit b70d4fe

Please sign in to comment.