}
}
private void addPath(IPath path, List<IBuildpathEntry> entries) {
// find parent
IBuildpathEntry parent = null;
int parentLength = 0;
IPath entryPath;
for (IBuildpathEntry entry : entries) {
entryPath = entry.getPath();
if (entryPath.isPrefixOf(path)
&& (parent == null || (entryPath.toString().length() > parentLength))) {
parent = entry;
parentLength = parent.getPath().toString().length();
}
}
// add path as exclusion to found parent
if (parent != null) {
List<IPath> exclusions = new ArrayList<IPath>();
exclusions.addAll(Arrays.asList(parent.getExclusionPatterns()));
IPath diff = path.removeFirstSegments(path.matchingFirstSegments(parent.getPath()));
if (parent.getPath().equals(composerPath)) {
diff = diff.uptoSegment(1);
}
diff = diff.removeTrailingSeparator().addTrailingSeparator();
if (!exclusions.contains(diff)) {
exclusions.add(diff);
}
entries.remove(parent);
parent = DLTKCore.newSourceEntry(parent.getPath(), exclusions.toArray(new IPath[]{}));
entries.add(parent);
}
// add own entry
// leave vendor/composer untouched with exclusions