import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public final class YangModelParserListenerImpl extends YangParserBaseListener {\r
-\r
+public final class YangModelParserListenerImpl extends YangParserBaseListener {
+
private static final Logger logger = LoggerFactory
.getLogger(YangModelParserListenerImpl.class);
private String yangModelPrefix;
private Date revision = new Date(0L);
- public final static DateFormat simpleDateFormat = new SimpleDateFormat(\r
+ public final static DateFormat simpleDateFormat = new SimpleDateFormat(
"yyyy-MM-dd");
private final Stack<String> actualPath = new Stack<String>();
public void enterAugment_stmt(YangParser.Augment_stmtContext ctx) {
final String augmentPath = stringFromNode(ctx);
AugmentationSchemaBuilder builder = moduleBuilder.addAugment(
- augmentPath, actualPath);
+ augmentPath, actualPath, ctx.getStart().getLine());
updatePath(augmentPath);
for (int i = 0; i < ctx.getChildCount(); i++) {
public void enterExtension_stmt(YangParser.Extension_stmtContext ctx) {
final String extName = stringFromNode(ctx);
QName qname = new QName(namespace, revision, yangModelPrefix, extName);
- ExtensionBuilder builder = moduleBuilder.addExtension(qname);
+ ExtensionBuilder builder = moduleBuilder.addExtension(qname, ctx
+ .getStart().getLine());
parseSchemaNodeArgs(ctx, builder);
String argument = null;
QName typedefQName = new QName(namespace, revision, yangModelPrefix,
typedefName);
TypedefBuilder builder = moduleBuilder.addTypedef(typedefQName,
- actualPath);
+ actualPath, ctx.getStart().getLine());
updatePath(typedefName);
builder.setPath(createActualSchemaPath(actualPath, namespace, revision,
@Override
public void enterType_stmt(YangParser.Type_stmtContext ctx) {
final String typeName = stringFromNode(ctx);
- QName typeQName = parseQName(typeName);
+ final int line = ctx.getStart().getLine();
+ final QName typeQName = parseQName(typeName);
TypeDefinition<?> type = null;
Type_body_stmtsContext typeBody = null;
// if this is base yang type...
if (YangTypesConverter.isBaseYangType(typeName)) {
if (typeBody == null) {
+ // check for types which must have body
+ checkMissingBody(typeName, moduleName, line);
// if there are no constraints, just grab default base yang type
- type = YangTypesConverter.javaTypeForBaseYangType(actualPath, namespace, revision, typeName);
+ type = YangTypesConverter.javaTypeForBaseYangType(actualPath,
+ namespace, revision, typeName);
moduleBuilder.setType(type, actualPath);
} else {
if ("union".equals(typeName)) {
- moduleBuilder.addUnionType(actualPath, namespace, revision);
- } else if("identityref".equals(typeName)) {
- SchemaPath path = createActualSchemaPath(actualPath, namespace, revision, yangModelPrefix);
- moduleBuilder.addIdentityrefType(getIdentityrefBase(typeBody), actualPath, path);
+ moduleBuilder.addUnionType(actualPath, namespace, revision,
+ line);
+ } else if ("identityref".equals(typeName)) {
+ SchemaPath path = createActualSchemaPath(actualPath,
+ namespace, revision, yangModelPrefix);
+ moduleBuilder.addIdentityrefType(
+ getIdentityrefBase(typeBody), actualPath, path,
+ line);
} else {
List<String> typePath = new ArrayList<String>(actualPath);
typePath.remove(0);
QName groupQName = new QName(namespace, revision, yangModelPrefix,
groupName);
GroupingBuilder groupBuilder = moduleBuilder.addGrouping(groupQName,
- actualPath);
+ actualPath, ctx.getStart().getLine());
updatePath("grouping");
updatePath(groupName);
parseSchemaNodeArgs(ctx, groupBuilder);
QName containerQName = new QName(namespace, revision, yangModelPrefix,
containerName);
ContainerSchemaNodeBuilder containerBuilder = moduleBuilder
- .addContainerNode(containerQName, actualPath);
+ .addContainerNode(containerQName, actualPath, ctx.getStart()
+ .getLine());
updatePath(containerName);
containerBuilder.setPath(createActualSchemaPath(actualPath, namespace,
QName leafQName = new QName(namespace, revision, yangModelPrefix,
leafName);
LeafSchemaNodeBuilder leafBuilder = moduleBuilder.addLeafNode(
- leafQName, actualPath);
+ leafQName, actualPath, ctx.getStart().getLine());
updatePath(leafName);
leafBuilder.setPath(createActualSchemaPath(actualPath, namespace,
@Override
public void enterUses_stmt(YangParser.Uses_stmtContext ctx) {
final String groupingPathStr = stringFromNode(ctx);
- moduleBuilder.addUsesNode(groupingPathStr,
- actualPath);
+ moduleBuilder.addUsesNode(groupingPathStr, actualPath, ctx.getStart()
+ .getLine());
updatePath(groupingPathStr);
}
QName leafListQName = new QName(namespace, revision, yangModelPrefix,
leafListName);
LeafListSchemaNodeBuilder leafListBuilder = moduleBuilder
- .addLeafListNode(leafListQName, actualPath);
+ .addLeafListNode(leafListQName, actualPath, ctx.getStart()
+ .getLine());
updatePath(leafListName);
parseSchemaNodeArgs(ctx, leafListBuilder);
QName containerQName = new QName(namespace, revision, yangModelPrefix,
containerName);
ListSchemaNodeBuilder listBuilder = moduleBuilder.addListNode(
- containerQName, actualPath);
+ containerQName, actualPath, ctx.getStart().getLine());
updatePath(containerName);
listBuilder.setPath(createActualSchemaPath(actualPath, namespace,
QName anyXmlQName = new QName(namespace, revision, yangModelPrefix,
anyXmlName);
AnyXmlBuilder anyXmlBuilder = moduleBuilder.addAnyXml(anyXmlQName,
- actualPath);
+ actualPath, ctx.getStart().getLine());
updatePath(anyXmlName);
anyXmlBuilder.setPath(createActualSchemaPath(actualPath, namespace,
QName choiceQName = new QName(namespace, revision, yangModelPrefix,
choiceName);
ChoiceBuilder choiceBuilder = moduleBuilder.addChoice(choiceQName,
- actualPath);
+ actualPath, ctx.getStart().getLine());
updatePath(choiceName);
choiceBuilder.setPath(createActualSchemaPath(actualPath, namespace,
QName choiceQName = new QName(namespace, revision, yangModelPrefix,
caseName);
ChoiceCaseBuilder caseBuilder = moduleBuilder.addCase(choiceQName,
- actualPath);
+ actualPath, ctx.getStart().getLine());
updatePath(caseName);
caseBuilder.setPath(createActualSchemaPath(actualPath, namespace,
QName notificationQName = new QName(namespace, revision,
yangModelPrefix, notificationName);
NotificationBuilder notificationBuilder = moduleBuilder
- .addNotification(notificationQName, actualPath);
+ .addNotification(notificationQName, actualPath, ctx.getStart()
+ .getLine());
updatePath(notificationName);
notificationBuilder.setPath(createActualSchemaPath(actualPath,
final String nodeTypeStr = ctx.getChild(0).getText();
final String[] splittedElement = nodeTypeStr.split(":");
if (splittedElement.length == 1) {
- nodeType = new QName(null, null, yangModelPrefix, splittedElement[0]);
+ nodeType = new QName(null, null, yangModelPrefix,
+ splittedElement[0]);
} else {
nodeType = new QName(null, null, splittedElement[0],
splittedElement[1]);
splittedName[0]);
}
} else {
- qname = new QName(namespace, revision, yangModelPrefix, nodeParameter);
+ qname = new QName(namespace, revision, yangModelPrefix,
+ nodeParameter);
}
UnknownSchemaNodeBuilder builder = moduleBuilder.addUnknownSchemaNode(
- qname, actualPath);
+ qname, actualPath, ctx.getStart().getLine());
builder.setNodeType(nodeType);
builder.setNodeParameter(nodeParameter);
updatePath(nodeParameter);
QName rpcQName = new QName(namespace, revision, yangModelPrefix,
rpcName);
RpcDefinitionBuilder rpcBuilder = moduleBuilder.addRpc(rpcQName,
- actualPath);
+ actualPath, ctx.getStart().getLine());
updatePath(rpcName);
rpcBuilder.setPath(createActualSchemaPath(actualPath, namespace,
QName featureQName = new QName(namespace, revision, yangModelPrefix,
featureName);
FeatureBuilder featureBuilder = moduleBuilder.addFeature(featureQName,
- actualPath);
+ actualPath, ctx.getStart().getLine());
updatePath(featureName);
featureBuilder.setPath(createActualSchemaPath(actualPath, namespace,
String reference = null;
String deviate = null;
DeviationBuilder builder = moduleBuilder.addDeviation(targetPath,
- actualPath);
+ actualPath, ctx.getStart().getLine());
updatePath(targetPath);
for (int i = 0; i < ctx.getChildCount(); i++) {
final String identityName = stringFromNode(ctx);
final QName identityQName = new QName(namespace, revision,
yangModelPrefix, identityName);
- IdentitySchemaNodeBuilder builder = moduleBuilder
- .addIdentity(identityQName, actualPath);
+ IdentitySchemaNodeBuilder builder = moduleBuilder.addIdentity(
+ identityQName, actualPath, ctx.getStart().getLine());
updatePath(identityName);
builder.setPath(createActualSchemaPath(actualPath, namespace, revision,