Skip to main content

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

IndexUI.getTranslationUnit(ICProject, IASTName) predated IASTTranslationUnit.getOriginatingTranslationUnit(). I've changed it to use IASTTranslationUnit.getOriginatingTranslationUnit() (https://git.eclipse.org/r/#/c/63666/).

-sergey

On Tue, Jan 5, 2016 at 11:57 PM, Nathan Ridge <zeratul976@xxxxxxxxxxx> wrote:
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

_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/cdt-dev


Back to the top