use of com.github.checkstyle.data.MergedConfigurationModule in project contribution by checkstyle.
the class ConfigurationMerger method merge.
/**
* Merges two ConfigurationModule instances with respect to their tree structure.
*
* @param baseModule
* base ConfigurationModule instance.
* @param patchModule
* parsed ConfigurationModule instance.
* @param parentName
* full name of the parent module.
* @return merged configuration modules.
*/
public static MergedConfigurationModule merge(ConfigurationModule baseModule, ConfigurationModule patchModule, String parentName) {
// creation of paired module
final MergedConfigurationModule doubledModule = getMergedConfigurationModule(baseModule, patchModule, parentName);
// getting silbings
final List<ConfigurationModule> baseChildren;
if (baseModule != null) {
baseChildren = baseModule.getChildren();
} else {
baseChildren = new ArrayList<>(0);
}
final List<ConfigurationModule> patchChildren;
if (patchModule != null) {
patchChildren = patchModule.getChildren();
} else {
patchChildren = new ArrayList<>(0);
}
// flags for detection of used patch siblings.
final boolean[] usedPatchParentChildren = new boolean[patchChildren.size()];
// processing of base siblings
for (ConfigurationModule module : baseChildren) {
final String moduleName = module.getName();
final ConfigurationModule patchSibling = getSibling(moduleName, patchChildren, usedPatchParentChildren);
doubledModule.addChild(merge(module, patchSibling, doubledModule.getFullModuleName()));
}
// processing of residual patch siblings
for (int i = 0; i < patchChildren.size(); i++) {
if (!usedPatchParentChildren[i]) {
doubledModule.addChild(merge(null, patchChildren.get(i), doubledModule.getFullModuleName()));
}
}
return doubledModule;
}
use of com.github.checkstyle.data.MergedConfigurationModule 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.MergedConfigurationModule in project contribution by checkstyle.
the class CheckstyleConfigurationsParser method parse.
/**
* Parses both configuration XML files, then merges them into one
* entity, which is ready for output.
*
* @param baseConfigPath
* path to the base configuration xml.
* @param patchConfigPath
* path to the patch configuration xml.
* @return merged configurations.
* @throws FileNotFoundException
* if files not found.
* @throws XMLStreamException
* on internal parser error.
*/
public static MergedConfigurationModule parse(Path baseConfigPath, Path patchConfigPath) throws FileNotFoundException, XMLStreamException {
final ConfigurationModule baseRoot = parseConfiguration(baseConfigPath, ROOT_MODULE_NAME);
final ConfigurationModule patchRoot = parseConfiguration(patchConfigPath, ROOT_MODULE_NAME);
return ConfigurationMerger.merge(baseRoot, patchRoot, ROOT_MODULE_NAME);
}
Aggregations