Search in sources :

Example 1 with ICLanguageSettingEntry

use of org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry 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);
            }
        }
    }
}
Also used : ICFolderDescription(org.eclipse.cdt.core.settings.model.ICFolderDescription) ICLanguageSettingEntry(org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry) CIncludePathEntry(org.eclipse.cdt.core.settings.model.CIncludePathEntry) ICLanguageSetting(org.eclipse.cdt.core.settings.model.ICLanguageSetting)

Example 2 with ICLanguageSettingEntry

use of org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry 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);
    }
}
Also used : NarLib(com.github.sdedwards.m2e_nar.internal.model.NarLib) ICLibraryPathEntry(org.eclipse.cdt.core.settings.model.ICLibraryPathEntry) ICLanguageSettingEntry(org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry) ArrayList(java.util.ArrayList) ICLanguageSetting(org.eclipse.cdt.core.settings.model.ICLanguageSetting)

Example 3 with ICLanguageSettingEntry

use of org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry 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;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) ICFolderDescription(org.eclipse.cdt.core.settings.model.ICFolderDescription) ICLanguageSettingEntry(org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry) IPath(org.eclipse.core.runtime.IPath) CIncludePathEntry(org.eclipse.cdt.core.settings.model.CIncludePathEntry) ICLanguageSetting(org.eclipse.cdt.core.settings.model.ICLanguageSetting)

Example 4 with ICLanguageSettingEntry

use of org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry 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);
    }
}
Also used : ICLanguageSettingEntry(org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry) ICIncludePathEntry(org.eclipse.cdt.core.settings.model.ICIncludePathEntry) ArrayList(java.util.ArrayList) File(java.io.File) ICLanguageSetting(org.eclipse.cdt.core.settings.model.ICLanguageSetting)

Example 5 with ICLanguageSettingEntry

use of org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry 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);
    }
}
Also used : ICLanguageSettingEntry(org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry) ArrayList(java.util.ArrayList) ICMacroEntry(org.eclipse.cdt.core.settings.model.ICMacroEntry) ICLanguageSetting(org.eclipse.cdt.core.settings.model.ICLanguageSetting)

Aggregations

ICLanguageSetting (org.eclipse.cdt.core.settings.model.ICLanguageSetting)6 ICLanguageSettingEntry (org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry)6 ArrayList (java.util.ArrayList)4 NarLib (com.github.sdedwards.m2e_nar.internal.model.NarLib)2 CIncludePathEntry (org.eclipse.cdt.core.settings.model.CIncludePathEntry)2 ICFolderDescription (org.eclipse.cdt.core.settings.model.ICFolderDescription)2 NarSysLib (com.github.sdedwards.m2e_nar.internal.model.NarSysLib)1 File (java.io.File)1 ICIncludePathEntry (org.eclipse.cdt.core.settings.model.ICIncludePathEntry)1 ICLibraryFileEntry (org.eclipse.cdt.core.settings.model.ICLibraryFileEntry)1 ICLibraryPathEntry (org.eclipse.cdt.core.settings.model.ICLibraryPathEntry)1 ICMacroEntry (org.eclipse.cdt.core.settings.model.ICMacroEntry)1 IPath (org.eclipse.core.runtime.IPath)1 IStatus (org.eclipse.core.runtime.IStatus)1 Status (org.eclipse.core.runtime.Status)1