com.intellij.openapi.util.Trinity Java Examples
The following examples show how to use
com.intellij.openapi.util.Trinity.
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: StubTreeBuilder.java From consulo with Apache License 2.0 | 6 votes |
/** * Order is deterministic. First element matches {@link FileViewProvider#getStubBindingRoot()} */ @Nonnull public static List<Pair<IStubFileElementType, PsiFile>> getStubbedRoots(@Nonnull FileViewProvider viewProvider) { final List<Trinity<Language, IStubFileElementType, PsiFile>> roots = new SmartList<>(); final PsiFile stubBindingRoot = viewProvider.getStubBindingRoot(); for (Language language : viewProvider.getLanguages()) { final PsiFile file = viewProvider.getPsi(language); if (file instanceof PsiFileImpl) { final IElementType type = ((PsiFileImpl)file).getElementTypeForStubBuilder(); if (type != null) { roots.add(Trinity.create(language, (IStubFileElementType)type, file)); } } } ContainerUtil.sort(roots, (o1, o2) -> { if (o1.third == stubBindingRoot) return o2.third == stubBindingRoot ? 0 : -1; else if (o2.third == stubBindingRoot) return 1; else return StringUtil.compare(o1.first.getID(), o2.first.getID(), false); }); return ContainerUtil.map(roots, trinity -> Pair.create(trinity.second, trinity.third)); }
Example #2
Source File: LogModel.java From consulo with Apache License 2.0 | 6 votes |
void removeNotification(Notification notification) { synchronized (myNotifications) { myNotifications.remove(notification); } Runnable handler = removeHandlers.remove(notification); if (handler != null) { UIUtil.invokeLaterIfNeeded(handler); } Trinity<Notification, String, Long> oldStatus = getStatusMessage(); if (oldStatus != null && notification == oldStatus.first) { setStatusToImportant(); } fireModelChanged(); }
Example #3
Source File: ConsoleLogModel.java From aem-ide-tooling-4-intellij with Apache License 2.0 | 6 votes |
public void removeNotification(Notification notification) { synchronized (myNotifications) { myNotifications.remove(notification); } Runnable handler = removeHandlers.remove(notification); if (handler != null) { UIUtil.invokeLaterIfNeeded(handler); } Trinity<Notification, String, Long> oldStatus = getStatusMessage(); if (oldStatus != null && notification == oldStatus.first) { setStatusToImportant(); } fireModelChanged(); }
Example #4
Source File: TemplateKindCombo.java From consulo with Apache License 2.0 | 6 votes |
public TemplateKindCombo() { getComboBox().setRenderer(new ColoredListCellRenderer() { @Override protected void customizeCellRenderer(@Nonnull JList list, Object value, int index, boolean selected, boolean hasFocus) { if (value instanceof Trinity) { append((String)((Trinity)value).first); setIcon((Image)((Trinity)value).second); } } }); new ComboboxSpeedSearch(getComboBox()) { @Override protected String getElementText(Object element) { if (element instanceof Trinity) { return (String)((Trinity)element).first; } return null; } }; setButtonListener(null); }
Example #5
Source File: CodeStyleBlankLinesPanel.java From consulo with Apache License 2.0 | 6 votes |
@Override public void showCustomOption(Class<? extends CustomCodeStyleSettings> settingsClass, String fieldName, String title, String groupName, @Nullable OptionAnchor anchor, @Nullable String anchorFieldName, Object... options) { if (myIsFirstUpdate) { myCustomOptions.putValue(groupName, Trinity.create(settingsClass, fieldName, title)); } for (IntOption option : myOptions) { if (option.myTarget.getName().equals(fieldName)) { option.myIntField.setEnabled(true); } } }
Example #6
Source File: CreateWithTemplatesDialogPanel.java From consulo with Apache License 2.0 | 5 votes |
public CreateWithTemplatesDialogPanel(@Nonnull List<Trinity<String, Image, String>> templates, @Nullable String selectedItem) { super(templates, LIST_RENDERER); myTemplatesList.addListSelectionListener(e -> { Trinity<String, Image, String> selectedValue = myTemplatesList.getSelectedValue(); if (selectedValue != null) { setTextFieldIcon(selectedValue.second); } }); selectTemplate(selectedItem); setTemplatesListVisible(templates.size() > 1); }
Example #7
Source File: ResolveCache.java From consulo with Apache License 2.0 | 5 votes |
@Nullable private <TRef extends PsiReference, TResult> TResult resolve(@Nonnull final TRef ref, @Nonnull final AbstractResolver<? super TRef, TResult> resolver, boolean needToPreventRecursion, final boolean incompleteCode, boolean isPoly, boolean isPhysical) { ProgressIndicatorProvider.checkCanceled(); if (isPhysical) { ApplicationManager.getApplication().assertReadAccessAllowed(); } int index = getIndex(incompleteCode, isPoly); Map<TRef, TResult> map = getMap(isPhysical, index); TResult result = map.get(ref); if (result != null) { return result; } RecursionGuard.StackStamp stamp = RecursionManager.markStack(); result = needToPreventRecursion ? RecursionManager.doPreventingRecursion(Trinity.create(ref, incompleteCode, isPoly), true, () -> resolver.resolve(ref, incompleteCode)) : resolver.resolve(ref, incompleteCode); if (result instanceof ResolveResult) { ensureValidPsi((ResolveResult)result); } else if (result instanceof ResolveResult[]) { ensureValidResults((ResolveResult[])result); } else if (result instanceof PsiElement) { PsiUtilCore.ensureValid((PsiElement)result); } if (stamp.mayCacheNow()) { cache(ref, map, result); } return result; }
Example #8
Source File: LocalInspectionsPass.java From consulo with Apache License 2.0 | 5 votes |
@Override public boolean process(Trinity<ProblemDescriptor, LocalInspectionToolWrapper, ProgressIndicator> trinity) { ProgressIndicator indicator = trinity.getThird(); if (indicator.isCanceled()) { return false; } ProblemDescriptor descriptor = trinity.first; LocalInspectionToolWrapper tool = trinity.second; PsiElement psiElement = descriptor.getPsiElement(); if (psiElement == null) return true; PsiFile file = psiElement.getContainingFile(); Document thisDocument = documentManager.getDocument(file); HighlightSeverity severity = inspectionProfile.getErrorLevel(HighlightDisplayKey.find(tool.getShortName()), file).getSeverity(); infos.clear(); createHighlightsForDescriptor(infos, emptyActionRegistered, ilManager, file, thisDocument, tool, severity, descriptor, psiElement); for (HighlightInfo info : infos) { final EditorColorsScheme colorsScheme = getColorsScheme(); UpdateHighlightersUtil .addHighlighterToEditorIncrementally(myProject, myDocument, getFile(), myRestrictRange.getStartOffset(), myRestrictRange.getEndOffset(), info, colorsScheme, getId(), ranges2markersCache); } return true; }
Example #9
Source File: LocalInspectionsPass.java From consulo with Apache License 2.0 | 5 votes |
private void addDescriptorIncrementally(@Nonnull final ProblemDescriptor descriptor, @Nonnull final LocalInspectionToolWrapper tool, @Nonnull final ProgressIndicator indicator) { if (myIgnoreSuppressed && SuppressionUtil.inspectionResultSuppressed(descriptor.getPsiElement(), tool.getTool())) { return; } myTransferToEDTQueue.offer(Trinity.create(descriptor, tool, indicator)); }
Example #10
Source File: ConsoleLog.java From aem-ide-tooling-4-intellij with Apache License 2.0 | 5 votes |
@Nullable public static Trinity<Notification, String, Long> getStatusMessage(@Nullable Project project) { ConsoleLogModel model = getLogModel(project); if(model != null) { return model.getStatusMessage(); } return null; }
Example #11
Source File: PrattBuilderImpl.java From consulo with Apache License 2.0 | 5 votes |
@Nullable private TokenParser findParser() { final IElementType tokenType = getTokenType(); for (final Trinity<Integer, PathPattern, TokenParser> trinity : myRegistry.getParsers(tokenType)) { if (trinity.first > myPriority && trinity.second.accepts(this)) { return trinity.third; } } return null; }
Example #12
Source File: BraceMatcherBasedSelectioner.java From consulo with Apache License 2.0 | 5 votes |
@Override public List<TextRange> select(final PsiElement e, final CharSequence editorText, final int cursorOffset, final Editor editor) { final VirtualFile file = e.getContainingFile().getVirtualFile(); final FileType fileType = file == null? null : file.getFileType(); if (fileType == null) return super.select(e, editorText, cursorOffset, editor); final int textLength = editorText.length(); final TextRange totalRange = e.getTextRange(); final HighlighterIterator iterator = ((EditorEx)editor).getHighlighter().createIterator(totalRange.getStartOffset()); final BraceMatcher braceMatcher = BraceMatchingUtil.getBraceMatcher(fileType, iterator); final ArrayList<TextRange> result = new ArrayList<TextRange>(); final LinkedList<Trinity<Integer, Integer, IElementType>> stack = new LinkedList<Trinity<Integer, Integer, IElementType>>(); while (!iterator.atEnd() && iterator.getStart() < totalRange.getEndOffset()) { final Trinity<Integer, Integer, IElementType> last; if (braceMatcher.isLBraceToken(iterator, editorText, fileType)) { stack.addLast(Trinity.create(iterator.getStart(), iterator.getEnd(), iterator.getTokenType())); } else if (braceMatcher.isRBraceToken(iterator, editorText, fileType) && !stack.isEmpty() && braceMatcher.isPairBraces((last = stack.getLast()).third, iterator.getTokenType())) { stack.removeLast(); result.addAll(expandToWholeLine(editorText, new TextRange(last.first, iterator.getEnd()))); int bodyStart = last.second; int bodyEnd = iterator.getStart(); while (bodyStart < textLength && Character.isWhitespace(editorText.charAt(bodyStart))) bodyStart ++; while (bodyEnd > 0 && Character.isWhitespace(editorText.charAt(bodyEnd - 1))) bodyEnd --; result.addAll(expandToWholeLine(editorText, new TextRange(bodyStart, bodyEnd))); } iterator.advance(); } result.add(e.getTextRange()); return result; }
Example #13
Source File: CreateWithTemplatesDialogPanel.java From consulo with Apache License 2.0 | 5 votes |
private void selectTemplate(@Nullable String selectedItem) { if (selectedItem == null) { myTemplatesList.setSelectedIndex(0); return; } ListModel<Trinity<String, Image, String>> model = myTemplatesList.getModel(); for (int i = 0; i < model.getSize(); i++) { String templateID = model.getElementAt(i).getThird(); if (selectedItem.equals(templateID)) { myTemplatesList.setSelectedIndex(i); return; } } }
Example #14
Source File: CreateDirectoryOrPackageAction.java From consulo with Apache License 2.0 | 5 votes |
@RequiredUIAccess @Override public void actionPerformed(@Nonnull AnActionEvent e) { IdeView view = e.getData(LangDataKeys.IDE_VIEW); Project project = e.getData(CommonDataKeys.PROJECT); if (view == null || project == null) { return; } PsiDirectory directory = DirectoryChooserUtil.getOrChooseDirectory(view); if (directory == null) { return; } Trinity<ContentFolderTypeProvider, PsiDirectory, ChildType> info = getInfo(directory); boolean isDirectory = info.getThird() == ChildType.Directory; CreateDirectoryOrPackageHandler validator = new CreateDirectoryOrPackageHandler(project, directory, isDirectory, info.getThird().getSeparator()); String title = isDirectory ? IdeBundle.message("title.new.directory") : IdeBundle.message("title.new.package"); createLightWeightPopup(validator, title, element -> { if (element != null) { view.selectElement(element); } }).showCenteredInCurrentWindow(project); }
Example #15
Source File: CreateDirectoryOrPackageAction.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull @RequiredUIAccess private static Trinity<ContentFolderTypeProvider, PsiDirectory, ChildType> getInfo(PsiDirectory d) { Project project = d.getProject(); ProjectFileIndex projectFileIndex = ProjectFileIndex.getInstance(project); Module moduleForPsiElement = ModuleUtilCore.findModuleForPsiElement(d); if (moduleForPsiElement != null) { boolean isPackageSupported = false; ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(moduleForPsiElement); List<PsiPackageSupportProvider> extensions = PsiPackageSupportProvider.EP_NAME.getExtensionList(); for (ModuleExtension moduleExtension : moduleRootManager.getExtensions()) { for (PsiPackageSupportProvider supportProvider : extensions) { if (supportProvider.isSupported(moduleExtension)) { isPackageSupported = true; break; } } } if (isPackageSupported) { ContentFolderTypeProvider contentFolderTypeForFile = projectFileIndex.getContentFolderTypeForFile(d.getVirtualFile()); if (contentFolderTypeForFile != null) { Image childPackageIcon = contentFolderTypeForFile.getChildPackageIcon(); return Trinity.create(contentFolderTypeForFile, d, childPackageIcon != null ? ChildType.Package : ChildType.Directory); } } } return Trinity.create(null, d, ChildType.Directory); }
Example #16
Source File: TemplateKindCombo.java From consulo with Apache License 2.0 | 5 votes |
public String getSelectedName() { //noinspection unchecked final Trinity<String, Image, String> trinity = (Trinity<String, Image, String>)getComboBox().getSelectedItem(); if (trinity == null) { // design time return null; } return trinity.third; }
Example #17
Source File: TemplateKindCombo.java From consulo with Apache License 2.0 | 5 votes |
public void setSelectedName(@Nullable String name) { if (name == null) return; ComboBoxModel model = getComboBox().getModel(); for (int i = 0, n = model.getSize(); i < n; i++) { Trinity<String, Image, String> trinity = (Trinity<String, Image, String>)model.getElementAt(i); if (name.equals(trinity.third)) { getComboBox().setSelectedItem(trinity); return; } } }
Example #18
Source File: LogModel.java From consulo with Apache License 2.0 | 5 votes |
void setStatusMessage(@Nullable Notification statusMessage, long stamp) { synchronized (myNotifications) { if (myStatusMessage != null && myStatusMessage.first == statusMessage) return; if (myStatusMessage == null && statusMessage == null) return; myStatusMessage = statusMessage == null ? null : Trinity.create(statusMessage, EventLog.formatForLog(statusMessage, "").status, stamp); } StatusBar.Info.set("", myProject, EventLog.LOG_REQUESTOR); }
Example #19
Source File: ConsoleLogModel.java From aem-ide-tooling-4-intellij with Apache License 2.0 | 5 votes |
void setStatusMessage(@Nullable Notification statusMessage, long stamp) { synchronized (myNotifications) { if (myStatusMessage != null && myStatusMessage.first == statusMessage) return; if (myStatusMessage == null && statusMessage == null) return; myStatusMessage = statusMessage == null ? null : Trinity.create(statusMessage, myStatuses.get(statusMessage), stamp); } StatusBar.Info.set("", myProject, ConsoleLog.LOG_REQUESTOR); }
Example #20
Source File: MethodParameterResolveContext.java From consulo-csharp with Apache License 2.0 | 5 votes |
@Nonnull @RequiredReadAction @Override public Trinity<String, DotNetTypeRef, Boolean> getParameterInfo(@Nonnull DotNetParameter parameter) { return Trinity.create(parameter.getName(), parameter.toTypeRef(true), parameter.hasModifier(CSharpModifier.OPTIONAL)); }
Example #21
Source File: SimpleParameterResolveContext.java From consulo-csharp with Apache License 2.0 | 5 votes |
@RequiredReadAction @Nonnull @Override public Trinity<String, DotNetTypeRef, Boolean> getParameterInfo(@Nonnull CSharpSimpleParameterInfo parameter) { return Trinity.create(parameter.getNotNullName(), parameter.getTypeRef(), parameter.isOptional()); }
Example #22
Source File: PackageFileWorker.java From consulo with Apache License 2.0 | 5 votes |
public static void packageFile(@Nonnull VirtualFile file, @Nonnull Project project, final Artifact[] artifacts) throws IOException { LOG.debug("Start packaging file: " + file.getPath()); final Collection<Trinity<Artifact, PackagingElementPath, String>> items = ArtifactUtil.findContainingArtifactsWithOutputPaths(file, project, artifacts); File ioFile = VfsUtilCore.virtualToIoFile(file); for (Trinity<Artifact, PackagingElementPath, String> item : items) { final Artifact artifact = item.getFirst(); final String outputPath = artifact.getOutputPath(); if (!StringUtil.isEmpty(outputPath)) { PackageFileWorker worker = new PackageFileWorker(ioFile, item.getThird()); LOG.debug(" package to " + outputPath); worker.packageFile(outputPath, item.getSecond().getParents()); } } }
Example #23
Source File: TranslatingCompilerFilesMonitor.java From consulo with Apache License 2.0 | 5 votes |
public abstract void collectFiles(CompileContext context, TranslatingCompiler compiler, Iterator<VirtualFile> scopeSrcIterator, boolean forceCompile, boolean isRebuild, Collection<VirtualFile> toCompile, Collection<Trinity<File, String, Boolean>> toDelete);
Example #24
Source File: LogModel.java From consulo with Apache License 2.0 | 4 votes |
@Nullable Trinity<Notification, String, Long> getStatusMessage() { synchronized (myNotifications) { return myStatusMessage; } }
Example #25
Source File: CodeStyleBlankLinesPanel.java From consulo with Apache License 2.0 | 4 votes |
private void initCustomOptions(OptionGroup optionGroup, String groupName) { for (Trinity<Class<? extends CustomCodeStyleSettings>, String, String> each : myCustomOptions.get(groupName)) { doCreateOption(optionGroup, each.third, new IntOption(each.third, each.first, each.second), each.second); } }
Example #26
Source File: ConsoleLogModel.java From aem-ide-tooling-4-intellij with Apache License 2.0 | 4 votes |
@Nullable Trinity<Notification, String, Long> getStatusMessage() { synchronized (myNotifications) { return myStatusMessage; } }
Example #27
Source File: TemplateKindCombo.java From consulo with Apache License 2.0 | 4 votes |
public void addItem(String presentableName, Image icon, String templateName) { getComboBox().addItem(new Trinity<>(presentableName, icon, templateName)); }
Example #28
Source File: FakeModel.java From teamcity-vmware-plugin with Apache License 2.0 | 4 votes |
public List<Trinity<String, String, Long>> getEvents() { return myEvents; }
Example #29
Source File: FakeModel.java From teamcity-vmware-plugin with Apache License 2.0 | 4 votes |
public void publishEvent(String entityName, String actionName){ myEvents.add(Trinity.create(entityName, actionName, System.currentTimeMillis())); }
Example #30
Source File: CreateDirectoryOrPackageAction.java From consulo with Apache License 2.0 | 4 votes |
@RequiredUIAccess @Override public void update(@Nonnull AnActionEvent event) { Presentation presentation = event.getPresentation(); Project project = event.getData(CommonDataKeys.PROJECT); if (project == null) { presentation.setVisible(false); presentation.setEnabled(false); return; } IdeView view = event.getData(LangDataKeys.IDE_VIEW); if (view == null) { presentation.setVisible(false); presentation.setEnabled(false); return; } final PsiDirectory[] directories = view.getDirectories(); if (directories.length == 0) { presentation.setVisible(false); presentation.setEnabled(false); return; } presentation.setVisible(true); presentation.setEnabled(true); // is more that one directories not show package support if (directories.length > 1) { presentation.setText(ChildType.Directory.getName()); presentation.setIcon(AllIcons.Nodes.TreeClosed); } else { Trinity<ContentFolderTypeProvider, PsiDirectory, ChildType> info = getInfo(directories[0]); presentation.setText(info.getThird().getName()); ContentFolderTypeProvider first = info.getFirst(); Image childIcon; if (first == null) { childIcon = AllIcons.Nodes.TreeClosed; } else { childIcon = first.getChildPackageIcon() == null ? first.getChildDirectoryIcon() : first.getChildPackageIcon(); } presentation.setIcon(childIcon); } }