} else {
generateTypesFromAugmentedChoiceCases(module, augmentPackageName, targetTypeBuilder.toInstance(),
- (ChoiceSchemaNode) targetSchemaNode, augSchema.getChildNodes());
+ (ChoiceSchemaNode) targetSchemaNode, augSchema.getChildNodes(), null);
}
}
augSchema);
} else {
generateTypesFromAugmentedChoiceCases(module, augmentPackageName, targetTypeBuilder.toInstance(),
- (ChoiceSchemaNode) targetSchemaNode, augSchema.getChildNodes());
+ (ChoiceSchemaNode) targetSchemaNode, augSchema.getChildNodes(), usesNodeParent);
}
}
* </ul>
*/
private void generateTypesFromAugmentedChoiceCases(final Module module, final String basePackageName,
- final Type targetType, final ChoiceSchemaNode targetNode, final Iterable<DataSchemaNode> augmentedNodes) {
+ final Type targetType, final ChoiceSchemaNode targetNode, final Iterable<DataSchemaNode> augmentedNodes,
+ final DataNodeContainer usesNodeParent) {
checkArgument(basePackageName != null, "Base Package Name cannot be NULL.");
checkArgument(targetType != null, "Referenced Choice Type cannot be NULL.");
checkArgument(augmentedNodes != null, "Set of Choice Case Nodes cannot be NULL.");
}
ChoiceCaseNode node = null;
+ final String caseLocalName = caseNode.getQName().getLocalName();
if (caseNode instanceof ChoiceCaseNode) {
node = (ChoiceCaseNode) caseNode;
+ } else if (targetNode.getCaseNodeByName(caseLocalName) == null) {
+ final String targetNodeLocalName = targetNode.getQName().getLocalName();
+ for (DataSchemaNode dataSchemaNode : usesNodeParent.getChildNodes()) {
+ if (dataSchemaNode instanceof ChoiceSchemaNode && targetNodeLocalName.equals(dataSchemaNode.getQName
+ ().getLocalName())) {
+ node = ((ChoiceSchemaNode) dataSchemaNode).getCaseNodeByName(caseLocalName);
+ break;
+ }
+ }
} else {
- node = targetNode.getCaseNodeByName(caseNode.getQName().getLocalName());
+ node = targetNode.getCaseNodeByName(caseLocalName);
}
final Iterable<DataSchemaNode> childNodes = node.getChildNodes();
if (childNodes != null) {
builder.addAnnotation("", "Deprecated");
}
}
-}
+}
\ No newline at end of file
cleanUp(sourcesOutputDir, compiledOutputDir);
}
+ @Test
+ public void testBug5461() throws Exception {
+ final File sourcesOutputDir = new File(GENERATOR_OUTPUT_PATH + FS + "bug5461");
+ assertTrue("Failed to create test file '" + sourcesOutputDir + "'", sourcesOutputDir.mkdir());
+ final File compiledOutputDir = new File(COMPILER_OUTPUT_PATH + FS + "bug5461");
+ assertTrue("Failed to create test file '" + compiledOutputDir + "'", compiledOutputDir.mkdir());
+
+ generateTestSources("/compilation/bug5461", sourcesOutputDir);
+
+ // Test if sources are compilable
+ testCompilation(sourcesOutputDir, compiledOutputDir);
+
+ cleanUp(sourcesOutputDir, compiledOutputDir);
+ }
+
/**
* Test if class generated for node from grouping implements ChildOf.
*