-
-
Save antonioj-mattos/fbb83efb96e23b95f45af4741f159c40 to your computer and use it in GitHub Desktop.
Revisions
-
Slakah revised this gist
Aug 26, 2019 . 1 changed file with 0 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -12,8 +12,6 @@ object Resources { def readResourceImpl(c: whitebox.Context)(path: c.Expr[String]): c.Expr[String] = { import c.universe._ val Literal(Constant(thePath: String)) = path.tree val resourcePath = Paths.get(this.getClass.getResource("/" + thePath).toURI) val body = Files.readAllLines(resourcePath).asScala.mkString("\n") -
Slakah created this gist
Aug 26, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ package fastparse.protobuf import java.nio.file.{Files, Paths} import scala.reflect.macros.whitebox import scala.jdk.CollectionConverters._ object Resources { def readResource(path: String): String = macro Resources.readResourceImpl def readResourceImpl(c: whitebox.Context)(path: c.Expr[String]): c.Expr[String] = { import c.universe._ val Literal(Constant(thePath: String)) = path.tree println(this.getClass.getResource("/")) println(this.getClass.getResource("/" + thePath).toURI) val resourcePath = Paths.get(this.getClass.getResource("/" + thePath).toURI) val body = Files.readAllLines(resourcePath).asScala.mkString("\n") c.Expr[String](Literal(Constant(body))) } }