Skip to content

Commit

Permalink
feat: add a method to unload the currently loaded platform
Browse files Browse the repository at this point in the history
  • Loading branch information
ava-fred committed Jan 9, 2025
1 parent a41ab3a commit 7cd808c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1447,7 +1447,7 @@ protected void installSourceLevelURIs(final BuildData buildData) {
* the platform to test, may not be {@code null}.
*/
protected void updateBinaryStorageAvailability(final IXtextTargetPlatform platform) {
isBinaryModelStorageAvailable = platform.getBinaryModelStore() != null;
isBinaryModelStorageAvailable = platform != null && platform.getBinaryModelStore() != null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,17 @@ protected IXtextTargetPlatformFactory getPlatformFactory() {
return platformFactory;
}

@Override
public void unload() {
synchronized (this) {
if (platform != null) {
platform.close(new NullProgressMonitor());
}
platform = null;
}
notifyListeners(null, Collections.<IResourceDescription.Delta> emptyList(), false);
}

@Override
public synchronized IXtextTargetPlatform getPlatform() {
ensureLoaded();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ public interface IXtextTargetPlatformManager {
*/
IXtextTargetPlatform getPlatform();

/**
* Unloads the currently loaded platform, if any is currently loaded.
*/
void unload();

/**
* Add a listener for changes in target platform.
*
Expand Down

0 comments on commit 7cd808c

Please sign in to comment.