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(qsync): NPE in "Add to project" panel action #6967

Merged
merged 1 commit into from
Nov 6, 2024

Conversation

tpasternak
Copy link
Collaborator

@tpasternak tpasternak commented Nov 5, 2024

A comment contains a warning that there should be at least two packages found in order to provide user a choice. However in some cases there is only a single package to add.

For this reason, we stop the lookup if it reaches project root, but we don't add a package automatically, so a user can always reject the change.

closes #6966

qsync-add-to-project.mov

Checklist

  • I have filed an issue about this change and discussed potential changes with the maintainers.
  • I have received the approval from the maintainers to make this change.
  • This is not a stylistic, refactoring, or cleanup change.

Please note that the maintainers will not be reviewing this change until all checkboxes are ticked. See
the Contributions section in the README for more
details.

Discussion thread for this change

Issue number: <please reference the issue number or url here>

Description of this change

A comment contains a warning that there should be at least two packages
found in order to provide user a choice. However in some cases there
is only a single package to add.

For this reason, we stop the lookup if it reaches project root,
but we don't add a package automatically, so a user can always reject
the change.

closes bazelbuild#6966
@github-actions github-actions bot added product: CLion CLion plugin product: IntelliJ IntelliJ plugin product: GoLand GoLand plugin awaiting-review Awaiting review from Bazel team on PRs labels Nov 5, 2024
xuansontrinh
xuansontrinh previously approved these changes Nov 6, 2024
do {
cancellationCheck.run();
packages = runQuery(forPath);
if (!packages.isEmpty()) {
candidates.add(new CandidatePackage(forPath, packages.size()));
}
forPath = forPath.getParent();
} while (candidates.size() < 2 && packages.size() < 2);
} while (candidates.size() < 2 && packages.size() < 2 && forPath != null);
Copy link
Collaborator

Choose a reason for hiding this comment

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

forPath != null

this could become an infinite loop

Returns the parent path, or null if this path does not have a parent.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

what do you mean?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it's a Path, running .getParent on it must end with a null eventually

Copy link
Collaborator

Choose a reason for hiding this comment

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

oh, my bad, I'm so sorry about that

do {
cancellationCheck.run();
packages = runQuery(forPath);
if (!packages.isEmpty()) {
candidates.add(new CandidatePackage(forPath, packages.size()));
}
forPath = forPath.getParent();
} while (candidates.size() < 2 && packages.size() < 2);
} while (candidates.size() < 2 && packages.size() < 2 && forPath != null);
Copy link
Collaborator

Choose a reason for hiding this comment

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

oh, my bad, I'm so sorry about that

@tpasternak tpasternak merged commit c63414c into bazelbuild:master Nov 6, 2024
8 checks passed
@tpasternak tpasternak deleted the fix-add-to-project branch November 6, 2024 11:26
@github-actions github-actions bot removed the awaiting-review Awaiting review from Bazel team on PRs label Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
product: CLion CLion plugin product: GoLand GoLand plugin product: IntelliJ IntelliJ plugin
Projects
Development

Successfully merging this pull request may close these issues.

Query Sync: Add file to proejct doesn't work
4 participants