Java Code Examples for com.intellij.util.containers.ContainerUtil#map2Array()
The following examples show how to use
com.intellij.util.containers.ContainerUtil#map2Array() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IntentionActionBean.java From consulo with Apache License 2.0 | 6 votes |
@Nullable public String[] getCategories() { if (categoryKey != null) { final String baseName = bundleName != null ? bundleName : myPluginDescriptor.getResourceBundleBaseName(); if (baseName == null) { LOG.error("No resource bundle specified for "+myPluginDescriptor); } final ResourceBundle bundle = AbstractBundle.getResourceBundle(baseName, myPluginDescriptor.getPluginClassLoader()); final String[] keys = categoryKey.split("/"); if (keys.length > 1) { return ContainerUtil.map2Array(keys, String.class, new Function<String, String>() { @Override public String fun(final String s) { return CommonBundle.message(bundle, s); } }); } category = CommonBundle.message(bundle, categoryKey); } if (category == null) return null; return category.split("/"); }
Example 2
Source File: MasterDetailsComponent.java From consulo with Apache License 2.0 | 6 votes |
@Override public void update(AnActionEvent e) { final Presentation presentation = e.getPresentation(); presentation.setEnabled(false); final TreePath[] selectionPath = myTree.getSelectionPaths(); if (selectionPath != null) { Object[] nodes = ContainerUtil.map2Array(selectionPath, new Function<TreePath, Object>() { @Override public Object fun(TreePath treePath) { return treePath.getLastPathComponent(); } }); if (!myCondition.value(nodes)) return; presentation.setEnabled(true); } }
Example 3
Source File: InspectionManagerEx.java From consulo with Apache License 2.0 | 6 votes |
@Nullable public static SuppressIntentionAction[] getSuppressActions(@Nonnull InspectionToolWrapper toolWrapper) { final InspectionProfileEntry tool = toolWrapper.getTool(); if (tool instanceof CustomSuppressableInspectionTool) { return ((CustomSuppressableInspectionTool)tool).getSuppressActions(null); } final List<LocalQuickFix> actions = new ArrayList<LocalQuickFix>(Arrays.asList(tool.getBatchSuppressActions(null))); if (actions.isEmpty()) { final Language language = Language.findLanguageByID(toolWrapper.getLanguage()); if (language != null) { final List<InspectionSuppressor> suppressors = LanguageInspectionSuppressors.INSTANCE.allForLanguage(language); for (InspectionSuppressor suppressor : suppressors) { final SuppressQuickFix[] suppressActions = suppressor.getSuppressActions(null, tool.getShortName()); Collections.addAll(actions, suppressActions); } } } return ContainerUtil.map2Array(actions, SuppressIntentionAction.class, new Function<LocalQuickFix, SuppressIntentionAction>() { @Override public SuppressIntentionAction fun(final LocalQuickFix fix) { return SuppressIntentionActionFromFix.convertBatchToSuppressIntentionAction((SuppressQuickFix)fix); } }); }
Example 4
Source File: Diff.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull private static String[] trim(@Nonnull String[] lines) { return ContainerUtil.map2Array(lines, String.class, new Function<String, String>() { @Override public String fun(String s) { return s.trim(); } }); }
Example 5
Source File: TreeFileChooserDialog.java From consulo with Apache License 2.0 | 5 votes |
@Override @Nonnull public String[] getNames(final boolean checkBoxState) { final String[] fileNames; if (myFileType != null && myProject != null) { GlobalSearchScope scope = myShowLibraryContents ? GlobalSearchScope.allScope(myProject) : GlobalSearchScope.projectScope(myProject); Collection<VirtualFile> virtualFiles = FileTypeIndex.getFiles(myFileType, scope); fileNames = ContainerUtil.map2Array(virtualFiles, String.class, new Function<VirtualFile, String>() { @Override public String fun(VirtualFile file) { return file.getName(); } }); } else { fileNames = FilenameIndex.getAllFilenames(myProject); } final Set<String> array = new THashSet<String>(); for (String fileName : fileNames) { if (!array.contains(fileName)) { array.add(fileName); } } final String[] result = ArrayUtil.toStringArray(array); Arrays.sort(result); return result; }
Example 6
Source File: DirectoryPathMatcher.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull GlobalSearchScope narrowDown(@Nonnull GlobalSearchScope fileSearchScope) { if (myFiles == null) return fileSearchScope; VirtualFile[] array = ContainerUtil.map2Array(myFiles, VirtualFile.class, p -> p.first); return GlobalSearchScopesCore.directoriesScope(myModel.getProject(), true, array).intersectWith(fileSearchScope); }
Example 7
Source File: BlockTreeNode.java From consulo with Apache License 2.0 | 5 votes |
@Override public BlockTreeNode[] getChildren() { return ContainerUtil.map2Array(myBlock.getSubBlocks(), BlockTreeNode.class, new Function<Block, BlockTreeNode>() { @Override public BlockTreeNode fun(Block block) { return new BlockTreeNode(block, BlockTreeNode.this); } }); }
Example 8
Source File: UsageViewUtil.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull public static PsiElement[] toElements(@Nonnull UsageInfo[] usageInfos) { return ContainerUtil.map2Array(usageInfos, PsiElement.class, new Function<UsageInfo, PsiElement>() { @Override public PsiElement fun(UsageInfo info) { return info.getElement(); } }); }
Example 9
Source File: SeverityRenderer.java From consulo with Apache License 2.0 | 5 votes |
public static SeverityRenderer create(final InspectionProfileImpl inspectionProfile, @Nullable final Runnable onClose) { final SortedSet<HighlightSeverity> severities = LevelChooserAction.getSeverities(((SeverityProvider)inspectionProfile.getProfileManager()).getOwnSeverityRegistrar()); return new SeverityRenderer(ContainerUtil.map2Array(severities, new SeverityState[severities.size()], new Function<HighlightSeverity, SeverityState>() { @Override public SeverityState fun(HighlightSeverity severity) { return new SeverityState(severity, true, false); } }), onClose); }
Example 10
Source File: ASTDelegatePsiElement.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull @RequiredReadAction protected <T extends PsiElement> T[] findChildrenByType(TokenSet elementType, Class<T> arrayClass) { return ContainerUtil.map2Array(getNode().getChildren(elementType), arrayClass, new Function<ASTNode, T>() { @Override public T fun(final ASTNode s) { return (T)s.getPsi(); } }); }
Example 11
Source File: ASTDelegatePsiElement.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull @RequiredReadAction protected <T extends PsiElement> T[] findChildrenByType(IElementType elementType, Class<T> arrayClass) { return ContainerUtil.map2Array(SharedImplUtil.getChildrenOfType(getNode(), elementType), arrayClass, new Function<ASTNode, T>() { @Override public T fun(final ASTNode s) { return (T)s.getPsi(); } }); }
Example 12
Source File: StatisticsManagerImpl.java From consulo with Apache License 2.0 | 5 votes |
public StatisticsInfo[] getAllValues(final String context) { final String[] strings; synchronized (LOCK) { strings = getUnit(getUnitNumber(context)).getKeys2(context); } return ContainerUtil.map2Array(strings, StatisticsInfo.class, (NotNullFunction<String, StatisticsInfo>)s -> new StatisticsInfo(context, s)); }
Example 13
Source File: SuppressIntentionActionFromFix.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull public static SuppressIntentionAction[] convertBatchToSuppressIntentionActions(@Nonnull SuppressQuickFix[] actions) { return ContainerUtil.map2Array(actions, SuppressIntentionAction.class, new Function<SuppressQuickFix, SuppressIntentionAction>() { @Override public SuppressIntentionAction fun(SuppressQuickFix fix) { return convertBatchToSuppressIntentionAction(fix); } }); }
Example 14
Source File: ExternalSystemImportingTestCase.java From intellij-quarkus with Eclipse Public License 2.0 | 4 votes |
protected void assertModuleOutputs(String moduleName, String... outputs) { String[] outputPaths = ContainerUtil.map2Array(CompilerPathsEx.getOutputPaths(new Module[]{getModule(moduleName)}), String.class, s -> getAbsolutePath(s)); assertUnorderedElementsAreEqual(outputPaths, outputs); }
Example 15
Source File: PersistentFSImpl.java From consulo with Apache License 2.0 | 4 votes |
@Override @Nonnull public String[] list(@Nonnull VirtualFile file) { FSRecords.NameId[] nameIds = listAll(file); return ContainerUtil.map2Array(nameIds, String.class, id -> id.name.toString()); }
Example 16
Source File: ExecutorAction.java From consulo with Apache License 2.0 | 4 votes |
@Nonnull public static AnAction[] getActions(final int order) { return ContainerUtil.map2Array(ExecutorRegistry.getInstance().getRegisteredExecutors(), AnAction.class, (Function<Executor, AnAction>)executor -> new ExecutorAction(ActionManager.getInstance().getAction(executor.getContextActionId()), executor, order)); }
Example 17
Source File: UsageInfoToUsageConverter.java From consulo with Apache License 2.0 | 4 votes |
@Nonnull private static PsiElement[] convertToPsiElements(@Nonnull List<SmartPsiElementPointer<PsiElement>> primary) { return ContainerUtil.map2Array(primary, PsiElement.class, SMARTPOINTER_TO_ELEMENT_MAPPER); }
Example 18
Source File: CSharpRefactoringUtil.java From consulo-csharp with Apache License 2.0 | 4 votes |
public static PsiElement[] findStatementsInRange(PsiFile file, int startOffset, int endOffset) { PsiElement element1 = file.findElementAt(startOffset); PsiElement element2 = file.findElementAt(endOffset - 1); if(element1 instanceof PsiWhiteSpace) { startOffset = element1.getTextRange().getEndOffset(); element1 = file.findElementAt(startOffset); } if(element2 instanceof PsiWhiteSpace) { endOffset = element2.getTextRange().getStartOffset(); element2 = file.findElementAt(endOffset - 1); } if(element1 != null && element2 != null) { PsiElement commonParent = PsiTreeUtil.findCommonParent(element1, element2); if(commonParent instanceof DotNetExpression) { return new PsiElement[]{commonParent}; } } final DotNetStatement statements = PsiTreeUtil.getParentOfType(element1, DotNetStatement.class); if(statements == null || element1 == null || element2 == null || !PsiTreeUtil.isAncestor(statements, element2, true)) { return PsiElement.EMPTY_ARRAY; } // don't forget about leafs (ex. ';') final ASTNode[] astResult = UsefulPsiTreeUtil.findChildrenRange(statements.getNode().getChildren(null), startOffset, endOffset); return ContainerUtil.map2Array(astResult, PsiElement.class, new Function<ASTNode, PsiElement>() { @Override public PsiElement fun(ASTNode node) { return node.getPsi(); } }); }
Example 19
Source File: XmlDescriptorUtil.java From idea-php-typo3-plugin with MIT License | 4 votes |
public static XmlElementDescriptor[] getElementsDescriptors(XmlTag context) { XmlDocumentImpl xmlDocument = PsiTreeUtil.getParentOfType(context, XmlDocumentImpl.class); if (xmlDocument == null) return EMPTY_ARRAY; return ContainerUtil.map2Array(xmlDocument.getRootTagNSDescriptor().getRootElementsDescriptors(xmlDocument), XmlElementDescriptor.class, descriptor -> wrapInDelegating(descriptor)); }