Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -787,14 +787,19 @@ private String getValue(String s) {
}

}
protected boolean isExistingProject(File element) {

protected IProject findExistingProject(File element) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If the new findExistingProject is only called by the old isExistingProject method, what is the purpose of such a new method that is only called in one place and could be in-lined at that location? The fact it's protected suggests that you might want to use it somewhere in a derived class...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fair point, and you're right to question it in isolation - as it stands in this PR alone, there's no second caller, so the split doesn't pay for itself yet.

The motivation is forward-looking: this was split out of the discussion on #4170, which is exploring letting users act on an already-imported project (open it if closed, etc.), and that would need the actual IProject, not just the boolean isExistingProject returns today. Since that follow-up direction is still being worked out there, I wanted to land the lookup itself separately rather than bundle it with a still-undecided UI change.

That said, I take the concern seriously - if it's not going to be used elsewhere in the near term, inlining it back into
isExistingProject and reintroducing it later (alongside whatever change actually needs it) is a perfectly reasonable alternative, and probably cleaner than speculative API surface sitting unused. Happy to go either way - do you have a preference, or would you rather see this land together with its first real caller instead of ahead of it?

On protected: that was just matching the existing visibility of isExistingProject and isExistingProjectName in the same class, not a signal that subclassing was the intent - no derived class uses it today, so I don't think that reasoning holds up either. If we do keep the split, private is more honest until there's an actual external/derived caller.

for (IProject project : ResourcesPlugin.getWorkspace().getRoot().getProjects()) {
IPath location = project.getLocation();
if (location != null && element.equals(location.toFile())) {
return true;
return project;
}
}
return false;
return null;
}

protected boolean isExistingProject(File element) {
return findExistingProject(element) != null;
}

protected boolean isExistingProjectName(File element) {
Expand Down
Loading