Logging improvements.
-Added: Improved Logging to parsing & Building
This commit is contained in:
parent
e752679d78
commit
0f00ad1771
|
@ -37,7 +37,7 @@ public class ConditionedSegment
|
|||
return builder.length() - length;
|
||||
}
|
||||
|
||||
public static int parse(String currentLine, List<String> lines, int currentIndex, int startIndex, List<ConditionedSegment> segments) throws IllegalStateException
|
||||
public static int parse(String fileName, String currentLine, List<String> lines, int currentIndex, int startIndex, List<ConditionedSegment> segments) throws IllegalStateException
|
||||
{
|
||||
ConditionedSegment segment = new ConditionedSegment(startIndex);
|
||||
ICondition condition = ICondition.parse(currentLine);
|
||||
|
@ -71,13 +71,13 @@ public class ConditionedSegment
|
|||
}
|
||||
else if(trimmed.startsWith("#if"))
|
||||
{
|
||||
i += parse(trimmed.substring(3).trim(), lines, i, segmentText.length(), childSegments);
|
||||
i += parse(fileName, trimmed.substring(3).trim(), lines, i, segmentText.length(), childSegments);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
segmentText.add(s);
|
||||
}
|
||||
throw new IllegalStateException("Unclosed #If found!");
|
||||
throw new IllegalStateException("Unclosed #If found in ["+fileName+"] at line ["+startIndex+"]");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -58,6 +58,7 @@ public class Template
|
|||
|
||||
public static Template parse(Path file) throws IOException
|
||||
{
|
||||
String fileName = FileUtils.getFileName(file.getFileName());
|
||||
List<ConditionedSegment> segments = new ArrayList<ConditionedSegment>();
|
||||
StringJoiner joiner = new StringJoiner("\n");
|
||||
List<String> lines = Files.readAllLines(file);
|
||||
|
@ -69,7 +70,7 @@ public class Template
|
|||
{
|
||||
if(trimmed.startsWith("#if"))
|
||||
{
|
||||
i += ConditionedSegment.parse(s.trim().substring(3).trim(), lines, i, joiner.length(), segments);
|
||||
i += ConditionedSegment.parse(fileName, s.trim().substring(3).trim(), lines, i, joiner.length(), segments);
|
||||
continue;
|
||||
}
|
||||
else if(trimmed.startsWith("#symlink"))
|
||||
|
@ -79,6 +80,6 @@ public class Template
|
|||
}
|
||||
joiner.add(s);
|
||||
}
|
||||
return new Template(FileUtils.getFileName(file.getFileName()), joiner.toString(), segments);
|
||||
return new Template(fileName, joiner.toString(), segments);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ public class BuildTask implements Runnable
|
|||
@Override
|
||||
public void run()
|
||||
{
|
||||
String s = template.build(process.parsePool, process.mappers, mappers != null, mappers[1]);
|
||||
String s = template.build(process.parsePool, process.mappers, mappers != null, mappers != null ? mappers[1] : null);
|
||||
if(mappers != null)
|
||||
{
|
||||
mappers[0].addAll(process.mappers);
|
||||
|
@ -38,6 +38,7 @@ public class BuildTask implements Runnable
|
|||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
try(BufferedWriter writer = Files.newBufferedWriter(path))
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue