-
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
Add command to list Java projects #1238
Conversation
throws JavaModelException { | ||
final String displayName; | ||
final String fullName; | ||
if (element instanceof IPackageFragment && ((IPackageFragment) element).isDefaultPackage()) { | ||
displayName = DEFAULT_PACKAGE_NAME; | ||
fullName = DEFAULT_PACKAGE_NAME; | ||
fullName = ""; |
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.
is empty string working?
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 default package's element name is empty.
While here I should get the fullName in just one call, no need to handle separately, will update it.
final ISourceRange nameRange = ((ISourceReference) element).getNameRange(); | ||
if (SourceRange.isAvailable(sourceRange) && SourceRange.isAvailable(nameRange)) { | ||
return JDTUtils.toRange(element.getOpenable(), nameRange.getOffset(), | ||
sourceRange.getLength() - nameRange.getOffset() + sourceRange.getOffset()); |
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.
sourceRange.getLength() - nameRange.getOffset() + sourceRange.getOffset()
equals to nameRange.getLength()
?
can you briefly explain?
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.
sourceRange contains JavaDocs, so (nameRange.getOffset() - sourceRange.getOffset())
equals to the length of JavaDoc, I'll add a comment for it.
...soft.java.test.plugin/src/main/java/com/microsoft/java/test/plugin/util/TestSearchUtils.java
Outdated
Show resolved
Hide resolved
return Collections.emptyList(); | ||
} | ||
final List<IJavaProject> javaProjects = new LinkedList<>(); | ||
for (final IJavaProject project : ProjectUtils.getJavaProjects()) { |
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.
Among ProjectUtils.getJavaProjects()
, what else are you going to filter together with default project?
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.
No other projects so far. All the projects that can be seen in user's workspaces should be listed
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.
Just curious about if we can simply remove default project, and skip the "prefix checking"?
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.
prefix checking it totally fine with me, just curious about 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.
Oh, that's a good point. As far as I know, currently we could have default project, visible project and invisible project. It seems that we can just remove the default project and put other Java projects into the list.
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.
Overall the list projects part LGTM. But I remember JDTLS also has similar utility, is it exposed?
JDTLS has a utility to get all Java projects (ProjectUtils.getJavaProjects()), which I've used here |
No description provided.