@@ -32,7 +32,7 @@ object ScalaBuff {
32
32
*/
33
33
def apply (file : File )(implicit settings : Settings = defaultSettings) = {
34
34
val tree = parse(file)
35
- val symbols = processImportSymbols(tree)
35
+ val symbols = processImportSymbols(tree, file.getParentFile )
36
36
Generator (tree, file.getName, symbols, settings.generateJsonMethod, settings.targetScalaVersion)
37
37
}
38
38
@@ -59,7 +59,8 @@ object ScalaBuff {
59
59
* Process "import" statements in a protobuf AST by scanning the imported
60
60
* files and building a map of their exported symbols.
61
61
*/
62
- def processImportSymbols (tree : List [Node ])(implicit settings : Settings = defaultSettings): Map [String , ImportedSymbol ] = {
62
+ def processImportSymbols (tree : List [Node ], parentFolder : File )(implicit settings : Settings = defaultSettings): Map [String , ImportedSymbol ] = {
63
+ implicit val searchInFirst = Some (parentFolder)
63
64
def dig (name : String ): List [(String , ImportedSymbol )] = {
64
65
val tree = parse(searchPath(name).getOrElse { throw new IOException (" Unable to import: " + name) })
65
66
val packageName = tree.collectFirst {
@@ -94,13 +95,13 @@ object ScalaBuff {
94
95
recurse(startAt)
95
96
}
96
97
97
- def searchPath (filename : String )(implicit settings : Settings = defaultSettings): Option [File ] = {
98
+ def searchPath (filename : String )(implicit settings : Settings = defaultSettings, searchInFirst : Option [ File ] = None ): Option [File ] = {
98
99
val file = new File (filename)
99
100
100
101
if (file.isAbsolute) {
101
102
Option (file).filter(_.exists)
102
103
} else {
103
- settings.importDirectories.map { folder =>
104
+ (searchInFirst.toSeq ++ settings.importDirectories) .map { folder =>
104
105
new File (folder, filename)
105
106
}.find(_.exists)
106
107
}
0 commit comments