Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-dev] Linked Resource Bug with class CSearchResultPage

CDT Devs,

I think I found an issue with the CSearchResultPage class that is making it
troublesome for us to navigate throughout our source code (all of which is
in linked resources).  The method I believe is causing the problem is
below:

private IFile getCanonicalFile(IFile originalFile){

      if (originalFile == null)
            return null;

      File tempFile = originalFile.getRawLocation().toFile();
      String canonicalPath = null;
      try {
            canonicalPath = tempFile.getCanonicalPath();
      } catch (IOException e1) {}

      if (canonicalPath != null && (!(originalFile.isLinked()))){
            IPath path = new Path(canonicalPath);
            originalFile =
CUIPlugin.getWorkspace().getRoot().getFileForLocation(path);
      }
      return originalFile;
}

In my case, the search result is a child of a linked resource.  I can get
the result, but if I double-click it (to open it), an exception occurs.
The cause of the exception is that this method returns null.  Specifically,
"getFileForLocation(path)" returns null because the "path" is the child of
a linked resource (this is documented behavior in the javaDoc).  Perhaps
this should be replaced with "findFilesForLocation(path)", and return the
first match?

Note that "isLinked()" returns false for this result because it is the
child of a linked resource, not the linked resource itself.  Maybe we
shouldn't even be entering this if-statement...

I wanted to try to fix this myself, but come to realize I do not have
access to the CVS repository from behind my company's firewall.  Is there
an alternate way to get the CDT projects?

Chad Barnes
Rockwell Collins Inc.



Back to the top