mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Add downloaded JS library to current file's scope
This commit is contained in:
+26
@@ -51,6 +51,32 @@ public class ScriptingLibraryMappings extends LanguagePerFileMappings<ScriptingL
|
||||
myLibraryManager.reset();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an association between a virtual file and a library specified by name.
|
||||
* @param file The file to associate the library with.
|
||||
* @param libName The library name.
|
||||
*/
|
||||
public void associate(VirtualFile file, String libName) {
|
||||
ScriptingLibraryTable.LibraryModel libraryModel = myLibraryManager.getLibraryByName(libName);
|
||||
if (libraryModel == null) return;
|
||||
ScriptingLibraryTable.LibraryModel container = getImmediateMapping(file);
|
||||
if (container == null || !(container instanceof CompoundLibrary)) {
|
||||
container = new CompoundLibrary();
|
||||
}
|
||||
if (!((CompoundLibrary)container).containsLibrary(libName)) {
|
||||
((CompoundLibrary)container).toggleLibrary(libraryModel);
|
||||
setMapping(file, container);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isAssociatedWith(VirtualFile file, String libName) {
|
||||
ScriptingLibraryTable.LibraryModel libraryModel = myLibraryManager.getLibraryByName(libName);
|
||||
if (libraryModel == null) return false;
|
||||
ScriptingLibraryTable.LibraryModel container = getImmediateMapping(file);
|
||||
if (container == null) return false;
|
||||
return ((CompoundLibrary)container).containsLibrary(libName);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected String getValueAttribute() {
|
||||
|
||||
Reference in New Issue
Block a user