-
Notifications
You must be signed in to change notification settings - Fork 89
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
Sort maven project list in Explorer and hide invalid pom.xml files #118
Conversation
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.
In reviewing this PR, I find a issue that originally exists. When you have more than one pom.xml files in the workspace, if for some reason one of the pom.xml file cannot be successfully parsed, then all the other projects cannot be rendered in the explorer. (because rejected promise is not properly handled.)
Potential promise rejects in _sortChildren
. It can fail the getChildren
. This PR is facing the same issue.
@@ -53,7 +53,7 @@ export class MavenProjectNode extends NodeBase { | |||
return this._mavenProject.modules.length > 0; | |||
} | |||
|
|||
private async _ensureMavenProjectParsed(): Promise<void> { | |||
public async ensureMavenProjectParsed(): Promise<void> { | |||
if (!this._mavenProject) { | |||
const pom: {} = await Utils.parseXmlFile(this._pomPath); |
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.
Notice here it parses the pom.xml file, error would possibly be thrown.
|
||
private async _sortChildren(): Promise<void> { | ||
for ( const projectNode of this._children ) { | ||
await projectNode.ensureMavenProjectParsed(); |
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.
Here for each pom.xml, you parse the content here. And if error occurs when parsing any of the pom.xml files, the it rejects.
Hi @Eskibear, I've updated the code to handle errors thrown in the Here is a screenshot showing the difference: Valid pom.xml ^ Invalid pom.xml ^ (notice the project missing from the Explorer 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.
Up to this commit, I see you choose to directly remove the item containing invalid pom.xml (as mentioned in #119 (comment) ). That's ok for me since it's better than before anyway. We can discuss later in that issue about whether to simply remove or show the invalid pom entry for users to fast navigate.
Overall it looks good to me, and there are just some nits to be resolved before we can merge it. Please take a look.
…e accruately describle it does. Remove unused `async` on WorkspaceFolderNode._sortChildren.
I think I got all the changes. I also changed Apologies, I hadn't seen that you made an issue for the parsing of invalid pom.xml files. |
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.
LGTM!
_ensureMavenProjectParsed
ofMavenProjectNode
to become public.MavenProjectNode
items inWorkspaceFolderNode
.If I've made any mistakes or if there is a better way of approaching the problem, please let me know.