import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.SchemaNode;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser;
import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException;
import org.opendaylight.yangtools.yang.parser.builder.api.AugmentationSchemaBuilder;
}
}
- private void resolveIdentity(final ModuleBuilder module, final IdentitySchemaNodeBuilder identity) {
+ private void resolveIdentity(final ModuleBuilder module,
+ final IdentitySchemaNodeBuilder identity) {
final String baseIdentityName = identity.getBaseIdentityName();
if (baseIdentityName != null) {
IdentitySchemaNodeBuilder result = null;
final int line = identity.getLine();
String[] splittedBase = baseIdentityName.split(":");
if (splittedBase.length > 2) {
- throw new YangParseException(module.getName(), line, "Failed to parse identityref base: "
- + baseIdentityName);
+ throw new YangParseException(module.getName(), line,
+ "Failed to parse identityref base: "
+ + baseIdentityName);
}
String prefix = splittedBase[0];
String name = splittedBase[1];
- ModuleBuilder dependentModule = BuilderUtils.getModuleByPrefix(module, prefix);
- result = BuilderUtils.findIdentity(dependentModule.getAddedIdentities(), name);
+
+ if (prefix.equals(module.getPrefix())
+ && name.equals(identity.getQName().getLocalName())) {
+ throw new YangParseException(module.getName(),
+ identity.getLine(),
+ "Failed to parse base, identity name equals base identity name: "
+ + baseIdentityName);
+ }
+
+ ModuleBuilder dependentModule = BuilderUtils.getModuleByPrefix(
+ module, prefix);
+ result = BuilderUtils.findIdentity(
+ dependentModule.getAddedIdentities(), name);
} else {
- result = BuilderUtils.findIdentity(module.getAddedIdentities(), baseIdentityName);
+ if (baseIdentityName.equals(identity.getQName().getLocalName())) {
+ throw new YangParseException(module.getName(),
+ identity.getLine(),
+ "Failed to parse base, identity name equals base identity name: "
+ + baseIdentityName);
+ }
+ result = BuilderUtils.findIdentity(module.getAddedIdentities(),
+ baseIdentityName);
}
identity.setBaseIdentity(result);
}