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

The following examples show how to use com.intellij.util.containers.ContainerUtil#emptyList() . 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: OCamlSourcesOrderRootTypeUIFactory.java    From reasonml-idea-plugin with MIT License 6 votes vote down vote up
@NotNull
List<VirtualFile> suggestOCamlRoots(@NotNull VirtualFile dir, @NotNull final ProgressIndicator progressIndicator) {
    if (!dir.isDirectory()) {
        return ContainerUtil.emptyList();
    }

    final FileTypeManager typeManager = FileTypeManager.getInstance();
    final ArrayList<VirtualFile> foundDirectories = new ArrayList<>();
    try {
        VfsUtilCore.visitChildrenRecursively(dir, new VirtualFileVisitor() {
            @NotNull
            @Override
            public Result visitFileEx(@NotNull VirtualFile file) {
                progressIndicator.checkCanceled();

                if (!file.isDirectory()) {
                    FileType type = typeManager.getFileTypeByFileName(file.getName());

                    if (type.getDefaultExtension().equals("ml")) {
                        VirtualFile root = file.getParent();
                        if (root != null) {
                            foundDirectories.add(root);
                            return skipTo(root);
                        }
                    }
                }

                return CONTINUE;
            }
        });
    } catch (ProcessCanceledException ignore) {
    }

    return foundDirectories;
}
 
Example 2
Source File: PsiTreeUtil.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
public static <T extends PsiElement> Collection<T> findChildrenOfAnyType(@Nullable final PsiElement element, @Nonnull final Class<? extends T>... classes) {
  if (element == null) {
    return ContainerUtil.emptyList();
  }

  PsiElementProcessor.CollectElements<T> processor = new PsiElementProcessor.CollectElements<T>() {
    @Override
    public boolean execute(@Nonnull T each) {
      if (each == element) return true;
      if (instanceOf(each, classes)) {
        return super.execute(each);
      }
      return true;
    }
  };
  processElements(element, processor);
  return processor.getCollection();
}
 
Example 3
Source File: FluidTypeResolver.java    From idea-php-typo3-plugin with MIT License 6 votes vote down vote up
/**
 * Get the "for IN" variable identifier as separated string
 * <p>
 * {% for car in "cars" %}
 * {% for car in "cars"|length %}
 * {% for car in "cars.test" %}
 */
@NotNull
public static Collection<String> getForTagIdentifierAsString(XmlTag forTag) {
    XmlAttribute each = forTag.getAttribute("each");
    if (each == null || each.getValueElement() == null) {
        return ContainerUtil.emptyList();
    }

    PsiElement fluidElement = FluidUtil.retrieveFluidElementAtPosition(each.getValueElement());
    if (fluidElement == null) {
        return Collections.emptyList();
    }

    PsiElement deepestFirst = PsiTreeUtil.getDeepestFirst(fluidElement);

    return FluidTypeResolver.formatPsiTypeName(deepestFirst);
}
 
Example 4
Source File: PsiRecord.java    From reasonml-idea-plugin with MIT License 5 votes vote down vote up
@NotNull
public Collection<PsiRecordField> getFields() {
    PsiElement[] children = getChildren();
    if (children.length == 0) {
        return ContainerUtil.emptyList();
    }

    List<PsiRecordField> result = new ArrayList<>();
    for (PsiElement child : children) {
        if (child instanceof PsiRecordField) {
            result.add((PsiRecordField) child);
        }
    }
    return result;
}
 
Example 5
Source File: TreeBackedLighterAST.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public List<LighterASTNode> getChildren(@Nonnull final LighterASTNode parent) {
  final ASTNode[] children = ((NodeWrapper)parent).myNode.getChildren(null);
  if (children.length == 0) return ContainerUtil.emptyList();

  List<LighterASTNode> result = new ArrayList<>(children.length);
  for (final ASTNode child : children) {
    result.add(wrap(child));
  }
  return result;
}
 
Example 6
Source File: StringUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
/**
 * @return list containing all words in {@code text}, or {@link ContainerUtil#emptyList()} if there are none.
 * The <b>word</b> here means the maximum sub-string consisting entirely of characters which are <code>Character.isJavaIdentifierPart(c)</code>.
 */
@Nonnull
@Contract(pure = true)
public static List<String> getWordsIn(@Nonnull String text) {
  List<String> result = null;
  int start = -1;
  for (int i = 0; i < text.length(); i++) {
    char c = text.charAt(i);
    boolean isIdentifierPart = Character.isJavaIdentifierPart(c);
    if (isIdentifierPart && start == -1) {
      start = i;
    }
    if (isIdentifierPart && i == text.length() - 1 && start != -1) {
      if (result == null) {
        result = new SmartList<String>();
      }
      result.add(text.substring(start, i + 1));
    }
    else if (!isIdentifierPart && start != -1) {
      if (result == null) {
        result = new SmartList<String>();
      }
      result.add(text.substring(start, i));
      start = -1;
    }
  }
  if (result == null) {
    return ContainerUtil.emptyList();
  }
  return result;
}
 
Example 7
Source File: GroupByPackages.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
public List<File> getChildren(File file) {
  Collection<File> collection = myParentToChildrenMap.get(file);
  if (collection == null) {
    return ContainerUtil.emptyList();
  }
  return new ArrayList<File>(collection);
}
 
Example 8
Source File: VfsUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
public static List<VirtualFile> getChildren(@Nonnull VirtualFile dir, @Nonnull VirtualFileFilter filter) {
  List<VirtualFile> result = null;
  for (VirtualFile child : dir.getChildren()) {
    if (filter.accept(child)) {
      if (result == null) result = ContainerUtil.newSmartList();
      result.add(child);
    }
  }
  return result != null ? result : ContainerUtil.<VirtualFile>emptyList();
}
 
Example 9
Source File: PushLog.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
private List<CommitNode> getSelectedCommitNodes() {
  int[] rows = myTree.getSelectionRows();
  if (rows != null && rows.length != 0) {
    List<DefaultMutableTreeNode> selectedNodes = getNodesForRows(getSortedRows(rows));
    return collectSelectedCommitNodes(selectedNodes);
  }
  return ContainerUtil.emptyList();
}
 
Example 10
Source File: VcsAwareFormatChangedTextUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
@Nonnull
public List<TextRange> getChangedTextRanges(@Nonnull Project project, @Nonnull PsiFile file) throws FilesTooBigForDiffException {
  Document document = PsiDocumentManager.getInstance(project).getDocument(file);
  if (document == null) return ContainerUtil.emptyList();

  List<TextRange> cachedChangedLines = getCachedChangedLines(project, document);
  if (cachedChangedLines != null) {
    return cachedChangedLines;
  }

  if (ApplicationManager.getApplication().isUnitTestMode()) {
    CharSequence testContent = file.getUserData(TEST_REVISION_CONTENT);
    if (testContent != null) {
      return calculateChangedTextRanges(document, testContent);
    }
  }

  Change change = ChangeListManager.getInstance(project).getChange(file.getVirtualFile());
  if (change == null) {
    return ContainerUtilRt.emptyList();
  }
  if (change.getType() == Change.Type.NEW) {
    return ContainerUtil.newArrayList(file.getTextRange());
  }

  String contentFromVcs = getRevisionedContentFrom(change);
  return contentFromVcs != null ? calculateChangedTextRanges(document, contentFromVcs)
                                : ContainerUtil.<TextRange>emptyList();
}
 
Example 11
Source File: IgnoreFilesIndex.java    From idea-gitignore with MIT License 5 votes vote down vote up
/**
 * Returns collection of indexed {@link IgnoreEntryOccurrence} for given {@link Project} and {@link IgnoreFileType}.
 *
 * @param project  current project
 * @param fileType filetype
 * @return {@link IgnoreEntryOccurrence} collection
 */
@NotNull
public static List<IgnoreEntryOccurrence> getEntries(@NotNull Project project, @NotNull IgnoreFileType fileType) {
    try {
        if (ApplicationManager.getApplication().isReadAccessAllowed()) {
            final GlobalSearchScope scope = IgnoreSearchScope.get(project);
            return FileBasedIndex.getInstance()
                    .getValues(IgnoreFilesIndex.KEY, new IgnoreFileTypeKey(fileType), scope);
        }
    } catch (RuntimeException ignored) {
    }
    return ContainerUtil.emptyList();
}
 
Example 12
Source File: ApiStructureViewElement.java    From ApiDebugger with Apache License 2.0 5 votes vote down vote up
@NotNull
@Override
public Collection<StructureViewTreeElement> getChildrenBase() {
    PsiElement element = getElement();
    if (element instanceof ApiPsiFile) {
        ApiDebugger type = PsiTreeUtil.findChildOfType(element, ApiDebugger.class);
        if (type != null) {

            return ContainerUtil.newArrayList();
        }
    }
    return ContainerUtil.emptyList();
}
 
Example 13
Source File: DetailsPanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
protected void onEmptySelection() {
  myEmptyText.setText("No commits selected");
  myMainContentPanel.removeAll();
  mySelection = ContainerUtil.emptyList();
  myCommitDetails = Collections.emptySet();
}
 
Example 14
Source File: ExtLocalconfNamespaceProvider.java    From idea-php-typo3-plugin with MIT License 5 votes vote down vote up
@NotNull
@Override
public Collection<FluidNamespace> provideForElement(@NotNull PsiElement element) {
    PsiFile[] filesByName = FilenameIndex.getFilesByName(element.getProject(), "ext_localconf.php", GlobalSearchScope.allScope(element.getProject()));

    return ContainerUtil.emptyList();
}
 
Example 15
Source File: CommitPanel.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
private List<VcsRef> sortRefs(@Nonnull Collection<VcsRef> refs) {
  VcsRef ref = ContainerUtil.getFirstItem(refs);
  if (ref == null) return ContainerUtil.emptyList();
  return ContainerUtil.sorted(refs, myLogData.getLogProvider(ref.getRoot()).getReferenceManager().getLabelsOrderComparator());
}
 
Example 16
Source File: ArrangementStandardSettingsManager.java    From consulo with Apache License 2.0 4 votes vote down vote up
public ArrangementStandardSettingsManager(@Nonnull ArrangementStandardSettingsAware delegate,
                                          @Nonnull ArrangementColorsProvider colorsProvider) {
  this(delegate, colorsProvider, ContainerUtil.<StdArrangementRuleAliasToken>emptyList());
}
 
Example 17
Source File: LoadingDetails.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
public Collection<Change> getChanges() {
  return ContainerUtil.emptyList();
}
 
Example 18
Source File: RunAnythingRunConfigurationProvider.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
public List<RunAnythingContext> getExecutionContexts(@Nonnull DataContext dataContext) {
  return ContainerUtil.emptyList();
}
 
Example 19
Source File: Utils.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
public static List<Shortcut> shortcutsOf(@Nonnull String actionId) {
  AnAction action = ActionManager.getInstance().getAction(actionId);
  return action == null ? ContainerUtil.<Shortcut>emptyList() : ContainerUtil.immutableList(action.getShortcutSet().getShortcuts());
}
 
Example 20
Source File: StdArrangementRuleAliasToken.java    From consulo with Apache License 2.0 4 votes vote down vote up
public StdArrangementRuleAliasToken(@Nonnull String name) {
  this(name, ContainerUtil.<StdArrangementMatchRule>emptyList());
}