-
Notifications
You must be signed in to change notification settings - Fork 207
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
Use ${ProjName} for workspace includes referencing folders from the project to better support project renames #402 #405
Conversation
I don't really like this but it is the best I could come up with
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.
This code has a bug if the user selects a project that starts with the same name as the current project you get an error. e.g. create two projects, simple
and simpler
. In simple
press Add and then choose a directory in simpler
, the resulting value you get is: /${ProjName}r/src/include
instead of the expected /simpler/src/include
I think messing around with the string at this point is too late, instead I think the code that creates the string in the first place could be modified:
cdt/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractCPropertyTab.java
Lines 576 to 582 in 7c8bb9f
if (dialog.open() == Window.OK) { | |
IResource resource = (IResource) dialog.getFirstResult(); | |
if (resource != null) { | |
StringBuilder buf = new StringBuilder(); | |
return buf.append("${").append("workspace_loc:").append(resource.getFullPath()).append("}").toString(); //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$ | |
} | |
} |
using the same algorithm as discussed in #402 (comment)
If that proves impossible/impractical, the current solution looks fine to me, but does it need some null checks around get the project name from cfgd
?
Please also provide a self contained commit message / PR title. If you add to the body of the commit message and PR something like Fixes #402
then merging the PR will close the issue with the appropriate cross reference. See help for more info on that.
I fully agree. That is why I stated : "I don't really like this solution but it is the best I could come up with." I tried to modify cdt/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractCPropertyTab.java So I opted for a quick and dirty method. If you are ok with removing the statics I'll do it. |
If it were me I would pass in the project as an additional parameter and leave it static. |
A bit confusing as it already gets a IProject as a parameter cdt/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractCPropertyTab.java Line 520 in 7c8bb9f
And a explicit null is provided and a check for null is done. cdt/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractCPropertyTab.java Line 531 in 7c8bb9f
|
Yeah, bit annoying to have two iproject in one signature. But they have distinctly different purposes at least. Or add another boolean parameter like "limit selection to project" and always pass the project in. The other alternative is to add a new button called project and that would limit selection to the project. Or fix the bug in your initial implementation. |
I'll try this one |
This does not work because the project folder is added in front of the ${ProjectName}after pressing ok when having "is workspace" selected (which is default after pressing "add workspace folder")
This seems to fail as well as the project folder is added when getting back to the properties pages. |
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.
First pass review before I try to run it.
core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractCPropertyTab.java
Outdated
Show resolved
Hide resolved
core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractCPropertyTab.java
Outdated
Show resolved
Hide resolved
return getWorkspaceDialog(shell, text, false, true, null); | ||
} | ||
|
||
public static String getWorkspaceDirDialog(Shell shell, String text, IProject prj) { |
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.
Needs @since
- but we can resolve that later in the review process
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.
Which version number is to be used?
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.
The minor version in MANIFEST.MF needs to be increased and use that number. The auto-fix in Eclipse should do that if you have API baseline setup. If you don't have it setup I think it will be 8.1
I can handle that as part of the merging if it isn't straightforward for you.
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.
The code change looks good - can you please address this:
Please also provide a self contained commit message / PR title. If you add to the body of the commit message and PR something like Fixes #402 then merging the PR will close the issue with the appropriate cross reference. See help for more info on that.
return getWorkspaceDialog(shell, text, false, true, null); | ||
} | ||
|
||
public static String getWorkspaceDirDialog(Shell shell, String text, IProject prj) { |
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.
The minor version in MANIFEST.MF needs to be increased and use that number. The auto-fix in Eclipse should do that if you have API baseline setup. If you don't have it setup I think it will be 8.1
I can handle that as part of the merging if it isn't straightforward for you.
core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractCPropertyTab.java
Outdated
Show resolved
Hide resolved
|
See https://github.com/eclipse-cdt/cdt/blob/main/POLICY.md#Using-API-Tooling for instructions on setting up and using API tooling |
I'm fixing API errors, doing last check and merging this now. |
I found a bug related to how the new code was handling slashes if the project was the selection as opposed to a folder in a project. In commit bde0761 I fixed the handling to use Path class to assemble the path as the reference code did that I mentioned in #402 (comment) |
I understand what you mean - for now it is marked as fixed, at least fixed in the same way as other places using the same methodology. |
I don't really like this solution but it is the best I could come up with.
If there are better ways please tell me how.