use of com.intellij.openapi.roots.impl.libraries.LibraryEx in project google-cloud-intellij by GoogleCloudPlatform.
the class AppEngineStandardSupportProviderTest method testAppEngine_defaultManagedLibrariesSelected.
public void testAppEngine_defaultManagedLibrariesSelected() {
AppEngineStandardLibraryPanel libraryPanel = new AppEngineStandardLibraryPanel(true);
LibraryEx library = mock(LibraryEx.class);
when(library.getTable()).thenReturn(ProjectLibraryTable.getInstance(myModule.getProject()));
when(library.getExcludedRoots()).thenReturn(new VirtualFile[0]);
when(library.getName()).thenReturn("javax.servlet:servlet-api:2.5");
setupAppEngine(libraryPanel, library);
addSupport();
assertNull(FacetManager.getInstance(myModule).getFacetByType(WebFacet.ID));
final String moduleName = myModule.getName();
ArtifactsTestUtil.assertLayout(myProject, moduleName, "<root>\n" + " WEB-INF/\n" + " classes/\n" + " module:" + moduleName + "\n" + " lib/\n" + " lib:javax.servlet:servlet-api:2.5(project)\n");
}
use of com.intellij.openapi.roots.impl.libraries.LibraryEx in project go-lang-idea-plugin by go-lang-plugin-org.
the class GoModuleLibrariesInitializer method attachLibraries.
private void attachLibraries(@NotNull Collection<VirtualFile> libraryRoots, Set<VirtualFile> exclusions) {
ApplicationManager.getApplication().assertIsDispatchThread();
if (!libraryRoots.isEmpty()) {
ApplicationManager.getApplication().runWriteAction(() -> {
ModuleRootManager model = ModuleRootManager.getInstance(myModule);
LibraryOrderEntry goLibraryEntry = OrderEntryUtil.findLibraryOrderEntry(model, getLibraryName());
if (goLibraryEntry != null && goLibraryEntry.isValid()) {
Library library = goLibraryEntry.getLibrary();
if (library != null && !((LibraryEx) library).isDisposed()) {
fillLibrary(library, libraryRoots, exclusions);
}
} else {
LibraryTable libraryTable = LibraryTablesRegistrar.getInstance().getLibraryTable(myModule.getProject());
Library library = libraryTable.createLibrary(getLibraryName());
fillLibrary(library, libraryRoots, exclusions);
ModuleRootModificationUtil.addDependency(myModule, library);
}
});
showNotification(myModule.getProject());
} else {
removeLibraryIfNeeded();
}
}
use of com.intellij.openapi.roots.impl.libraries.LibraryEx in project go-lang-idea-plugin by go-lang-plugin-org.
the class GoPathLibraryTest method assertLibrary.
private void assertLibrary(@NotNull Collection<String> libUrls, String... exclusionUrls) {
UIUtil.dispatchAllInvocationEvents();
GoModuleLibrariesInitializer initializer = myModule.getComponent(GoModuleLibrariesInitializer.class);
ModuleRootManager model = ModuleRootManager.getInstance(myModule);
LibraryOrderEntry libraryOrderEntry = OrderEntryUtil.findLibraryOrderEntry(model, initializer.getLibraryName());
if (libUrls.isEmpty()) {
assertNull(libraryOrderEntry);
return;
}
LibraryEx library = (LibraryEx) libraryOrderEntry.getLibrary();
assertNotNull(library);
assertSameElements(Arrays.asList(library.getUrls(OrderRootType.CLASSES)), libUrls);
assertSameElements(library.getExcludedRootUrls(), exclusionUrls);
}
use of com.intellij.openapi.roots.impl.libraries.LibraryEx in project intellij-plugins by JetBrains.
the class DartUrlResolverImpl method initPackagesMapFromLib.
private void initPackagesMapFromLib(@NotNull final VirtualFile contextFile) {
final Module module = ModuleUtilCore.findModuleForFile(contextFile, myProject);
final List<OrderEntry> orderEntries = module != null ? Arrays.asList(ModuleRootManager.getInstance(module).getOrderEntries()) : ProjectRootManager.getInstance(myProject).getFileIndex().getOrderEntriesForFile(contextFile);
for (OrderEntry orderEntry : orderEntries) {
if (orderEntry instanceof LibraryOrderEntry && LibraryTablesRegistrar.PROJECT_LEVEL.equals(((LibraryOrderEntry) orderEntry).getLibraryLevel()) && DartPackagesLibraryType.DART_PACKAGES_LIBRARY_NAME.equals(((LibraryOrderEntry) orderEntry).getLibraryName())) {
final LibraryEx library = (LibraryEx) ((LibraryOrderEntry) orderEntry).getLibrary();
final LibraryProperties properties = library == null ? null : library.getProperties();
if (properties instanceof DartPackagesLibraryProperties) {
for (Map.Entry<String, List<String>> entry : ((DartPackagesLibraryProperties) properties).getPackageNameToDirsMap().entrySet()) {
if (entry != null && entry.getKey() != null && entry.getValue() != null) {
myPackagesMapFromLib.put(entry.getKey(), entry.getValue());
}
}
return;
}
}
}
}
use of com.intellij.openapi.roots.impl.libraries.LibraryEx in project intellij-plugins by JetBrains.
the class FlexProjectConfigTest method createModuleLibrary.
private String createModuleLibrary() {
final ModifiableRootModel modifiableModel = ModuleRootManager.getInstance(myModule).getModifiableModel();
final LibraryTable.ModifiableModel libraryTable = modifiableModel.getModuleLibraryTable().getModifiableModel();
LibraryEx library = (LibraryEx) libraryTable.createLibrary("test", FlexLibraryType.FLEX_LIBRARY);
String libraryId = UUID.randomUUID().toString();
((FlexLibraryProperties) library.getProperties()).setId(libraryId);
ApplicationManager.getApplication().runWriteAction(() -> {
libraryTable.commit();
modifiableModel.commit();
});
return libraryId;
}
Aggregations