本文整理汇总了Java中com.intellij.util.containers.ContainerUtil.mapNotNull方法的典型用法代码示例。如果您正苦于以下问题:Java ContainerUtil.mapNotNull方法的具体用法?Java ContainerUtil.mapNotNull怎么用?Java ContainerUtil.mapNotNull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.util.containers.ContainerUtil
的用法示例。
在下文中一共展示了ContainerUtil.mapNotNull方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPackageDirectories
import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
private static PsiDirectory[] getPackageDirectories(Project project, String rootPackage, final GlobalSearchScope scope) {
final PsiManager manager = PsiManager.getInstance(project);
Query<VirtualFile> query = DirectoryIndex.getInstance(scope.getProject()).getDirectoriesByPackageName(rootPackage, true);
query = new FilteredQuery<VirtualFile>(query, new Condition<VirtualFile>() {
@Override
public boolean value(VirtualFile virtualFile) {
return scope.contains(virtualFile);
}
});
List<PsiDirectory> directories = ContainerUtil.mapNotNull(query.findAll(), new Function<VirtualFile, PsiDirectory>() {
@Override
public PsiDirectory fun(VirtualFile virtualFile) {
return manager.findDirectory(virtualFile);
}
});
return directories.toArray(new PsiDirectory[directories.size()]);
}
示例2: VcsLogUserFilterImpl
import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
public VcsLogUserFilterImpl(@NotNull Collection<String> users,
@NotNull Map<VirtualFile, VcsUser> meData,
@NotNull Set<VcsUser> allUsers) {
myUsers = users;
myData = meData;
myAllUserNames = ContainerUtil.mapNotNull(allUsers, new Function<VcsUser, String>() {
@Override
public String fun(VcsUser vcsUser) {
String name = vcsUser.getName();
if (!name.isEmpty()) {
return name.toLowerCase();
}
String email = vcsUser.getEmail();
int at = email.indexOf('@');
if (at > 0) {
return email.substring(0, at).toLowerCase();
}
return null;
}
});
}
示例3: findRootsWithMergeCommits
import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
@NotNull
private Collection<VirtualFile> findRootsWithMergeCommits(@NotNull Collection<GitRepository> rootsToSearch) {
return ContainerUtil.mapNotNull(rootsToSearch, new Function<GitRepository, VirtualFile>() {
@Override
public VirtualFile fun(GitRepository repo) {
PushSpec<GitPushSource, GitPushTarget> pushSpec = myPushSpecs.get(repo);
if (pushSpec == null) { // repository is not selected to be pushed, but can be rebased
GitPushSource source = myPushSupport.getSource(repo);
GitPushTarget target = myPushSupport.getDefaultTarget(repo);
if (target == null) {
return null;
}
pushSpec = new PushSpec<GitPushSource, GitPushTarget>(source, target);
}
String baseRef = pushSpec.getTarget().getBranch().getFullName();
String currentRef = pushSpec.getSource().getBranch().getFullName();
return GitRebaseOverMergeProblem.hasProblem(myProject, repo.getRoot(), baseRef, currentRef) ? repo.getRoot() : null;
}
});
}
示例4: getActionName
import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
private String getActionName(DataContext dataContext, @NotNull Executor executor) {
final ConfigurationContext context = ConfigurationContext.getFromContext(dataContext);
List<RunConfigurationProducer<?>> producers = RunConfigurationProducer.getProducers(context.getProject());
List<ConfigurationFromContext> list = ContainerUtil.mapNotNull(producers,
new Function<RunConfigurationProducer<?>, ConfigurationFromContext>() {
@Override
public ConfigurationFromContext fun(RunConfigurationProducer<?> producer) {
return createConfiguration(producer, context);
}
}
);
if (list.isEmpty()) return null;
ConfigurationFromContext configuration = list.get(myOrder < list.size() ? myOrder : 0);
String actionName = BaseRunConfigurationAction.suggestRunActionName((LocatableConfiguration)configuration.getConfiguration());
return executor.getStartActionText(actionName);
}
示例5: getSelectedRepoNode
import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
private Collection<MyRepoModel<?, ?, ?>> getSelectedRepoNode() {
if (mySingleRepoProject) {
return myView2Model.values();
}
//return not only selected but all loading with something to push;
// otherwise push/forcepush button may be enabled but no selected node exists
return ContainerUtil.mapNotNull(myView2Model.entrySet(),
new Function<Map.Entry<RepositoryNode, MyRepoModel<?, ?, ?>>, MyRepoModel<?, ?, ?>>() {
@Override
public MyRepoModel fun(Map.Entry<RepositoryNode, MyRepoModel<?, ?, ?>> entry) {
MyRepoModel<?, ?, ?> model = entry.getValue();
return model.isSelected() ||
(entry.getKey().isLoading() &&
model.getTarget() != null &&
notExcludedByUser(model.getRepository()) &&
model.getTarget().hasSomethingToPush()) ? model :
null;
}
});
}
示例6: getModelMappings
import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
@NotNull
private List<VcsDirectoryMapping> getModelMappings() {
return ContainerUtil.mapNotNull(myModel.getItems(), new Function<MapInfo, VcsDirectoryMapping>() {
@Override
public VcsDirectoryMapping fun(MapInfo info) {
return info == MapInfo.SEPARATOR || info.type == MapInfo.Type.UNREGISTERED ? null : info.mapping;
}
});
}
示例7: getFilesByModuleName
import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
@NotNull
private static List<ElmFile> getFilesByModuleName(@NotNull String moduleName, @NotNull Project project, @NotNull GlobalSearchScope searchScope) {
final PsiManager psiManager = PsiManager.getInstance(project);
Collection<VirtualFile> virtualFiles = getVirtualFilesByModuleName(moduleName, searchScope);
return ContainerUtil.mapNotNull(virtualFiles, virtualFile -> {
final PsiFile psiFile = psiManager.findFile(virtualFile);
return psiFile instanceof ElmFile ? (ElmFile)psiFile : null;
});
}
示例8: getDownNodes
import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
@NotNull
public static List<Integer> getDownNodes(@NotNull LinearGraph graph, final int nodeIndex) {
return ContainerUtil.mapNotNull(graph.getAdjacentEdges(nodeIndex, EdgeFilter.NORMAL_DOWN), new Function<GraphEdge, Integer>() {
@Nullable
@Override
public Integer fun(GraphEdge graphEdge) {
return graphEdge.getDownNodeIndex();
}
});
}
示例9: parseRemoteBranches
import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
@NotNull
private static List<String> parseRemoteBranches(@NotNull final GitRemote remote, @NotNull List<String> lsRemoteOutputLines) {
return ContainerUtil.mapNotNull(lsRemoteOutputLines, new Function<String, String>() {
@Override
public String fun(@NotNull String line) {
if (StringUtil.isEmptyOrSpaces(line)) return null;
String shortRemoteName = line.trim().substring(line.indexOf(GitBranch.REFS_HEADS_PREFIX) + GitBranch.REFS_HEADS_PREFIX.length());
return remote.getName() + "/" + shortRemoteName;
}
});
}
示例10: findNSFilesByURI
import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
public static Collection<XmlFile> findNSFilesByURI(String namespace, final Project project, Module module) {
final List<IndexedRelevantResource<String, XsdNamespaceBuilder>>
resources = XmlNamespaceIndex.getResourcesByNamespace(namespace, project, module);
final PsiManager psiManager = PsiManager.getInstance(project);
return ContainerUtil.mapNotNull(resources, new NullableFunction<IndexedRelevantResource<String, XsdNamespaceBuilder>, XmlFile>() {
@Override
public XmlFile fun(IndexedRelevantResource<String, XsdNamespaceBuilder> resource) {
PsiFile file = psiManager.findFile(resource.getFile());
return file instanceof XmlFile ? (XmlFile)file : null;
}
});
}
示例11: getRaisedExceptions
import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
@NotNull
@Override
public List<String> getRaisedExceptions() {
return ContainerUtil.mapNotNull(getExceptionFields(), new Function<SectionField, String>() {
@Override
public String fun(SectionField field) {
return StringUtil.nullize(field.getType());
}
});
}
示例12: getNodesForSupport
import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
@NotNull
private Collection<RepositoryNode> getNodesForSupport(final PushSupport<?, ?, ?> support) {
return ContainerUtil
.mapNotNull(myView2Model.entrySet(), new Function<Map.Entry<RepositoryNode, MyRepoModel<?, ?, ?>>, RepositoryNode>() {
@Override
public RepositoryNode fun(Map.Entry<RepositoryNode, MyRepoModel<?, ?, ?>> entry) {
return support.equals(entry.getValue().getSupport()) ? entry.getKey() : null;
}
});
}
示例13: replaceInjectionsWithUndo
import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
public static <T> void replaceInjectionsWithUndo(final Project project, final T add, final T remove,
final List<? extends PsiElement> psiElementsToRemove,
final PairProcessor<T, T> actualProcessor) {
final UndoableAction action = new GlobalUndoableAction() {
@Override
public void undo() {
actualProcessor.process(remove, add);
}
@Override
public void redo() {
actualProcessor.process(add, remove);
}
};
final List<PsiFile> psiFiles = ContainerUtil.mapNotNull(psiElementsToRemove, new NullableFunction<PsiElement, PsiFile>() {
@Override
public PsiFile fun(final PsiElement psiAnnotation) {
return psiAnnotation instanceof PsiCompiledElement ? null : psiAnnotation.getContainingFile();
}
});
new WriteCommandAction.Simple(project, "Language Injection Configuration Update", PsiUtilCore.toPsiFileArray(psiFiles)) {
@Override
public void run() {
for (PsiElement annotation : psiElementsToRemove) {
annotation.delete();
}
actualProcessor.process(add, remove);
UndoManager.getInstance(project).undoableActionPerformed(action);
}
@Override
protected UndoConfirmationPolicy getUndoConfirmationPolicy() {
return UndoConfirmationPolicy.REQUEST_CONFIRMATION;
}
}.execute();
}
示例14: loadDetails
import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
@NotNull
public static <T> List<T> loadDetails(@NotNull final Project project,
@NotNull final VirtualFile root,
boolean withRefs,
boolean withChanges,
@NotNull NullableFunction<GitLogRecord, T> converter,
String... parameters)
throws VcsException {
GitSimpleHandler h = new GitSimpleHandler(project, root, GitCommand.LOG);
GitLogParser.NameStatus status = withChanges ? GitLogParser.NameStatus.STATUS : GitLogParser.NameStatus.NONE;
GitLogParser.GitLogOption[] options = { HASH, COMMIT_TIME, AUTHOR_NAME, AUTHOR_TIME, AUTHOR_EMAIL, COMMITTER_NAME, COMMITTER_EMAIL,
PARENTS, SUBJECT, BODY, RAW_BODY };
if (withRefs) {
options = ArrayUtil.append(options, REF_NAMES);
}
GitLogParser parser = new GitLogParser(project, status, options);
h.setStdoutSuppressed(true);
h.addParameters(parameters);
h.addParameters(parser.getPretty(), "--encoding=UTF-8");
if (withRefs) {
h.addParameters("--decorate=full");
}
if (withChanges) {
h.addParameters("-M", "--name-status", "-c");
}
h.endOptions();
StopWatch sw = StopWatch.start("loading details");
String output = h.run();
sw.report();
sw = StopWatch.start("parsing");
List<GitLogRecord> records = parser.parse(output);
sw.report();
sw = StopWatch.start("Creating objects");
List<T> commits = ContainerUtil.mapNotNull(records, converter);
sw.report();
return commits;
}
示例15: collectRepositoriesFromFiles
import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
@NotNull
public static List<HgRepository> collectRepositoriesFromFiles(@NotNull final HgRepositoryManager repositoryManager,
@NotNull Collection<VirtualFile> files) {
return ContainerUtil.mapNotNull(files, new Function<VirtualFile, HgRepository>() {
@Override
public HgRepository fun(VirtualFile file) {
return repositoryManager.getRepositoryForFile(file);
}
});
}