use of com.intellij.webcore.libraries.ScriptingLibraryModel in project intellij-plugins by JetBrains.
the class ChooseScopeAndCreateLibraryDialog method createLibraryAndAssociate.
@Nullable
private ErrorMessage createLibraryAndAssociate() {
String libraryName = myLibraryNameTextField.getText();
ScriptingLibraryModel libraryModel = myLibraryHelper.getOrCreateJsLibraryModel(libraryName);
try {
ScriptingLibraryMappings libraryMappings = ServiceManager.getService(myProject, JSLibraryMappings.class);
if (myModuleSelector.isAssociateWithProjectView()) {
if (myModuleSelector.isAssociateWithProjectRequested()) {
libraryMappings.associateWithProject(libraryModel.getName());
LOG.info("Library '" + libraryModel.getName() + "' has been successfully associated with the project");
} else {
libraryMappings.disassociateWithProject(libraryModel.getName());
}
} else {
for (Module module : myModuleSelector.getSelectedModules()) {
ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module);
VirtualFile[] roots = moduleRootManager.getContentRoots();
for (VirtualFile root : roots) {
libraryMappings.associate(root, libraryModel.getName(), false);
LOG.info("Library '" + libraryModel.getName() + "' has been associated with " + root);
}
}
}
myLibraryHelper.commit();
return null;
} catch (Exception ex) {
return new ErrorMessage("Unable to associate '" + libraryName + "' JavaScript library", ex);
}
}
use of com.intellij.webcore.libraries.ScriptingLibraryModel 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.webcore.libraries.ScriptingLibraryModel in project intellij-plugins by JetBrains.
the class JsLibraryHelper method getOrCreateJsLibraryModel.
@NotNull
public ScriptingLibraryModel getOrCreateJsLibraryModel(@NotNull String libraryName) {
if (myReusableJsLibraryModel != null) {
return myReusableJsLibraryModel;
}
ScriptingLibraryModel libraryModel = myJsLibraryManager.createLibrary(libraryName, VfsUtilCore.toVirtualFileArray(myLibraryFiles), VirtualFile.EMPTY_ARRAY, ArrayUtil.EMPTY_STRING_ARRAY, ScriptingLibraryModel.LibraryLevel.GLOBAL, false);
LOG.info("JavaScript library '" + libraryModel.getName() + "' has been successfully created.");
return libraryModel;
}
use of com.intellij.webcore.libraries.ScriptingLibraryModel in project oxy-template-support-plugin by mutant-industries.
the class InnerJsPredefinedLibrary method getPredefinedLibraries.
@NotNull
@Override
public ScriptingLibraryModel[] getPredefinedLibraries(@NotNull Project project) {
Set<VirtualFile> virtualFiles = getVirtualFiles();
ScriptingLibraryModel scriptingLibraryModel = ScriptingLibraryModel.createPredefinedLibrary(LIBRARY_NAME, virtualFiles.toArray(new VirtualFile[virtualFiles.size()]), true);
return new ScriptingLibraryModel[] { scriptingLibraryModel };
}
use of com.intellij.webcore.libraries.ScriptingLibraryModel in project intellij-plugins by JetBrains.
the class JstdResolveTest method removeLibrary.
private static void removeLibrary(@NotNull final Project project) {
ApplicationManager.getApplication().runWriteAction(() -> {
ScriptingLibraryManager libraryManager = ServiceManager.getService(project, JSLibraryManager.class);
ScriptingLibraryModel model = libraryManager.getLibraryByName(JstdLibraryUtil.LIBRARY_NAME);
assert model != null;
libraryManager.removeLibrary(model);
libraryManager.commitChanges();
});
}
Aggregations