@Nullable public ScriptingLibraryModel lookupLibraryByContent( @NotNull Collection<VirtualFile> expectedSourceFiles) { ScriptingLibraryModel[] libraryModels = myScriptingLibraryManager.getAllLibraries(); for (ScriptingLibraryModel libraryModel : libraryModels) { if (scriptingLibraryModelConsistsOf(libraryModel, expectedSourceFiles)) { return libraryModel; } } return null; }
@NotNull public String findAvailableJsLibraryName(@NotNull String initialLibraryName) { myScriptingLibraryManager.reset(); String libraryName = initialLibraryName; boolean available = getScriptingLibraryModel(libraryName) == null; int id = 1; while (!available) { libraryName = initialLibraryName + " #" + id; available = getScriptingLibraryModel(libraryName) == null; id++; } return libraryName; }
@Nullable public ScriptingLibraryModel getScriptingLibraryModel(@NotNull String libraryName) { return myScriptingLibraryManager.getLibraryByName(libraryName); }