use of com.intellij.openapi.roots.OrderEntry in project kotlin by JetBrains.
the class SourceNavigationHelper method filterByOrderEntries.
@NotNull
private static List<KtNamedDeclaration> filterByOrderEntries(@NotNull KtNamedDeclaration declaration, @NotNull Collection<KtNamedDeclaration> candidates) {
final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(declaration.getProject()).getFileIndex();
final List<OrderEntry> orderEntries = fileIndex.getOrderEntriesForFile(declaration.getContainingFile().getVirtualFile());
return CollectionsKt.filter(candidates, new Function1<KtNamedDeclaration, Boolean>() {
@Override
public Boolean invoke(KtNamedDeclaration candidate) {
List<OrderEntry> candidateOrderEntries = fileIndex.getOrderEntriesForFile(candidate.getContainingFile().getVirtualFile());
return ContainerUtil.intersects(orderEntries, candidateOrderEntries);
}
});
}
use of com.intellij.openapi.roots.OrderEntry in project kotlin by JetBrains.
the class FrameworksCompatibilityUtils method suggestRemoveIncompatibleFramework.
public static void suggestRemoveIncompatibleFramework(@NotNull ModifiableRootModel rootModel, @NotNull Set<? extends LibraryKind> frameworkLibraryKinds, @NotNull FrameworkType frameworkType) {
List<OrderEntry> existingEntries = new ArrayList<OrderEntry>();
for (OrderEntry entry : rootModel.getOrderEntries()) {
if (!(entry instanceof LibraryOrderEntry))
continue;
Library library = ((LibraryOrderEntry) entry).getLibrary();
if (library == null)
continue;
for (LibraryKind kind : frameworkLibraryKinds) {
if (LibraryPresentationManager.getInstance().isLibraryOfKind(Arrays.asList(library.getFiles(OrderRootType.CLASSES)), kind)) {
existingEntries.add(entry);
}
}
}
removeWithConfirm(rootModel, existingEntries, String.format("Current module is already configured with '%s' framework.\nDo you want to remove it?", frameworkType.getPresentableName()), "Framework Conflict");
}
use of com.intellij.openapi.roots.OrderEntry in project kotlin by JetBrains.
the class FrameworksCompatibilityUtils method suggestRemoveOldJsLibrary.
public static void suggestRemoveOldJsLibrary(@NotNull ModifiableRootModel rootModel) {
List<OrderEntry> oldJsLibraries = new ArrayList<OrderEntry>();
for (OrderEntry entry : rootModel.getOrderEntries()) {
if (!(entry instanceof LibraryOrderEntry))
continue;
Library library = ((LibraryOrderEntry) entry).getLibrary();
if (library == null)
continue;
if (JSLibraryStdPresentationProvider.detectOld(library)) {
oldJsLibraries.add(entry);
}
}
removeWithConfirm(rootModel, oldJsLibraries, "Current module is configured with old js library.\nDo you want to remove it?", "Old JS Library");
}
use of com.intellij.openapi.roots.OrderEntry in project azure-tools-for-java by Microsoft.
the class ApplicationInsightsPanel method configureAzureSDK.
private void configureAzureSDK() {
final ModifiableRootModel modifiableModel = ModuleRootManager.getInstance(module).getModifiableModel();
for (OrderEntry orderEntry : modifiableModel.getOrderEntries()) {
if (orderEntry instanceof ModuleLibraryOrderEntryImpl && AzureLibrary.APP_INSIGHTS.getName().equals(((ModuleLibraryOrderEntryImpl) orderEntry).getLibraryName())) {
return;
}
}
final LibrariesContainer.LibraryLevel level = LibrariesContainer.LibraryLevel.MODULE;
AccessToken token = WriteAction.start();
try {
Library newLibrary = LibrariesContainerFactory.createContainer(modifiableModel).createLibrary(AzureLibrary.APP_INSIGHTS.getName(), level, new ArrayList<OrderRoot>());
for (OrderEntry orderEntry : modifiableModel.getOrderEntries()) {
if (orderEntry instanceof ModuleLibraryOrderEntryImpl && AzureLibrary.APP_INSIGHTS.getName().equals(((ModuleLibraryOrderEntryImpl) orderEntry).getLibraryName())) {
((ModuleLibraryOrderEntryImpl) orderEntry).setExported(true);
break;
}
}
Library.ModifiableModel newLibraryModel = newLibrary.getModifiableModel();
AddLibraryUtility.addLibraryFiles(new File(PluginHelper.getAzureLibLocation()), newLibraryModel, AzureLibrary.APP_INSIGHTS.getFiles());
newLibraryModel.commit();
modifiableModel.commit();
} catch (Exception ex) {
ex.printStackTrace();
} finally {
token.finish();
}
}
use of com.intellij.openapi.roots.OrderEntry in project azure-tools-for-java by Microsoft.
the class LibrariesConfigurationDialog method editLibrary.
private void editLibrary() {
AzureLibrary azureLibrary = (AzureLibrary) librariesList.getSelectedValue();
final ModifiableRootModel modifiableModel = ModuleRootManager.getInstance(module).getModifiableModel();
OrderEntry libraryOrderEntry = null;
for (OrderEntry orderEntry : modifiableModel.getOrderEntries()) {
if (orderEntry instanceof ModuleLibraryOrderEntryImpl && azureLibrary.getName().equals(((ModuleLibraryOrderEntryImpl) orderEntry).getLibraryName())) {
libraryOrderEntry = orderEntry;
break;
}
}
if (libraryOrderEntry != null) {
LibraryPropertiesPanel libraryPropertiesPanel = new LibraryPropertiesPanel(module, azureLibrary, true, ((ModuleLibraryOrderEntryImpl) libraryOrderEntry).isExported());
DefaultDialogWrapper libraryProperties = new DefaultDialogWrapper(module.getProject(), libraryPropertiesPanel);
libraryProperties.show();
if (libraryProperties.isOK()) {
AccessToken token = WriteAction.start();
try {
((ModuleLibraryOrderEntryImpl) libraryOrderEntry).setExported(libraryPropertiesPanel.isExported());
modifiableModel.commit();
} finally {
token.finish();
}
LocalFileSystem.getInstance().findFileByPath(PluginUtil.getModulePath(module)).refresh(true, true);
}
} else {
PluginUtil.displayInfoDialog("Library not found", "Library was not found");
}
}
Aggregations