Skip to content

Commit

Permalink
ClasspathComputer: support updating source attachment
Browse files Browse the repository at this point in the history
without changing unrelated attributes
  • Loading branch information
haubi committed Mar 13, 2023
1 parent bc5adc4 commit 5364d35
Showing 1 changed file with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -249,13 +249,19 @@ private static void addLibraryEntry(IProject project, IPluginLibrary library, IP
IPackageFragmentRoot root = JavaCore.create(project).getPackageFragmentRoot(jarFile);
if (root.exists() && root.getKind() == IPackageFragmentRoot.K_BINARY) {
IClasspathEntry oldEntry = root.getRawClasspathEntry();
// If we have the same binary root but new or different source, we should recreate the entry
if ((sourceAttachment == null && oldEntry.getSourceAttachmentPath() != null) || (sourceAttachment != null && sourceAttachment.equals(oldEntry.getSourceAttachmentPath()))) {
if (paths.add(oldEntry.getPath())) {
result.add(oldEntry);
return;
// If we have the same binary root but new or different source,
// we should recreate the entry, preserving unrelated attributes.
if (sourceAttachment != null && !sourceAttachment.equals(oldEntry.getSourceAttachmentPath())) {
if (paths.remove(oldEntry.getPath())) {
result.remove(oldEntry);
}
oldEntry = createClasspathEntry(project, jarFile, name, sourceAttachment, oldEntry.getExtraAttributes(),
oldEntry.isExported());
}
if (paths.add(oldEntry.getPath())) {
result.add(oldEntry);
}
return;
}

if (paths.add(jarFile.getFullPath())) {
Expand Down

0 comments on commit 5364d35

Please sign in to comment.