com.intellij.psi.codeStyle.CustomCodeStyleSettings#com.intellij.openapi.util.Trinity源码实例Demo

下面列出了com.intellij.psi.codeStyle.CustomCodeStyleSettings#com.intellij.openapi.util.Trinity 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

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();
}
 
源代码2 项目: consulo   文件: LogModel.java
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();
}
 
源代码3 项目: consulo   文件: StubTreeBuilder.java
/**
 * 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));
}
 
源代码4 项目: consulo   文件: CodeStyleBlankLinesPanel.java
@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);
    }
  }
}
 
源代码5 项目: consulo   文件: TemplateKindCombo.java
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);
}
 
源代码6 项目: aem-ide-tooling-4-intellij   文件: ConsoleLog.java
@Nullable
public static Trinity<Notification, String, Long> getStatusMessage(@Nullable Project project) {
    ConsoleLogModel model = getLogModel(project);
    if(model != null) {
        return model.getStatusMessage();
    }
    return null;
}
 
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);
}
 
@Nonnull
@RequiredReadAction
@Override
public Trinity<String, DotNetTypeRef, Boolean> getParameterInfo(@Nonnull DotNetParameter parameter)
{
	return Trinity.create(parameter.getName(), parameter.toTypeRef(true), parameter.hasModifier(CSharpModifier.OPTIONAL));
}
 
@RequiredReadAction
@Nonnull
@Override
public Trinity<String, DotNetTypeRef, Boolean> getParameterInfo(@Nonnull CSharpSimpleParameterInfo parameter)
{
	return Trinity.create(parameter.getNotNullName(), parameter.getTypeRef(), parameter.isOptional());
}
 
源代码10 项目: consulo   文件: TranslatingCompilerFilesMonitor.java
public abstract void collectFiles(CompileContext context,
TranslatingCompiler compiler,
Iterator<VirtualFile> scopeSrcIterator,
boolean forceCompile,
boolean isRebuild,
Collection<VirtualFile> toCompile,
Collection<Trinity<File, String, Boolean>> toDelete);
 
源代码11 项目: consulo   文件: PackageFileWorker.java
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());
    }
  }
}
 
源代码12 项目: consulo   文件: LogModel.java
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);
}
 
源代码13 项目: consulo   文件: ResolveCache.java
@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;
}
 
源代码14 项目: consulo   文件: LocalInspectionsPass.java
@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;
}
 
源代码15 项目: consulo   文件: LocalInspectionsPass.java
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));
}
 
源代码16 项目: consulo   文件: BraceMatcherBasedSelectioner.java
@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;
}
 
源代码17 项目: consulo   文件: PrattBuilderImpl.java
@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;
}
 
源代码18 项目: consulo   文件: CreateWithTemplatesDialogPanel.java
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);
}
 
源代码19 项目: consulo   文件: CreateWithTemplatesDialogPanel.java
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;
    }
  }
}
 
源代码20 项目: consulo   文件: CreateDirectoryOrPackageAction.java
@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);
}
 
源代码21 项目: consulo   文件: CreateDirectoryOrPackageAction.java
@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);
}
 
源代码22 项目: consulo   文件: TemplateKindCombo.java
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;
}
 
源代码23 项目: consulo   文件: TemplateKindCombo.java
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;
    }
  }
}
 
@Nullable
Trinity<Notification, String, Long> getStatusMessage() {
    synchronized (myNotifications) {
        return myStatusMessage;
    }
}
 
源代码25 项目: teamcity-vmware-plugin   文件: FakeModel.java
public List<Trinity<String, String, Long>> getEvents() {
  return myEvents;
}
 
源代码26 项目: teamcity-vmware-plugin   文件: FakeModel.java
public void publishEvent(String entityName, String actionName){
  myEvents.add(Trinity.create(entityName, actionName, System.currentTimeMillis()));
}
 
源代码27 项目: consulo   文件: CompositeDependencyCache.java
@Override
public void syncOutDir(Trinity<File, String, Boolean> trinity) throws CacheCorruptedException {
  for (DependencyCache ourDependencyExtension : myDependencyCaches) {
    ourDependencyExtension.syncOutDir(trinity);
  }
}
 
源代码28 项目: consulo   文件: LogModel.java
@Nullable
Trinity<Notification, String, Long> getStatusMessage() {
  synchronized (myNotifications) {
    return myStatusMessage;
  }
}
 
源代码29 项目: consulo   文件: CodeStyleBlankLinesPanel.java
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);
  }
}
 
源代码30 项目: consulo   文件: ExecutorRegistryImpl.java
@Nonnull
private static Trinity<Project, String, String> createExecutionId(String executorId, @Nonnull ExecutionEnvironment environment) {
  return Trinity.create(environment.getProject(), executorId, environment.getRunner().getRunnerId());
}