use of com.intellij.openapi.roots.ModuleRootModel in project intellij-community by JetBrains.
the class ProductionModuleOutputPackagingElement method getSourceRoots.
@NotNull
@Override
public Collection<VirtualFile> getSourceRoots(PackagingElementResolvingContext context) {
Module module = findModule(context);
if (module == null)
return Collections.emptyList();
ModuleRootModel rootModel = context.getModulesProvider().getRootModel(module);
return rootModel.getSourceRoots(JavaModuleSourceRootTypes.PRODUCTION);
}
use of com.intellij.openapi.roots.ModuleRootModel in project intellij-community by JetBrains.
the class EclipseEmlTest method checkModule.
protected static void checkModule(String path, Module module) throws WriteExternalException, IOException, JDOMException {
ModuleRootModel rootModel = ModuleRootManager.getInstance(module);
final Element root = new Element("component");
IdeaSpecificSettings.writeIdeaSpecificClasspath(root, rootModel);
assertThat(root).isEqualTo(Paths.get(path, module.getName() + EclipseXml.IDEA_SETTINGS_POSTFIX));
}
use of com.intellij.openapi.roots.ModuleRootModel in project intellij-community by JetBrains.
the class ArtifactEditorContextImpl method selectLibrary.
@Override
public void selectLibrary(@NotNull Library library) {
final LibraryTable table = library.getTable();
if (table != null) {
ProjectStructureConfigurable.getInstance(getProject()).selectProjectOrGlobalLibrary(library, true);
} else {
final Module module = ((LibraryImpl) library).getModule();
if (module != null) {
final ModuleRootModel rootModel = myParent.getModulesProvider().getRootModel(module);
final String libraryName = library.getName();
for (OrderEntry entry : rootModel.getOrderEntries()) {
if (entry instanceof ModuleLibraryOrderEntryImpl) {
final ModuleLibraryOrderEntryImpl libraryEntry = (ModuleLibraryOrderEntryImpl) entry;
if (libraryName != null && libraryName.equals(libraryEntry.getLibraryName()) || libraryName == null && library.equals(libraryEntry.getLibrary())) {
ProjectStructureConfigurable.getInstance(getProject()).selectOrderEntry(module, libraryEntry);
return;
}
}
}
}
}
}
use of com.intellij.openapi.roots.ModuleRootModel in project intellij-community by JetBrains.
the class AppEngineFacetEditor method doAdd.
private void doAdd() {
final FileChooserDescriptor descriptor = new FileChooserDescriptor(true, true, false, false, false, true);
final ModuleRootModel rootModel = myContext.getRootModel();
descriptor.setRoots(rootModel.getSourceRoots(JavaModuleSourceRootTypes.SOURCES));
final VirtualFile[] files = FileChooser.chooseFiles(descriptor, myContext.getProject(), null);
for (VirtualFile file : files) {
myFilesListModel.addElement(file.getPath());
}
}
use of com.intellij.openapi.roots.ModuleRootModel in project intellij-community by JetBrains.
the class MavenProjectImporter method removeUnusedProjectLibraries.
private boolean removeUnusedProjectLibraries() {
Set<Library> unusedLibraries = new HashSet<>();
Collections.addAll(unusedLibraries, myModelsProvider.getAllLibraries());
for (ModuleRootModel eachModel : collectModuleModels()) {
for (OrderEntry eachEntry : eachModel.getOrderEntries()) {
if (eachEntry instanceof LibraryOrderEntry) {
unusedLibraries.remove(((LibraryOrderEntry) eachEntry).getLibrary());
}
}
}
boolean removed = false;
for (Library each : unusedLibraries) {
if (!isDisposed(each) && MavenRootModelAdapter.isMavenLibrary(each) && !MavenRootModelAdapter.isChangedByUser(each)) {
myModelsProvider.removeLibrary(each);
removed = true;
}
}
return removed;
}
Aggregations