use of org.eclipse.cdt.core.settings.model.ICLanguageSetting 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.ICLanguageSetting in project m2e-nar by maven-nar.
the class AbstractSettingsSynchroniser method setLibraryPaths.
private void setLibraryPaths(final ICConfigurationDescription conf, final NarBuildArtifact settings) throws CoreException {
final ICLanguageSetting[] languageSettings = conf.getRootFolderDescription().getLanguageSettings();
final List<ICLibraryPathEntry> libraryPathEntries = new ArrayList<ICLibraryPathEntry>();
for (final NarLib lib : settings.getDependencyLibs()) {
ICLibraryPathEntry libraryPath = createLibraryPathEntry(lib.getDirectory().getPath(), 0);
libraryPathEntries.add(libraryPath);
}
for (final NarLib lib : settings.getLinkerSettings().getLibs()) {
ICLibraryPathEntry libraryPath = createLibraryPathEntry(lib.getDirectory().getPath(), 0);
libraryPathEntries.add(libraryPath);
}
for (final ICLanguageSetting setting : languageSettings) {
final List<ICLanguageSettingEntry> l = setting.getSettingEntriesList(ICSettingEntry.LIBRARY_PATH);
l.clear();
l.addAll(libraryPathEntries);
setting.setSettingEntries(ICSettingEntry.LIBRARY_PATH, l);
}
}
use of org.eclipse.cdt.core.settings.model.ICLanguageSetting 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;
}
use of org.eclipse.cdt.core.settings.model.ICLanguageSetting in project m2e-nar by maven-nar.
the class AbstractSettingsSynchroniser method setIncludes.
private void setIncludes(final ICConfigurationDescription conf, final NarBuildArtifact settings) throws CoreException {
final ICLanguageSetting[] languageSettings = conf.getRootFolderDescription().getLanguageSettings();
final List<ICIncludePathEntry> cIncludePathEntries = new ArrayList<ICIncludePathEntry>();
for (final String path : settings.getCSettings().getIncludePaths()) {
ICIncludePathEntry includePath = createIncludePathEntry(path, ICSettingEntry.LOCAL);
cIncludePathEntries.add(includePath);
}
for (final String path : settings.getCSettings().getSystemIncludePaths()) {
ICIncludePathEntry includePath = createIncludePathEntry(path, 0);
cIncludePathEntries.add(includePath);
}
final List<ICIncludePathEntry> cppIncludePathEntries = new ArrayList<ICIncludePathEntry>();
for (final String path : settings.getCppSettings().getIncludePaths()) {
ICIncludePathEntry includePath = createIncludePathEntry(path, ICSettingEntry.LOCAL);
cppIncludePathEntries.add(includePath);
}
for (final String path : settings.getCppSettings().getSystemIncludePaths()) {
ICIncludePathEntry includePath = createIncludePathEntry(path, 0);
cppIncludePathEntries.add(includePath);
}
final List<ICIncludePathEntry> commonIncludePathEntries = new ArrayList<ICIncludePathEntry>();
for (final String path : settings.getJavahIncludePaths()) {
ICIncludePathEntry includePath = createIncludePathEntry(path, ICSettingEntry.LOCAL);
commonIncludePathEntries.add(includePath);
}
for (final String path : settings.getJavaIncludePaths()) {
ICIncludePathEntry includePath = createIncludePathEntry(path, 0);
commonIncludePathEntries.add(includePath);
}
for (final File f : settings.getDependencyIncludePaths()) {
ICIncludePathEntry includePath = createIncludePathEntry(f.getPath(), 0);
commonIncludePathEntries.add(includePath);
}
for (ICLanguageSetting setting : languageSettings) {
final List<ICLanguageSettingEntry> l = setting.getSettingEntriesList(ICSettingEntry.INCLUDE_PATH);
l.clear();
l.addAll(commonIncludePathEntries);
if (cppLanguageId.equals(setting.getLanguageId())) {
l.addAll(cppIncludePathEntries);
} else if (cLanguageId.equals(setting.getLanguageId())) {
l.addAll(cIncludePathEntries);
}
setting.setSettingEntries(ICSettingEntry.INCLUDE_PATH, l);
}
}
use of org.eclipse.cdt.core.settings.model.ICLanguageSetting in project m2e-nar by maven-nar.
the class AbstractSettingsSynchroniser method setDefinedSymbols.
private void setDefinedSymbols(final ICConfigurationDescription conf, final NarBuildArtifact settings) throws CoreException {
final ICLanguageSetting[] languageSettings = conf.getRootFolderDescription().getLanguageSettings();
final List<ICMacroEntry> cMacroEntries = new ArrayList<ICMacroEntry>();
for (final String define : settings.getCSettings().getDefines()) {
final String escapedDefine = CdtUtils.escapeOption(define);
ICMacroEntry macroEntry = createMacroEntry(escapedDefine, 0);
cMacroEntries.add(macroEntry);
}
final List<ICMacroEntry> cppMacroEntries = new ArrayList<ICMacroEntry>();
for (final String define : settings.getCppSettings().getDefines()) {
final String escapedDefine = CdtUtils.escapeOption(define);
ICMacroEntry macroEntry = createMacroEntry(escapedDefine, 0);
cppMacroEntries.add(macroEntry);
}
for (ICLanguageSetting setting : languageSettings) {
final List<ICLanguageSettingEntry> l = setting.getSettingEntriesList(ICSettingEntry.MACRO);
l.clear();
if (cppLanguageId.equals(setting.getLanguageId())) {
l.addAll(cppMacroEntries);
} else if (cLanguageId.equals(setting.getLanguageId())) {
l.addAll(cMacroEntries);
}
setting.setSettingEntries(ICSettingEntry.MACRO, l);
}
}
Aggregations