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;
|
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);
|
ConditionedSegment segment = new ConditionedSegment(startIndex);
|
||||||
ICondition condition = ICondition.parse(currentLine);
|
ICondition condition = ICondition.parse(currentLine);
|
||||||
|
@ -71,13 +71,13 @@ public class ConditionedSegment
|
||||||
}
|
}
|
||||||
else if(trimmed.startsWith("#if"))
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
segmentText.add(s);
|
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
|
public static Template parse(Path file) throws IOException
|
||||||
{
|
{
|
||||||
|
String fileName = FileUtils.getFileName(file.getFileName());
|
||||||
List<ConditionedSegment> segments = new ArrayList<ConditionedSegment>();
|
List<ConditionedSegment> segments = new ArrayList<ConditionedSegment>();
|
||||||
StringJoiner joiner = new StringJoiner("\n");
|
StringJoiner joiner = new StringJoiner("\n");
|
||||||
List<String> lines = Files.readAllLines(file);
|
List<String> lines = Files.readAllLines(file);
|
||||||
|
@ -69,7 +70,7 @@ public class Template
|
||||||
{
|
{
|
||||||
if(trimmed.startsWith("#if"))
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
else if(trimmed.startsWith("#symlink"))
|
else if(trimmed.startsWith("#symlink"))
|
||||||
|
@ -79,6 +80,6 @@ public class Template
|
||||||
}
|
}
|
||||||
joiner.add(s);
|
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
|
@Override
|
||||||
public void run()
|
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)
|
if(mappers != null)
|
||||||
{
|
{
|
||||||
mappers[0].addAll(process.mappers);
|
mappers[0].addAll(process.mappers);
|
||||||
|
@ -38,6 +38,7 @@ public class BuildTask implements Runnable
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch(Exception e)
|
||||||
{
|
{
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
try(BufferedWriter writer = Files.newBufferedWriter(path))
|
try(BufferedWriter writer = Files.newBufferedWriter(path))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue