Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-dev] IndexUI.getTranslationUnit(ICProject, IASTName)

We have a helper function IndexUI.getTranslationUnit(ICProject, IASTName), which given an IASTName, returns the ITranslationUnit representing the translation unit that contains the name. 

Its implementation does roughly the following:
  - gets an IASTFileLocation from the name
  - gets an IPath from the file location
  - uses ResourceLookupTree.findFilesForLocation() to find all IFile resources that match the path
  - uses some "relevance" metrics to pick a particular IFile from the list
  - looks up or creates the ITranslationUnit for the selected IFile

This seems very roundabout, as the IASTName is contained inside an AST, which was created for a particular ITranslationUnit (accessible via IASTTranslationUnit.getOriginatingTranslationUnit()). Is the originating translation unit not always the one we want?

Thanks,
Nate
 		 	   		  

Back to the top