WorkspaceEntity (@NotNull MutableEntityStorage diff, @NotNull EntitySource source, @NotNull Project project) { WorkspaceEntity existingEntity = getExistingEntity(diff); if (existingEntity != null) return existingEntity; LibraryFilesPackagingElementEntity entity; if (myLibraryName == null) { entity = diff.addEntity(LibraryFilesPackagingElementEntity.create(source)); } else { LibraryId id; if (myLevel.equals("module")) { id = new LibraryId(myLibraryName, new LibraryTableId.ModuleLibraryTableId(new ModuleId(myModuleName))); } else if (myLevel.equals("project")) { id = new LibraryId(myLibraryName, LibraryTableId.ProjectLibraryTableId.INSTANCE); } else { id = new LibraryId(myLibraryName, new LibraryTableId.GlobalLibraryTableId(myLevel)); } entity = diff.addEntity(LibraryFilesPackagingElementEntity.create(source, o -> { o.setLibrary(id); return Unit.INSTANCE; })); } diff.getMutableExternalMapping("intellij.artifacts.packaging.elements").addMapping(entity, this); return entity; }