@NotNull final Collection<VirtualFile> libSourceFiles) {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
JSLibraryManager jsLibraryManager = ServiceManager.getService(project, JSLibraryManager.class);
ScriptingLibraryModel libraryModel = jsLibraryManager.createLibrary(
JstdLibraryUtil.LIBRARY_NAME,
VfsUtilCore.toVirtualFileArray(libSourceFiles),
VirtualFile.EMPTY_ARRAY,
ArrayUtil.EMPTY_STRING_ARRAY,
ScriptingLibraryModel.LibraryLevel.GLOBAL,
false
);
JSLibraryMappings jsLibraryMappings = ServiceManager.getService(project, JSLibraryMappings.class);
jsLibraryMappings.associate(null, libraryModel.getName());
jsLibraryManager.commitChanges();
}
});
}