Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] Programmatically adding additional include paths for indexer

Hey Richard, does it work if you add the paths in the UI? Does a project Reindex help?


From: <cdt-dev-bounces@xxxxxxxxxxx> on behalf of "Memory, Richard" <Richard_Memory@xxxxxxxxxx>
Reply-To: "CDT General developers list." <cdt-dev@xxxxxxxxxxx>
Date: Friday, March 24, 2017 at 8:00 PM
To: "cdt-dev@xxxxxxxxxxx" <cdt-dev@xxxxxxxxxxx>
Subject: [cdt-dev] Programmatically adding additional include paths for indexer

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.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);



Back to the top