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

Extend Classes Syntax for anonymous / inner / outer classes #207

Closed
codecholeric opened this issue Jul 28, 2019 · 4 comments · Fixed by #245
Closed

Extend Classes Syntax for anonymous / inner / outer classes #207

codecholeric opened this issue Jul 28, 2019 · 4 comments · Fixed by #245

Comments

@codecholeric
Copy link
Collaborator

It would be neat to have classes().that().

  • areAnonymous()
  • areInnerClasses() (includes anonymous classes, do we need areNamedInnerClasses()?)
  • areOuterClasses() (i.e. no enclosing class / toplevel, I'm open for better naming 😉)

Same holds for classes().should().be...

@codecholeric
Copy link
Collaborator Author

Overlaps in parts with #172

@rweisleder
Copy link
Contributor

The JLS defines four different kinds of classes, see chapter 8.

With this reference I suggest to add the methods classes().that().

  • areTopLevelClasses()
  • areNestedClasses()
  • areLocalClasses()
  • areAnonymousClasses()

And of course the same for classes().should().be...

To be consistent with existing methods we should also add the negated methods like areNotTopLevelClasses() and notBeTopLevelClasses().

@codecholeric
Copy link
Collaborator Author

We should also make the determination of the nested class type more resilient. Currently isAnonymous() is implemented by checking the simple name for being empty. The class file import should be able though, to derive a type of the nested class (static nested, inner, local, anonymous) and pass that on to the JavaClass instead of applying some heuristics later (since for a local class this would be something shady like javaClass.getName().matches(".*\\$\\d+\\w+") or similar 😨)

@rweisleder
Copy link
Contributor

I started working on this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants