-
Notifications
You must be signed in to change notification settings - Fork 135
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: Support running tests from Java Project explorer #1125
Conversation
if (packageFragment != null && packageFragment instanceof IPackageFragment) { | ||
final IJavaElement[] packages = ((IPackageFragmentRoot) packageFragment.getParent()).getChildren(); | ||
for (final IJavaElement p : packages) { | ||
if (!(p instanceof IPackageFragment)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks better in style?
if (p instanceof IPackageFragment)
if (p.getElementName().startsWith(packageFragment.getElementName()))
result.add((IPackageFragment) p);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got the point, or maybe merge the if blocks into one?
/** | ||
* Get all sub-packages whose name starts with the given package. | ||
*/ | ||
public static IPackageFragment[] getAllSubPackages(IJavaElement packageFragment) throws CoreException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this method actually returns the package itself and its children, so a better name should be getPackageAndSubpackages
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is duplicated utility in jdt.core.manipulation jar.
See org.eclipse.jdt.internal.corext.refactoring.util.JavaElementUtil.getPackageAndSubpackages(), suggest to reuse it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes that will be much better.
Support run tests from the Java Project explorer
Demo
demo.mp4
Note
Since we need to run all the children nodes if the explorer is in Hierarchical mode, so I made some workaround in the implementation. Basically it's to patch the arguments resolved by the configuration delegator.