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

refactor(TypeFactory#get(String qualifiedName)): Look for type in factory.Package() first, and not at the end. Workaround for #1889 #1891

Merged
merged 1 commit into from Mar 3, 2018

Conversation

nharrand
Copy link
Collaborator

@nharrand nharrand commented Mar 2, 2018

As mentioned in the name of the PR, this would refactor TypeFactory.get(String qualifiedName). Instead of looking in existing packages for the wanted type only if it is not resolve otherwise, it starts by that.

It prevent to resolve recursively nested type from their root type as a first option. If you look for A$B$C it won't resolve A then A$B and then A$B$C. if A$B is already reachable, it will stop there.

This allow the resolution of class whose name contains $. The current behavior can't resolve a class named A$B if it's not a class B nested in A.

…tory.Package() first, and not at the end. Workaround for #1889
@monperrus
Copy link
Collaborator

Heavily used method yet all tests pass.

OK for me.

@@ -419,6 +419,21 @@ public CtTypeParameterReference createReference(CtTypeParameter type) {
*/
@SuppressWarnings("unchecked")
public <T> CtType<T> get(final String qualifiedName) {
int packageIndex = qualifiedName.lastIndexOf(CtPackage.PACKAGE_SEPARATOR);
CtPackage pack;
if (packageIndex > 0) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

if (packageIndex >= 0) would be better

I am wrong here. Your code is correct

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

3 participants