use of com.intellij.lang.javascript.library.JSLibraryMappings 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.JSLibraryMappings in project intellij-plugins by JetBrains.
the class JstdLibraryUtil method isCorrectMapping.
private static boolean isCorrectMapping(@NotNull Project project, @NotNull VirtualFile file) {
JSLibraryMappings jsLibraryMappings = JSLibraryMappings.getInstance(project);
// TODO search for all JsTD libraries
List<VirtualFile> usageScope = jsLibraryMappings.getMappingsByLibraryName(LIBRARY_NAME);
String filePath = file.getPath();
for (VirtualFile root : usageScope) {
if (root == null) {
return true;
}
if (filePath.startsWith(root.getPath())) {
return true;
}
}
return false;
}
Aggregations