use of com.intellij.openapi.roots.ModifiableModelsProvider in project ballerina by ballerina-lang.
the class BallerinaModuleLibrariesInitializer method removeLibraryIfNeeded.
private void removeLibraryIfNeeded() {
ApplicationManager.getApplication().assertIsDispatchThread();
ModifiableModelsProvider modelsProvider = ModifiableModelsProvider.SERVICE.getInstance();
ModifiableRootModel model = modelsProvider.getModuleModifiableModel(myModule);
LibraryOrderEntry ballerinaLibraryEntry = OrderEntryUtil.findLibraryOrderEntry(model, getLibraryName());
if (ballerinaLibraryEntry != null) {
ApplicationManager.getApplication().runWriteAction(() -> {
Library library = ballerinaLibraryEntry.getLibrary();
if (library != null) {
LibraryTable table = library.getTable();
if (table != null) {
table.removeLibrary(library);
model.removeOrderEntry(ballerinaLibraryEntry);
modelsProvider.commitModuleModifiableModel(model);
}
} else {
modelsProvider.disposeModuleModifiableModel(model);
}
});
} else {
ApplicationManager.getApplication().runWriteAction(() -> modelsProvider.disposeModuleModifiableModel(model));
}
}
Aggregations