Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 330750 - Include path defined as ${workspace_loc} incorrectly displayed in Project Explorer view
Summary: Include path defined as ${workspace_loc} incorrectly displayed in Project Exp...
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-core (show other bugs)
Version: 8.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 8.0   Edit
Assignee: Andrew Gvozdev CLA
QA Contact: Andrew Gvozdev CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-11-21 11:33 EST by Alex Freidin CLA
Modified: 2011-05-02 11:17 EDT (History)
5 users (show)

See Also:


Attachments
Patch for the problem (1.76 KB, patch)
2010-11-22 03:55 EST, Alex Freidin CLA
no flags Details | Diff
Modified to display "/" in Includes container (1.75 KB, patch)
2010-11-23 04:13 EST, Alex Freidin CLA
no flags Details | Diff
Updated patch for (HEAD) (3.20 KB, patch)
2010-12-01 09:44 EST, Alex Freidin CLA
no flags Details | Diff
Like in this screenshot? (46.26 KB, image/jpeg)
2010-12-07 04:14 EST, Alex Freidin CLA
no flags Details
Corresponding view of paths in project settings (44.38 KB, image/jpeg)
2010-12-07 04:18 EST, Alex Freidin CLA
no flags Details
One more screenshot (53.24 KB, image/jpeg)
2010-12-07 04:43 EST, Alex Freidin CLA
no flags Details
Patch with the requested changes from Comment 7 (3.21 KB, patch)
2010-12-07 07:12 EST, Alex Freidin CLA
no flags Details | Diff
PHP Explorer (19.68 KB, image/jpeg)
2010-12-09 10:11 EST, Alex Freidin CLA
no flags Details
Package Explorer in JDT (72.38 KB, image/jpeg)
2010-12-09 10:13 EST, Alex Freidin CLA
no flags Details
Status bar in Java/PHP (12.23 KB, image/jpeg)
2010-12-09 10:23 EST, Alex Freidin CLA
no flags Details
CDT project resources in status bar (29.54 KB, image/jpeg)
2010-12-09 10:33 EST, Alex Freidin CLA
no flags Details
Displays workspace root as absolute path (3.21 KB, patch)
2011-01-25 05:13 EST, Alex Freidin CLA
angvoz.dev: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Freidin CLA 2010-11-21 11:33:55 EST
Build Identifier: 20100917-0705

Steps to reproduce (CDT 7.0.1):
1. Define an include path as ${workspace_loc} in project settings
2. Observe that instead of pointing to workspace root, the Includes container in Project Explorer view shows the current project entry.

The handling of workspace location as include path is missing in two places:
1.PathEntryTranslator.PathEntryComposer.valueToEntryPath()
2.CViewLabelProvider.getText()

Question is how the workspace root should appear in the Includes container? Is there a common symbol (e.g. /) or should it be displayed as an absolute path?

Reproducible: Always
Comment 1 Alex Freidin CLA 2010-11-22 03:55:24 EST
Created attachment 183553 [details]
Patch for the problem

Updated the PathEntryTranslator to handle the workspace root path and CViewLabelProvider to display "R/" - toString() value of workspace root.
Comment 2 Andrew Gvozdev CLA 2010-11-22 12:39:47 EST
>Question is how the workspace root should appear in the Includes container? Is there a common symbol (e.g. /) or should it be displayed as an absolute path?
In my vision it should be "Include folder in workspace" icon and "/" as a text. For folders in the project it should be "Include folder in project" icon and one of a) workspace path (including project name) or b) path rooted in the project. It should be consistent with presentation in "Paths and Symbols", bug 279502.
Comment 3 Alex Freidin CLA 2010-11-23 04:13:02 EST
Created attachment 183648 [details]
Modified to display "/" in Includes container

The "/" text is reasonable, patch updated.
Not sure how the "Include folder in workspace" icon looks like in HEAD. Currently, it has the same icon as "${workspace_loc:/OtherPrj/folder}" include path (blue in CDT 6.0, purple in CDT 7.0.1).
Comment 4 Andrew Gvozdev CLA 2010-11-23 10:02:17 EST
(In reply to comment #3)
> Created an attachment (id=183648)
> Modified to display "/" in Includes container
Hmm, I do not observe "/" instead I observe absolute path of the workspace on the filesystem. Is that what is intended?

> The "/" text is reasonable, patch updated.
> Not sure how the "Include folder in workspace" icon looks like in HEAD.
> Currently, it has the same icon as "${workspace_loc:/OtherPrj/folder}" include
> path (blue in CDT 6.0, purple in CDT 7.0.1).
Yeah, that's the one.
Comment 5 Alex Freidin CLA 2010-11-29 05:00:14 EST
Oops, I wasn't checking the patch against HEAD. It appears that the logic of getting labels for Includes elements has changed since CDT 7.0.1.
CNavigatorLabelProvider is now IStyledLabelProvider and therefore getStyledText() is called instead of getText(). Unfortunately, CViewLabelProvider wasn't adapted to implement getStyledText(). It has only getText(), which is no longer called and therefore all workspace includes are now displayed with full paths, not only the workspace root from my patch.
Comment 6 Alex Freidin CLA 2010-12-01 09:44:50 EST
Created attachment 184263 [details]
Updated patch for (HEAD)

Added a trivial implementation of CViewLabelProvider.getStyledText() that reuses the existing getText(). 
Note that CViewLabelProvider.getText() was missing decorateText() calls which are used in super.getText() implementation (CUILabelProvider). If there are any text decorations, we should apply them to all objects, not some of them. Added the missing calls at return statements.
Comment 7 Andrew Gvozdev CLA 2010-12-01 12:21:56 EST
The root folder looks good but now presentation of other workspace folders is inconsistent since they do not have leading slash. Could you correct that as well?
Comment 8 Alex Freidin CLA 2010-12-07 04:14:29 EST
Created attachment 184692 [details]
Like in this screenshot?
Comment 9 Alex Freidin CLA 2010-12-07 04:18:41 EST
Created attachment 184693 [details]
Corresponding view of paths in project settings
Comment 10 James Blackburn CLA 2010-12-07 04:22:43 EST
Would it not be better to display this as an absolute path?

Note that projects can live anywhere on the filesystem.  So with this UI you're implying to the user:
  /
  /ProjA
  /ProjB/src

that both ProjA and ProjB/src are realtive to '/'.  In fact the project may live anywhere.  

The workspace root is useful when you're resolving workspace resources against it. However if you're using it as a file-system location in its own right, its location bears no relationship to the project locations.
Comment 11 James Blackburn CLA 2010-12-07 04:30:08 EST
And further note that while CVS & SVN may check-out projects directly under the workspace, ClearCase, Git, and plain-old filesystem import, likely have the projects nested elsewhere.

Andrew: I thought you were keen on distinguishing IResource paths (resolved to locations at runtime) to hard-coded filesystem paths (different per user).  The WR itself is one of the latter.
Comment 12 Alex Freidin CLA 2010-12-07 04:43:08 EST
Created attachment 184697 [details]
One more screenshot

Here is another screenshot. It shows also the subfolders and the status bar. The status bar shows the full path, while Includes container shows the relative project structure of the workspace.
Nothing changed here in the concept from previous implementation, showing the workspace relative path makes it clear that it is a project in the workspace, unlike any other path. The preceding slash doesn't make it more clear than before, but I don't have a strong opinion whether to have it or not.
Comment 13 Alex Freidin CLA 2010-12-07 07:12:01 EST
Created attachment 184709 [details]
Patch with the requested changes from Comment 7
Comment 14 Andrew Gvozdev CLA 2010-12-07 10:42:12 EST
(In reply to comment #10)
> Would it not be better to display this as an absolute path?
> Note that projects can live anywhere on the filesystem.  So with this UI you're
> implying to the user:
> /
> /ProjA
> /ProjB/src
> that both ProjA and ProjB/src are realtive to '/'.  In fact the project may live
> anywhere.
> The workspace root is useful when you're resolving workspace resources against
> it. However if you're using it as a file-system location in its own right, its
> location bears no relationship to the project locations.
I explained the rationale in comment#2. We are talking here about workspace resources represented as ${workspace_loc:/Project/path}. The presentation should be consistent with presentation in Paths&Symbols properties. If we let the user to enter workspace path in UI we should display it as workspace path the same way everywhere. This is not relative path to workspace location but workspace path as in IResource.getFullPath() and it is clearly marked as such by workspace icon IMO. Note that IResource.getFullPath() returns a path starting with "/". That does not imply that the path is relative to workspace location.

(In reply to comment #11)
> And further note that while CVS & SVN may check-out projects directly under the
> workspace, ClearCase, Git, and plain-old filesystem import, likely have the
> projects nested elsewhere.
> Andrew: I thought you were keen on distinguishing IResource paths (resolved to
> locations at runtime) to hard-coded filesystem paths (different per user).  The
> WR itself is one of the latter.

What is your vision? Do you think we should always display filesystem path in PE? That path is very long line in many cases. I think that displaying workspace path is more succinct, expressive, and consistent and I like the last screenshot from Alex where the location on the filesystem is presented in status bar.
Comment 15 James Blackburn CLA 2010-12-07 10:47:44 EST
Perhaps my point wasn't celar.

The issue is that in general the location corresponding to "workspace_loc" bears no resemblance to an arbitrary project.getLocation().

By displaying, in the UI, the variable "${workspace_loc}" as a 'workspace path' of '/' you're misleading the user.  It implies that that '/ProjectA' is relative to the thing that looks like '/', which it isn't.

I have no issue with projects, folders, etc starting with a leading '/', the only issue is with how you display the variable ${workspace_loc} itself.
Comment 16 Andrew Gvozdev CLA 2010-12-07 11:23:37 EST
(In reply to comment #15)
> Perhaps my point wasn't celar.
> The issue is that in general the location corresponding to "workspace_loc" bears
> no resemblance to an arbitrary project.getLocation().
> By displaying, in the UI, the variable "${workspace_loc}" as a 'workspace path'
> of '/' you're misleading the user.  It implies that that '/ProjectA' is relative
> to the thing that looks like '/', which it isn't.
> I have no issue with projects, folders, etc starting with a leading '/', the
> only issue is with how you display the variable ${workspace_loc} itself.
IMO the distinct workspace icon itself denotes ${workspace_loc}, do you think it could be confusing? What if we display the path explicitly ${workspace_loc:/ProjectA/path}, would it do the trick? Although I like that slightly less as it more verbose.
Comment 17 James Blackburn CLA 2010-12-07 11:28:12 EST
(In reply to comment #16)
> IMO the distinct workspace icon itself denotes ${workspace_loc}, do you think
> it could be confusing? 

No, that's fine I think that's great.

> What if we display the path explicitly
> ${workspace_loc:/ProjectA/path}, would it do the trick? Although I like that
> slightly less as it more verbose.

No, no, it's fine to have: ${workspace_loc:/ProjectA/path} displayed prettily as <icon>/ProjectA/path. 

The problem is that ${workspace_loc} is resolved somewhere different.  So include paths resolved relative to -I ${workspace_loc} are ${workspace_loc}/relative/path, not ${workspace_loc:/relative/path}

I think that ${workspace_loc) itself should just be displayed as an external full location.

It's the same difference as:
${workspace_loc)/ProjectA/path vs. ${workspace_loc:/ProjectA/path)

The first is bad, the second is OK.  Does that make sense?
Comment 18 Andrew Gvozdev CLA 2010-12-07 12:00:47 EST
Is the difference you see is that for the paths like ${workspace_loc:/ProjectA/path} dependent resources are managed as IResource, i.e. ${workspace_loc:/ProjectA/path/include_file.h}, and for workspace root they are not, i.e. ${workspace_loc:/}/include_file.h?
Comment 19 James Blackburn CLA 2010-12-07 12:12:38 EST
(In reply to comment #18)
> Is the difference you see is that for the paths like
> ${workspace_loc:/ProjectA/path} dependent resources are managed as IResource,
> i.e. ${workspace_loc:/ProjectA/path/include_file.h}, and for workspace root
> they are not, i.e. ${workspace_loc:/}/include_file.h?

Not quite. The -I is a resolved to a real _directory_ location in the filesystem.  The compiler resolves includes relative to this directory.

The issue is that:
   ${workspace_loc:/ProjectA/path} != ${workspace_loc}/ProjectA/path

The first is resolved using IResource API, the second is just string concatenation.  Importantly ${workspace_loc:/ProjectA} may live anywhere (it may be ${workspace_loc}/ProjectA, it may not...).  
With linked resources ${workspace_loc:/ProjectA/path} may not live under ${workspace_loc:/ProjectA} *

The only way to guarantee when two users check-out a project that the -Is work, is to ensure that ${workspace_loc:/ProjectA/path} is used consistently, not ${workspace_loc}/ProjectA/path

So:
  ${workspace_loc:/ProjectA/path}   should be displayed as:
  <ws-icon>/ProjectA/path

Whereas:
  ${workspace_loc}/ProjectA/path    should be displayed as:
  <absolute-icon>/path/to/workspace/ProjectA/path
and:
  ${workspace_loc}  should be displayed as:
  <absolute-icon>/path/to/workspace/


*http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse.platform.doc.user/concepts/concepts-exttools.htm
Comment 20 Andrew Gvozdev CLA 2010-12-07 13:12:07 EST
> The issue is that:
>   ${workspace_loc:/ProjectA/path} != ${workspace_loc}/ProjectA/path
I am not disputing this fact and totally in agreement with you on this one. I am trying to understand what is your logic regarding to workspace root. As far as root I am getting equation  ${workspace_loc:/} == ${workspace_loc}. Do you argue that ${workspace_loc} is different than ${workspace_loc:/} and should be represented differently in UI? Isn't ${workspace_loc:/} correct to represent workspace root?
Comment 21 James Blackburn CLA 2010-12-07 13:32:37 EST
(In reply to comment #20)
> I am getting equation  ${workspace_loc:/} == ${workspace_loc}.

Yes, true.
> Do you
> Isn't ${workspace_loc:/} correct to represent
> workspace root?

Well this is the crux of it.  The "Workspace Root" is the root of workspace resources.  ${workspace_loc:<ws_relative_path>} are relative to that workspace root.  
${workspace_loc} when *resolved* to a location is no longer the workspace root.  It's just a filesystem location.  And workspace resources aren't relative to this location.  As every user has a different resolved ${workspace_root}, as a base directory it should be shown as the absolute path, from which relative paths are computed, rather than '/'. 

'/' implies that other workspace resources are relative to it, which in this case they aren't.
Comment 22 James Blackburn CLA 2010-12-07 13:42:08 EST
Out of interest Alex, how are you using ${workspace_loc} as an include directory?

Given you can't checkout resources directly under the workspace, presumably all your resources are project relative.  
Do you have #include "proj1/incs" in your source files or are you picking up headers not part of an eclipse project?
Comment 23 Andrew Gvozdev CLA 2010-12-07 16:48:37 EST
(In reply to comment #13)
> Created an attachment (id=184709)
> Patch with the requested changes from Comment 7
I looked at the code and it is very simple. I am happy with it. But there is one addition we discussed with James by chat... I'd like to learn about your setup first how you use -I${workspace_loc}. Can you satisfy our curiosity?
Comment 24 James Blackburn CLA 2010-12-08 03:21:28 EST
Andrew and I had a long discussion on this.

From my POV the path ${workspace_loc} can't ever be used safely in a multi-user version controlled environment.  This is because projects may live anywhere on disk (and users put them anywhere). So using the workspace location as the base for include lookup, for example, is a very bad idea.  

${workspace_loc:/ProjName} is much better. Any path that works for one user is guaranteed to work for others as the project is the root of version control in eclipse.

The Workspace Root shouldn't be treated as the same as other IResources as it isn't a general purpose IContainer.  The root can only contain IProjects, it can't contain IFiles or IFolders.  So ${workspace_loc} without any context resolves to a fs-location unrelated to the projects under the workspace.

For these reasons, I think that paths like: ${workspace_loc} ${workspace_loc}/Proj should look different & need to be annotated in some way, so users are aware that such paths aren't safe for sharing.  Either a warning annotation, or display them using the location rather than the full path.
Comment 25 Alex Freidin CLA 2010-12-08 10:10:08 EST
This bug gets more attention than I expected. Bottom line, it seems reasonable to display the workspace root as full fs path for the reason that it might confuse users expecting /ProjectA and /ProjectB as if they were under the same fs parent folder. Also, when working in unix, it might be highly confusing having / and /Project/some/long/path that look similar to a real fs path. So, I'm in favor of not having leading slashes and to display workspace root as absolute path.
To address your comments:

(In reply to comment #23)
> I'd like to learn about your setup first how you use -I${workspace_loc}. 

While working with CDT 6.0, I encountered a problem with handling of -I${workspace_loc}/Project/Path. This was fixed in bug 318738, but during testing of this fix with different include paths, I came across this problem. It is quite common though to have complex source trees in make based projects with some shared header files that reside one folder up to the source projects. E.g.
/Top - root of all sources/headers
/Top/Some/Path <- common headers are here
/Top/Some/Path/Project1
/Top/Some/Path/Project2
/Top/Other/Path/Project3

With this source tree, the user can create a workspace in /Top/Some/Path without putting it under version control and define -I${workspace_loc} for Project3 as include path. 
This is not a common nor recommended case, but as of current state, the workspace include path is displayed completely wrong and we should fix it this way or another.

(In reply to comment #24)
> From my POV the path ${workspace_loc} can't ever be used safely in a multi-user
> version controlled environment.  This is because projects may live anywhere on
> disk (and users put them anywhere). So using the workspace location as the base
> for include lookup, for example, is a very bad idea.  
> ${workspace_loc:/ProjName} is much better. Any path that works for one user is
> guaranteed to work for others as the project is the root of version control in
> eclipse.
In general case, it's a bad idea, in practice it works when the projects are agreed to be at certain location relative to each other, e.g. under same parent folder. The problem using ${workspace_loc:/ProjName} is that it doesn't work when the project is not imported inside the workspace, even if it is physically inside, the makefile is generated without -I switch, since it can't resolve the path.

> The Workspace Root shouldn't be treated as the same as other IResources as it
> isn't a general purpose IContainer.  The root can only contain IProjects, it
> can't contain IFiles or IFolders.  So ${workspace_loc} without any context
> resolves to a fs-location unrelated to the projects under the workspace.
> 
> For these reasons, I think that paths like: ${workspace_loc}
> ${workspace_loc}/Proj should look different & need to be annotated in some way,
> so users are aware that such paths aren't safe for sharing.  Either a warning
> annotation, or display them using the location rather than the full path.

As of the moment,  include path is displayed relative to the workspace, not as it appears in the project properties. In other words, if an absolute path can be resolved to a workspace project path, then it is displayed as a workspace project path. The good thing about it is the succinct representation. When the referred project is removed from the workspace, the representation changes to absolute path. If the project is closed, but not removed, the icon changes to regular (yellow), but the path is still workspace-relative. This looks good to me, as Includes container is not intended to show how the path is defined in project properties, but to show to what resources it refers in the workspace.
Regarding annotation, we should not add a warning annotation, these paths are valid and used in practice. Projects sometimes expected to reside at workspace folder, but not necessary be open in the workspace. The user always gets a path like ${workspace_loc:/ProjName} using the "Workspace" button. But if he manually types ${workspace_loc}/Proj, then he knows what he's doing. 

With the latest patch, I found that "${workspace_loc}/RefProj" is displayed without leading slash when the project is not in the workspace. If we still want the leading slash, I'll update the patch to take care of that, but imho the leading slash will be confusing in linux.

Btw, without the patch, we have unrelated problem, the CViewLabelProvider.getText() is no longer called at all, it should be fixed in any case.
Comment 26 James Blackburn CLA 2010-12-08 10:22:48 EST
It's unclear when you say "full path" whether you mean workspace full path or fs location?

Nonetheless, we're clearly talking about two different uses here:
  - Paths resolved in the workspace: ${workspace_loc:...}
  - Paths relative to the workspace location: ${workspace_loc}/...

I agree that both of them are allowed and have their uses.  However we shouldn't use the same icon for them in the PE display, as the former is resolved in eclipse with knowledge of project and link locations, whereas the latter is concatenated and assumes a fixed fs layout.

So in fixing this, please don't make the two types look the same in the UI.
Comment 27 James Blackburn CLA 2010-12-08 10:30:50 EST
(In reply to comment #25)
> So,
> I'm in favor of not having leading slashes and to display workspace root as
> absolute path.

I agree, this would be clean.
Comment 28 Alex Freidin CLA 2010-12-08 10:49:25 EST
(In reply to comment #26)
> It's unclear when you say "full path" whether you mean workspace full path or
> fs location?
By full path, I mean file system absolute path.
 
> Nonetheless, we're clearly talking about two different uses here:
>   - Paths resolved in the workspace: ${workspace_loc:...}
>   - Paths relative to the workspace location: ${workspace_loc}/...
> 
> I agree that both of them are allowed and have their uses.  However we
> shouldn't use the same icon for them in the PE display, as the former is
> resolved in eclipse with knowledge of project and link locations, whereas the
> latter is concatenated and assumes a fixed fs layout.
> 
> So in fixing this, please don't make the two types look the same in the UI.

CDT 7.0.1 always tries to resolve the display of fs absolute paths and ${workspace_loc}/<path> to workspace project relative path and it succeeds when the project is in the workspace. When it doesn't succeed, then absolute fs path is displayed as is, but ${workspace_loc}/<...> display is a little different. Do you propose to completely change that and disable the resolving of these two paths to their workspace relative form and instead always display fs path?
Comment 29 Andrew Gvozdev CLA 2010-12-08 11:00:41 EST
(In reply to comment #27)
> (In reply to comment #25)
> > So,
> > I'm in favor of not having leading slashes and to display workspace root as
> > absolute path.
> I agree, this would be clean.
I don't agree. In Project Explorer, if you select a resource you see workspace path starting with slash in the status line and it does not cause confusion. Also, there is an option "Copy qualified name" in Package Explorer and that also gives you the path with leading slash. Finally, IResource.getFullPath() returns the path with leading slash as well.
If you do not display leading slash in Includes node that suggests relative path which can be interpreted as relative to the project.
Comment 30 Doug Schaefer CLA 2010-12-08 11:01:45 EST
In all this discussion, please remember that it is very common that projects do *NOT* reside in the workspace in the file system. If you want to properly represent the location of a project, you need to use ${workspace_loc:/project}. Simply using ${workspace_loc} is actually meaningless and should be an error.
Comment 31 Andrew Gvozdev CLA 2010-12-08 11:09:22 EST
We are operating inside eclipse world and I think we should represent paths following rules of this world, i.e. workspace paths. Perhaps we should represent filesystem paths differently, i.e. with URI syntax?
Comment 32 Alex Freidin CLA 2010-12-08 11:12:40 EST
(In reply to comment #30)
> In all this discussion, please remember that it is very common that projects do
> *NOT* reside in the workspace in the file system. If you want to properly
> represent the location of a project, you need to use ${workspace_loc:/project}.
> Simply using ${workspace_loc} is actually meaningless and should be an error.

Agree with everything except the last sentence. Some users imply the location of a referred project under the workspace fs path, not necessary imported in the workspace, we should not take that option away from them if it is legal in Eclipse.

Further on include path display:
In CDT 7.0.1 path like ${workspace_loc}/Project is displayed as "Project" with purple icon if the project is in the workspace, if the project is closed or not in the workspace, then it appears as "Project" with yellow icon, not absolute path.

How is it handled by other (not CDT) tools plug-ins?
Comment 33 Alex Freidin CLA 2010-12-08 11:16:56 EST
For example, in Java, opening Plug-in Dependencies container, I don't see any leading slashes for referred projects in my workspace. So when a project is referred, no leading slash is used. I haven't seen any special symbol for workspace root in JDT plug-in.
Comment 34 Andrew Gvozdev CLA 2010-12-08 11:18:03 EST
(In reply to comment #32)
> (In reply to comment #30)
> > In all this discussion, please remember that it is very common that projects
> do
> > *NOT* reside in the workspace in the file system. If you want to properly
> > represent the location of a project, you need to use
> ${workspace_loc:/project}.
> > Simply using ${workspace_loc} is actually meaningless and should be an error.
> Agree with everything except the last sentence. Some users imply the location of
> a referred project under the workspace fs path, not necessary imported in the
> workspace, we should not take that option away from them if it is legal in
> Eclipse.
I do not think we should necessarily disallow that but we should discourage it. As we discussed with James, we need warning/error overlay on the icon (perhaps a stop sign overlay?) and a warning message in status line. Also, UI in Paths&Symbols and Settings should warn a user about such paths.
Comment 35 Alex Freidin CLA 2010-12-09 10:06:44 EST
(In reply to comment #34)
> As we discussed with James, we need warning/error overlay on the icon (perhaps
> a stop sign overlay?) and a warning message in status line. Also, UI in
> Paths&Symbols and Settings should warn a user about such paths.

I've three arguments to leave it without decoration:
1) ${workspace_loc}/ macro should be considered the same as any other macro that gets resolved to a fs absolute path. That's how it is defined in Eclipse help and it is the same as ${PWD} for example. Using other macros is not safe in the same way.
2) Errors or warnings are not displayed on linked resources that were created using WORKSPACE_LOC macro. The argument that it is not safe applies exactly the same for this case, but it is expected that the user creates it for purpose. 
3) Some projects have a strict constrain of zero errors and warnings. It's clear that as any other macro, this macro can find its uses and thus adding a warning in this case blocks a legitimate use of this feature.

My proposal is to stick with (1), because that reflects Eclipse definition of this macro and it should be displayed that way in PE view.
To avoid unintended mistakes, a warning message can appear in "Add directory path" dialog when adding a new include path with this syntax.


(In reply to comment #29)
> (In reply to comment #27)
> > (In reply to comment #25)
> > > So,
> > > I'm in favor of not having leading slashes and to display workspace root as
> > > absolute path.
> > I agree, this would be clean.
> I don't agree. In Project Explorer, if you select a resource you see workspace
> path starting with slash in the status line and it does not cause confusion.

Well, this is not so for Projects and this is not so any Java project or file displayed in Package Explorer. And this is not true for non source files in Project Explorer, e.g. makefiles. Only the source files are displayed with leading slash in Project Explorer. The current display in the status bar is completely inconsistent if we speak about it. After installing PHP, I can note that it's not true in PHP as well.
We should align the status bar to Java/PHP display, since CDT doesn't live alone in this world. A workspace may have both C and Java.

> Also, there is an option "Copy qualified name" in Package Explorer and that
> also gives you the path with leading slash. Finally, IResource.getFullPath()
> returns the path with leading slash as well.

You're right, but this is different, the path is not displayed in UI that way, only copied to the buffer. I will post some screenshots from PHP/Java PE views.

> If you do not display leading slash in Includes node that suggests relative
> path which can be interpreted as relative to the project.

Well, that's the current state and no one complained so far. I can't say for sure what's more confusing seeing it as now or seeing in Linux paths like /.../.../.../.../ with different icons, when one is fs absolute and another is workspace relative.
Comment 36 Alex Freidin CLA 2010-12-09 10:11:22 EST
Created attachment 184855 [details]
PHP Explorer

No slashes and the icon in includes path is the same as for project. This makes it clear that it's a reference to a workspace project. Same was in CDT 6.0, now it has been changed.
Comment 37 Alex Freidin CLA 2010-12-09 10:13:42 EST
Created attachment 184856 [details]
Package Explorer in JDT

No slashes, the folders in Plug-in Dependencies have the same icon as workspace projects except the "J". Pretty clear as well.
Comment 38 Alex Freidin CLA 2010-12-09 10:23:55 EST
Created attachment 184857 [details]
Status bar in Java/PHP

Both look in sync.
Comment 39 Alex Freidin CLA 2010-12-09 10:33:13 EST
Created attachment 184860 [details]
CDT project resources in status bar

Different resources are displayed differently in status bar. The project and makefile (not a source file) are in sync with Java/PHP screenshots above.
Comment 40 Andrew Gvozdev CLA 2010-12-09 11:26:22 EST
(In reply to comment #35)
> (In reply to comment #34)
> > As we discussed with James, we need warning/error overlay on the icon (perhaps
> > a stop sign overlay?) and a warning message in status line. Also, UI in
> > Paths&Symbols and Settings should warn a user about such paths.
> 
> I've three arguments to leave it without decoration:
> 1) ${workspace_loc}/ macro should be considered the same as any other macro that
> gets resolved to a fs absolute path. That's how it is defined in Eclipse help
> and it is the same as ${PWD} for example. Using other macros is not safe in the
> same way.
After sleeping on that I think I can buy that argument for plain ${workspace_loc}. In this case the path is the absolute filesystem path and the icon is also filesystem path. But with the stipulation that UI where the user enters it treats it as such as well and does not set the underlying ICSettingEntry with VALUE_WORKSPACE_PATH flag (which is outside the scope of this bug though). If the user intentionally enters ${workspace_loc:/} that will still formally imply workspace resource as well as any ${workspace_loc:/path} syntax - and presentation with workspace icon and workspace path.

> > > > So,
> > > > I'm in favor of not having leading slashes and to display workspace root
> > > > as absolute path.
> > > I agree, this would be clean.
> > I don't agree. In Project Explorer, if you select a resource you see workspace
> > path starting with slash in the status line and it does not cause confusion.
> Well, this is not so for Projects and this is not so any Java project or file
> displayed in Package Explorer. And this is not true for non source files in
> Project Explorer, e.g. makefiles. Only the source files are displayed with
> leading slash in Project Explorer. The current display in the status bar is
> completely inconsistent if we speak about it. After installing PHP, I can note
> that it's not true in PHP as well.
> We should align the status bar to Java/PHP display, since CDT doesn't live alone
> in this world. A workspace may have both C and Java.
What I see in PE for Java for most resources is that resource name is shown in the tree (last segment of the path) and in status line it is as [name - path]. This way you would see for include path "/MinGW/include/c++/3.4.5/" something like [3.4.5] in the PE tree and [3.4.5 - MinGW/include/c++] in the status line. I don't think dismembering include path is the good way to display it in our case. The point of my example was that there are places in eclipse where workspace path is used with leading slash and it does not cause any confusion whatsoever.

> > If you do not display leading slash in Includes node that suggests relative
> > path which can be interpreted as relative to the project.
> Well, that's the current state and no one complained so far. I can't say for
> sure what's more confusing seeing it as now or seeing in Linux paths like
> /.../.../.../.../ with different icons, when one is fs absolute and another is
> workspace relative.
I heard complains about it. I think the current state of representing "Includes" in PE totally sucks. There is no well defined logic behind it.
Comment 41 Alex Freidin CLA 2010-12-12 11:17:57 EST
This definition is reasonable and matches James suggestion in comment #17:

> ${workspace_loc:/ProjectA/path} displayed prettily as <icon>/ProjectA/path. 
> ${workspace_loc} itself should just be displayed as an external full location.

With addition of comment #40:
> If the user intentionally enters ${workspace_loc:/} that will still formally
> imply workspace resource
That is displayed as: <purple_icon>/

This implies comment #26: ${workspace_loc}/ProjectA/path is also displayed as an external full location. Same for includes defined as absolute fs path. 

In CDT 7.0.1, any include path location is resolved to workspace path if  possible. That should be changed according to above.

Is my understanding is correct?
Comment 42 James Blackburn CLA 2010-12-12 11:36:41 EST
(In reply to comment #41)
> With addition of comment #40:
> > If the user intentionally enters ${workspace_loc:/} that will still formally
> > imply workspace resource
> That is displayed as: <purple_icon>/

This is weird.  ${workspace_loc:/} == ${workspace_loc} so it would be odd to display them differently.

 > This implies comment #26: ${workspace_loc}/ProjectA/path is also displayed as
> an external full location. Same for includes defined as absolute fs path. 

That's one option. However it's a bit lossy as it would be ideal to display something to the user that implies: ProjectA/path relative to wherever the workspace is located.

> In CDT 7.0.1, any include path location is resolved to workspace path if 
> possible. That should be changed according to above.
> 
> Is my understanding is correct?

Only paths like: ${workspace_loc:...} are workspace paths. Everything else is either: absolute (easy), or relative to some base (where the base may be resolved in the workspace, or may not be).  We may not even know the base... At the moment we don't have a good way of distinguishing these.  However we should at the very least support:
  - Paths resolved entirely in the workspace
  - Absolute paths
  - Relative paths (what do these mean?)
There's a lot more discussion on this in bug 280677. It's not clear what the right answer is... My feeling is that tooling should contribute only workspace paths, or absolute paths to cdt.core, relative paths are problematic as they're relative to the directory in which the compiler was invoked which could be anywhere.
Comment 43 Alex Freidin CLA 2010-12-12 12:03:24 EST
(In reply to comment #42)
> This is weird.  ${workspace_loc:/} == ${workspace_loc} so it would be odd to
> display them differently.
It's an attempt to divide between the two representations. The other way around is to always show it combined as "/ - <full fs path>".
Comment 44 Sergey Prigogin CLA 2010-12-13 19:46:37 EST
I see a weird behavior in cdt_7_0 when {workspace_loc}/.metadata/.plugins/org.eclipse.core.resources/.projects/my_project is interpreted as a relative workspace path.
Comment 45 Andrew Gvozdev CLA 2011-01-06 16:29:53 EST
It does not appear we agree on representation of the paths in general as far as the icon or the label. This task is originally about ${workspace_loc} workspace root pointing to project location which is a clear bug. In this case I suggest to fix the text of broken label only i.e. display full filesystem path and open another bug to discuss representation of paths in PE. Would that be the least common denominator for this bug?
Comment 46 James Blackburn CLA 2011-01-06 17:15:47 EST
(In reply to comment #45)
> i.e. display full filesystem path and open
> another bug to discuss representation of paths in PE. Would that be the least
> common denominator for this bug?

I think that would be the best thing to do in this case.
Comment 47 Alex Freidin CLA 2011-01-13 11:16:29 EST
+1
I'll update the patch.
Comment 48 Alex Freidin CLA 2011-01-25 05:13:44 EST
Created attachment 187502 [details]
Displays workspace root as absolute path

This patch leaves the display of the includes as is, but fixes the display of include path defined as workspace root. The path is displayed as absolute path with a purple icon.
Added missing getStyledText() as this is what is called in CDT 7. The super class is using the StyledCellLabelProvider.styleDecoratedString(), which I'm not familiar with, so just added Strings.markLTR() for BiDi support. 
Added decorateText() calls like in the getText() of the super class.
Comment 50 Andrew Gvozdev CLA 2011-01-25 11:23:21 EST
Applied on HEAD (8.0), thanks. Is the patch intended for 7.0.X? It does not apply cleanly there.
Comment 51 Alex Freidin CLA 2011-01-26 03:06:45 EST
The patch is for HEAD. Thanks for applying.
Comment 52 Alex Freidin CLA 2011-03-01 10:10:50 EST
The ${workspace_loc} is now displayed correctly. For the rest of this discussion, I opened bug 338543. Marking as Fixed.