-
Notifications
You must be signed in to change notification settings - Fork 224
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
Clean up Java support in metacp #1367
Conversation
* remove this$0 fields for inner classes * merge inner classes with their outer class files * skip anonymous classes
ClassNode.access for inner classes does not contain whether a class is static or not, it's only available through ClassNode.innerClasses for the outer class.
@@ -59,4 +59,7 @@ void packagePrivateMethod() { } | |||
|
|||
public Serializable anonymous = new Serializable() { }; | |||
|
|||
static void staticMethod() {} | |||
static class StaticClass {} |
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.
Let's test a static field too, if you don't mind.
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.
Done.
@@ -36,73 +36,6 @@ _empty_.B#`<init>`(). => primaryctor <init>: (): B | |||
_empty_.B#a(). => def a: : A | |||
A => _empty_.A# | |||
|
|||
com/javacp/ClassSuffix$Inner$Bar$Fuz.class | |||
------------------------------------------ |
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.
Nested classes are now stored in their owner's semanticdb files, right?
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.
Correct, these entries are included below see https://github.com/scalameta/scalameta/pull/1367/files#diff-026fd03a8437acdb4213e4e80bf077d1R71
|
||
Symbols: | ||
_root_. => package _root_ | ||
_root_.com. => package com | ||
_root_.com.javacp. => package javacp | ||
_root_.com.javacp.Javacp# => class Javacp[A <: CharSequence with Serializable, B <: Object].{+30 decls} | ||
_root_.com.javacp.Javacp# => class Javacp[A <: CharSequence with Serializable, B <: Object].{+31 decls} |
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.
Why is it just +1 decl when you added both a static class and a static method?
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.
Good catch, I've updated the logic to include direct inner classes as ClassInfo.declarations.
extends Serializable | ||
_root_.com.javacp.Javacp#1#<init>(Javacp). => private[javacp] def <init>: (arg0: Javacp): Unit | ||
arg0 => _root_.com.javacp.Javacp#1#<init>(Javacp).(arg0) | ||
_root_.com.javacp.ClassSuffix#Inner#<init>(ClassSuffix). => private[javacp] def <init>: (arg0: ClassSuffix): Unit |
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 like that this$N
outer fields no longer show up in SemanticDB. Can we also filter out the corresponding outer parameters from inner class constructors? The heuristic would be "if the class contains a field such that field.name.startsWith("this$")
, then drop the first parameters of the constructor".
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.
Done.
.filter { f => | ||
!isVisited(f) && | ||
Files.isRegularFile(f) | ||
} |
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.
Do we still need sorting? If not, let's go back to having all logic in visitFile
.
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.
We still need sorting in order to ensure we visit Foo.class
before Foo$Inner.class
. I propose we keep this unchanged for now.
* avoid duplicate addInfo for _root_ package * add direct inner classes to ClasInfo.declarations
It was reporting parse errors for the javacp test files.
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.
Thanks for the review!
@@ -59,4 +59,7 @@ void packagePrivateMethod() { } | |||
|
|||
public Serializable anonymous = new Serializable() { }; | |||
|
|||
static void staticMethod() {} | |||
static class StaticClass {} |
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.
Done.
.filter { f => | ||
!isVisited(f) && | ||
Files.isRegularFile(f) | ||
} |
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.
We still need sorting in order to ensure we visit Foo.class
before Foo$Inner.class
. I propose we keep this unchanged for now.
@@ -36,73 +36,6 @@ _empty_.B#`<init>`(). => primaryctor <init>: (): B | |||
_empty_.B#a(). => def a: : A | |||
A => _empty_.A# | |||
|
|||
com/javacp/ClassSuffix$Inner$Bar$Fuz.class | |||
------------------------------------------ |
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.
Correct, these entries are included below see https://github.com/scalameta/scalameta/pull/1367/files#diff-026fd03a8437acdb4213e4e80bf077d1R71
extends Serializable | ||
_root_.com.javacp.Javacp#1#<init>(Javacp). => private[javacp] def <init>: (arg0: Javacp): Unit | ||
arg0 => _root_.com.javacp.Javacp#1#<init>(Javacp).(arg0) | ||
_root_.com.javacp.ClassSuffix#Inner#<init>(ClassSuffix). => private[javacp] def <init>: (arg0: ClassSuffix): Unit |
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.
Done.
|
||
Symbols: | ||
_root_. => package _root_ | ||
_root_.com. => package com | ||
_root_.com.javacp. => package javacp | ||
_root_.com.javacp.Javacp# => class Javacp[A <: CharSequence with Serializable, B <: Object].{+30 decls} | ||
_root_.com.javacp.Javacp# => class Javacp[A <: CharSequence with Serializable, B <: Object].{+31 decls} |
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.
Good catch, I've updated the logic to include direct inner classes as ClassInfo.declarations.
While running javacp against the JDK: ``` error: can't convert /java/util/regex/Pattern.class java.lang.UnsupportedOperationException: tail of empty list at scala.collection.immutable.Nil$.tail(List.scala:430) ``` Happens while trying to drop of the first parameter for outer class reference to an inner class ctor.
Partially addressed the checkboxes in #1362.