本文整理汇总了Java中com.intellij.util.containers.Convertor.convert方法的典型用法代码示例。如果您正苦于以下问题:Java Convertor.convert方法的具体用法?Java Convertor.convert怎么用?Java Convertor.convert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.util.containers.Convertor
的用法示例。
在下文中一共展示了Convertor.convert方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processFilesRecursively
import com.intellij.util.containers.Convertor; //导入方法依赖的package包/类
public static void processFilesRecursively(@NotNull VirtualFile root,
@NotNull Processor<VirtualFile> processor,
@NotNull Convertor<VirtualFile, Boolean> directoryFilter) {
if (!processor.process(root)) return;
if (root.isDirectory() && directoryFilter.convert(root)) {
final LinkedList<VirtualFile[]> queue = new LinkedList<VirtualFile[]>();
queue.add(root.getChildren());
do {
final VirtualFile[] files = queue.removeFirst();
for (VirtualFile file : files) {
if (!processor.process(file)) return;
if (file.isDirectory() && directoryFilter.convert(file)) {
queue.add(file.getChildren());
}
}
} while (!queue.isEmpty());
}
}
示例2: filterUniqueRoots
import com.intellij.util.containers.Convertor; //导入方法依赖的package包/类
@Override
public <S> List<S> filterUniqueRoots(final List<S> in, final Convertor<S, VirtualFile> convertor) {
Collections.sort(in, new ComparatorDelegate<S, VirtualFile>(convertor, FilePathComparator.getInstance()));
for (int i = 1; i < in.size(); i++) {
final S sChild = in.get(i);
final VirtualFile child = convertor.convert(sChild);
final VirtualFile childRoot = GitUtil.gitRootOrNull(child);
if (childRoot == null) {
// non-git file actually, skip it
continue;
}
for (int j = i - 1; j >= 0; --j) {
final S sParent = in.get(j);
final VirtualFile parent = convertor.convert(sParent);
// the method check both that parent is an ancestor of the child and that they share common git root
if (VfsUtilCore.isAncestor(parent, child, false) && VfsUtilCore.isAncestor(childRoot, parent, false)) {
in.remove(i);
//noinspection AssignmentToForLoopParameter
--i;
break;
}
}
}
return in;
}
示例3: filterUniqueRoots
import com.intellij.util.containers.Convertor; //导入方法依赖的package包/类
@Override
public <S> List<S> filterUniqueRoots(final List<S> in, final Convertor<S, VirtualFile> convertor) {
Collections.sort(in, new ComparatorDelegate<S, VirtualFile>(convertor, FilePathComparator.getInstance()));
for (int i = 1; i < in.size(); i++) {
final S sChild = in.get(i);
final VirtualFile child = convertor.convert(sChild);
final VirtualFile childRoot = HgUtil.getHgRootOrNull(myProject, child);
if (childRoot == null) {
continue;
}
for (int j = i - 1; j >= 0; --j) {
final S sParent = in.get(j);
final VirtualFile parent = convertor.convert(sParent);
// if the parent is an ancestor of the child and that they share common root, the child is removed
if (VfsUtilCore.isAncestor(parent, child, false) && VfsUtilCore.isAncestor(childRoot, parent, false)) {
in.remove(i);
//noinspection AssignmentToForLoopParameter
--i;
break;
}
}
}
return in;
}
示例4: requestClientAuthentication
import com.intellij.util.containers.Convertor; //导入方法依赖的package包/类
@Override
public SVNAuthentication requestClientAuthentication(String kind,
SVNURL url,
String realm,
SVNErrorMessage errorMessage,
SVNAuthentication previousAuth,
boolean authMayBeStored) {
authMayBeStored = authMayBeStored && mySaveData;
Convertor<SVNURL, SVNAuthentication> convertor = myData.get(kind);
SVNAuthentication result = convertor == null ? null : convertor.convert(url);
if (result == null) {
if (ISVNAuthenticationManager.USERNAME.equals(kind)) {
result = new SVNUserNameAuthentication("username", authMayBeStored);
} else if (ISVNAuthenticationManager.PASSWORD.equals(kind)) {
result = new SVNPasswordAuthentication("username", "abc", authMayBeStored, url, false);
} else if (ISVNAuthenticationManager.SSH.equals(kind)) {
result = new SVNSSHAuthentication("username", "abc", -1, authMayBeStored, url, false);
} else if (ISVNAuthenticationManager.SSL.equals(kind)) {
result = new SVNSSLAuthentication(new File("aaa"), "abc", authMayBeStored, url, false);
}
}
if (! ISVNAuthenticationManager.USERNAME.equals(kind)) {
myManager.requested(ProviderType.interactive, url, realm, kind, result == null);
}
return result;
}
示例5: TableSpeedSearch
import com.intellij.util.containers.Convertor; //导入方法依赖的package包/类
public TableSpeedSearch(JTable table, final Convertor<Object, String> toStringConvertor) {
this(table, new PairFunction<Object, Cell, String>() {
@Override
public String fun(Object o, Cell c) {
return toStringConvertor.convert(o);
}
});
}
示例6: doIfCast
import com.intellij.util.containers.Convertor; //导入方法依赖的package包/类
@Nullable
public static <T, S> S doIfCast(@Nullable Object obj, @NotNull Class<T> clazz, final Convertor<T, S> convertor) {
if (clazz.isInstance(obj)) {
//noinspection unchecked
return convertor.convert((T)obj);
}
return null;
}
示例7: convert
import com.intellij.util.containers.Convertor; //导入方法依赖的package包/类
public static <T,U, S extends U> List<S> convert(@NotNull final Collection<T> in, final Convertor<T,S> convertor,
@Nullable final NotNullFunction<U, Boolean> outFilter) {
final List<S> out = new ArrayList<S>();
for (T t : in) {
final S converted = convertor.convert(t);
if ((outFilter != null) && (! Boolean.TRUE.equals(outFilter.fun(converted)))) continue;
out.add(converted);
}
return out;
}
示例8: restoreReadConfirm
import com.intellij.util.containers.Convertor; //导入方法依赖的package包/类
private void restoreReadConfirm(final VcsConfiguration.StandardConfirmation confirm,
final Convertor<String, VcsShowConfirmationOption.Value> initOptions) {
final VcsShowConfirmationOption.Value initValue = initOptions.convert(confirm.getId());
if (initValue != null) {
getConfirmation(confirm).setValue(initValue);
}
}
示例9: addNext
import com.intellij.util.containers.Convertor; //导入方法依赖的package包/类
public <T> void addNext(final Collection<T> values, final Convertor<T, String> convertor) {
final TreeSet<String> set = new TreeSet<String>(Arrays.asList(myValues));
for (T value : values) {
final String converted = convertor.convert(value);
if (converted != null) {
// also works as filter
set.add(converted);
}
}
myValues = ArrayUtil.toStringArray(set);
fireContentsChanged(this, 0, myValues.length);
}
示例10: findListToRemoveFrom
import com.intellij.util.containers.Convertor; //导入方法依赖的package包/类
private <T> boolean findListToRemoveFrom(@NotNull String name, @NotNull final List<T> elements,
final Convertor<T, AbstractUrl> convertor) {
Collection<TreeItem<Pair<AbstractUrl, String>>> list = getFavoritesListRootUrls(name);
if (elements.size() > 1) {
final List<T> sublist = elements.subList(0, elements.size() - 1);
for (T obj : sublist) {
AbstractUrl objUrl = convertor.convert(obj);
final TreeItem<Pair<AbstractUrl, String>> item = findNextItem(objUrl, list);
if (item == null || item.getChildren() == null) return false;
list = item.getChildren();
}
}
TreeItem<Pair<AbstractUrl, String>> found = null;
AbstractUrl url = convertor.convert(elements.get(elements.size() - 1));
if (url == null) return false;
for (TreeItem<Pair<AbstractUrl, String>> pair : list) {
if (url.equals(pair.getData().getFirst())) {
found = pair;
break;
}
}
if (found != null) {
list.remove(found);
rootsChanged();
return true;
}
return false;
}
示例11: extractRevision
import com.intellij.util.containers.Convertor; //导入方法依赖的package包/类
@Nullable
protected String extractRevision(final LocalPathIndifferentLogOperation operation, final Convertor<CvsRevisionNumber, Boolean> chooser) {
final Collection<CvsRevisionNumber> numberCollection = operation.getAllRevisions();
if (numberCollection == null) return null;
for (CvsRevisionNumber revisionNumber : numberCollection) {
final String stringPresentation = revisionNumber.asString();
if (chooser.convert(revisionNumber)) {
return stringPresentation;
}
}
return null;
}
示例12: translate
import com.intellij.util.containers.Convertor; //导入方法依赖的package包/类
public static String translate(NativeLogReader.CallInfo callInfo) {
final Convertor<NativeLogReader.CallInfo, String> convertor = ourAdvices.get(callInfo.getResultCode());
if (convertor != null) {
final String advice = convertor.convert(callInfo);
if (advice != null) return advice;
}
final Trinity<String, String, String> trinity = macMessages.get(callInfo.getResultCode());
if (trinity == null) return null;
return MessageFormat.format(ourGenericAdvice, callInfo.getFunctionName(),
new StringBuilder().append(callInfo.getResultCode()).append(" ( ").append(trinity.getFirst())
.append(" - ").append(trinity.getSecond()).append(")").toString());
}
示例13: filterUniqueRoots
import com.intellij.util.containers.Convertor; //导入方法依赖的package包/类
@Override
public <S> List<S> filterUniqueRoots(final List<S> in, final Convertor<S, VirtualFile> convertor) {
if (in.size() <= 1) return in;
final List<MyPair<S>> infos = new ArrayList<MyPair<S>>(in.size());
final SvnFileUrlMappingImpl mapping = (SvnFileUrlMappingImpl)getSvnFileUrlMapping();
final List<S> notMatched = new LinkedList<S>();
for (S s : in) {
final VirtualFile vf = convertor.convert(s);
if (vf == null) continue;
final File ioFile = new File(vf.getPath());
SVNURL url = mapping.getUrlForFile(ioFile);
if (url == null) {
url = SvnUtil.getUrl(this, ioFile);
if (url == null) {
notMatched.add(s);
continue;
}
}
infos.add(new MyPair<S>(vf, url.toString(), s));
}
final List<MyPair<S>> filtered = new UniqueRootsFilter().filter(infos);
final List<S> converted = ObjectsConvertor.convert(filtered, new Convertor<MyPair<S>, S>() {
@Override
public S convert(final MyPair<S> o) {
return o.getSrc();
}
});
if (!notMatched.isEmpty()) {
// potential bug is here: order is not kept. but seems it only occurs for cases where result is sorted after filtering so ok
converted.addAll(notMatched);
}
return converted;
}