* @return A new representation instance.
* @throws YangSyntaxErrorException
* if we fail to extract dependency information.
+ *
+ * @deprecated Use {@link #create(SourceIdentifier, ParserRuleContext)} instead.
*/
+ @Deprecated
public static ASTSchemaSource create(@Nonnull final SourceIdentifier identifier,
@Nonnull final ParserRuleContext tree, final String text) throws YangSyntaxErrorException {
+ return create(identifier, tree);
+ }
+
+ /**
+ * Create a new instance of AST representation for a abstract syntax tree,
+ * performing minimal semantic analysis to acquire dependency information.
+ *
+ * @param identifier
+ * SourceIdentifier of yang schema source.
+ * @param tree
+ * ANTLR abstract syntax tree
+ * @return A new representation instance.
+ * @throws YangSyntaxErrorException
+ * if we fail to extract dependency information.
+ */
+ public static ASTSchemaSource create(@Nonnull final SourceIdentifier identifier,
+ @Nonnull final ParserRuleContext tree) throws YangSyntaxErrorException {
final YangModelDependencyInfo depInfo = YangModelDependencyInfo.fromAST(identifier.getName(), tree);
final SourceIdentifier id = getSourceId(depInfo);
import com.google.common.util.concurrent.Futures;
import java.io.IOException;
import java.io.InputStream;
-import java.nio.charset.StandardCharsets;
import org.antlr.v4.runtime.ParserRuleContext;
import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException;
import org.opendaylight.yangtools.yang.model.repo.api.SchemaRepository;
//:TODO missing validation (YangModelBasicValidationListener should be re-implemented to new parser)
- // Backwards compatibility
- final String text = input.asCharSource(StandardCharsets.UTF_8).read();
-
- return Futures.immediateCheckedFuture(ASTSchemaSource.create(input.getIdentifier(), ctx, text));
+ return Futures.immediateCheckedFuture(ASTSchemaSource.create(input.getIdentifier(), ctx));
}
}
}