Hey Richard, does it work if you add the paths in the UI? Does a project Reindex help?
Doug.
Hi All,
I am attempting to programmatically add additional header files paths to a project. Ideally I'd like the added paths to appear in the UI (i.e. properties->C/C++ General->Paths and Symbols->Includes), but even if not, at least I'd like to make the indexer
happy. Without the additional paths, it currently shows the "Unresolved inclusion" marker.
Here is the code I am using at the moment, which I found from a post a few years ago which seems to be happy, but so far the indexer is still showing the same marker.
IPath someHeaderFilePath = new Path("/some/absolute/path");
IPath someOtherHeaderFilePath = new Path("/some/other/workspaceRelative/path");
ICProjectDescription projectDescription = CoreModel.getDefault().getProjectDescription(getProject(), true);
ICConfigurationDescription configDecriptions[] = projectDescription.getConfigurations();
for (ICConfigurationDescription configDescription : configDecriptions) {
ICFolderDescription projectRoot = configDescription.getRootFolderDescription();
ICLanguageSetting[] settings = projectRoot.getLanguageSettings();
for (ICLanguageSetting setting : settings) {
List<ICLanguageSettingEntry> includes = new ArrayList<ICLanguageSettingEntry>();
includes.addAll(setting.getSettingEntriesList(ICSettingEntry.INCLUDE_PATH));
includes.add(new CIncludePathEntry(someHeaderFilePath, ICSettingEntry.LOCAL));
includes.add(new CIncludePathEntry(someOtherHeaderFilePath, ICSettingEntry.LOCAL));
setting.setSettingEntries(ICSettingEntry.INCLUDE_PATH, includes);
// Set information to project description
ManagedBuildManager.saveBuildInfo(getProject(), true);
}
}
Thanks,
Richard