BUG-6497: Do not lose augmentation statement order
[yangtools.git] / yang / yang-parser-impl / src / main / java / org / opendaylight / yangtools / yang / parser / stmt / rfc6020 / YangStatementSourceImpl.java
index 3080e48b5e4bbfc4ced75a4ff00f085b9197f763..e53b855ce41092936b49a62ecd3fdbb86393b1f6 100644 (file)
@@ -41,11 +41,9 @@ public final class YangStatementSourceImpl implements StatementStreamSource {
     private YangStatementParser.StatementContext statementContext;
     private ParseTreeWalker walker;
     private String sourceName;
-//    private String source;
-//    private InputStream sourceStream;
     private static final Logger LOG = LoggerFactory.getLogger(YangStatementSourceImpl.class);
 
-    public YangStatementSourceImpl(final String fileName, boolean isAbsolute) {
+    public YangStatementSourceImpl(final String fileName, final boolean isAbsolute) {
         try {
             statementContext = parseYangSource(loadFile(fileName, isAbsolute));
             walker = new ParseTreeWalker();
@@ -65,7 +63,7 @@ public final class YangStatementSourceImpl implements StatementStreamSource {
         }
     }
 
-    public YangStatementSourceImpl(SourceIdentifier identifier, YangStatementParser.StatementContext statementContext) {
+    public YangStatementSourceImpl(final SourceIdentifier identifier, final YangStatementParser.StatementContext statementContext) {
         try {
             this.statementContext = statementContext;
             this.sourceName = identifier.getName();
@@ -100,17 +98,11 @@ public final class YangStatementSourceImpl implements StatementStreamSource {
         walker.walk(yangStatementModelParser, statementContext);
     }
 
-    private NamedFileInputStream loadFile(final String fileName, boolean isAbsolute) throws URISyntaxException,
+    private NamedFileInputStream loadFile(final String fileName, final boolean isAbsolute) throws URISyntaxException,
             IOException {
         //TODO: we need absolute path first!
         return isAbsolute ? new NamedFileInputStream(new File(fileName), fileName) : new NamedFileInputStream(new File
                 (getClass().getResource(fileName).toURI()), fileName);
-
-//        final File file = new File(fileName);
-//        final ByteSource byteSource = BuilderUtils.fileToByteSource(file);
-//        source = byteSource.asCharSource(Charsets.UTF_8).read();
-//        return isAbsolute ? new NamedFileInputStream(file, fileName) : new NamedFileInputStream(new File
-//                (getClass().getResource(fileName).toURI()), fileName);
     }
 
     private YangStatementParser.StatementContext parseYangSource(final InputStream stream) throws IOException,
@@ -124,18 +116,12 @@ public final class YangStatementSourceImpl implements StatementStreamSource {
         final YangErrorListener errorListener = new YangErrorListener();
         parser.addErrorListener(errorListener);
 
-        if(stream instanceof NamedFileInputStream) {
+        if (stream instanceof NamedFileInputStream) {
             sourceName = stream.toString();
         } else {
             sourceName = null;
         }
 
-//        sourceStream = stream;
-//        sourceName = parser.getSourceName();
-//
-//        if (sourceName == null) {
-//            sourceName = stream.toString();
-//        }
         final StatementContext result = parser.statement();
         errorListener.validate();
 
@@ -151,11 +137,7 @@ public final class YangStatementSourceImpl implements StatementStreamSource {
         return sourceName;
     }
 
-//    public InputStream getSourceStream() {
-//        return sourceStream;
-//    }
-
-    private static void logError(Exception e) {
+    private static void logError(final Exception e) {
         if (e instanceof YangSyntaxErrorException) {
             LOG.error(((YangSyntaxErrorException) e).getFormattedMessage(), e);
         } else {