Skip to content
This repository has been archived by the owner on Mar 26, 2020. It is now read-only.

Commit

Permalink
Finish searching for import files after one is found in the include path
Browse files Browse the repository at this point in the history
  • Loading branch information
GreatCall-KayeK committed Dec 9, 2016
1 parent a8c8971 commit 512f3dc
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/source/parser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import java.util.{Map => JMap}
import org.yaml.snakeyaml.Yaml
import scala.collection.JavaConversions._
import scala.collection.mutable
import scala.util.control.Breaks._
import scala.util.parsing.combinator.RegexParsers
import scala.util.parsing.input.{Position, Positional}

Expand Down Expand Up @@ -53,16 +54,15 @@ private object IdlParser extends RegexParsers {
def importFile(fileName: String): File = {
var file: Option[File] = None

includePaths.foreach(path => {
if (file.isEmpty) {
var relPath = if (path.isEmpty) fileParent else path + "/"
val tmp = new File(relPath + fileName);
if (tmp.exists)
file = Some(tmp)
}
val path = includePaths.find(path => {
val relPath = if (path.isEmpty) fileParent else path + "/"
val tmp = new File(relPath + fileName)
val exists = tmp.exists
if (exists) file = Some(tmp)
exists
})

if (file.isEmpty) throw new FileNotFoundException("Unable to find file \"" + fileName + "\" at " + fileStack.top.getCanonicalPath)
if (path.isEmpty || file.isEmpty) throw new FileNotFoundException("Unable to find file \"" + fileName + "\" at " + fileStack.top.getCanonicalPath)

return file.get
}
Expand Down

0 comments on commit 512f3dc

Please sign in to comment.