protected void ensureRemoveElementInList(List cp, ClasspathElement element) { IClasspathEntry[] cpEntries = element.newClasspathEntries(); if (cpEntries == null || cpEntries.length == 0) return; for (int i = 0; i < cpEntries.length; i++) { if (cp.contains(cpEntries[i])) { int index = getIndex(cp, cpEntries[i]); if (index != -1) cp.remove(index); } } }
protected void ensureElementNotInList(List cp, ClasspathElement element) { IClasspathEntry[] cpEntries = element.newClasspathEntries(); if (cpEntries == null || cpEntries.length == 0) return; for (int i = 0; i < cpEntries.length; i++) { if (allClasspathEntries.contains(cpEntries[i])) // This may be included indirectly by a transitive dependency continue; int index = getIndex(cp, cpEntries[i]); if (index != -1) cp.remove(index); } }
int predecessorPos = predecessor == null ? -1 : getIndex(cp, predecessor); addedEntry = cpEntries[0]; int pos = getIndex(cp, addedEntry); if (pos == -1) { if (predecessorPos == -1) int index = getIndex(cp, cpEntries[i]); if (index != -1) { addedEntry = (IClasspathEntry) cp.get(index); } else addedEntry = cpEntries[i]; pos = getIndex(cp, cpEntries[0]); cp.add(pos + 1, addedEntry);
protected void ensureClasspathEntryIsExported(List cp, IClasspathEntry entry) { if (entry.isExported()) return; int index = getIndex(cp, entry); IClasspathEntry newEntry = null; switch (entry.getEntryKind()) { case IClasspathEntry.CPE_PROJECT : newEntry = JavaCore.newProjectEntry(entry.getPath(), true); break; case IClasspathEntry.CPE_LIBRARY : newEntry = JavaCore.newLibraryEntry(entry.getPath(), entry.getSourceAttachmentPath(), entry.getSourceAttachmentRootPath(), true); break; case IClasspathEntry.CPE_VARIABLE : newEntry = JavaCore.newVariableEntry(entry.getPath(), entry.getSourceAttachmentPath(), entry.getSourceAttachmentRootPath()); default : break; } if (entry != null) cp.set(index, newEntry); }