Bug 521226 - Indexer chooses wrong file when included file is symlinked in another folder
Summary: Indexer chooses wrong file when included file is symlinked in another folder
Status: NEW
Alias: None
Product: CDT
Classification: Tools
Component: cdt-indexer (show other bugs)
Version: 9.3.0   Edit
Hardware: PC Linux
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact: Jonah Graham CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-08-22 04:28 EDT by Bing-Yi Wong CLA
Modified: 2020-09-04 15:21 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Bing-Yi Wong CLA 2017-08-22 04:28:08 EDT
Given this tree structure:


include/
  helloWorld.h  -> symlink to src/helloWorld.h
src/
  helloWorld.h
src2/
  helloWorld.cpp


and content:

helloWorld.h
============
#ifndef HELLOWORLD_H_
#define HELLOWORLD_H_

inline void foo() {}

#endif /* HELLOWORLD_H_ */


helloWorld.cpp
==============
#include "../src/helloWorld.h"

int main() {
    foo();
    return 0;
}


and then "Open declaration" on foo() in helloWorld.cpp.

Now, Eclipse goes to include/helloWorld.h, which is incorrect.  **BUG 1

Eclipse should follow the symlink and open src/helloWorld.h even if helloWorld.cpp #include "../include/helloWorld.h", but that is not current behavior, too.  **BUG 2

And now, we are at include/helloWorld.h, try "Open call hierarchy" on foo().  Eclipse reports: The file 'helloWorld.h' is currently not part of the index.  **BUG 3
Comment 1 Bing-Yi Wong CLA 2017-08-22 12:11:40 EDT
Why I think Bug-2 is important is because it makes Perforce plugin (p4eclipse) difficult to use.  If it is the symlink we open, not the real file, p4eclipse will mark edited on the symlink, but since a symlink cannot have code change, we will fail to check in the code change.
Comment 2 Nathan Ridge CLA 2017-09-22 17:51:31 EDT
(In reply to Bing-Yi Wong from comment #0)
> Now, Eclipse goes to include/helloWorld.h, which is incorrect.  **BUG 1

I agree that this is a bug.

> Eclipse should follow the symlink and open src/helloWorld.h even if
> helloWorld.cpp #include "../include/helloWorld.h", but that is not current
> behavior, too.  **BUG 2

For me, it opens src/helloWorld.h when opening an include of either form. However, it's possible that the behaviour here is not deterministic.

> And now, we are at include/helloWorld.h, try "Open call hierarchy" on foo().
> Eclipse reports: The file 'helloWorld.h' is currently not part of the index.
> **BUG 3

This can be worked around by checking Preferences -> C/C++ -> Indexer -> Index unused headers.

(In reply to Bing-Yi Wong from comment #1)
> If it is the symlink we open, not the real
> file, p4eclipse will mark edited on the symlink, but since a symlink cannot
> have code change, we will fail to check in the code change.

This sounds like a bug in p4eclipse.