use of org.eclipse.cdt.core.settings.model.ICFolderDescription in project arduino-eclipse-plugin by Sloeber.
the class Helpers method addIncludeFolder.
/**
* This method is the internal working class that adds the provided include path
* to all configurations and languages.
*
* @param configurationDescription
* The configuration description of the project to add it to
* @param IncludePath
* The path to add to the include folders
* @see addLibraryDependency {@link #addLibraryDependency(IProject, IProject)}
*/
private static void addIncludeFolder(ICConfigurationDescription configurationDescription, IPath IncludePath) {
// find all languages
ICFolderDescription folderDescription = configurationDescription.getRootFolderDescription();
ICLanguageSetting[] languageSettings = folderDescription.getLanguageSettings();
// Add include path to all languages
for (int idx = 0; idx < languageSettings.length; idx++) {
ICLanguageSetting lang = languageSettings[idx];
String LangID = lang.getLanguageId();
if (LangID != null) {
if (LangID.startsWith("org.eclipse.cdt.")) {
ICLanguageSettingEntry[] OrgIncludeEntries = lang.getSettingEntries(ICSettingEntry.INCLUDE_PATH);
ICLanguageSettingEntry[] IncludeEntries = new ICLanguageSettingEntry[OrgIncludeEntries.length + 1];
System.arraycopy(OrgIncludeEntries, 0, IncludeEntries, 0, OrgIncludeEntries.length);
IncludeEntries[OrgIncludeEntries.length] = new CIncludePathEntry(IncludePath, // (location.toString());
ICSettingEntry.VALUE_WORKSPACE_PATH);
lang.setSettingEntries(ICSettingEntry.INCLUDE_PATH, IncludeEntries);
}
}
}
}
use of org.eclipse.cdt.core.settings.model.ICFolderDescription in project arduino-eclipse-plugin by Sloeber.
the class Helpers method removeInvalidIncludeFolders.
/**
* Removes include folders that are not valid. This method does not save the
* configurationDescription description
*
* @param configurationDescription
* the configuration that is checked
* @return true is a include path has been removed. False if the include path
* remains unchanged.
*/
public static boolean removeInvalidIncludeFolders(ICConfigurationDescription configurationDescription) {
// find all languages
ICFolderDescription folderDescription = configurationDescription.getRootFolderDescription();
ICLanguageSetting[] languageSettings = folderDescription.getLanguageSettings();
boolean hasChange = false;
// Add include path to all languages
for (int idx = 0; idx < languageSettings.length; idx++) {
ICLanguageSetting lang = languageSettings[idx];
String LangID = lang.getLanguageId();
if (LangID != null) {
if (LangID.startsWith("org.eclipse.cdt.")) {
ICLanguageSettingEntry[] OrgIncludeEntries = lang.getSettingEntries(ICSettingEntry.INCLUDE_PATH);
ICLanguageSettingEntry[] OrgIncludeEntriesFull = lang.getResolvedSettingEntries(ICSettingEntry.INCLUDE_PATH);
int copiedEntry = 0;
for (int curEntry = 0; curEntry < OrgIncludeEntries.length; curEntry++) {
IPath cusPath = ((CIncludePathEntry) OrgIncludeEntriesFull[curEntry]).getFullPath();
if ((ResourcesPlugin.getWorkspace().getRoot().exists(cusPath)) || (((CIncludePathEntry) OrgIncludeEntries[curEntry]).isBuiltIn())) {
OrgIncludeEntries[copiedEntry++] = OrgIncludeEntries[curEntry];
} else {
Common.log(new Status(IStatus.WARNING, Const.CORE_PLUGIN_ID, "Removed invalid include path" + cusPath, null));
}
}
if (// do not save
copiedEntry != OrgIncludeEntries.length) // if nothing
// has changed
{
ICLanguageSettingEntry[] IncludeEntries = new ICLanguageSettingEntry[copiedEntry];
System.arraycopy(OrgIncludeEntries, 0, IncludeEntries, 0, copiedEntry);
lang.setSettingEntries(ICSettingEntry.INCLUDE_PATH, IncludeEntries);
hasChange = true;
}
}
}
}
return hasChange;
}
Aggregations