X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=yang%2Fyang-parser-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fyang%2Fparser%2Futil%2FParserUtils.xtend;h=861778590e816e05ebc655caf393afcd34f1b33e;hb=6f5a05159fb2c12717e3d5465b1963e475b320c8;hp=16b740b77b3023263cadc14981f8122a8dfa6418;hpb=475f8732893197eb41bfa695a4c7dedb45f25f06;p=yangtools.git diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/util/ParserUtils.xtend b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/util/ParserUtils.xtend index 16b740b77b..861778590e 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/util/ParserUtils.xtend +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/util/ParserUtils.xtend @@ -59,6 +59,7 @@ import org.opendaylight.yangtools.yang.parser.builder.api.TypeDefinitionBuilder import org.opendaylight.yangtools.yang.parser.builder.impl.UnknownSchemaNodeBuilder import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode import org.opendaylight.yangtools.yang.model.api.DataNodeContainer +import com.google.common.base.Preconditions public final class ParserUtils { @@ -115,7 +116,9 @@ public final class ParserUtils { var ModuleBuilder dependentModule = null; var Date dependentModuleRevision = null; - if (prefix.equals(module.getPrefix())) { + if(prefix == null) { + dependentModule = module; + } else if (prefix.equals(module.getPrefix())) { dependentModule = module; } else { val ModuleImport dependentModuleImport = getModuleImport(module, prefix); @@ -223,7 +226,7 @@ public final class ParserUtils { * augmentation target node */ public static def dispatch fillAugmentTarget(AugmentationSchemaBuilder augment, DataNodeContainerBuilder target) { - for (DataSchemaNodeBuilder child : augment.getChildNodes()) { + for (DataSchemaNodeBuilder child : augment.getChildNodeBuilders()) { val childCopy = CopyUtils.copy(child, target, false); if (augment.parent instanceof UsesNodeBuilder) { setNodeAddedByUses(childCopy); @@ -249,7 +252,7 @@ public final class ParserUtils { * augmentation target choice node */ public static def dispatch fillAugmentTarget(AugmentationSchemaBuilder augment, ChoiceBuilder target) { - for (DataSchemaNodeBuilder builder : augment.getChildNodes()) { + for (DataSchemaNodeBuilder builder : augment.getChildNodeBuilders()) { val childCopy = CopyUtils.copy(builder, target, false); if (augment.parent instanceof UsesNodeBuilder) { setNodeAddedByUses(childCopy); @@ -257,7 +260,7 @@ public final class ParserUtils { setNodeAugmenting(childCopy) target.addCase(childCopy); } - for (UsesNodeBuilder usesNode : augment.getUsesNodes()) { + for (UsesNodeBuilder usesNode : augment.getUsesNodeBuilders()) { if (usesNode !== null) { throw new YangParseException(augment.getModuleName(), augment.getLine(), "Error in augment parsing: cannot augment choice with nodes from grouping"); @@ -272,7 +275,7 @@ public final class ParserUtils { child.setAugmenting(true); if (child instanceof DataNodeContainerBuilder) { val DataNodeContainerBuilder dataNodeChild = child as DataNodeContainerBuilder; - for (inner : dataNodeChild.getChildNodes()) { + for (inner : dataNodeChild.getChildNodeBuilders()) { setNodeAugmenting(inner); } } else if (child instanceof ChoiceBuilder) { @@ -290,7 +293,7 @@ public final class ParserUtils { child.setAddedByUses(true); if (child instanceof DataNodeContainerBuilder) { val DataNodeContainerBuilder dataNodeChild = child as DataNodeContainerBuilder; - for (inner : dataNodeChild.getChildNodes()) { + for (inner : dataNodeChild.getChildNodeBuilders()) { setNodeAddedByUses(inner); } } else if (child instanceof ChoiceBuilder) { @@ -338,7 +341,7 @@ public final class ParserUtils { var SchemaNodeBuilder node = module.getDataChildByName(first.localName) if (node == null) { - val notifications = module.notifications + val notifications = module.getAddedNotifications for (notification : notifications) { if (notification.QName.localName.equals(first.localName)) { node = notification @@ -346,7 +349,7 @@ public final class ParserUtils { } } if (node == null) { - val rpcs = module.rpcs + val rpcs = module.getAddedRpcs for (rpc : rpcs) { if (rpc.QName.localName.equals(first.localName)) { node = rpc @@ -408,10 +411,10 @@ public final class ParserUtils { val name = splittedBase.get(1); val dependentModule = findModuleFromBuilders(modules, module, prefix, line); if (dependentModule !== null) { - result = findIdentity(dependentModule.identities, name); + result = findIdentity(dependentModule.getAddedIdentities, name); } } else { - result = findIdentity(module.identities, baseString); + result = findIdentity(module.getAddedIdentities, baseString); } return result; } @@ -467,7 +470,12 @@ public final class ParserUtils { while (!(parent instanceof ModuleBuilder)) { parent = parent.getParent(); } - return parent as ModuleBuilder; + Preconditions.checkState(parent instanceof ModuleBuilder) + var parentModule = parent as ModuleBuilder + if(parentModule.submodule) { + parentModule = parentModule.parent; + } + return parentModule; } public static def Set wrapChildNodes(String moduleName, int line, Set nodes,