Skip to content

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

Merged
merged 3 commits into from
Jul 31, 2018

Conversation

Blaisorblade
Copy link
Contributor

@Blaisorblade Blaisorblade commented Jul 29, 2018

Fix #4306. Also document OutlineParser with what I needed to discover.

Copy link
Contributor

@allanrenucci allanrenucci left a 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 = {
Copy link
Contributor

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) {
Copy link
Contributor

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 = {
Copy link
Member

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 ?

@Blaisorblade Blaisorblade force-pushed the fix-4306-scansource-java branch from 576dd33 to 1387795 Compare July 30, 2018 18:38
@Blaisorblade Blaisorblade assigned allanrenucci and unassigned smarter Jul 30, 2018
@Blaisorblade
Copy link
Contributor Author

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.

Copy link
Contributor

@allanrenucci allanrenucci left a 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

@Blaisorblade Blaisorblade merged commit f6b5d50 into scala:master Jul 31, 2018
@Blaisorblade Blaisorblade deleted the fix-4306-scansource-java branch July 31, 2018 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants