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

Fix some issues with static imports and inner classes or enums #1048

Merged
merged 16 commits into from
Dec 17, 2016
Merged

Fix some issues with static imports and inner classes or enums #1048

merged 16 commits into from
Dec 17, 2016

Conversation

surli
Copy link
Collaborator

@surli surli commented Dec 16, 2016

Some issues have been detected using spoon on open source projects (see https://ci.inria.fr/sos/job/EveryNightRegressionTesting/516/) du to failing static import on inner classes or enum.
Fix the detected errors by changing the way fully qualified name are printed in imports for inner classes (for now a $ was printed before the inner class name) and by detecting in the MinimalImportScanner if the simpleName of the currentRef is creating a collision: in that case, we should not import the element as it could create bug by autoreference.

monperrus and others added 15 commits November 16, 2016 22:28
…ith an or instead of an and. Now the test is failing, proof that the assertion is checked :)
… a local variable in the same block or by a field (or a variable in another block). First detection implemented but patch not satisfying.
}

}
printer.writeln().writeTabs();
}
}

private String removeInnerTypeSeparator(String FQN) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Name FQN does not comply with Java conventions. Our xxxx-checkstyle doesn't detect this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Apparently not... I'll open an issue to fix/simplify the checkstyle!

}

}
printer.writeln().writeTabs();
}
}

private String removeInnerTypeSeparator(String FQN) {
return FQN.replace('$', '.');
Copy link
Collaborator

Choose a reason for hiding this comment

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

we have a TYPE_SEPARATOR representing $ somewhere.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Indeed.

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.

2 participants