Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-dev] Unable to programatically add to CDT References

Hi,

I am trying to add References for a CDT project. I am trying to add the references programmatically to both Project References and C/C++ General - > Paths and Symbols -> References. However the references are not getting updated in Paths and Symbols -> References. Below is the code for the same. Do let me know what i am doing wrong.

private void setProjectDependencies(IWorkspaceRoot root, IProject project, 
    IProjectDescription description) {
        try {
        Map <String, String> refMap = new HashMap<String, String>();
            IProject[] depProjects = new IProject[projDependencies.length]; // projDependencies is a String array of dependent project names
            for (int i=0; i< projDependencies.length; i++) {
                depProjects[i] = root.getProject(projDependencies[i]);
                refMap.put(projDependencies[i], ""); // Active Configuration
            }
            description.setReferencedProjects(depProjects);
            
            // Set in CDT's Paths and Symbols too       
            CoreModel coreModel = CoreModel.getDefault();
            ICProjectDescription desc = coreModel.getProjectDescription(project);
ICConfigurationDescription[] cDescriptions = desc.getConfigurations();
for (ICConfigurationDescription cfgDesc : cDescriptions) {
cfgDesc.setReferenceInfo(refMap);
}
project.setDescription(description, null);
        } catch (CoreException e) {
           // TODO: Throw error
        }  
    }

Thanks in advance.

Regards,
Anitha

Back to the top