[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] Finding include dependencies.


Thanks for the quick response. Given a file I need to know what other files are including it. I think the code below gives the include paths so it will not give me what I want.
--
neeraj


cdt-dev-bounces@xxxxxxxxxxx wrote on 06/08/2006 08:43:49 PM:

> Well here it is anyway.
> Assuming you want to find the include paths for a given resource (I start
> from the project)...
> Here is some code adapted from what I wrote to figure out how to navigate
> the MBS info and find (and change) the include paths.
> If it's not a Managed Build System project, I'm sure there's a similar way.
> (This will probably get the formatting all garbled by the email, my
> apologies in advance.)
>
> IResource resource= ... ;// can be any resource, I use project.
> IManagedBuildInfo mbo = ManagedBuildManager.getBuildInfo(resource);
> IManagedProject mp=mbo.getManagedProject();
> showOptions(mp);
>
>
> /**
>        * Print the options for a project.<br>
>        * e.g. for Debug and Release configurations, get all the tools
> (compiler, linker etc.) then for each tool,
>        * get all the options and print them.
>        * <br>
>        * This helps in figuring out what they are, and what you want to
> change.
>        *
>        * @param proj the (managed) project for which print all this stuff.
>        */
>       private void showOptions(IManagedProject proj) {
>             System.out.println("Managed Project: "+proj.getName());
>             IConfiguration[] configs = proj.getConfigurations();
>             try {
>                   for (int i = 0; i < configs.length; i++) {
>                         IConfiguration cf = configs[i];
>                         ITool[] allTools = cf.getTools();
>
>                         int numTools = allTools.length;
>                         System.out.println("Config " + i + ": " +
> cf.getName()+ " has "+numTools+" tools.");
>
>                         for (int k = 0; k < allTools.length; k++) {
>                               ITool tool = allTools[k];
>                               System.out.println("  Tool " + k + ": " +
> tool.getName());
>                               IOption[] options = tool.getOptions();
>
>                               for (int j = 0; j < options.length; j++) {
>                                     IOption opt = options[j];
>                                     String foundOptionID = opt.getId();
>                                     System.out.println("    option " + j +
> " " + opt.getName() + " id="
>                                                 + foundOptionID);
>                                     if(opt.getValueType()==IOption.
> INCLUDE_PATH) {
>                                           showIncludePaths(opt);
>                                     }
>                               }
>                         }
>
>                         System.out.println("Config " + i + ": " +
> cf.getName()
>                                     + "======= End of ALL tools ");
>
>                         // another way to access Tool
>                         String ext = "c";
>                         ITool cfTool = cf.getToolFromInputExtension(ext);
>                         System.out.println("Tool by ext: " + ext + " is: "
> + cfTool.getName());
>
>                         // Look for include path when we know the option ID
>                         String optID =
> "gnu.c.compiler.option.include.paths";
>                         IOption option = cfTool.getOptionById(optID);
>                         System.out.println("Option " + optID + " is " +
> option.getName());
>
>                         IOption[] options = cfTool.getOptions();
>                         for (int j = 0; j < options.length; j++) {
>                               IOption opt = options[j];
>                               String foundOptionID = opt.getId();
>                               System.out.println("  option " + j + " " +
> opt.getName() + " id="
>                                           + foundOptionID);
>                               if(opt.getValueType()==IOption.INCLUDE_PATH)
> {
>                                     showIncludePaths(opt);
>                               }
>                         }
>                   }
>             } catch (Exception e) {
>                   e.printStackTrace();
>             }
>
>       }
>
>       /**
>        * Display the list of include paths in an option which is presumed
>        * to be the include paths option.
>        * @param opt
>        * @throws BuildException
>        */
>       private void showIncludePaths(IOption opt) throws BuildException {
>             Assert.isTrue(opt.getValueType() == IOption.INCLUDE_PATH);
>             // if the option is a list of include paths, display them.
>             String[] includePaths = opt.getIncludePaths();
>             for (int index = 0; index < includePaths.length; index++) {
>                   String path = includePaths[index];
>                   System.out.println("   include path " + index + ": " +
> path);
>             }
>
>       }
>
> ...Beth
>
> Beth Tibbitts  (859) 243-4981  (TL 545-4981)
> IBM T.J.Watson Research Center
> Mailing Address:  IBM Corp., 455 Park Place, Lexington, KY 40511
>
>
>                                                                            
>              Beth                                                          
>              Tibbitts/Watson/I                                            
>              BM@IBMUS                                                   To
>              Sent by:                  "CDT General developers list."      
>              cdt-dev-bounces@e         <cdt-dev@xxxxxxxxxxx>              
>              clipse.org                                                 cc
>                                                                            
>                                                                    Subject
>              06/08/2006 10:47          Re: [cdt-dev] Finding include      
>              AM                        dependencies.                      
>                                                                            
>                                                                            
>              Please respond to                                            
>                "CDT General                                                
>              developers list."                                            
>              <cdt-dev@eclipse.                                            
>                    org>                                                    
>                                                                            
>                                                                            
>
>
>
>
> If you mean walking the build info to find the includes,
> I recently figured out how to do that, I used Search before, too, and
> that's gone now.
> Confirm that's what you need, and I'll include some sample code.
>
>
> ...Beth
>
> Beth Tibbitts  (859) 243-4981  (TL 545-4981)
> IBM T.J.Watson Research Center
> Mailing Address:  IBM Corp., 455 Park Place, Lexington, KY 40511
>
>
>
>              Neeraj U Bhope
>              <neerajbhope@xxxx
>              bm.com>                                                    To
>              Sent by:                  cdt-dev@xxxxxxxxxxx
>              cdt-dev-bounces@e                                          cc
>              clipse.org
>                                                                    Subject
>                                        [cdt-dev] Finding include
>              06/08/2006 10:09          dependencies.
>              AM
>
>
>              Please respond to
>                "CDT General
>              developers list."
>              <cdt-dev@eclipse.
>                    org>
>
>
>
>
>
>
>
> In the earlier search functionality there was a way to search for include
> dependencies.
> One could do something like the following (extracted from erstwhile class
> org.eclipse.cdt.internal.core.sourcedependency.UpdateDependency)
>
> CSearchPattern.createPattern(location.toOSString(),ICSearchConstants.INCLUDE,
>
>  ICSearchConstants.REFERENCES,ICSearchConstants.EXACT_MATCH, true);
>
>
> What would be the new equivalent on the PDOM infrastructure?
> --
> neeraj_______________________________________________
> cdt-dev mailing list
> cdt-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/cdt-dev
>
>
> _______________________________________________
> cdt-dev mailing list
> cdt-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/cdt-dev
>
>
> _______________________________________________
> cdt-dev mailing list
> cdt-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/cdt-dev