Search in sources :

Example 1 with IIndexInclude

use of org.eclipse.cdt.core.index.IIndexInclude in project arduino-eclipse-plugin by Sloeber.

the class Libraries method getUnresolvedProjectIncludes.

private static Set<String> getUnresolvedProjectIncludes(IProject iProject) {
    Set<String> ret = new TreeSet<>();
    ICProject tt = CoreModel.getDefault().create(iProject);
    IIndex index = null;
    try {
        index = CCorePlugin.getIndexManager().getIndex(tt);
        index.acquireReadLock();
        try {
            IIndexFile[] allFiles = index.getFilesWithUnresolvedIncludes();
            for (IIndexFile curUnesolvedIncludeFile : allFiles) {
                IIndexInclude[] includes = curUnesolvedIncludeFile.getIncludes();
                for (IIndexInclude curinclude : includes) {
                    if (curinclude.isActive() && !curinclude.isResolved()) {
                        ret.add(new Path(curinclude.getName()).removeFileExtension().toString());
                    }
                }
            }
        } finally {
            index.releaseReadLock();
        }
    } catch (CoreException e1) {
        // ignore
        e1.printStackTrace();
    } catch (InterruptedException e) {
        // ignore
        e.printStackTrace();
    }
    return ret;
}
Also used : IIndex(org.eclipse.cdt.core.index.IIndex) IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) ICProject(org.eclipse.cdt.core.model.ICProject) CoreException(org.eclipse.core.runtime.CoreException) TreeSet(java.util.TreeSet) IIndexInclude(org.eclipse.cdt.core.index.IIndexInclude) IIndexFile(org.eclipse.cdt.core.index.IIndexFile)

Aggregations

TreeSet (java.util.TreeSet)1 IIndex (org.eclipse.cdt.core.index.IIndex)1 IIndexFile (org.eclipse.cdt.core.index.IIndexFile)1 IIndexInclude (org.eclipse.cdt.core.index.IIndexInclude)1 ICProject (org.eclipse.cdt.core.model.ICProject)1 CoreException (org.eclipse.core.runtime.CoreException)1 IPath (org.eclipse.core.runtime.IPath)1 Path (org.eclipse.core.runtime.Path)1