Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-dev] CTags indexer cannot process linked source folders

When working with a standard make C++ project which contained only
linked source folders I found that the CTags indexer produced an index
file which was empty except for a few header lines. I investigated and
found that it's not surprising. Indexing is started in 
 
org.eclipse.cdt.internal.core.index.ctagsindexer.CTagsIndexAll.execute(I
ProgressMonitor)
 
which, to get a full index, calls 
 
  //run CTags over project
  success = runCTags(project.getLocation());
 
which in turn start the ctags utility from the project's base directory,
telling it to recurse into all subfolders.
ctags of course is an external process which knows nothing about
eclipse's linked resource concept and will therefore not pick up the
linked folders.
 
So in order to make things better runCTags() should be called for every
source folder in the project. I made a fix which worked for me like
this:
 
 try {
  ICProject cproject = CModelManager.getDefault().create(project);
  ISourceRoot[] sourceRoots = cproject.getAllSourceRoots();
  success = true ;
  for (int i = 0; i < sourceRoots.length; i++) {
   ISourceRoot sourceRoot = sourceRoots[i];
   success = runCTags(sourceRoot.getPath());
  }
  ctagsFileToUse=ctagsFile;
 } catch (CModelException e) {
  success = false ;
 }
 
Open question at the moment: Will this als work for "simple" projects
which contain some source files in the project base directory, others in
folders. Will the files in the base directory be indexed?
 
I would like to put this up to discussion, do some more testing and, if
there are no objections, submit the patches.

Note that I have created
https://bugs.eclipse.org/bugs/show_bug.cgi?id=117847 to track the
discussion.

Comments?


Norbert


Back to the top