-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix #4306: Implement -scansource for Java files #4861
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
Fix #4306: Implement -scansource for Java files #4861
Conversation
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'll defer to @smarter for a proper review.
*/ | ||
class OutlineJavaParser(source: SourceFile)(implicit ctx: Context) extends JavaParser(source) { | ||
|
||
def skipBraces[T](body: T): T = { |
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 realise it was taken from the Scala OutlineParser
, but I find it a bit weird that this method takes an argument and just returns it. I would define it and use as:
private def skipBraces(): Unit = ...
override def typeBody(leadingToken: Int, parentName: Name, parentTParams: List[TypeDef]) = {
skipBraces()
(List(EmptyValDef), List(EmptyTree))
}
Maybe change the implementation in the Scala OutlineParser as well.
* This is necessary even for Java, because the filename defining a non-public classes cannot be determined from the | ||
* classname alone. | ||
*/ | ||
class OutlineJavaParser(source: SourceFile)(implicit ctx: Context) extends JavaParser(source) { |
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.
Nitpick: the documentation style we (try to) use across the code base is:
/** First line
*
* More lines...
* @param ...
*/
def foo =
We start on the first line and all lines are alligned
*/ | ||
class OutlineJavaParser(source: SourceFile)(implicit ctx: Context) extends JavaParser(source) { | ||
|
||
def skipBraces[T](body: T): T = { |
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.
This is identical to the Scala version except for the lack of XMLSTART handling, can't we just use the Scala version for Java too ?
Also document `OutlineParser` with what I needed to discover.
576dd33
to
1387795
Compare
All comments addressed, without too much complication. @allanrenucci last commit is a refactoring that might be worth reviewing for style, the new code is a bit more convoluted. |
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 am not convinced the refactoring makes things simpler. The skipBracesHook
is a bit convoluted.
But otherwise LGTM. Feel free to merge as is
Fix #4306. Also document
OutlineParser
with what I needed to discover.