Deprecate YangStatementStreamSource.getYangText() 22/90422/1
authorRobert Varga <robert.varga@pantheon.tech>
Fri, 12 Jun 2020 08:07:59 +0000 (10:07 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Fri, 12 Jun 2020 08:07:59 +0000 (10:07 +0200)
We do not need to leak this internal implementation detail,
remove is visibility.

Change-Id: I13be830b8dedff8478c9859cda2c6b1f44eabf31
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/repo/TextToASTTransformer.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/repo/YangModelDependencyInfo.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/repo/YangStatementStreamSource.java

index 4a5ce79313a00f2d25d5cf0be5fc444e72dd6310..4d593813c39188b530f50c8fca0a4d2a48fd7ee4 100644 (file)
@@ -5,13 +5,11 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.yangtools.yang.parser.rfc7950.repo;
 
 import com.google.common.annotations.Beta;
 import com.google.common.util.concurrent.Futures;
 import java.io.IOException;
-import org.antlr.v4.runtime.ParserRuleContext;
 import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException;
 import org.opendaylight.yangtools.yang.model.repo.api.SchemaRepository;
 import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceException;
@@ -41,11 +39,11 @@ public final class TextToASTTransformer extends SchemaSourceTransformer<YangText
     public static ASTSchemaSource transformText(final YangTextSchemaSource text) throws SchemaSourceException,
             IOException, YangSyntaxErrorException {
         final YangStatementStreamSource src = YangStatementStreamSource.create(text);
-        final ParserRuleContext ctx = src.getYangAST();
         LOG.debug("Model {} parsed successfully", text);
 
         // TODO: missing validation (YangModelBasicValidationListener should be re-implemented to new parser)
 
-        return ASTSchemaSource.create(text.getIdentifier(), text.getSymbolicName().orElse(null), ctx);
+        return ASTSchemaSource.create(text.getIdentifier(), text.getSymbolicName().orElse(null),
+            src.statementContext());
     }
 }
index 7e8d21345f7d07dc2c3d707283a50412d45719f2..61f35683254bf4fb3dbf744a614d5bab3ad52c07 100644 (file)
@@ -210,9 +210,7 @@ public abstract class YangModelDependencyInfo {
             throws IOException, YangSyntaxErrorException {
         final YangStatementStreamSource source = YangStatementStreamSource.create(
             YangTextSchemaSource.forResource(refClass, resourceName));
-        final ParserRuleContext ast = source.getYangAST();
-        checkArgument(ast instanceof StatementContext);
-        return parseAST((StatementContext) ast, source.getIdentifier());
+        return parseAST(source.statementContext(), source.getIdentifier());
     }
 
     private static @NonNull YangModelDependencyInfo parseModuleContext(final StatementContext module,
index 588cac66ad990dec83aa0b3f4c06d9cbc249d69b..7d26fa946cfd0879222491ae2efb59775a79bb2d 100644 (file)
@@ -150,7 +150,12 @@ public final class YangStatementStreamSource extends AbstractIdentifiable<Source
         }.visit(context);
     }
 
+    @Deprecated(forRemoval = true)
     public ParserRuleContext getYangAST() {
+        return statementContext();
+    }
+
+    StatementContext statementContext() {
         return context;
     }