Skip to content

Commit

Permalink
Support resolution relative to a path with specified caches (#286)
Browse files Browse the repository at this point in the history
  • Loading branch information
travisbrown authored Jul 27, 2021
1 parent 9b317c6 commit 993e4c7
Showing 1 changed file with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import org.http4s.client.Client

object Resolver {
def resolve[F[_] <: AnyRef](expr: Expr)(implicit Client: Client[F], F: Async[F]): F[Expr] =
F.flatMap(ResolveImportsVisitor[F](cwd))(expr.accept(_))
resolveRelativeTo[F](cwd)(expr)

def resolveRelativeTo[F[_] <: AnyRef](relativeTo: Path)(
expr: Expr
Expand All @@ -19,12 +19,23 @@ object Resolver {
semanticCache: ImportCache[F],
semiSemanticCache: ImportCache[F]
)(expr: Expr)(implicit Client: Client[F], F: Async[F]): F[Expr] =
expr.accept(ResolveImportsVisitor[F](semanticCache, semiSemanticCache, cwd))
resolveRelativeTo[F](semanticCache, semiSemanticCache)(cwd)(expr)

def resolveRelativeTo[F[_] <: AnyRef](
semanticCache: ImportCache[F],
semiSemanticCache: ImportCache[F]
)(relativeTo: Path)(expr: Expr)(implicit Client: Client[F], F: Async[F]): F[Expr] =
expr.accept(ResolveImportsVisitor[F](semanticCache, semiSemanticCache, relativeTo))

def resolve[F[_] <: AnyRef](
semanticCache: ImportCache[F]
)(expr: Expr)(implicit Client: Client[F], F: Async[F]): F[Expr] =
expr.accept(ResolveImportsVisitor[F](semanticCache, new ImportCache.NoopImportCache[F], cwd))
resolveRelativeTo[F](semanticCache)(cwd)(expr)

def resolveRelativeTo[F[_] <: AnyRef](
semanticCache: ImportCache[F]
)(relativeTo: Path)(expr: Expr)(implicit Client: Client[F], F: Async[F]): F[Expr] =
expr.accept(ResolveImportsVisitor[F](semanticCache, new ImportCache.NoopImportCache[F], relativeTo))

private def cwd: Path = Paths.get(".")

Expand Down

0 comments on commit 993e4c7

Please sign in to comment.