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

feat: Support running tests from Java Project explorer #1125

Merged
merged 4 commits into from
Jan 19, 2021

Conversation

jdneo
Copy link
Member

@jdneo jdneo commented Jan 12, 2021

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.

@jdneo jdneo added this to the 0.28.0 milestone Jan 12, 2021
if (packageFragment != null && packageFragment instanceof IPackageFragment) {
final IJavaElement[] packages = ((IPackageFragmentRoot) packageFragment.getParent()).getChildren();
for (final IJavaElement p : packages) {
if (!(p instanceof IPackageFragment)) {
Copy link
Member

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);

Copy link
Member Author

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?

Eskibear
Eskibear previously approved these changes Jan 18, 2021
/**
* Get all sub-packages whose name starts with the given package.
*/
public static IPackageFragment[] getAllSubPackages(IJavaElement packageFragment) throws CoreException {
Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Member Author

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.

@jdneo jdneo merged commit 8f16b71 into master Jan 19, 2021
@jdneo jdneo deleted the cs/testFromJavaProjectExplorer branch January 19, 2021 02:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants