Skip to content

Commit

Permalink
Removed deviation parameter. Handle missing config case when replacing.
Browse files Browse the repository at this point in the history
  • Loading branch information
dhuebner committed Jan 10, 2024
1 parent 328163f commit a64c831
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ public ProcessedDataModel process(List<AbstractModule> modules, List<String> inc

/**
* @param moduleData data to serialize
* @param format tree or json. tree is default
* @param output target
* @param format tree or json. tree is default
* @param output target
*/
public void serialize(ModuleData moduleData, Format format, StringBuilder output) {
switch (format) {
Expand Down Expand Up @@ -118,7 +118,8 @@ protected ProcessedDataModel processInternal(List<AbstractModule> modules, List<
private void collectResourceErrors(AbstractModule entryModule, ProcessedDataModel processedModel) {
var moduleFile = moduleFileName(entryModule);
entryModule.eResource().getErrors().forEach(diagnostic -> {
processedModel.addError(moduleFile, diagnostic.getLine(), diagnostic.getColumn(), diagnostic.getMessage(), false);
processedModel.addError(moduleFile, diagnostic.getLine(), diagnostic.getColumn(), diagnostic.getMessage(),
false);
});
}

Expand Down Expand Up @@ -179,9 +180,14 @@ protected void processDeviate(Deviate deviate, AbstractModule module, ProcessedD
var copy = ProcessorUtility.copyEObject(statement);
targetNode.getSubstatements().add(copy);
} else {
processedModel.addProcessorError(moduleFileName(module), statement,
"the \"" + YangNameUtils.getYangName(statement) + "\" property does not exist in node \""
+ nodeQName(targetNode) + "\"");
if (statement.eClass() == YangPackage.Literals.CONFIG) {
// config could be inherited from parent or be default = true
targetNode.getSubstatements().add(ProcessorUtility.copyEObject(statement));
} else {
processedModel.addProcessorError(moduleFileName(module), statement,
"the \"" + YangNameUtils.getYangName(statement)
+ "\" property does not exist in node \"" + nodeQName(targetNode) + "\"");
}
}
}
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ public static class Args {

@Parameter(description = "<file...>", required = true)
public List<String> modules = newArrayList();

@Parameter(names = { "-d",
"--deviation-module" }, description = "DISABLED! Use to apply the deviations defined in this file.")
public String deviationModule;
//
// @Parameter(names = { "-d",
// "--deviation-module" }, description = "DISABLED! Use to apply the deviations defined in this file.")
// public String deviationModule;

@Parameter(names = { "-f", "--format" }, description = "Output format.")
public Format format;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ public void processHelpArg() {
YangProcessorApp.parseArgs(out, "--help");
assertEquals("Usage: yang-tool [options] <file...>\n"
+ " Options:\n"
+ " -d, --deviation-module\n"
+ " DISABLED! Use to apply the deviations defined in this file.\n"
+ " -X, --exclude-features\n"
+ " Excluded features.\n"
+ " Default: []\n"
Expand Down Expand Up @@ -62,10 +60,9 @@ public void processOnlyRequieredArgs() {

@Test
public void processMainArgs() {
var parsed = parseArgs("-f", "tree", "ietf-system.yang", "--deviation-module", "example-system-ext.yang");
var parsed = parseArgs("-f", "tree", "ietf-system.yang");
assertEquals(Format.tree, parsed.format);
assertEquals("ietf-system.yang", parsed.modules.get(0));
assertEquals("example-system-ext.yang", parsed.deviationModule);
}

@Test
Expand Down

0 comments on commit a64c831

Please sign in to comment.