Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import cleanup #52

Merged
merged 1 commit into from
Apr 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import java.net.URI

import cats.effect.Sync
import org.dhallj.core.DhallException.ResolutionFailure
import org.dhallj.imports.ResolveImportsVisitor._
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching this. We should probably set up the unused import warnings, etc.

import org.http4s.Headers
import org.http4s.headers.`Access-Control-Allow-Origin`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@ object ReferentialSanityCheck {
case ImportContext.Local(path) =>
F.raiseError(
new ResolutionFailure(
"Referential sanity violation - remote import $uri cannot reference local import $path"
s"Referential sanity violation - remote import $uri cannot reference local import $path"
)
)
case ImportContext.Classpath(path) =>
F.raiseError(
new ResolutionFailure(
"Referential sanity violation - remote import $uri cannot reference classpath import $path"
s"Referential sanity violation - remote import $uri cannot reference classpath import $path"
)
)
case ImportContext.Env(v) =>
F.raiseError(
new ResolutionFailure("Referential sanity violation - remote import $uri cannot reference env import $v")
new ResolutionFailure(s"Referential sanity violation - remote import $uri cannot reference env import $v")
)
}
case ImportContext.Missing => F.raiseError(new ResolutionFailure(s"Missing import cannot reference import $child"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,16 +144,7 @@ final private class ResolveImportsVisitor[F[_] <: AnyRef](
}

def loadWithSemiSemanticCache(imp: ImportContext, mode: ImportMode, hash: Array[Byte]): F[Expr] = mode match {
case ImportMode.LOCATION =>
imp match {
case ImportContext.Local(path) => makeLocation("Local", path.toString)
// Cannot support this and remain spec-compliant as result type must be <Local Text | Remote Text | Environment Text | Missing>
case ImportContext.Classpath(path) =>
F.raiseError(new ResolutionFailure("Importing classpath as location is not supported"))
case ImportContext.Remote(uri, _) => makeLocation("Remote", uri.toString)
case ImportContext.Env(value) => makeLocation("Environment", value)
case ImportContext.Missing => F.pure(Expr.makeFieldAccess(Expr.Constants.LOCATION_TYPE, "Missing"))
}
case ImportMode.LOCATION => F.raiseError(new ResolutionFailure("Unreachable - location imports already handled"))
case ImportMode.RAW_TEXT =>
for {
text <- fetch(imp)
Expand Down