use of com.intellij.lang.javascript.library.JSLibraryManager in project intellij-plugins by JetBrains.
the class JstdResolveTest method addJstdLibrary.
private static void addJstdLibrary(@NotNull final Project project, @NotNull final Collection<VirtualFile> libSourceFiles) {
ApplicationManager.getApplication().runWriteAction(() -> {
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();
});
}
use of com.intellij.lang.javascript.library.JSLibraryManager in project intellij-plugins by JetBrains.
the class JstdLibraryUtil method doInit.
private static void doInit(@NotNull final Project project) {
ApplicationManager.getApplication().runReadAction(() -> {
JSLibraryManager libraryManager = JSLibraryManager.getInstance(project);
LibraryTable libraryTable = libraryManager.getLibraryTable(ScriptingLibraryModel.LibraryLevel.GLOBAL);
libraryTable.addListener(new MyLibraryChangeWatcher());
});
}
use of com.intellij.lang.javascript.library.JSLibraryManager in project intellij-plugins by JetBrains.
the class JstdLibraryUtil method doesCorrectJstdLibExist.
private static boolean doesCorrectJstdLibExist(@NotNull final Project project) {
Boolean correctJstdLibExists = JSTD_LIBRARY_EXISTS;
if (correctJstdLibExists == null) {
correctJstdLibExists = ReadAction.compute(() -> {
VirtualFile libVirtualFile = VfsUtil.findFileByURL(JstdDefaultAssertionFrameworkSrcMarker.class.getResource("TestCase.js"));
if (libVirtualFile == null) {
return false;
}
JSLibraryManager libraryManager = JSLibraryManager.getInstance(project);
for (ScriptingLibraryModel libraryModel : libraryManager.getAllLibraries()) {
if (libraryModel == null) {
continue;
}
String libraryName = libraryModel.getName();
if (libraryName != null && libraryName.startsWith(LIBRARY_NAME)) {
Library library = libraryModel.getOriginalLibrary();
if (library instanceof LibraryEx) {
LibraryEx libraryEx = (LibraryEx) library;
if (libraryEx.isDisposed()) {
continue;
}
}
if (libraryModel.containsFile(libVirtualFile)) {
return true;
}
}
}
return false;
});
JSTD_LIBRARY_EXISTS = correctJstdLibExists;
}
return correctJstdLibExists;
}
Aggregations