-
Notifications
You must be signed in to change notification settings - Fork 17
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
Change to Scala based HOCON config library for JVM #65
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,7 @@ object TypesafeConfig2Class { | |
case lst: ConfigList => | ||
Conf.Lst(lst.listIterator().asScala.map(loop).toList) | ||
case _ => | ||
value.unwrapped() match { | ||
value.unwrapped match { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I personally don't mind this change, but I would expect a drop-in Scala replacement to not require this diff even if that means using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I really wasn't sure what to do as the internal tests in Scala where inconsistent how it called Java with or without parens. So overall, I tried to make it more Scala-like. I left them on for obvious side-effecting 0-arity methods. Someone who was really bored could do an entire API review 😆 If it really could have been a drop-in then I think Lightbend should have serious considered the PR - it is close but will probably change again for Scala 3 support etc. I also still have to change the package which will require import changes. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't mind the parenthesis diff, metaconfig touches such a tiny surface of the API anyways.
with or without parens works when calling Java methods, but Scala "nullary methods" have additional information in their signatures to prohibit calling
I doubt that ;) I suspect it will work without any changes. This PR is very close to being ready!
|
||
case x: String => Conf.Str(x) | ||
case x: java.lang.Integer => Conf.Num(BigDecimal(x)) | ||
case x: java.lang.Long => Conf.Num(BigDecimal(x)) | ||
|
@@ -43,14 +43,14 @@ object TypesafeConfig2Class { | |
) | ||
} | ||
} | ||
getPositionOpt(value.origin(), cache).fold(conf)(conf.withPos) | ||
getPositionOpt(value.origin, cache).fold(conf)(conf.withPos) | ||
} | ||
try { | ||
Configured.Ok(loop(config().resolve().root())) | ||
Configured.Ok(loop(config().resolve().root)) | ||
} catch { | ||
case e: ConfigException.Parse => | ||
Configured.NotOk( | ||
ConfError.parseError(getPosition(e.origin(), cache), e.getMessage) | ||
ConfError.parseError(getPosition(e.origin, cache), e.getMessage) | ||
) | ||
} | ||
} | ||
|
@@ -67,8 +67,8 @@ object TypesafeConfig2Class { | |
): Option[Position] = | ||
for { | ||
origin <- Option(originOrNull) | ||
url <- Option(origin.url()) | ||
linePlus1 <- Option(origin.lineNumber()) | ||
url <- Option(origin.url) | ||
linePlus1 <- Option(origin.lineNumber) | ||
line = linePlus1 - 1 | ||
input = Input.File(new java.io.File(url.toURI)) | ||
offsetByLine = cache.getOrElseUpdate( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be best to create a new module
sconfig
and keep the currenttypesafeConfig
module unchanged.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. I'll change that once I make a first JVM release. Should I leave the original?