Skip to content
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

feat: find companion object of AnyVal, implicit class in class finder #4974

Merged
merged 2 commits into from Mar 21, 2023

Conversation

kpodsiad
Copy link
Member

@kpodsiad kpodsiad commented Feb 16, 2023

classes like implicit class FooOps(private val foo: Int) extends AnyVal produces two class files: FooOps.class and FooOps$.class. This PR:

  • does some refactor in ClassFinder
  • thanks to modifications, it's easier to add companion object for implicit, anyval classes
  • EDIT: case class companion object was missing too, added

Comment on lines +25 to +27
mangledClassName: MangledClassName,
shortClassName: ShortClassName,
extensionSuffix: String,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

after some time, I had no idea what friendlyName and description are. MangledClassName and ShortClassName have defined meaning which makes it easier to see what's going on

Comment on lines +254 to +256
object ClassFinderGranularity {
case object ClassFiles extends ClassFinderGranularity
case object Tasty extends ClassFinderGranularity
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better tha boolean, isn't it?

@@ -178,6 +178,6 @@ class ClassBreakpointSuite extends BaseClassFinderSuite {
buffers.put(path, sourceText)
val sym = classFinder.findClass(path, pos.toLsp.getStart())
assert(sym.isDefined)
assertNoDiff(sym.get, expected)
assertNoDiff(sym.get.value, expected)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this suite is relevant anymore, since breakpoints are handled within the debug-adapter-library. We could probably move everything to one suite and remove the public methods

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So both findClass and findTasty methods can be removed and test suites can be removed too?

Copy link
Contributor

@tgodzik tgodzik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super minor comment, but otherwise LGTM!


class ClassFinder(trees: Trees) {

def findClass(path: AbsolutePath, pos: l.Position): Option[String] =
findClass(path, pos, checkInnerClasses = true)
def findClass(path: AbsolutePath, pos: l.Position): Option[MangledClassName] =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two methods seem to only be used in tests 🤔

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#4974 (comment)
If I got you correctly we can remove test suites and then those methods, right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so, unless some of those cases are not tested in FindAllClassesSuite

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll create an issue about checking usage of this method, after it's created, I'll merge PR.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issue created #5071, I'm merging this PR

@kpodsiad kpodsiad merged commit b33ed44 into scalameta:main Mar 21, 2023
@kpodsiad kpodsiad deleted the kpodsiadlo/class-finder branch March 21, 2023 11:26
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.

None yet

2 participants