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

Use imports instead of fully qualified names #97

Open
filiphr opened this issue May 19, 2017 · 5 comments · May be fixed by #99
Open

Use imports instead of fully qualified names #97

filiphr opened this issue May 19, 2017 · 5 comments · May be fixed by #99

Comments

@filiphr
Copy link

filiphr commented May 19, 2017

I think it would be a nice addition if the generated XXXAssertions use imports for types. Of course if there are 2 types from different packages then one of them will have to have FQN

@joel-costigliola
Copy link
Member

I'm not sure to see the value of that, sure it looks nicer but you don't expect generated code to be nice and I see that it gonna make the code more complex.

Do you have a good use case for that ?

@filiphr
Copy link
Author

filiphr commented May 19, 2017

Apart from making the code more readable nothing more, this is more like nice to have. You can close it if you think it is not something interesting.

Another point is the Javadoc it will have nice shorter names.

@joel-costigliola
Copy link
Member

joel-costigliola commented May 19, 2017

I remember having started using imports and run into conflicting imports, let's keep it simple in the code.
For javadoc, we can generate links with short description like {@link long.package.MyClass #isCompatible() isCompatible} without having to use imports (I think)

@filiphr
Copy link
Author

filiphr commented May 20, 2017

We do do this in MapStruct, we generate imports for all the possible types and if there are conflicts we only create import for one type and FQN for the rest. If you want I can try it out, when I have some time. However, I don't know the code, so I can't say how complex or easy it is to do here.

Your example with the Javadoc works. However, the signature of the method still uses FQN (at least in IntelliJ), and I don't think that you can change this.

@joel-costigliola
Copy link
Member

That's great if you can give it a try ! :)

The code is more complex than assertj-core and needs some refactoring love, it was been written before java 8 but I'm keen to migrate the code base to Java 8.

What you want to look at is the AssertionsEntryPointGenerator which is responsible for creating Assertions style classes and more specifically BaseAssertionGenerator#generateAssertionsEntryPointClassContent.

filiphr added a commit to filiphr/assertj-assertions-generator that referenced this issue May 21, 2017
@filiphr filiphr linked a pull request May 21, 2017 that will close this issue
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 a pull request may close this issue.

2 participants