Added line number to error messages. 97/297/2
authorMartin Vitez <mvitez@cisco.com>
Mon, 6 May 2013 07:12:46 +0000 (09:12 +0200)
committerMartin Vitez <mvitez@cisco.com>
Mon, 6 May 2013 13:30:19 +0000 (15:30 +0200)
Change-Id: I180438f8e617ca910b16d524576e88650d966bbd
Signed-off-by: Martin Vitez <mvitez@cisco.com>
34 files changed:
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/api/AbstractTypeAwareBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/api/Builder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/api/TypeAwareBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/AnyXmlBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/AugmentationSchemaBuilderImpl.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/ChoiceBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/ChoiceCaseBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/ConstraintsBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/ContainerSchemaNodeBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/DeviationBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/ExtensionBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/FeatureBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/GroupingBuilderImpl.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/IdentitySchemaNodeBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/IdentityrefTypeBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/LeafListSchemaNodeBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/LeafSchemaNodeBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/ListSchemaNodeBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/ModuleBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/NotificationBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/RpcDefinitionBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/TypedefBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/UnionTypeBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/UnknownSchemaNodeBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/UsesNodeBuilderImpl.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/impl/YangModelParserImpl.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/impl/YangModelParserListenerImpl.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/util/ParserUtils.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/util/RefineHolder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/util/YangModelBuilderUtil.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/util/YangParseException.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/validator/BasicValidations.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/java/org/opendaylight/controller/yang/model/validator/YangModelValidationTest.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/YangTypesConverter.java

index 212e2f8..68f2d06 100644 (file)
@@ -20,10 +20,11 @@ import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;
 import org.opendaylight.controller.yang.model.parser.builder.api.DataSchemaNodeBuilder;
 
 public class AnyXmlBuilder implements DataSchemaNodeBuilder {
+    private final int line;
     private final QName qname;
     private SchemaPath path;
     private final AnyXmlSchemaNodeImpl instance;
-    private final ConstraintsBuilder constraints = new ConstraintsBuilder();
+    private final ConstraintsBuilder constraints;
     private final List<UnknownSchemaNodeBuilder> addedUnknownNodes = new ArrayList<UnknownSchemaNodeBuilder>();
 
     private String description;
@@ -31,9 +32,11 @@ public class AnyXmlBuilder implements DataSchemaNodeBuilder {
     private Status status = Status.CURRENT;
     private boolean configuration;
 
-    public AnyXmlBuilder(final QName qname) {
+    public AnyXmlBuilder(final QName qname, final int line) {
         this.qname = qname;
+        this.line = line;
         instance = new AnyXmlSchemaNodeImpl(qname);
+        constraints = new ConstraintsBuilder(line);
     }
 
     @Override
@@ -55,6 +58,11 @@ public class AnyXmlBuilder implements DataSchemaNodeBuilder {
         return instance;
     }
 
+    @Override
+    public int getLine() {
+        return line;
+    }
+
     @Override
     public QName getQName() {
         return qname;
index e7d389f..c85955d 100644 (file)
@@ -31,8 +31,8 @@ import org.opendaylight.controller.yang.model.parser.util.YangModelBuilderUtil;
 import org.opendaylight.controller.yang.model.util.RevisionAwareXPathImpl;
 
 public class AugmentationSchemaBuilderImpl implements AugmentationSchemaBuilder {
-
     private final AugmentationSchemaImpl instance;
+    private final int line;
     private final String augmentTargetStr;
     private final SchemaPath augmentTarget;
     private String whenCondition;
@@ -40,14 +40,20 @@ public class AugmentationSchemaBuilderImpl implements AugmentationSchemaBuilder
     private final Set<GroupingBuilder> groupings = new HashSet<GroupingBuilder>();
     private final Set<UsesNodeBuilder> usesNodes = new HashSet<UsesNodeBuilder>();
 
-    AugmentationSchemaBuilderImpl(final String augmentTargetStr) {
+    AugmentationSchemaBuilderImpl(final String augmentTargetStr, final int line) {
         this.augmentTargetStr = augmentTargetStr;
+        this.line = line;
         final SchemaPath targetPath = YangModelBuilderUtil
                 .parseAugmentPath(augmentTargetStr);
         augmentTarget = targetPath;
         instance = new AugmentationSchemaImpl(targetPath);
     }
 
+    @Override
+    public int getLine() {
+        return line;
+    }
+
     @Override
     public void addChildNode(DataSchemaNodeBuilder childNode) {
         childNodes.add(childNode);
index 946ba4a..6660ac3 100644 (file)
@@ -32,6 +32,7 @@ import org.opendaylight.controller.yang.model.parser.builder.api.UsesNodeBuilder
 public class ChoiceBuilder implements DataSchemaNodeBuilder, ChildNodeBuilder,
         AugmentationTargetBuilder {
     private final ChoiceNodeImpl instance;
+    private final int line;
     // SchemaNode args
     private final QName qname;
     private SchemaPath schemaPath;
@@ -52,10 +53,11 @@ public class ChoiceBuilder implements DataSchemaNodeBuilder, ChildNodeBuilder,
     private final Set<ChoiceCaseBuilder> cases = new HashSet<ChoiceCaseBuilder>();
     private String defaultCase;
 
-    public ChoiceBuilder(QName qname) {
+    public ChoiceBuilder(final QName qname, final int line) {
         this.qname = qname;
+        this.line = line;
         instance = new ChoiceNodeImpl(qname);
-        constraints = new ConstraintsBuilder();
+        constraints = new ConstraintsBuilder(line);
     }
 
     @Override
@@ -93,6 +95,11 @@ public class ChoiceBuilder implements DataSchemaNodeBuilder, ChildNodeBuilder,
         return instance;
     }
 
+    @Override
+    public int getLine() {
+        return line;
+    }
+
     public Set<ChoiceCaseBuilder> getCases() {
         return cases;
     }
@@ -101,7 +108,7 @@ public class ChoiceBuilder implements DataSchemaNodeBuilder, ChildNodeBuilder,
     public void addChildNode(DataSchemaNodeBuilder childNode) {
         if (!(childNode instanceof ChoiceCaseBuilder)) {
             ChoiceCaseBuilder caseBuilder = new ChoiceCaseBuilder(
-                    childNode.getQName());
+                    childNode.getQName(), childNode.getLine());
             caseBuilder.addChildNode(childNode);
             cases.add(caseBuilder);
         } else {
index 27cead1..a631f00 100644 (file)
@@ -27,6 +27,7 @@ import org.opendaylight.controller.yang.model.parser.builder.api.UsesNodeBuilder
 public final class ChoiceCaseBuilder extends AbstractChildNodeBuilder implements
         DataSchemaNodeBuilder {
     private final ChoiceCaseNodeImpl instance;
+    private final int line;
     private SchemaPath schemaPath;
     private String description;
     private String reference;
@@ -37,10 +38,11 @@ public final class ChoiceCaseBuilder extends AbstractChildNodeBuilder implements
     private final Set<UsesNodeBuilder> addedUsesNodes = new HashSet<UsesNodeBuilder>();
     private final Set<AugmentationSchema> augmentations = new HashSet<AugmentationSchema>();
 
-    ChoiceCaseBuilder(QName qname) {
+    ChoiceCaseBuilder(final QName qname, final int line) {
         super(qname);
+        this.line = line;
         instance = new ChoiceCaseNodeImpl(qname);
-        constraints = new ConstraintsBuilder();
+        constraints = new ConstraintsBuilder(line);
     }
 
     @Override
@@ -77,6 +79,11 @@ public final class ChoiceCaseBuilder extends AbstractChildNodeBuilder implements
         return instance;
     }
 
+    @Override
+    public int getLine() {
+        return line;
+    }
+
     public SchemaPath getPath() {
         return schemaPath;
     }
index 905a107..2454953 100644 (file)
@@ -19,15 +19,16 @@ import org.opendaylight.controller.yang.model.parser.builder.api.Builder;
 import org.opendaylight.controller.yang.model.util.RevisionAwareXPathImpl;
 
 public class ConstraintsBuilder implements Builder {
-
     private final ConstraintDefinitionImpl instance;
+    private final int line;
     private final Set<MustDefinition> mustDefinitions;
     private String whenCondition;
     private boolean mandatory;
     private Integer min;
     private Integer max;
 
-    ConstraintsBuilder() {
+    ConstraintsBuilder(final int line) {
+        this.line = line;
         instance = new ConstraintDefinitionImpl();
         mustDefinitions = new HashSet<MustDefinition>();
     }
@@ -48,6 +49,11 @@ public class ConstraintsBuilder implements Builder {
         return instance;
     }
 
+    @Override
+    public int getLine() {
+        return line;
+    }
+
     public Integer getMinElements() {
         return min;
     }
index 8d82bda..7693b3a 100644 (file)
@@ -38,8 +38,8 @@ import org.opendaylight.controller.yang.model.parser.builder.api.UsesNodeBuilder
 public class ContainerSchemaNodeBuilder extends AbstractChildNodeBuilder
         implements TypeDefinitionAwareBuilder, AugmentationTargetBuilder,
         DataSchemaNodeBuilder {
-
     private final ContainerSchemaNodeImpl instance;
+    private final int line;
     private final ConstraintsBuilder constraints;
     private SchemaPath schemaPath;
     private String description;
@@ -54,10 +54,11 @@ public class ContainerSchemaNodeBuilder extends AbstractChildNodeBuilder
     private final Set<AugmentationSchemaBuilder> addedAugmentations = new HashSet<AugmentationSchemaBuilder>();
     private final List<UnknownSchemaNodeBuilder> addedUnknownNodes = new ArrayList<UnknownSchemaNodeBuilder>();
 
-    public ContainerSchemaNodeBuilder(QName qname) {
+    public ContainerSchemaNodeBuilder(final QName qname, final int line) {
         super(qname);
+        this.line = line;
         instance = new ContainerSchemaNodeImpl(qname);
-        constraints = new ConstraintsBuilder();
+        constraints = new ConstraintsBuilder(line);
     }
 
     @Override
@@ -118,6 +119,11 @@ public class ContainerSchemaNodeBuilder extends AbstractChildNodeBuilder
         return instance;
     }
 
+    @Override
+    public int getLine() {
+        return line;
+    }
+
     public Set<TypeDefinitionBuilder> getTypedefs() {
         return addedTypedefs;
     }
index 0888811..53fcbf5 100644 (file)
@@ -14,10 +14,11 @@ import org.opendaylight.controller.yang.model.parser.builder.api.Builder;
 import org.opendaylight.controller.yang.model.parser.util.YangModelBuilderUtil;
 
 public class DeviationBuilder implements Builder {
-
     private final DeviationImpl instance;
+    private final int line;
 
-    DeviationBuilder(final String targetPathStr) {
+    DeviationBuilder(final String targetPathStr, final int line) {
+        this.line = line;
         final SchemaPath targetPath = YangModelBuilderUtil
                 .parseAugmentPath(targetPathStr);
         instance = new DeviationImpl(targetPath);
@@ -28,6 +29,11 @@ public class DeviationBuilder implements Builder {
         return instance;
     }
 
+    @Override
+    public int getLine() {
+        return line;
+    }
+
     public void setDeviate(final String deviate) {
         if ("not-supported".equals(deviate)) {
             instance.setDeviate(Deviate.NOT_SUPPORTED);
@@ -130,11 +136,12 @@ public class DeviationBuilder implements Builder {
 
         @Override
         public String toString() {
-            StringBuilder sb = new StringBuilder(DeviationImpl.class.getSimpleName());
+            StringBuilder sb = new StringBuilder(
+                    DeviationImpl.class.getSimpleName());
             sb.append("[");
-            sb.append("targetPath="+ targetPath);
-            sb.append(", deviate="+ deviate);
-            sb.append(", reference="+ reference);
+            sb.append("targetPath=" + targetPath);
+            sb.append(", deviate=" + deviate);
+            sb.append(", reference=" + reference);
             sb.append("]");
             return sb.toString();
         }
index 5828a33..cca167c 100644 (file)
@@ -19,15 +19,16 @@ import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;
 import org.opendaylight.controller.yang.model.parser.builder.api.SchemaNodeBuilder;
 
 public class ExtensionBuilder implements SchemaNodeBuilder {
-
     private final ExtensionDefinitionImpl instance;
+    private final int line;
     private final QName qname;
     private SchemaPath schemaPath;
     private final List<UnknownSchemaNodeBuilder> addedExtensions = new ArrayList<UnknownSchemaNodeBuilder>();
     private final List<UnknownSchemaNodeBuilder> addedUnknownNodes = new ArrayList<UnknownSchemaNodeBuilder>();
 
-    ExtensionBuilder(final QName qname) {
+    ExtensionBuilder(final QName qname, final int line) {
         this.qname = qname;
+        this.line = line;
         instance = new ExtensionDefinitionImpl(qname);
     }
 
@@ -45,6 +46,11 @@ public class ExtensionBuilder implements SchemaNodeBuilder {
         return instance;
     }
 
+    @Override
+    public int getLine() {
+        return line;
+    }
+
     public void addExtension(UnknownSchemaNodeBuilder extension) {
         addedExtensions.add(extension);
     }
index ec5bcd7..372d786 100644 (file)
@@ -19,14 +19,15 @@ import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;
 import org.opendaylight.controller.yang.model.parser.builder.api.SchemaNodeBuilder;
 
 public class FeatureBuilder implements SchemaNodeBuilder {
-
     private final FeatureDefinitionImpl instance;
+    private final int line;
     private final QName qname;
     private SchemaPath schemaPath;
     private final List<UnknownSchemaNodeBuilder> addedUnknownNodes = new ArrayList<UnknownSchemaNodeBuilder>();
 
-    FeatureBuilder(final QName qname) {
+    FeatureBuilder(final QName qname, final int line) {
         this.qname = qname;
+        this.line = line;
         instance = new FeatureDefinitionImpl(qname);
     }
 
@@ -44,6 +45,11 @@ public class FeatureBuilder implements SchemaNodeBuilder {
         return instance;
     }
 
+    @Override
+    public int getLine() {
+        return line;
+    }
+
     @Override
     public QName getQName() {
         return qname;
index bffa7e3..1ccd0fc 100644 (file)
@@ -29,8 +29,8 @@ import org.opendaylight.controller.yang.model.parser.builder.api.TypeDefinitionB
 import org.opendaylight.controller.yang.model.parser.builder.api.UsesNodeBuilder;
 
 public class GroupingBuilderImpl implements GroupingBuilder {
-
     private final GroupingDefinitionImpl instance;
+    private final int line;
     private SchemaPath schemaPath;
     private final Set<DataSchemaNodeBuilder> childNodes = new HashSet<DataSchemaNodeBuilder>();
     private final Set<GroupingBuilder> groupings = new HashSet<GroupingBuilder>();
@@ -38,8 +38,9 @@ public class GroupingBuilderImpl implements GroupingBuilder {
     private final Set<UsesNodeBuilder> usesNodes = new HashSet<UsesNodeBuilder>();
     private final List<UnknownSchemaNodeBuilder> addedUnknownNodes = new ArrayList<UnknownSchemaNodeBuilder>();
 
-    GroupingBuilderImpl(final QName qname) {
+    GroupingBuilderImpl(final QName qname, final int line) {
         this.instance = new GroupingDefinitionImpl(qname);
+        this.line = line;
     }
 
     @Override
@@ -84,6 +85,11 @@ public class GroupingBuilderImpl implements GroupingBuilder {
         return instance;
     }
 
+    @Override
+    public int getLine() {
+        return line;
+    }
+
     /**
      * Always returns null.
      */
index 5cfde8e..810ceec 100644 (file)
@@ -20,14 +20,16 @@ import org.opendaylight.controller.yang.model.parser.builder.api.SchemaNodeBuild
 
 public final class IdentitySchemaNodeBuilder implements SchemaNodeBuilder {
     private final IdentitySchemaNodeImpl instance;
+    private final int line;
     private final QName qname;
     private SchemaPath schemaPath;
     private IdentitySchemaNodeBuilder baseIdentity;
     private String baseIdentityName;
     private final List<UnknownSchemaNodeBuilder> addedUnknownNodes = new ArrayList<UnknownSchemaNodeBuilder>();
 
-    IdentitySchemaNodeBuilder(final QName qname) {
+    IdentitySchemaNodeBuilder(final QName qname, final int line) {
         this.qname = qname;
+        this.line = line;
         instance = new IdentitySchemaNodeImpl(qname);
     }
 
@@ -48,6 +50,11 @@ public final class IdentitySchemaNodeBuilder implements SchemaNodeBuilder {
         return instance;
     }
 
+    @Override
+    public int getLine() {
+        return line;
+    }
+
     @Override
     public QName getQName() {
         return qname;
index 33b6416..f46b1d5 100644 (file)
@@ -30,12 +30,14 @@ import org.opendaylight.controller.yang.model.util.IdentityrefType;
  */
 public class IdentityrefTypeBuilder extends AbstractTypeAwareBuilder implements
         TypeDefinitionBuilder, Builder {
+    private final int line;
     private final String baseString;
     private final SchemaPath schemaPath;
     private QName baseQName;
 
 
-    public IdentityrefTypeBuilder(final String baseString, SchemaPath schemaPath) {
+    public IdentityrefTypeBuilder(final String baseString, final SchemaPath schemaPath, final int line) {
+        this.line = line;
         this.baseString = baseString;
         this.schemaPath = schemaPath;
     }
@@ -48,6 +50,11 @@ public class IdentityrefTypeBuilder extends AbstractTypeAwareBuilder implements
         this.baseQName = baseQName;
     }
 
+    @Override
+    public int getLine() {
+        return line;
+    }
+
     @Override
     public TypeDefinition<?> getType() {
         return null;
index 3884311..5ea82c2 100644 (file)
@@ -25,21 +25,26 @@ import org.opendaylight.controller.yang.model.parser.builder.api.SchemaNodeBuild
 public class LeafListSchemaNodeBuilder extends AbstractTypeAwareBuilder
         implements SchemaNodeBuilder, DataSchemaNodeBuilder {
     private final LeafListSchemaNodeImpl instance;
+    private final int line;
+    // SchemaNode args
     private final QName qname;
-    private final ConstraintsBuilder constraints = new ConstraintsBuilder();
     private SchemaPath schemaPath;
     private String description;
     private String reference;
     private Status status = Status.CURRENT;
+    private final List<UnknownSchemaNodeBuilder> addedUnknownNodes = new ArrayList<UnknownSchemaNodeBuilder>();
+    // DataSchemaNode args
     private boolean augmenting;
     private boolean configuration;
+    private final ConstraintsBuilder constraints;
+    // LeafListSchemaNode args
     private boolean userOrdered;
 
-    private final List<UnknownSchemaNodeBuilder> addedUnknownNodes = new ArrayList<UnknownSchemaNodeBuilder>();
-
-    public LeafListSchemaNodeBuilder(final QName qname) {
+    public LeafListSchemaNodeBuilder(final QName qname, final int line) {
         this.qname = qname;
+        this.line = line;
         instance = new LeafListSchemaNodeImpl(qname);
+        constraints = new ConstraintsBuilder(line);
     }
 
     @Override
@@ -69,6 +74,11 @@ public class LeafListSchemaNodeBuilder extends AbstractTypeAwareBuilder
         return instance;
     }
 
+    @Override
+    public int getLine() {
+        return line;
+    }
+
     @Override
     public QName getQName() {
         return qname;
@@ -107,7 +117,7 @@ public class LeafListSchemaNodeBuilder extends AbstractTypeAwareBuilder
 
     @Override
     public void setStatus(Status status) {
-        if(status != null) {
+        if (status != null) {
             this.status = status;
         }
     }
index fe039b2..45bb17b 100644 (file)
@@ -24,23 +24,28 @@ import org.opendaylight.controller.yang.model.parser.builder.api.SchemaNodeBuild
 
 public class LeafSchemaNodeBuilder extends AbstractTypeAwareBuilder implements
         DataSchemaNodeBuilder, SchemaNodeBuilder {
+    private final LeafSchemaNodeImpl instance;
+    private final int line;
+    // SchemaNode args
     private final QName qname;
     private SchemaPath path;
-    private final LeafSchemaNodeImpl instance;
-    private final ConstraintsBuilder constraints = new ConstraintsBuilder();
-    private final List<UnknownSchemaNodeBuilder> addedUnknownNodes = new ArrayList<UnknownSchemaNodeBuilder>();
-
     private String description;
     private String reference;
     private Status status = Status.CURRENT;
+    private final List<UnknownSchemaNodeBuilder> addedUnknownNodes = new ArrayList<UnknownSchemaNodeBuilder>();
+    // DataSchemaNode args
     private boolean augmenting;
     private boolean configuration;
+    private final ConstraintsBuilder constraints;
+    // leaf args
     private String defaultStr;
     private String unitsStr;
 
-    public LeafSchemaNodeBuilder(final QName qname) {
+    public LeafSchemaNodeBuilder(final QName qname, final int line) {
         this.qname = qname;
+        this.line = line;
         instance = new LeafSchemaNodeImpl(qname);
+        constraints = new ConstraintsBuilder(line);
     }
 
     @Override
@@ -72,6 +77,11 @@ public class LeafSchemaNodeBuilder extends AbstractTypeAwareBuilder implements
         return instance;
     }
 
+    @Override
+    public int getLine() {
+        return line;
+    }
+
     @Override
     public QName getQName() {
         return qname;
index b032b32..c9f338f 100644 (file)
@@ -40,25 +40,31 @@ public class ListSchemaNodeBuilder extends AbstractChildNodeBuilder implements
         DataSchemaNodeBuilder, SchemaNodeBuilder, AugmentationTargetBuilder,
         TypeDefinitionAwareBuilder {
     private final ListSchemaNodeImpl instance;
-    private List<QName> keyDefinition;
-    private final ConstraintsBuilder constraints;
+    private final int line;
+    // SchemaNode args
     private SchemaPath schemaPath;
     private String description;
     private String reference;
     private Status status = Status.CURRENT;
+    private final List<UnknownSchemaNodeBuilder> addedUnknownNodes = new ArrayList<UnknownSchemaNodeBuilder>();
+    // DataSchemaNode args
     private boolean augmenting;
     private boolean configuration;
-    private boolean userOrdered;
-
+    private final ConstraintsBuilder constraints;
+    // DataNodeContainer args
     private final Set<TypeDefinitionBuilder> addedTypedefs = new HashSet<TypeDefinitionBuilder>();
     private final Set<UsesNodeBuilder> addedUsesNodes = new HashSet<UsesNodeBuilder>();
+    // AugmentationTarget args
     private final Set<AugmentationSchemaBuilder> addedAugmentations = new HashSet<AugmentationSchemaBuilder>();
-    private final List<UnknownSchemaNodeBuilder> addedUnknownNodes = new ArrayList<UnknownSchemaNodeBuilder>();
+    // ListSchemaNode args
+    private List<QName> keyDefinition;
+    private boolean userOrdered;
 
-    public ListSchemaNodeBuilder(final QName qname) {
+    public ListSchemaNodeBuilder(final QName qname, final int line) {
         super(qname);
+        this.line = line;
         instance = new ListSchemaNodeImpl(qname);
-        constraints = new ConstraintsBuilder();
+        constraints = new ConstraintsBuilder(line);
     }
 
     @Override
@@ -102,7 +108,7 @@ public class ListSchemaNodeBuilder extends AbstractChildNodeBuilder implements
 
         // AUGMENTATIONS
         final Set<AugmentationSchema> augmentations = new HashSet<AugmentationSchema>();
-        for(AugmentationSchemaBuilder builder : addedAugmentations) {
+        for (AugmentationSchemaBuilder builder : addedAugmentations) {
             augmentations.add(builder.build());
         }
         instance.setAvailableAugmentations(augmentations);
@@ -120,6 +126,11 @@ public class ListSchemaNodeBuilder extends AbstractChildNodeBuilder implements
         return instance;
     }
 
+    @Override
+    public int getLine() {
+        return line;
+    }
+
     public Set<TypeDefinitionBuilder> getTypedefs() {
         return addedTypedefs;
     }
@@ -162,7 +173,7 @@ public class ListSchemaNodeBuilder extends AbstractChildNodeBuilder implements
 
     @Override
     public void setStatus(Status status) {
-        if(status != null) {
+        if (status != null) {
             this.status = status;
         }
     }
index cca505e..5d72a0e 100644 (file)
@@ -164,6 +164,11 @@ public class ModuleBuilder implements Builder {
         return instance;
     }
 
+    @Override
+    public int getLine() {
+        return 0;
+    }
+
     public Builder getNode(final List<String> path) {
         return moduleNodes.get(path);
     }
@@ -286,17 +291,18 @@ public class ModuleBuilder implements Builder {
         return imports;
     }
 
-    public ExtensionBuilder addExtension(final QName qname) {
-        final ExtensionBuilder builder = new ExtensionBuilder(qname);
+    public ExtensionBuilder addExtension(final QName qname, final int line) {
+        final ExtensionBuilder builder = new ExtensionBuilder(qname, line);
         addedExtensions.add(builder);
         return builder;
     }
 
     public ContainerSchemaNodeBuilder addContainerNode(
-            final QName containerName, final List<String> parentPath) {
+            final QName containerName, final List<String> parentPath,
+            final int line) {
         final List<String> pathToNode = new ArrayList<String>(parentPath);
         final ContainerSchemaNodeBuilder containerBuilder = new ContainerSchemaNodeBuilder(
-                containerName);
+                containerName, line);
         final ChildNodeBuilder parent = (ChildNodeBuilder) moduleNodes
                 .get(pathToNode);
         if (parent != null) {
@@ -314,10 +320,10 @@ public class ModuleBuilder implements Builder {
     }
 
     public ListSchemaNodeBuilder addListNode(final QName listName,
-            final List<String> parentPath) {
+            final List<String> parentPath, final int line) {
         final List<String> pathToNode = new ArrayList<String>(parentPath);
         final ListSchemaNodeBuilder listBuilder = new ListSchemaNodeBuilder(
-                listName);
+                listName, line);
         final ChildNodeBuilder parent = (ChildNodeBuilder) moduleNodes
                 .get(pathToNode);
         if (parent != null) {
@@ -335,10 +341,10 @@ public class ModuleBuilder implements Builder {
     }
 
     public LeafSchemaNodeBuilder addLeafNode(final QName leafName,
-            final List<String> parentPath) {
+            final List<String> parentPath, final int line) {
         final List<String> pathToNode = new ArrayList<String>(parentPath);
         final LeafSchemaNodeBuilder leafBuilder = new LeafSchemaNodeBuilder(
-                leafName);
+                leafName, line);
         final ChildNodeBuilder parent = (ChildNodeBuilder) moduleNodes
                 .get(pathToNode);
         if (parent != null) {
@@ -356,10 +362,10 @@ public class ModuleBuilder implements Builder {
     }
 
     public LeafListSchemaNodeBuilder addLeafListNode(final QName leafListName,
-            final List<String> parentPath) {
+            final List<String> parentPath, final int line) {
         final List<String> pathToNode = new ArrayList<String>(parentPath);
         final LeafListSchemaNodeBuilder leafListBuilder = new LeafListSchemaNodeBuilder(
-                leafListName);
+                leafListName, line);
         final ChildNodeBuilder parent = (ChildNodeBuilder) moduleNodes
                 .get(pathToNode);
         if (parent != null) {
@@ -377,9 +383,9 @@ public class ModuleBuilder implements Builder {
     }
 
     public GroupingBuilder addGrouping(final QName qname,
-            final List<String> parentPath) {
+            final List<String> parentPath, final int line) {
         final List<String> pathToGroup = new ArrayList<String>(parentPath);
-        final GroupingBuilder builder = new GroupingBuilderImpl(qname);
+        final GroupingBuilder builder = new GroupingBuilderImpl(qname, line);
         final ChildNodeBuilder parentNodeBuilder = (ChildNodeBuilder) moduleNodes
                 .get(pathToGroup);
         if (parentNodeBuilder != null) {
@@ -395,10 +401,10 @@ public class ModuleBuilder implements Builder {
     }
 
     public AugmentationSchemaBuilder addAugment(final String name,
-            final List<String> parentPath) {
+            final List<String> parentPath, final int line) {
         final List<String> pathToAugment = new ArrayList<String>(parentPath);
         final AugmentationSchemaBuilder builder = new AugmentationSchemaBuilderImpl(
-                name);
+                name, line);
 
         // augment can only be in 'module' or 'uses' statement
         final UsesNodeBuilder parent = addedUsesNodes.get(pathToAugment);
@@ -414,10 +420,10 @@ public class ModuleBuilder implements Builder {
     }
 
     public UsesNodeBuilder addUsesNode(final String groupingPathStr,
-            final List<String> parentPath) {
+            final List<String> parentPath, final int line) {
         final List<String> pathToUses = new ArrayList<String>(parentPath);
         final UsesNodeBuilder usesBuilder = new UsesNodeBuilderImpl(
-                groupingPathStr);
+                groupingPathStr, line);
         final ChildNodeBuilder parent = (ChildNodeBuilder) moduleNodes
                 .get(pathToUses);
         if (parent != null) {
@@ -445,9 +451,10 @@ public class ModuleBuilder implements Builder {
     }
 
     public RpcDefinitionBuilder addRpc(final QName qname,
-            final List<String> parentPath) {
+            final List<String> parentPath, final int line) {
         final List<String> pathToRpc = new ArrayList<String>(parentPath);
-        final RpcDefinitionBuilder rpcBuilder = new RpcDefinitionBuilder(qname);
+        final RpcDefinitionBuilder rpcBuilder = new RpcDefinitionBuilder(qname,
+                line);
 
         pathToRpc.add(qname.getLocalName());
         addedRpcs.put(pathToRpc, rpcBuilder);
@@ -455,7 +462,7 @@ public class ModuleBuilder implements Builder {
         final QName inputQName = new QName(qname.getNamespace(),
                 qname.getRevision(), qname.getPrefix(), "input");
         final ContainerSchemaNodeBuilder inputBuilder = new ContainerSchemaNodeBuilder(
-                inputQName);
+                inputQName, line);
         final List<String> pathToInput = new ArrayList<String>(pathToRpc);
         pathToInput.add("input");
         moduleNodes.put(pathToInput, inputBuilder);
@@ -464,7 +471,7 @@ public class ModuleBuilder implements Builder {
         final QName outputQName = new QName(qname.getNamespace(),
                 qname.getRevision(), qname.getPrefix(), "output");
         final ContainerSchemaNodeBuilder outputBuilder = new ContainerSchemaNodeBuilder(
-                outputQName);
+                outputQName, line);
         final List<String> pathToOutput = new ArrayList<String>(pathToRpc);
         pathToOutput.add("output");
         moduleNodes.put(pathToOutput, outputBuilder);
@@ -474,11 +481,12 @@ public class ModuleBuilder implements Builder {
     }
 
     public NotificationBuilder addNotification(final QName notificationName,
-            final List<String> parentPath) {
+            final List<String> parentPath, final int line) {
         final List<String> pathToNotification = new ArrayList<String>(
                 parentPath);
 
-        NotificationBuilder builder = new NotificationBuilder(notificationName);
+        NotificationBuilder builder = new NotificationBuilder(notificationName,
+                line);
 
         pathToNotification.add(notificationName.getLocalName());
         moduleNodes.put(pathToNotification, builder);
@@ -488,19 +496,19 @@ public class ModuleBuilder implements Builder {
     }
 
     public FeatureBuilder addFeature(final QName featureName,
-            final List<String> parentPath) {
+            final List<String> parentPath, final int line) {
         List<String> pathToFeature = new ArrayList<String>(parentPath);
         pathToFeature.add(featureName.getLocalName());
 
-        FeatureBuilder builder = new FeatureBuilder(featureName);
+        FeatureBuilder builder = new FeatureBuilder(featureName, line);
         addedFeatures.put(pathToFeature, builder);
         return builder;
     }
 
     public ChoiceBuilder addChoice(final QName choiceName,
-            final List<String> parentPath) {
+            final List<String> parentPath, final int line) {
         List<String> pathToChoice = new ArrayList<String>(parentPath);
-        ChoiceBuilder builder = new ChoiceBuilder(choiceName);
+        ChoiceBuilder builder = new ChoiceBuilder(choiceName, line);
 
         final ChildNodeBuilder parent = (ChildNodeBuilder) moduleNodes
                 .get(pathToChoice);
@@ -519,9 +527,9 @@ public class ModuleBuilder implements Builder {
     }
 
     public ChoiceCaseBuilder addCase(final QName caseName,
-            final List<String> parentPath) {
+            final List<String> parentPath, final int line) {
         List<String> pathToCase = new ArrayList<String>(parentPath);
-        ChoiceCaseBuilder builder = new ChoiceCaseBuilder(caseName);
+        ChoiceCaseBuilder builder = new ChoiceCaseBuilder(caseName, line);
 
         final ChildNodeBuilder parent = (ChildNodeBuilder) moduleNodes
                 .get(pathToCase);
@@ -539,9 +547,9 @@ public class ModuleBuilder implements Builder {
     }
 
     public AnyXmlBuilder addAnyXml(final QName anyXmlName,
-            final List<String> parentPath) {
+            final List<String> parentPath, final int line) {
         List<String> pathToAnyXml = new ArrayList<String>(parentPath);
-        AnyXmlBuilder builder = new AnyXmlBuilder(anyXmlName);
+        AnyXmlBuilder builder = new AnyXmlBuilder(anyXmlName, line);
 
         final ChildNodeBuilder parent = (ChildNodeBuilder) moduleNodes
                 .get(pathToAnyXml);
@@ -561,9 +569,9 @@ public class ModuleBuilder implements Builder {
     }
 
     public TypedefBuilder addTypedef(final QName typeDefName,
-            final List<String> parentPath) {
+            final List<String> parentPath, final int line) {
         List<String> pathToType = new ArrayList<String>(parentPath);
-        TypedefBuilder builder = new TypedefBuilder(typeDefName);
+        TypedefBuilder builder = new TypedefBuilder(typeDefName, line);
         TypeDefinitionAwareBuilder parent = (TypeDefinitionAwareBuilder) moduleNodes
                 .get(pathToType);
         if (parent != null) {
@@ -587,12 +595,12 @@ public class ModuleBuilder implements Builder {
     }
 
     public void addUnionType(final List<String> actualPath,
-            final URI namespace, final Date revision) {
+            final URI namespace, final Date revision, final int line) {
         List<String> pathToUnion = new ArrayList<String>(actualPath);
         TypeAwareBuilder parent = (TypeAwareBuilder) moduleNodes
                 .get(pathToUnion);
         UnionTypeBuilder union = new UnionTypeBuilder(pathToUnion, namespace,
-                revision);
+                revision, line);
         parent.setType(union);
 
         List<String> path = new ArrayList<String>(pathToUnion);
@@ -601,31 +609,33 @@ public class ModuleBuilder implements Builder {
         moduleNodes.put(path, union);
     }
 
-    public void addIdentityrefType(String baseString, List<String> parentPath,
-            SchemaPath schemaPath) {
+    public void addIdentityrefType(final String baseString,
+            final List<String> parentPath, final SchemaPath schemaPath,
+            final int line) {
         List<String> pathToIdentityref = new ArrayList<String>(parentPath);
         TypeAwareBuilder parent = (TypeAwareBuilder) moduleNodes
                 .get(pathToIdentityref);
         IdentityrefTypeBuilder identityref = new IdentityrefTypeBuilder(
-                baseString, schemaPath);
+                baseString, schemaPath, line);
         parent.setType(identityref);
         dirtyNodes.put(pathToIdentityref, parent);
     }
 
-    public DeviationBuilder addDeviation(String targetPath,
-            List<String> parentPath) {
+    public DeviationBuilder addDeviation(final String targetPath,
+            final List<String> parentPath, final int line) {
         final List<String> pathToDeviation = new ArrayList<String>(parentPath);
         pathToDeviation.add(targetPath);
-        DeviationBuilder builder = new DeviationBuilder(targetPath);
+        DeviationBuilder builder = new DeviationBuilder(targetPath, line);
         addedDeviations.put(targetPath, builder);
         moduleNodes.put(pathToDeviation, builder);
         return builder;
     }
 
-    public IdentitySchemaNodeBuilder addIdentity(QName qname,
-            List<String> parentPath) {
-        List<String> pathToIdentity = new ArrayList<String>(parentPath);
-        IdentitySchemaNodeBuilder builder = new IdentitySchemaNodeBuilder(qname);
+    public IdentitySchemaNodeBuilder addIdentity(final QName qname,
+            final List<String> parentPath, final int line) {
+        final List<String> pathToIdentity = new ArrayList<String>(parentPath);
+        final IdentitySchemaNodeBuilder builder = new IdentitySchemaNodeBuilder(
+                qname, line);
         pathToIdentity.add(qname.getLocalName());
         moduleNodes.put(pathToIdentity, builder);
         addedIdentities.add(builder);
@@ -642,11 +652,11 @@ public class ModuleBuilder implements Builder {
         }
     }
 
-    public UnknownSchemaNodeBuilder addUnknownSchemaNode(QName qname,
-            List<String> parentPath) {
+    public UnknownSchemaNodeBuilder addUnknownSchemaNode(final QName qname,
+            final List<String> parentPath, final int line) {
         final List<String> pathToUnknown = new ArrayList<String>(parentPath);
         final UnknownSchemaNodeBuilder builder = new UnknownSchemaNodeBuilder(
-                qname);
+                qname, line);
         final Builder parent = moduleNodes.get(pathToUnknown);
         if (parent instanceof RefineHolder) {
             ((RefineHolder) parent).addUnknownSchemaNode(builder);
index 3931b80..f2a0a07 100644 (file)
@@ -35,15 +35,16 @@ import org.opendaylight.controller.yang.model.parser.builder.api.UsesNodeBuilder
 
 public class NotificationBuilder extends AbstractChildNodeBuilder implements
         TypeDefinitionAwareBuilder, SchemaNodeBuilder {
-
     private final NotificationDefinitionImpl instance;
+    private final int line;
     private SchemaPath schemaPath;
     private final Set<TypeDefinitionBuilder> addedTypedefs = new HashSet<TypeDefinitionBuilder>();
     private final Set<UsesNodeBuilder> addedUsesNodes = new HashSet<UsesNodeBuilder>();
     private final List<UnknownSchemaNodeBuilder> addedUnknownNodes = new ArrayList<UnknownSchemaNodeBuilder>();
 
-    NotificationBuilder(QName qname) {
+    NotificationBuilder(final QName qname, final int line) {
         super(qname);
+        this.line = line;
         instance = new NotificationDefinitionImpl(qname);
     }
 
@@ -89,6 +90,11 @@ public class NotificationBuilder extends AbstractChildNodeBuilder implements
         return instance;
     }
 
+    @Override
+    public int getLine() {
+        return line;
+    }
+
     @Override
     public void addTypedef(final TypeDefinitionBuilder type) {
         addedTypedefs.add(type);
index 6bf7750..f9b1a04 100644 (file)
@@ -29,6 +29,7 @@ import org.opendaylight.controller.yang.model.parser.builder.api.TypeDefinitionB
 public class RpcDefinitionBuilder implements SchemaNodeBuilder,
         TypeDefinitionAwareBuilder {
     private final RpcDefinitionImpl instance;
+    private final int line;
     private final QName qname;
     private SchemaPath schemaPath;
     private ContainerSchemaNodeBuilder inputBuilder;
@@ -37,8 +38,9 @@ public class RpcDefinitionBuilder implements SchemaNodeBuilder,
     private final Set<GroupingBuilder> addedGroupings = new HashSet<GroupingBuilder>();
     private final List<UnknownSchemaNodeBuilder> addedUnknownNodes = new ArrayList<UnknownSchemaNodeBuilder>();
 
-    RpcDefinitionBuilder(final QName qname) {
+    RpcDefinitionBuilder(final QName qname, final int line) {
         this.qname = qname;
+        this.line = line;
         this.instance = new RpcDefinitionImpl(qname);
     }
 
@@ -75,6 +77,11 @@ public class RpcDefinitionBuilder implements SchemaNodeBuilder,
         return instance;
     }
 
+    @Override
+    public int getLine() {
+        return line;
+    }
+
     void setInput(final ContainerSchemaNodeBuilder inputBuilder) {
         this.inputBuilder = inputBuilder;
     }
index 0e768c1..94b46e6 100644 (file)
@@ -27,6 +27,7 @@ import org.opendaylight.controller.yang.model.util.UnknownType;
 
 public class TypedefBuilder extends AbstractTypeAwareBuilder implements
         TypeDefinitionBuilder {
+    private final int line;
     private final QName qname;
     private SchemaPath schemaPath;
 
@@ -42,8 +43,9 @@ public class TypedefBuilder extends AbstractTypeAwareBuilder implements
     private String units;
     private Object defaultValue;
 
-    public TypedefBuilder(final QName qname) {
+    public TypedefBuilder(final QName qname, final int line) {
         this.qname = qname;
+        this.line = line;
     }
 
     @Override
@@ -80,6 +82,11 @@ public class TypedefBuilder extends AbstractTypeAwareBuilder implements
         return result;
     }
 
+    @Override
+    public int getLine() {
+        return line;
+    }
+
     @Override
     public QName getQName() {
         return qname;
index 9ab103d..ec889c5 100644 (file)
@@ -33,6 +33,7 @@ import org.opendaylight.controller.yang.model.util.UnionType;
  */
 public class UnionTypeBuilder extends AbstractTypeAwareBuilder implements
         TypeDefinitionBuilder, Builder {
+    private final int line;
     private final List<TypeDefinition<?>> types;
     private final List<TypeDefinitionBuilder> typedefs;
     private final UnionType instance;
@@ -42,7 +43,8 @@ public class UnionTypeBuilder extends AbstractTypeAwareBuilder implements
     private final Date revision;
 
     public UnionTypeBuilder(final List<String> actualPath, final URI namespace,
-            final Date revision) {
+            final Date revision, final int line) {
+        this.line = line;
         types = new ArrayList<TypeDefinition<?>>();
         typedefs = new ArrayList<TypeDefinitionBuilder>();
         instance = new UnionType(actualPath, namespace, revision, types);
@@ -52,6 +54,11 @@ public class UnionTypeBuilder extends AbstractTypeAwareBuilder implements
         this.revision = revision;
     }
 
+    @Override
+    public int getLine() {
+        return line;
+    }
+
     public List<TypeDefinition<?>> getTypes() {
         return types;
     }
index f24502b..c2c32ca 100644 (file)
@@ -19,14 +19,16 @@ import org.opendaylight.controller.yang.model.parser.builder.api.SchemaNodeBuild
 
 public class UnknownSchemaNodeBuilder implements SchemaNodeBuilder {
     private final UnknownSchemaNodeImpl instance;
+    private final int line;
     private final QName qname;
     private SchemaPath schemaPath;
     private final List<UnknownSchemaNodeBuilder> addedUnknownNodes = new ArrayList<UnknownSchemaNodeBuilder>();
     private QName nodeType;
     private String nodeParameter;
 
-    UnknownSchemaNodeBuilder(final QName qname) {
+    UnknownSchemaNodeBuilder(final QName qname, final int line) {
         this.qname = qname;
+        this.line = line;
         instance = new UnknownSchemaNodeImpl(qname);
     }
 
@@ -45,6 +47,11 @@ public class UnknownSchemaNodeBuilder implements SchemaNodeBuilder {
         return instance;
     }
 
+    @Override
+    public int getLine() {
+        return line;
+    }
+
     @Override
     public QName getQName() {
         return qname;
index 05d2faa..65bdf6e 100644 (file)
@@ -28,13 +28,15 @@ import org.opendaylight.controller.yang.model.parser.util.RefineHolder;
 \r
 final class UsesNodeBuilderImpl implements UsesNodeBuilder, Builder {\r
     private final UsesNodeImpl instance;\r
+    private final int line;\r
     private final SchemaPath groupingPath;\r
     private final Set<AugmentationSchemaBuilder> addedAugments = new HashSet<AugmentationSchemaBuilder>();\r
     private List<SchemaNodeBuilder> refineBuilders = new ArrayList<SchemaNodeBuilder>();\r
     private List<RefineHolder> refines = new ArrayList<RefineHolder>();\r
 \r
-    UsesNodeBuilderImpl(final String groupingPathStr) {\r
+    UsesNodeBuilderImpl(final String groupingPathStr, final int line) {\r
         this.groupingPath = parseUsesPath(groupingPathStr);\r
+        this.line = line;\r
         instance = new UsesNodeImpl(groupingPath);\r
     }\r
 \r
@@ -49,7 +51,7 @@ final class UsesNodeBuilderImpl implements UsesNodeBuilder, Builder {
 \r
         // REFINES\r
         final Map<SchemaPath, SchemaNode> refineNodes = new HashMap<SchemaPath, SchemaNode>();\r
-        for(SchemaNodeBuilder refineBuilder : refineBuilders) {\r
+        for (SchemaNodeBuilder refineBuilder : refineBuilders) {\r
             SchemaNode refineNode = refineBuilder.build();\r
             refineNodes.put(refineNode.getPath(), refineNode);\r
         }\r
@@ -58,6 +60,11 @@ final class UsesNodeBuilderImpl implements UsesNodeBuilder, Builder {
         return instance;\r
     }\r
 \r
+    @Override\r
+    public int getLine() {\r
+        return line;\r
+    }\r
+\r
     @Override\r
     public SchemaPath getGroupingPath() {\r
         return groupingPath;\r
@@ -126,7 +133,8 @@ final class UsesNodeBuilderImpl implements UsesNodeBuilder, Builder {
             return augmentations;\r
         }\r
 \r
-        private void setAugmentations(final Set<AugmentationSchema> augmentations) {\r
+        private void setAugmentations(\r
+                final Set<AugmentationSchema> augmentations) {\r
             if (augmentations != null) {\r
                 this.augmentations = augmentations;\r
             }\r
@@ -147,7 +155,7 @@ final class UsesNodeBuilderImpl implements UsesNodeBuilder, Builder {
         }\r
 \r
         private void setRefines(Map<SchemaPath, SchemaNode> refines) {\r
-            if(refines != null) {\r
+            if (refines != null) {\r
                 this.refines = refines;\r
             }\r
         }\r
index 35c04a8..c7bd7f5 100644 (file)
@@ -318,9 +318,10 @@ public class YangModelParserImpl implements YangModelParser {
 
         // search for module which contains referenced typedef
         final ModuleBuilder dependentModule = findDependentModule(modules,
-                builder, unknownTypeQName.getPrefix());
+                builder, unknownTypeQName.getPrefix(), nodeToResolve.getLine());
         final TypeDefinitionBuilder lookedUpBuilder = findTypedefBuilderByName(
-                dependentModule, unknownTypeQName.getLocalName());
+                dependentModule, unknownTypeQName.getLocalName(),
+                builder.getName(), nodeToResolve.getLine());
 
         final TypeDefinitionBuilder lookedUpBuilderCopy = copyTypedefBuilder(
                 lookedUpBuilder, nodeToResolve instanceof TypeDefinitionBuilder);
@@ -344,9 +345,10 @@ public class YangModelParserImpl implements YangModelParser {
         final QName unknownTypeQName = unknownType.getQName();
         // search for module which contains referenced typedef
         final ModuleBuilder dependentModule = findDependentModule(modules,
-                module, unknownTypeQName.getPrefix());
+                module, unknownTypeQName.getPrefix(), nodeToResolve.getLine());
         final TypeDefinitionBuilder lookedUpBuilder = findTypedefBuilderByName(
-                dependentModule, unknownTypeQName.getLocalName());
+                dependentModule, unknownTypeQName.getLocalName(),
+                module.getName(), nodeToResolve.getLine());
 
         final TypeDefinitionBuilder lookedUpBuilderCopy = copyTypedefBuilder(
                 lookedUpBuilder, nodeToResolve instanceof TypeDefinitionBuilder);
@@ -361,7 +363,7 @@ public class YangModelParserImpl implements YangModelParser {
             final UnionTypeBuilder oldUnion = (UnionTypeBuilder) old;
             final UnionTypeBuilder newUnion = new UnionTypeBuilder(
                     oldUnion.getActualPath(), oldUnion.getNamespace(),
-                    oldUnion.getRevision());
+                    oldUnion.getRevision(), old.getLine());
             for (TypeDefinition<?> td : oldUnion.getTypes()) {
                 newUnion.setType(td);
             }
@@ -375,7 +377,8 @@ public class YangModelParserImpl implements YangModelParser {
         final QName newName = new QName(oldName.getNamespace(),
                 oldName.getRevision(), oldName.getPrefix(),
                 oldName.getLocalName());
-        final TypeDefinitionBuilder tdb = new TypedefBuilder(newName);
+        final TypeDefinitionBuilder tdb = new TypedefBuilder(newName,
+                old.getLine());
 
         tdb.setRanges(old.getRanges());
         tdb.setLengths(old.getLengths());
@@ -432,7 +435,7 @@ public class YangModelParserImpl implements YangModelParser {
             final QName unknownTypeQName = unknownType.getQName();
             final String unknownTypePrefix = unknownTypeQName.getPrefix();
             final ModuleBuilder dependentModule = findDependentModule(modules,
-                    builder, unknownTypePrefix);
+                    builder, unknownTypePrefix, copy.getLine());
             final TypeDefinitionBuilder utBuilder = getTypedefBuilder(copy,
                     modules, dependentModule);
             copy.setType(utBuilder);
@@ -454,12 +457,13 @@ public class YangModelParserImpl implements YangModelParser {
     private TypeDefinitionBuilder findTypedefBuilder(
             final QName unknownTypeQName,
             final Map<String, TreeMap<Date, ModuleBuilder>> modules,
-            final ModuleBuilder builder) {
+            final ModuleBuilder builder, int line) {
         // search for module which contains referenced typedef
         final ModuleBuilder dependentModule = findDependentModule(modules,
-                builder, unknownTypeQName.getPrefix());
+                builder, unknownTypeQName.getPrefix(), line);
         final TypeDefinitionBuilder lookedUpBuilder = findTypedefBuilderByName(
-                dependentModule, unknownTypeQName.getLocalName());
+                dependentModule, unknownTypeQName.getLocalName(),
+                builder.getName(), line);
         return copyTypedefBuilder(lookedUpBuilder, true);
     }
 
@@ -502,8 +506,9 @@ public class YangModelParserImpl implements YangModelParser {
             fractionDigits = ext.getFractionDigits();
             constraints.setFractionDigits(fractionDigits);
             return findConstraints(
-                    findTypedefBuilder(ext.getQName(), modules, builder),
-                    constraints, modules, builder);
+                    findTypedefBuilder(ext.getQName(), modules, builder,
+                            nodeToResolve.getLine()), constraints, modules,
+                    builder);
         } else if (referencedType instanceof UnknownType) {
             final UnknownType unknown = (UnknownType) referencedType;
             ranges = unknown.getRangeStatements();
@@ -520,9 +525,11 @@ public class YangModelParserImpl implements YangModelParser {
                 unknownTypePrefix = builder.getPrefix();
             }
             final ModuleBuilder dependentModule = findDependentModule(modules,
-                    builder, unknown.getQName().getPrefix());
+                    builder, unknown.getQName().getPrefix(),
+                    nodeToResolve.getLine());
             final TypeDefinitionBuilder utBuilder = findTypedefBuilder(
-                    unknown.getQName(), modules, builder);
+                    unknown.getQName(), modules, builder,
+                    nodeToResolve.getLine());
             return findConstraints(utBuilder, constraints, modules,
                     dependentModule);
         } else {
@@ -543,7 +550,8 @@ public class YangModelParserImpl implements YangModelParser {
      * @return typedef with name equals to given name
      */
     private TypeDefinitionBuilder findTypedefBuilderByName(
-            final ModuleBuilder dependentModule, final String name) {
+            final ModuleBuilder dependentModule, final String name,
+            final String currentModuleName, final int line) {
         TypeDefinitionBuilder result = null;
         final Set<TypeDefinitionBuilder> typedefs = dependentModule
                 .getModuleTypedefs();
@@ -554,9 +562,9 @@ public class YangModelParserImpl implements YangModelParser {
             }
         }
         if (result == null) {
-            throw new YangParseException("Target module '"
-                    + dependentModule.getName()
-                    + "' does not contain typedef '" + name + "'.");
+            throw new YangParseException(currentModuleName, line,
+                    "Target module '" + dependentModule.getName()
+                            + "' does not contain typedef '" + name + "'.");
         }
         return result;
     }
@@ -661,7 +669,7 @@ public class YangModelParserImpl implements YangModelParser {
 
                 DataSchemaNodeBuilder currentParent = null;
                 final ModuleBuilder dependentModule = findDependentModule(
-                        modules, module, prefix);
+                        modules, module, prefix, augmentBuilder.getLine());
                 for (DataSchemaNodeBuilder child : dependentModule
                         .getChildNodes()) {
                     final QName childQName = child.getQName();
@@ -733,7 +741,7 @@ public class YangModelParserImpl implements YangModelParser {
                     baseIdentityLocalName = baseIdentityName;
                 }
                 final ModuleBuilder dependentModule = findDependentModule(
-                        modules, module, baseIdentityPrefix);
+                        modules, module, baseIdentityPrefix, identity.getLine());
 
                 final Set<IdentitySchemaNodeBuilder> dependentModuleIdentities = dependentModule
                         .getAddedIdentities();
@@ -896,7 +904,7 @@ public class YangModelParserImpl implements YangModelParser {
             final ModuleBuilder module) {
         Builder result = null;
         final Builder lookedUpBuilder = findRefineTargetBuilder(groupingPath,
-                refine.getName(), modules, module);
+                refine, modules, module);
         if (lookedUpBuilder instanceof LeafSchemaNodeBuilder) {
             result = ParserUtils
                     .copyLeafBuilder((LeafSchemaNodeBuilder) lookedUpBuilder);
@@ -916,8 +924,8 @@ public class YangModelParserImpl implements YangModelParser {
             result = ParserUtils
                     .copyAnyXmlBuilder((AnyXmlBuilder) lookedUpBuilder);
         } else {
-            throw new YangParseException("Target '" + refine.getName()
-                    + "' can not be refined");
+            throw new YangParseException(module.getName(), refine.getLine(),
+                    "Target '" + refine.getName() + "' can not be refined");
         }
         return result;
     }
@@ -937,7 +945,7 @@ public class YangModelParserImpl implements YangModelParser {
      *         otherwise
      */
     private Builder findRefineTargetBuilder(final String groupingPath,
-            final String refineNodeName,
+            final RefineHolder refine,
             final Map<String, TreeMap<Date, ModuleBuilder>> modules,
             final ModuleBuilder module) {
         final SchemaPath path = ParserUtils.parseUsesPath(groupingPath);
@@ -952,13 +960,13 @@ public class YangModelParserImpl implements YangModelParser {
         }
 
         final ModuleBuilder dependentModule = findDependentModule(modules,
-                module, prefix);
+                module, prefix, refine.getLine());
         builderPath.add(0, "grouping");
         builderPath.add(0, dependentModule.getName());
         final GroupingBuilder builder = (GroupingBuilder) dependentModule
                 .getNode(builderPath);
 
-        return builder.getChildNode(refineNodeName);
+        return builder.getChildNode(refine.getName());
     }
 
     private QName findFullQName(
@@ -969,13 +977,13 @@ public class YangModelParserImpl implements YangModelParser {
         if (baseString.contains(":")) {
             String[] splittedBase = baseString.split(":");
             if (splittedBase.length > 2) {
-                throw new YangParseException(
+                throw new YangParseException(module.getName(), idref.getLine(),
                         "Failed to parse identityref base: " + baseString);
             }
             String prefix = splittedBase[0];
             String name = splittedBase[1];
             ModuleBuilder dependentModule = findDependentModule(modules,
-                    module, prefix);
+                    module, prefix, idref.getLine());
             result = new QName(dependentModule.getNamespace(),
                     dependentModule.getRevision(), prefix, name);
         } else {
@@ -994,15 +1002,16 @@ public class YangModelParserImpl implements YangModelParser {
                     || nodeType.getRevision() == null) {
                 try {
                     ModuleBuilder dependentModule = findDependentModule(
-                            modules, module, nodeType.getPrefix());
+                            modules, module, nodeType.getPrefix(),
+                            usnb.getLine());
                     QName newNodeType = new QName(
                             dependentModule.getNamespace(),
                             dependentModule.getRevision(),
                             nodeType.getPrefix(), nodeType.getLocalName());
                     usnb.setNodeType(newNodeType);
                 } catch (YangParseException e) {
-                    logger.debug("Failed to find unknown node type: "
-                            + nodeType);
+                    logger.debug(module.getName(), usnb.getLine(),
+                            "Failed to find unknown node type: " + nodeType);
                 }
             }
         }
@@ -1021,7 +1030,7 @@ public class YangModelParserImpl implements YangModelParser {
      */
     private ModuleBuilder findDependentModule(
             final Map<String, TreeMap<Date, ModuleBuilder>> modules,
-            final ModuleBuilder module, final String prefix) {
+            final ModuleBuilder module, final String prefix, final int line) {
         ModuleBuilder dependentModule = null;
         Date dependentModuleRevision = null;
 
@@ -1031,8 +1040,8 @@ public class YangModelParserImpl implements YangModelParser {
             final ModuleImport dependentModuleImport = ParserUtils
                     .getModuleImport(module, prefix);
             if (dependentModuleImport == null) {
-                throw new YangParseException("No import found with prefix '"
-                        + prefix + "' in module " + module.getName() + "'.");
+                throw new YangParseException(module.getName(), line,
+                        "No import found with prefix '" + prefix + "'.");
             }
             final String dependentModuleName = dependentModuleImport
                     .getModuleName();
@@ -1041,10 +1050,9 @@ public class YangModelParserImpl implements YangModelParser {
             final TreeMap<Date, ModuleBuilder> moduleBuildersByRevision = modules
                     .get(dependentModuleName);
             if (moduleBuildersByRevision == null) {
-                throw new YangParseException(
+                throw new YangParseException(module.getName(), line,
                         "Failed to find dependent module '"
-                                + dependentModuleName + "' needed by module '"
-                                + module.getName() + "'.");
+                                + dependentModuleName + "'.");
             }
             if (dependentModuleRevision == null) {
                 dependentModule = moduleBuildersByRevision.lastEntry()
@@ -1056,7 +1064,7 @@ public class YangModelParserImpl implements YangModelParser {
         }
 
         if (dependentModule == null) {
-            throw new YangParseException(
+            throw new YangParseException(module.getName(), line,
                     "Failed to find dependent module with prefix '" + prefix
                             + "' and revision '" + dependentModuleRevision
                             + "'.");
index 98b81bd..511c610 100644 (file)
@@ -78,8 +78,8 @@ import org.opendaylight.controller.yang.model.util.YangTypesConverter;
 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);
 
@@ -90,7 +90,7 @@ public final class YangModelParserListenerImpl extends YangParserBaseListener {
     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>();
 
@@ -238,7 +238,7 @@ public final class YangModelParserListenerImpl extends YangParserBaseListener {
     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++) {
@@ -269,7 +269,8 @@ public final class YangModelParserListenerImpl extends YangParserBaseListener {
     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;
@@ -292,7 +293,7 @@ public final class YangModelParserListenerImpl extends YangParserBaseListener {
         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,
@@ -310,7 +311,8 @@ public final class YangModelParserListenerImpl extends YangParserBaseListener {
     @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;
@@ -324,15 +326,22 @@ public final class YangModelParserListenerImpl extends YangParserBaseListener {
         // 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);
@@ -381,7 +390,7 @@ public final class YangModelParserListenerImpl extends YangParserBaseListener {
         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);
@@ -400,7 +409,8 @@ public final class YangModelParserListenerImpl extends YangParserBaseListener {
         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,
@@ -429,7 +439,7 @@ public final class YangModelParserListenerImpl extends YangParserBaseListener {
         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,
@@ -460,8 +470,8 @@ public final class YangModelParserListenerImpl extends YangParserBaseListener {
     @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);
     }
 
@@ -491,7 +501,8 @@ public final class YangModelParserListenerImpl extends YangParserBaseListener {
         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);
@@ -520,7 +531,7 @@ public final class YangModelParserListenerImpl extends YangParserBaseListener {
         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,
@@ -556,7 +567,7 @@ public final class YangModelParserListenerImpl extends YangParserBaseListener {
         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,
@@ -577,7 +588,7 @@ public final class YangModelParserListenerImpl extends YangParserBaseListener {
         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,
@@ -608,7 +619,7 @@ public final class YangModelParserListenerImpl extends YangParserBaseListener {
         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,
@@ -629,7 +640,8 @@ public final class YangModelParserListenerImpl extends YangParserBaseListener {
         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,
@@ -652,7 +664,8 @@ public final class YangModelParserListenerImpl extends YangParserBaseListener {
         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]);
@@ -668,11 +681,12 @@ public final class YangModelParserListenerImpl extends YangParserBaseListener {
                         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);
@@ -693,7 +707,7 @@ public final class YangModelParserListenerImpl extends YangParserBaseListener {
         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,
@@ -735,7 +749,7 @@ public final class YangModelParserListenerImpl extends YangParserBaseListener {
         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,
@@ -755,7 +769,7 @@ public final class YangModelParserListenerImpl extends YangParserBaseListener {
         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++) {
@@ -793,8 +807,8 @@ public final class YangModelParserListenerImpl extends YangParserBaseListener {
         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,
index fa88a29..8237da6 100644 (file)
@@ -103,7 +103,7 @@ public final class ParserUtils {
     public static LeafSchemaNodeBuilder copyLeafBuilder(
             final LeafSchemaNodeBuilder old) {
         final LeafSchemaNodeBuilder copy = new LeafSchemaNodeBuilder(
-                old.getQName());
+                old.getQName(), old.getLine());
         final TypeDefinition<?> type = old.getType();
 
         if (type == null) {
@@ -129,7 +129,7 @@ public final class ParserUtils {
     public static ContainerSchemaNodeBuilder copyContainerBuilder(
             final ContainerSchemaNodeBuilder old) {
         final ContainerSchemaNodeBuilder copy = new ContainerSchemaNodeBuilder(
-                old.getQName());
+                old.getQName(), old.getLine());
         copy.setPath(old.getPath());
         copyConstraints(old, copy);
         for (UnknownSchemaNodeBuilder unknown : old.getUnknownNodes()) {
@@ -165,7 +165,7 @@ public final class ParserUtils {
     public static ListSchemaNodeBuilder copyListBuilder(
             final ListSchemaNodeBuilder old) {
         final ListSchemaNodeBuilder copy = new ListSchemaNodeBuilder(
-                old.getQName());
+                old.getQName(), old.getLine());
         copy.setPath(old.getPath());
         copyConstraints(old, copy);
         for (UnknownSchemaNodeBuilder unknown : old.getUnknownNodes()) {
@@ -201,7 +201,7 @@ public final class ParserUtils {
     public static LeafListSchemaNodeBuilder copyLeafListBuilder(
             final LeafListSchemaNodeBuilder old) {
         final LeafListSchemaNodeBuilder copy = new LeafListSchemaNodeBuilder(
-                old.getQName());
+                old.getQName(), old.getLine());
         copy.setPath(old.getPath());
         copyConstraints(old, copy);
         final TypeDefinition<?> type = old.getType();
@@ -226,7 +226,7 @@ public final class ParserUtils {
     }
 
     public static ChoiceBuilder copyChoiceBuilder(final ChoiceBuilder old) {
-        final ChoiceBuilder copy = new ChoiceBuilder(old.getQName());
+        final ChoiceBuilder copy = new ChoiceBuilder(old.getQName(), old.getLine());
         copy.setPath(old.getPath());
         copyConstraints(old, copy);
         for (ChoiceCaseBuilder caseBuilder : old.getCases()) {
@@ -254,7 +254,7 @@ public final class ParserUtils {
     }
 
     public static AnyXmlBuilder copyAnyXmlBuilder(final AnyXmlBuilder old) {
-        final AnyXmlBuilder copy = new AnyXmlBuilder(old.getQName());
+        final AnyXmlBuilder copy = new AnyXmlBuilder(old.getQName(), old.getLine());
         copy.setPath(old.getPath());
         copyConstraints(old, copy);
         for (UnknownSchemaNodeBuilder unknown : old.getUnknownNodes()) {
index 0c31655..5a24773 100644 (file)
@@ -16,6 +16,7 @@ import org.opendaylight.controller.yang.model.parser.builder.impl.UnknownSchemaN
 
 public final class RefineHolder implements Builder {
     private final String name;
+    private final int line;
     private String defaultStr;
     private String description;
     private String reference;
@@ -27,8 +28,14 @@ public final class RefineHolder implements Builder {
     private Integer maxElements;
     private final List<UnknownSchemaNodeBuilder> addedUnknownNodes = new ArrayList<UnknownSchemaNodeBuilder>();
 
-    public RefineHolder(final String name) {
+    public RefineHolder(final String name, final int line) {
         this.name = name;
+        this.line = line;
+    }
+
+    @Override
+    public int getLine() {
+        return line;
     }
 
     public String getDefaultStr() {
index fff33b6..49b177e 100644 (file)
@@ -550,6 +550,7 @@ public final class YangModelBuilderUtil {
      */
     private static List<RangeConstraint> parseRangeConstraints(
             final Range_stmtContext ctx) {
+        final int line = ctx.getStart().getLine();
         List<RangeConstraint> rangeConstraints = new ArrayList<RangeConstraint>();
         String description = null;
         String reference = null;
@@ -571,10 +572,11 @@ public final class YangModelBuilderUtil {
             Number min;
             Number max;
             if (splittedRangeDef.length == 1) {
-                min = max = parseNumberConstraintValue(splittedRangeDef[0]);
+                min = max = parseNumberConstraintValue(splittedRangeDef[0],
+                        line);
             } else {
-                min = parseNumberConstraintValue(splittedRangeDef[0]);
-                max = parseNumberConstraintValue(splittedRangeDef[1]);
+                min = parseNumberConstraintValue(splittedRangeDef[0], line);
+                max = parseNumberConstraintValue(splittedRangeDef[1], line);
             }
             RangeConstraint range = BaseConstraints.rangeConstraint(min, max,
                     description, reference);
@@ -618,6 +620,7 @@ public final class YangModelBuilderUtil {
      */
     private static List<LengthConstraint> parseLengthConstraints(
             final Length_stmtContext ctx) {
+        final int line = ctx.getStart().getLine();
         List<LengthConstraint> lengthConstraints = new ArrayList<LengthConstraint>();
         String description = null;
         String reference = null;
@@ -639,10 +642,11 @@ public final class YangModelBuilderUtil {
             Number min;
             Number max;
             if (splittedRangeDef.length == 1) {
-                min = max = parseNumberConstraintValue(splittedRangeDef[0]);
+                min = max = parseNumberConstraintValue(splittedRangeDef[0],
+                        line);
             } else {
-                min = parseNumberConstraintValue(splittedRangeDef[0]);
-                max = parseNumberConstraintValue(splittedRangeDef[1]);
+                min = parseNumberConstraintValue(splittedRangeDef[0], line);
+                max = parseNumberConstraintValue(splittedRangeDef[1], line);
             }
             LengthConstraint range = BaseConstraints.lengthConstraint(min, max,
                     description, reference);
@@ -658,7 +662,8 @@ public final class YangModelBuilderUtil {
      * @return wrapper object of primitive java type or UnknownBoundaryNumber if
      *         type is one of special YANG values 'min' or 'max'
      */
-    private static Number parseNumberConstraintValue(final String value) {
+    private static Number parseNumberConstraintValue(final String value,
+            final int line) {
         Number result = null;
         if ("min".equals(value) || "max".equals(value)) {
             result = new UnknownBoundaryNumber(value);
@@ -666,8 +671,8 @@ public final class YangModelBuilderUtil {
             try {
                 result = Long.valueOf(value);
             } catch (NumberFormatException e) {
-                throw new YangParseException("Unable to parse range value '"
-                        + value + "'.", e);
+                throw new YangParseException("Error on line " + line
+                        + ": Unable to parse range value '" + value + "'.", e);
             }
         }
         return result;
@@ -988,35 +993,45 @@ public final class YangModelBuilderUtil {
                 typeBody, actualPath, namespace, revision, prefix);
 
         if ("decimal64".equals(typeName)) {
-            type = new Decimal64(actualPath, namespace, revision, fractionDigits);
+            type = new Decimal64(actualPath, namespace, revision,
+                    fractionDigits);
         } else if (typeName.startsWith("int")) {
             if (typeName.equals("int8")) {
-                type = new Int8(actualPath, namespace, revision, rangeStatements, null, null);
+                type = new Int8(actualPath, namespace, revision,
+                        rangeStatements, null, null);
             } else if (typeName.equals("int16")) {
-                type = new Int16(actualPath, namespace, revision, rangeStatements, null, null);
+                type = new Int16(actualPath, namespace, revision,
+                        rangeStatements, null, null);
             } else if (typeName.equals("int32")) {
-                type = new Int32(actualPath, namespace, revision, rangeStatements, null, null);
+                type = new Int32(actualPath, namespace, revision,
+                        rangeStatements, null, null);
             } else if (typeName.equals("int64")) {
-                type = new Int64(actualPath, namespace, revision, rangeStatements, null, null);
+                type = new Int64(actualPath, namespace, revision,
+                        rangeStatements, null, null);
             }
         } else if (typeName.startsWith("uint")) {
             if (typeName.equals("uint8")) {
-                type = new Uint8(actualPath, namespace, revision, rangeStatements, null, null);
+                type = new Uint8(actualPath, namespace, revision,
+                        rangeStatements, null, null);
             } else if (typeName.equals("uint16")) {
-                type = new Uint16(actualPath, namespace, revision, rangeStatements, null, null);
+                type = new Uint16(actualPath, namespace, revision,
+                        rangeStatements, null, null);
             } else if (typeName.equals("uint32")) {
-                type = new Uint32(actualPath, namespace, revision, rangeStatements, null, null);
+                type = new Uint32(actualPath, namespace, revision,
+                        rangeStatements, null, null);
             } else if (typeName.equals("uint64")) {
-                type = new Uint64(actualPath, namespace, revision, rangeStatements, null, null);
+                type = new Uint64(actualPath, namespace, revision,
+                        rangeStatements, null, null);
             }
         } else if ("enumeration".equals(typeName)) {
             type = new EnumerationType(actualPath, namespace, revision,
                     enumConstants);
         } else if ("string".equals(typeName)) {
-            type = new StringType(actualPath, namespace, revision, lengthStatements, patternStatements);
+            type = new StringType(actualPath, namespace, revision,
+                    lengthStatements, patternStatements);
         } else if ("bits".equals(typeName)) {
-            type = new BitsType(actualPath, namespace, revision, getBits(typeBody, actualPath, namespace,
-                    revision, prefix));
+            type = new BitsType(actualPath, namespace, revision, getBits(
+                    typeBody, actualPath, namespace, revision, prefix));
         } else if ("leafref".equals(typeName)) {
             final String path = parseLeafrefPath(typeBody);
             final boolean absolute = path.startsWith("/");
@@ -1025,18 +1040,19 @@ public final class YangModelBuilderUtil {
             type = new Leafref(actualPath, namespace, revision, xpath);
         } else if ("binary".equals(typeName)) {
             List<Byte> bytes = Collections.emptyList();
-            type = new BinaryType(actualPath, namespace, revision, bytes, lengthStatements, null);
+            type = new BinaryType(actualPath, namespace, revision, bytes,
+                    lengthStatements, null);
         } else if ("instance-identifier".equals(typeName)) {
             boolean requireInstance = isRequireInstance(typeBody);
-            type = new InstanceIdentifier(actualPath, namespace, revision, null, requireInstance);
+            type = new InstanceIdentifier(actualPath, namespace, revision,
+                    null, requireInstance);
         }
         return type;
     }
 
     public static String getIdentityrefBase(Type_body_stmtsContext ctx) {
         String result = null;
-        outer:
-        for (int i = 0; i < ctx.getChildCount(); i++) {
+        outer: for (int i = 0; i < ctx.getChildCount(); i++) {
             ParseTree child = ctx.getChild(i);
             if (child instanceof Identityref_specificationContext) {
                 for (int j = 0; j < child.getChildCount(); j++) {
@@ -1194,52 +1210,43 @@ public final class YangModelBuilderUtil {
         return yinValue;
     }
 
-//    public static List<RefineHolder> parseRefines(Uses_stmtContext ctx) {
-//        List<RefineHolder> refines = new ArrayList<RefineHolder>();
-//
-//        for (int i = 0; i < ctx.getChildCount(); i++) {
-//            ParseTree child = ctx.getChild(i);
-//            if (child instanceof Refine_stmtContext) {
-//                final String refineTarget = stringFromNode(child);
-//                final RefineHolder refine = new RefineHolder(refineTarget);
-//                for (int j = 0; j < child.getChildCount(); j++) {
-//                    ParseTree refinePom = child.getChild(j);
-//                    if (refinePom instanceof Refine_pomContext) {
-//                        for (int k = 0; k < refinePom.getChildCount(); k++) {
-//                            ParseTree refineStmt = refinePom.getChild(k);
-//                            if (refineStmt instanceof Refine_leaf_stmtsContext) {
-//                                parseRefine(refine,
-//                                        (Refine_leaf_stmtsContext) refineStmt);
-//                            } else if (refineStmt instanceof Refine_container_stmtsContext) {
-//                                parseRefine(
-//                                        refine,
-//                                        (Refine_container_stmtsContext) refineStmt);
-//                            } else if (refineStmt instanceof Refine_list_stmtsContext) {
-//                                parseRefine(refine,
-//                                        (Refine_list_stmtsContext) refineStmt);
-//                            } else if (refineStmt instanceof Refine_leaf_list_stmtsContext) {
-//                                parseRefine(
-//                                        refine,
-//                                        (Refine_leaf_list_stmtsContext) refineStmt);
-//                            } else if (refineStmt instanceof Refine_choice_stmtsContext) {
-//                                parseRefine(refine,
-//                                        (Refine_choice_stmtsContext) refineStmt);
-//                            } else if (refineStmt instanceof Refine_anyxml_stmtsContext) {
-//                                parseRefine(refine,
-//                                        (Refine_anyxml_stmtsContext) refineStmt);
-//                            }
-//                        }
-//                    }
-//                }
-//                refines.add(refine);
-//            }
-//        }
-//        return refines;
-//    }
+    /**
+     * Check this base type.
+     *
+     * @param typeName
+     *            base YANG type name
+     * @param moduleName
+     *            name of current module
+     * @param line
+     *            line in module
+     * @throws YangParseException
+     *             if this is one of YANG type which MUST contain additional
+     *             informations in its body
+     */
+    public static void checkMissingBody(final String typeName,
+            final String moduleName, final int line) throws YangParseException {
+        if ("decimal64".equals(typeName)) {
+            throw new YangParseException(moduleName, line,
+                    "The 'fraction-digits' statement MUST be present if the type is 'decimal64'.");
+        } else if ("identityref".equals(typeName)) {
+            throw new YangParseException(moduleName, line,
+                    "The 'base' statement MUST be present if the type is 'identityref'.");
+        } else if ("leafref".equals(typeName)) {
+            throw new YangParseException(moduleName, line,
+                    "The 'path' statement MUST be present if the type is 'leafref'.");
+        } else if("bits".equals(typeName)) {
+            throw new YangParseException(moduleName, line,
+                    "The 'bit' statement MUST be present if the type is 'bits'.");
+        } else if("enumeration".equals(typeName)) {
+            throw new YangParseException(moduleName, line,
+                    "The 'enum' statement MUST be present if the type is 'enumeration'.");
+        }
+    }
 
     public static RefineHolder parseRefine(Refine_stmtContext child) {
         final String refineTarget = stringFromNode(child);
-        final RefineHolder refine = new RefineHolder(refineTarget);
+        final RefineHolder refine = new RefineHolder(refineTarget, child
+                .getStart().getLine());
         for (int j = 0; j < child.getChildCount(); j++) {
             ParseTree refinePom = child.getChild(j);
             if (refinePom instanceof Refine_pomContext) {
@@ -1249,15 +1256,13 @@ public final class YangModelBuilderUtil {
                         parseRefine(refine,
                                 (Refine_leaf_stmtsContext) refineStmt);
                     } else if (refineStmt instanceof Refine_container_stmtsContext) {
-                        parseRefine(
-                                refine,
+                        parseRefine(refine,
                                 (Refine_container_stmtsContext) refineStmt);
                     } else if (refineStmt instanceof Refine_list_stmtsContext) {
                         parseRefine(refine,
                                 (Refine_list_stmtsContext) refineStmt);
                     } else if (refineStmt instanceof Refine_leaf_list_stmtsContext) {
-                        parseRefine(
-                                refine,
+                        parseRefine(refine,
                                 (Refine_leaf_list_stmtsContext) refineStmt);
                     } else if (refineStmt instanceof Refine_choice_stmtsContext) {
                         parseRefine(refine,
index 2c1b9b8..301e533 100644 (file)
@@ -19,4 +19,25 @@ public class YangParseException extends RuntimeException {
         super(errorMsg, exception);
     }
 
+    public YangParseException(final int line, final String errorMsg) {
+        super("Error on line " + line + ": " + errorMsg);
+    }
+
+    public YangParseException(final int line, final String errorMsg,
+            final Exception exception) {
+        super("Error on line " + line + ": " + errorMsg, exception);
+    }
+
+    public YangParseException(final String moduleName, final int line,
+            final String errorMsg) {
+        super("Error in module '" + moduleName + "' on line " + line + ": "
+                + errorMsg);
+    }
+
+    public YangParseException(final String moduleName, final int line,
+            final String errorMsg, final Exception exception) {
+        super("Error in module '" + moduleName + "' on line " + line + ": "
+                + errorMsg, exception);
+    }
+
 }
index f9e3fc2..ed8df46 100644 (file)
@@ -15,6 +15,7 @@ import java.util.Set;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
+import org.antlr.v4.runtime.ParserRuleContext;
 import org.antlr.v4.runtime.tree.ParseTree;
 import org.opendaylight.controller.antlrv4.code.gen.YangParser.Yang_version_stmtContext;
 import org.opendaylight.controller.yang.model.parser.impl.YangModelParserListenerImpl;
@@ -132,6 +133,10 @@ final class BasicValidations {
             message = parent.equals(name) ? message : ValidationUtil.f(
                     "(In (sub)module:%s) %s", parent, message);
 
+            if(statement instanceof ParserRuleContext) {
+                message = "Error on line "+ ((ParserRuleContext)statement).getStart().getLine() + ": "+ message;
+            }
+
             ValidationUtil.ex(message);
         }
     }
index ffcadf6..bd39da2 100644 (file)
@@ -7,9 +7,9 @@
  */
 package org.opendaylight.controller.yang.model.validator;
 
-import static org.hamcrest.core.Is.*;
+import static org.hamcrest.core.Is.is;
 import static org.junit.Assert.*;
-import static org.junit.matchers.JUnitMatchers.*;
+import static org.junit.matchers.JUnitMatchers.containsString;
 import static org.mockito.Mockito.*;
 
 import java.util.ArrayList;
@@ -17,6 +17,7 @@ import java.util.Date;
 import java.util.HashSet;
 import java.util.List;
 
+import org.antlr.v4.runtime.Token;
 import org.antlr.v4.runtime.tree.ParseTree;
 import org.junit.Before;
 import org.junit.Test;
@@ -159,8 +160,11 @@ public class YangModelValidationTest {
         int thrown = 0;
         for (String id : ids) {
             try {
+                Module_stmtContext module = mock(Module_stmtContext.class);
+                Token token = mock(Token.class);
+                when(module.getStart()).thenReturn(token);
                 BasicValidations.checkIdentifierInternal(
-                        mock(Module_stmtContext.class), id);
+                        module, id);
             } catch (YangValidationException e) {
                 thrown++;
             }
@@ -177,6 +181,9 @@ public class YangModelValidationTest {
                 "mod1");
         addChild(mod1, augument);
 
+        Token token = mock(Token.class);
+        when(augument.getStart()).thenReturn(token);
+
         try {
             valid.enterAugment_stmt(augument);
         } catch (YangValidationException e) {
index 6d41321..e4d176c 100644 (file)
@@ -73,8 +73,6 @@ public class YangTypesConverter {
             type = new StringType(actualPath, namespace, revision);\r
         } else if("binary".equals(typeName)) {\r
             type = new BinaryType(actualPath, namespace, revision);\r
-        } else if("bits".equals(typeName)) {\r
-            type = new BitsType(actualPath, namespace, revision);\r
         } else if("boolean".equals(typeName)) {\r
             type = new BooleanType(actualPath, namespace, revision);\r
         } else if("empty".equals(typeName)) {\r