Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] ITranslanUnits/IASTTranslationUnits from ICProject

Doug,
 
From your response, here is what I came up with:
 
 private List<ITranslationUnit> GetTranslationUnitsForProject(ICProject iCProject)
 {
  final List<ITranslationUnit> translationUnits = new ArrayList<ITranslationUnit>(); 
  
  try
  {
   iCProject.getCModel().accept(new ICElementVisitor()
   {
    
    @Override
    public boolean visit(ICElement element) throws CoreException
    {
     if (element instanceof ICContainer)
     {
        ICContainer container = (ICContainer) element;
      
        translationUnits.addAll(Arrays.asList(container.getTranslationUnits()));
     }
     
     return true;
    }
   });
  }
  catch (CoreException e)
  {   e.printStackTrace(); }
  
  
  return translationUnits;
 }
The problem is that with my very large project this takes a while.  Is this the most optimal way of getting the ITranslationUnits for a given project?
 
Thanks,
 
Chris
On Mon, May 9, 2011 at 10:58 AM, Schaefer, Doug <Doug.Schaefer@xxxxxxxxxxxxx> wrote:

CDOM was deprecated since we have better ways of getting the same information. The best place to start is with the CModel starting at ICProject, going through the ICContainers to find the ITranslationUnits and then from there get the AST.

 

Been a while since I worked in that area, though. Do others have other approaches?

 

Doug

 

From: cdt-dev-bounces@xxxxxxxxxxx [mailto:cdt-dev-bounces@xxxxxxxxxxx] On Behalf Of Christopher Andrews
Sent: Monday, May 09, 2011 8:47 AM
To: CDT General developers list.
Subject: [cdt-dev] ITranslanUnits/IASTTranslationUnits from ICProject

 

Given and ICProject, what is the best way to get all of the ITranslanUnits/IASTTranslationUnits for all files contained in the project? Most of the examples I see are from CDT 3.0 and I also noticed that the CDOM class was deprecated.

Thanks,


--
Chris


_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/cdt-dev




--
Chris Andrews

Back to the top