use of com.github.checkstyle.data.DiffReport in project contribution by checkstyle.
the class Main method main.
/**
* Executes all three processing stages according to CLI options.
*
* @param args
* cli arguments.
* @throws Exception
* on failure to execute stages.
*/
public static void main(final String... args) throws Exception {
System.out.println("patch-diff-report-tool execution started.");
final CommandLine commandLine = parseCli(args);
if (commandLine.hasOption(OPTION_HELP)) {
System.out.println(MSG_HELP);
} else {
final CliPaths paths = getCliPaths(commandLine);
final DiffReport diffReport;
if (paths.getCompareMode() == CompareMode.XML) {
// XML parsing stage
System.out.println("XML parsing is started.");
diffReport = CheckstyleReportsParser.parse(paths.getBaseReportPath(), paths.getPatchReportPath(), XML_PARSE_PORTION_SIZE);
} else {
// file parsing stage
System.out.println("File parsing is started.");
diffReport = CheckstyleTextParser.parse(paths.getBaseReportPath(), paths.getPatchReportPath());
}
// Configuration processing stage.
MergedConfigurationModule diffConfiguration = null;
if (paths.configurationPresent()) {
System.out.println("Creation of configuration report is started.");
diffConfiguration = CheckstyleConfigurationsParser.parse(paths.getBaseConfigPath(), paths.getPatchConfigPath());
} else {
System.out.println("Configuration processing skipped: " + "no configuration paths provided.");
}
// Site and XREF generation stage
System.out.println("Creation of diff html site is started.");
try {
exportResources(paths);
SiteGenerator.generate(diffReport, diffConfiguration, paths);
} finally {
for (String message : JxrDummyLog.getLogs()) {
System.out.println(message);
}
}
System.out.println("Creation of the result site succeed.");
}
System.out.println("patch-diff-report-tool execution finished.");
}
use of com.github.checkstyle.data.DiffReport in project contribution by checkstyle.
the class CheckstyleReportsParser method parse.
/**
* Parses input XML files: creates 2 parsers
* which process their XML files in rotation and try
* to write their results to the ParsedContent class
* inner map, where they are eagerly compared.
* @param baseXml
* path to base XML file.
* @param patchXml
* path to patch XML file.
* @param portionSize
* single portion of XML file processed at once by any parser.
* @return parsed content.
* @throws FileNotFoundException
* if files not found.
* @throws XMLStreamException
* on internal parser error.
*/
public static DiffReport parse(Path baseXml, Path patchXml, int portionSize) throws FileNotFoundException, XMLStreamException {
final DiffReport content = new DiffReport();
final XMLEventReader baseReader = StaxUtils.createReader(baseXml);
final XMLEventReader patchReader = StaxUtils.createReader(patchXml);
while (baseReader.hasNext() || patchReader.hasNext()) {
parseXmlPortion(content, baseReader, portionSize, BASE_REPORT_INDEX);
parseXmlPortion(content, patchReader, portionSize, PATCH_REPORT_INDEX);
}
content.getDiffStatistics();
return content;
}
use of com.github.checkstyle.data.DiffReport in project contribution by checkstyle.
the class CheckstyleTextParser method parse.
/**
* Parses input files: creates 2 parsers which process their files in rotation and try to
* compare and write their results to the {@link DiffReport} class.
*
* @param baseReport
* path to base directory.
* @param patchReport
* path to patch directory.
* @return parsed content.
* @throws IOException
* if there is a problem accessing a file.
*/
public static DiffReport parse(Path baseReport, Path patchReport) throws IOException {
final DiffReport content = new DiffReport();
final StringListIterator baseReader = getFiles(baseReport);
final StringListIterator patchReader = getFiles(patchReport);
while (true) {
final boolean baseNext = baseReader.hasNext();
final boolean patchNext = patchReader.hasNext();
if (baseNext && patchNext) {
parseDifference(content, baseReader, baseReport, patchReader, patchReport);
} else if (baseNext != patchNext) {
if (baseNext) {
parseDifferenceSingle(content, baseReader, baseReport, BASE_REPORT_INDEX);
} else {
parseDifferenceSingle(content, patchReader, patchReport, PATCH_REPORT_INDEX);
}
} else {
break;
}
}
content.getDiffStatistics();
return content;
}
Aggregations