Java Code Examples for com.intellij.util.containers.ContainerUtil#createMaybeSingletonList()

The following examples show how to use com.intellij.util.containers.ContainerUtil#createMaybeSingletonList() . 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: FossilLanguage.java    From idea-gitignore with MIT License 5 votes vote down vote up
/** {@link IgnoreLanguage} is a non-instantiable static class. */
private FossilLanguage() {
    super("Fossil", "ignore-glob", ".fossil-settings", Icons.FOSSIL, new OuterFileFetcher[]{

            // Outer file fetched from the .fossil-settings/ignore-glob file.
            project -> {
                final VirtualFile baseDir = Utils.guessProjectDir(project);
                return ContainerUtil.createMaybeSingletonList(baseDir == null ? null : baseDir
                        .findFileByRelativePath(INSTANCE.getVcsDirectory() + "/" + INSTANCE.getFilename()));
            }

    });
}
 
Example 2
Source File: CompilerEncodingServiceImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public Collection<Charset> getAllModuleEncodings(@Nonnull Module module) {
  final Set<Charset> encodings = myModuleFileEncodings.getValue().get(module);
  if (encodings != null) {
    return encodings;
  }
  return ContainerUtil.createMaybeSingletonList(EncodingProjectManager.getInstance(myProject).getDefaultCharset());
}
 
Example 3
Source File: PerFileMappingsBase.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void setMapping(@Nullable final VirtualFile file, @Nullable T dialect) {
  synchronized (myMappings) {
    if (dialect == null) {
      myMappings.remove(file);
    }
    else {
      myMappings.put(file, dialect);
    }
  }
  List<VirtualFile> files = ContainerUtil.createMaybeSingletonList(file);
  handleMappingChange(files, files, false);
}
 
Example 4
Source File: SingleRootFileViewProvider.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
@Nonnull
public final List<FileElement> getKnownTreeRoots() {
  PsiFile psiFile = getCachedPsi(getBaseLanguage());
  if (!(psiFile instanceof PsiFileImpl)) return Collections.emptyList();
  FileElement element = ((PsiFileImpl)psiFile).getTreeElement();
  return ContainerUtil.createMaybeSingletonList(element);
}
 
Example 5
Source File: FindUsagesHandler.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
protected Collection<String> getStringsToSearch(@Nonnull final PsiElement element) {
  if (element instanceof PsiNamedElement) {
    return ContainerUtil.createMaybeSingletonList(((PsiNamedElement)element).getName());
  }

  return Collections.singleton(element.getText());
}
 
Example 6
Source File: PackageViewPane.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public List<PsiElement> getElementsFromNode(@Nullable Object node) {
  Object o = getValueFromNode(node);
  if (o instanceof PackageElement) {
    PsiPackage aPackage = ((PackageElement)o).getPackage();
    return ContainerUtil.createMaybeSingletonList(aPackage.isValid() ? aPackage : null);
  }
  return super.getElementsFromNode(node);
}
 
Example 7
Source File: HaskellTarget.java    From intellij-haskforce with Apache License 2.0 4 votes vote down vote up
@NotNull
@Override
public Collection<File> getOutputRoots(CompileContext compileContext) {
    return ContainerUtil.createMaybeSingletonList(JpsJavaExtensionService.getInstance().getOutputDirectory(myModule, isTests()));
}
 
Example 8
Source File: UsageGroupingRuleEx.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
default List<UsageGroup> getParentGroupsFor(@Nonnull Usage usage, @Nonnull UsageTarget[] targets) {
  return ContainerUtil.createMaybeSingletonList(groupUsage(usage, targets));
}
 
Example 9
Source File: SingleParentUsageGroupingRule.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
public final List<UsageGroup> getParentGroupsFor(@Nonnull Usage usage, @Nonnull UsageTarget[] targets) {
  return ContainerUtil.createMaybeSingletonList(getParentGroupFor(usage, targets));
}
 
Example 10
Source File: DefaultProjectStoreImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
public List<SaveSession> createSaveSessions() {
  return ContainerUtil.createMaybeSingletonList(externalizationSession.createSaveSession());
}
 
Example 11
Source File: SingleRootFileViewProvider.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
@Nonnull
public List<PsiFile> getAllFiles() {
  return ContainerUtil.createMaybeSingletonList(getPsi(getBaseLanguage()));
}
 
Example 12
Source File: SingleRootFileViewProvider.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
public final List<PsiFile> getCachedPsiFiles() {
  return ContainerUtil.createMaybeSingletonList(getCachedPsi(getBaseLanguage()));
}
 
Example 13
Source File: NavigationGutterIconBuilder.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
@Nonnull
public Collection<? extends PsiElement> fun(final PsiElement element) {
  return ContainerUtil.createMaybeSingletonList(element);
}
 
Example 14
Source File: UsageGroupingRule.java    From consulo with Apache License 2.0 2 votes vote down vote up
/**
 * Return list of nested parent groups for a usage. The specified usage will be placed into the last group from the list, that group
 * will be placed under the next to last group, etc.
 * <p>If the rule returns at most one parent group extend {@link SingleParentUsageGroupingRule} and override
 * {@link SingleParentUsageGroupingRule#getParentGroupFor getParentGroupFor} instead.</p>
 */
@Nonnull
default List<UsageGroup> getParentGroupsFor(@Nonnull Usage usage, @Nonnull UsageTarget[] targets) {
  return ContainerUtil.createMaybeSingletonList(groupUsage(usage));
}