Skip to content

Commit

Permalink
Remove unnecessary Option in filename for importAbsolute and importRe…
Browse files Browse the repository at this point in the history
…lative

In all cases this methods called with Some(...)
  • Loading branch information
Mingun committed Sep 8, 2024
1 parent 8463d18 commit 6d08f2e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ class JavaScriptClassSpecs(importer: JavaScriptImporter, firstSpec: ClassSpec)
val MODE_REL = "rel"
val MODE_ABS = "abs"

override def importRelative(name: String, path: List[String], inFile: Option[String]): Future[Option[ClassSpec]] =
override def importRelative(name: String, path: List[String], inFile: String): Future[Option[ClassSpec]] =
doImport(name, path, MODE_REL)
override def importAbsolute(name: String, path: List[String], inFile: Option[String]): Future[Option[ClassSpec]] =
override def importAbsolute(name: String, path: List[String], inFile: String): Future[Option[ClassSpec]] =
doImport(name, path, MODE_ABS)

def doImport(name: String, path: List[String], mode: String): Future[Option[ClassSpec]] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ class JavaClassSpecs(relPath: String, absPaths: Seq[String], firstSpec: ClassSpe
private val relFiles: concurrent.Map[String, ClassSpec] = new ConcurrentHashMap[String, ClassSpec]().asScala
private val absFiles: concurrent.Map[String, ClassSpec] = new ConcurrentHashMap[String, ClassSpec]().asScala

override def importRelative(name: String, path: List[String], inFile: Option[String]): Future[Option[ClassSpec]] = Future {
override def importRelative(name: String, path: List[String], inFile: String): Future[Option[ClassSpec]] = Future {
Log.importOps.info(() => s".. importing relative $name")
JavaClassSpecs.cached(path, inFile, relFiles, name, (_) =>
JavaKSYParser.fileNameToSpec(s"$relPath/$name.ksy")
)
}

override def importAbsolute(name: String, path: List[String], inFile: Option[String]): Future[Option[ClassSpec]] = Future {
override def importAbsolute(name: String, path: List[String], inFile: String): Future[Option[ClassSpec]] = Future {
Log.importOps.info(() => s".. importing absolute $name")
JavaClassSpecs.cached(path, inFile, absFiles, name, tryAbsolutePaths)
}
Expand Down Expand Up @@ -62,7 +62,7 @@ class JavaClassSpecs(relPath: String, absPaths: Seq[String], firstSpec: ClassSpe
object JavaClassSpecs {
def cached(
path: List[String],
inFile: Option[String],
inFile: String,
cacheMap: mutable.Map[String, ClassSpec],
name: String,
importOp: (String) => ClassSpec
Expand All @@ -80,7 +80,7 @@ object JavaClassSpecs {
cacheMap(name) = spec
Some(spec)
} catch {
case err: Throwable => throw ErrorInInput(err, path, inFile).toException
case err: Throwable => throw ErrorInInput(err, path, Some(inFile)).toException
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,6 @@ abstract class ClassSpecs(val firstSpec: ClassSpec) extends mutable.HashMap[Stri
}
}

def importRelative(name: String, path: List[String], inFile: Option[String]): Future[Option[ClassSpec]]
def importAbsolute(name: String, path: List[String], inFile: Option[String]): Future[Option[ClassSpec]]
def importRelative(name: String, path: List[String], inFile: String): Future[Option[ClassSpec]]
def importAbsolute(name: String, path: List[String], inFile: String): Future[Option[ClassSpec]]
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class LoadImports(specs: ClassSpecs) {
private def loadImport(name: String, path: List[String], curClass: ClassSpec, workDir: ImportPath): Future[List[ClassSpec]] = {
Log.importOps.info(() => s".. LoadImports: loadImport($name, workDir = $workDir)")

val inFile = Some(curClass.fileNameAsStr)
val inFile = curClass.fileNameAsStr
val impPath = ImportPath.fromString(name)
val fullPath = ImportPath.add(workDir, impPath)

Expand Down

0 comments on commit 6d08f2e

Please sign in to comment.