Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean caches upon deletion of a Target Definition #1246 #1247

Merged
merged 1 commit into from
May 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
import org.eclipse.pde.internal.core.PDECore;
import org.eclipse.pde.internal.core.PDEPreferencesManager;
import org.eclipse.pde.internal.core.TargetDefinitionManager;
import org.eclipse.pde.internal.core.TargetPlatformHelper;
import org.osgi.service.prefs.BackingStoreException;

/**
Expand Down Expand Up @@ -156,6 +157,7 @@ public void deleteTarget(ITargetHandle handle) throws CoreException {
fExtTargetHandles.remove(((ExternalFileTargetHandle) handle).getLocation());
}
((AbstractTargetHandle) handle).delete();
TargetPlatformHelper.getTargetDefinitionMap().remove(handle);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,22 @@ public void testArguments() throws Exception {

}

/**
* Test for https://github.com/eclipse-pde/eclipse.pde/issues/1246
*/
@Test
public void testDeleteCleansCaches() throws Exception {
ITargetDefinition definition = getNewTarget();
try {
assertFalse(TargetPlatformHelper.getTargetDefinitionMap().containsKey(definition.getHandle()));
definition.resolve(null);
assertTrue(TargetPlatformHelper.getTargetDefinitionMap().containsKey(definition.getHandle()));
} finally {
getTargetService().deleteTarget(definition.getHandle());
assertFalse(TargetPlatformHelper.getTargetDefinitionMap().containsKey(definition.getHandle()));
}
}

/**
* Tests that a single (lower) version of a bundle can be included in the
* target platform.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -744,9 +744,6 @@ private void handleRemove() {
}
fRemoved.addAll(selected);
fTargets.removeAll(selected);
for (ITargetDefinition element : selected) {
TargetPlatformHelper.getTargetDefinitionMap().remove(element.getHandle());
}
// Quick hack because the first refresh loses the checkedState, which is being used to bold the active target
fTableViewer.refresh(false);
fTableViewer.refresh(true);
Expand Down
Loading