use of org.eclipse.cdt.core.settings.model.ICSourceEntry in project arduino-eclipse-plugin by Sloeber.
the class Libraries method addLibrariesToProject.
/**
* Adds one or more libraries to a project in a configuration
*
* @param project
* the project to add the libraries to
* @param confdesc
* the confdesc of the project
* @param libraries
* the list of libraries to add
* @return true if the configuration description has changed
*/
private static void addLibrariesToProject(IProject project, ICConfigurationDescription confdesc, Map<String, IPath> libraries) {
List<IPath> foldersToRemoveFromBuildPath = new LinkedList<>();
for (Entry<String, IPath> CurItem : libraries.entrySet()) {
try {
Helpers.addCodeFolder(project, CurItem.getValue(), WORKSPACE_LIB_FOLDER + CurItem.getKey(), confdesc, false);
} catch (CoreException e) {
Common.log(new Status(IStatus.ERROR, Const.CORE_PLUGIN_ID, Messages.import_lib_failed, e));
}
// Check the libraries to see if there are "unwanted subfolders"
File[] subFolders = CurItem.getValue().toFile().listFiles();
for (File file : subFolders) {
if (// $NON-NLS-1$ //$NON-NLS-2$
file.isDirectory() && !"src".equals(file.getName()) && !"utility".equals(file.getName()) && !"examples".equalsIgnoreCase(file.getName())) {
// $NON-NLS-1$
IPath excludePath = // $NON-NLS-1$
new Path("/" + project.getName()).append(WORKSPACE_LIB_FOLDER).append(CurItem.getKey()).append(file.getName());
foldersToRemoveFromBuildPath.add(excludePath);
}
}
}
if (!foldersToRemoveFromBuildPath.isEmpty()) {
ICResourceDescription cfgd = confdesc.getResourceDescription(new Path(new String()), true);
ICSourceEntry[] sourceEntries = cfgd.getConfiguration().getSourceEntries();
for (IPath curFile : foldersToRemoveFromBuildPath) {
try {
sourceEntries = CDataUtil.setExcluded(curFile, true, true, sourceEntries);
} catch (CoreException e1) {
// ignore
}
}
try {
cfgd.getConfiguration().setSourceEntries(sourceEntries);
} catch (Exception e) {
// ignore
}
}
}
use of org.eclipse.cdt.core.settings.model.ICSourceEntry in project usbdm-eclipse-plugins by podonoghue.
the class ProjectUtilities method createNewStyleProjectFolder.
/**
* @param monitor
* @param projectHandle
* @param folder
* @throws CoreException
* @throws WriteAccessException
*/
private static void createNewStyleProjectFolder(IProgressMonitor monitor, IProject projectHandle, IFolder folder) throws CoreException, WriteAccessException {
ICSourceEntry newEntry = new CSourceEntry(folder, null, 0);
ICProjectDescription description = CCorePlugin.getDefault().getProjectDescription(projectHandle);
ICConfigurationDescription[] configs = description.getConfigurations();
for (int i = 0; i < configs.length; i++) {
ICConfigurationDescription config = configs[i];
ICSourceEntry[] entries = config.getSourceEntries();
Set<ICSourceEntry> set = new HashSet<ICSourceEntry>();
for (int j = 0; j < entries.length; j++) {
if (new Path(entries[j].getValue()).segmentCount() == 1)
continue;
set.add(entries[j]);
}
set.add(newEntry);
config.setSourceEntries(set.toArray(new ICSourceEntry[set.size()]));
}
CCorePlugin.getDefault().setProjectDescription(projectHandle, description, false, monitor);
}
Aggregations