Bug 107313 - SourceLocation doesn't take into account linux file system links
Summary: SourceLocation doesn't take into account linux file system links
Status: RESOLVED WONTFIX
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 1.5.0 M4   Edit
Assignee: Adrian Colyer CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 82341
  Show dependency tree
 
Reported: 2005-08-18 05:41 EDT by Helen Beeken CLA
Modified: 2005-09-02 07:08 EDT (History)
0 users

See Also:


Attachments
sample workspace to recreate the problem (38.85 KB, application/octet-stream)
2005-08-18 05:44 EDT, Helen Beeken CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Helen Beeken CLA 2005-08-18 05:41:23 EDT
This has arisen from investigation into AJDT bug 82341 (in particular comment #7
and comment #13) which found that the SourceLocation.getSystemFile().getPath()
call returns the physical location of the file, rather than including the file
system link.


To reproduce, have the following file setup:

...../workspace/bla
...../workspace/foo ---> bla

where bla is a directory and foo is a file system link to bla, and you set your
workspace to be foo, then the results of
SourceLocation.getSystemFile().getPath() for some file in bla contains

..../workspace/bla/

rather than

..../workspace/foo

This is a problem for AJDT because when populating the problems view we try to
find the resource using a given string (which is the path to the resource) and
the project (in
org.eclipse.ajdt.internal.ui.ajde.ProjectProperties.findResource(String,
IProject)). We call this with the path calculated from the ISourceLocation (in
org.eclipse.ajdt.internal.ui.ajde.CompilerTaskListManager.locationToResource(..)).
 We then ask the given project to find its member with this path. However, the
project returns a location of ..../workspace/foo and consequently we cant find
it. This leads to incorrect messages in the problems view.
Comment 1 Helen Beeken CLA 2005-08-18 05:44:41 EDT
Created attachment 26222 [details]
sample workspace to recreate the problem

Use this workspace within AJDT and you will see that the problems view doesn't
populate correctly - this is the symptoms from AJDT's point of view.
Comment 2 Adrian Colyer CLA 2005-09-02 03:35:19 EDT
I spent a couple of hours investigating this last night, as a result of which I almost closed this bug 
"WONTFIX" - but I won't do that quite yet. The compiler canonicalizes filenames very early on, and then 
works with canonical filenames througout. I built a "user file name translation map" that mapped a 
canonical file back to the file name that was originally supplied to the compiler, and a "translating 
message handler" that would look at source locations for messages and restore source file names to the 
variant provided by the user. It works, but the results are unpleasant in many situations (you end up 
with locations like  "examples/../examples/x/y/z.java"). Especially when using .lst files which contain 
file references relative to their own location, it can be just a mess. 

I've pretty much concluded that working with canonicalized file names throughout is indeed the right 
thing to do for the command-line compiler. 

So.... what prevents AJDT from following the same scheme that I was using, only AJDT has extra 
knowledge that the compiler can't have that makes it much easier. I'm imagining an algorithm like the 
following:

* try to find the resource as normal today
* if that fails, compute (if you haven't already) a map from project directory to canonical file name (just 
get a File for the project dir, and call getCanonicalFile ). Now see if the source location in the message 
starts with any of these canonical prefixes, and if it does, you have your match
* if that fails, it could be sym-links within the project structure itself. Drive "find resource/type" using 
just the unqualified file name - that will give zero or more matches (hopefully 1 or more). Get the file 
for each and canonicalize it, the one that matches is your resource...

unless there is a compelling reason that AJDT can't do this, I'm going to close out this request against 
the compiler.
Comment 3 Helen Beeken CLA 2005-09-02 03:58:59 EDT
Hi Adrian,

Yes, that sounds reasonable. If it makes no sense from a compiler's point of
view, then it's up to AJDT to do the right thing. Thanks for the suggested
algorithm, I'll start implementing that in AJDT.

Please feel free to close this bug against the compiler.

Thanks, Helen
Comment 4 Adrian Colyer CLA 2005-09-02 07:08:17 EDT
closing bug as per discussion in this thread. if it proves impossible to do the right thing in AJDT then we 
can reopen and take another look...