本文整理汇总了Java中com.intellij.util.NullableFunction类的典型用法代码示例。如果您正苦于以下问题:Java NullableFunction类的具体用法?Java NullableFunction怎么用?Java NullableFunction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NullableFunction类属于com.intellij.util包,在下文中一共展示了NullableFunction类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkMethod
import com.intellij.util.NullableFunction; //导入依赖的package包/类
@Nullable
protected static PsiType checkMethod(@NotNull PsiMethod method, @NotNull @NonNls final String className, @NotNull final NullableFunction<PsiClass,PsiType> function) {
final PsiClass containingClass = method.getContainingClass();
if (containingClass == null) return null;
if (className.equals(containingClass.getQualifiedName())) {
return function.fun(containingClass);
}
final PsiType[] type = {null};
DeepestSuperMethodsSearch.search(method).forEach(new Processor<PsiMethod>() {
@Override
public boolean process(@NotNull PsiMethod psiMethod) {
final PsiClass rootClass = psiMethod.getContainingClass();
assert rootClass != null;
if (className.equals(rootClass.getQualifiedName())) {
type[0] = function.fun(rootClass);
return false;
}
return true;
}
});
return type[0];
}
示例2: filterTree
import com.intellij.util.NullableFunction; //导入依赖的package包/类
static SliceNode filterTree(SliceNode oldRoot,
NullableFunction<SliceNode, SliceNode> filter,
PairProcessor<SliceNode, List<SliceNode>> postProcessor) {
SliceNode filtered = filter.fun(oldRoot);
if (filtered == null) return null;
List<SliceNode> childrenFiltered = new ArrayList<SliceNode>();
if (oldRoot.myCachedChildren != null) {
for (SliceNode child : oldRoot.myCachedChildren) {
SliceNode childFiltered = filterTree(child, filter,postProcessor);
if (childFiltered != null) {
childrenFiltered.add(childFiltered);
}
}
}
boolean success = postProcessor == null || postProcessor.process(filtered, childrenFiltered);
if (!success) return null;
filtered.myCachedChildren = new ArrayList<SliceNode>(childrenFiltered);
return filtered;
}
示例3: createGroupTemplates
import com.intellij.util.NullableFunction; //导入依赖的package包/类
private static List<ArchivedProjectTemplate> createGroupTemplates(Element groupElement) {
return ContainerUtil.mapNotNull(groupElement.getChildren(TEMPLATE), new NullableFunction<Element, ArchivedProjectTemplate>() {
@Override
public ArchivedProjectTemplate fun(final Element element) {
if (!checkRequiredPlugins(element)) {
return null;
}
final ModuleType moduleType = ModuleTypeManager.getInstance().findByID(element.getChildText("moduleType"));
final String path = element.getChildText("path");
final String description = element.getChildTextTrim("description");
String name = element.getChildTextTrim("name");
RemoteProjectTemplate template = new RemoteProjectTemplate(name, element, moduleType, path, description);
template.populateFromElement(element);
return template;
}
});
}
示例4: getExtensions
import com.intellij.util.NullableFunction; //导入依赖的package包/类
@NotNull
public final List<V> getExtensions() {
synchronized (myExplicitExtensions) {
if (myCache == null) {
myExtensionPoint = getExtensionPoint();
myExtensionPoint.addExtensionPointListener(this);
myCache = new ArrayList<V>(myExplicitExtensions);
myCache.addAll(ContainerUtil.mapNotNull(myExtensionPoint.getExtensions(), new NullableFunction<Extension, V>() {
@Override
@Nullable
public V fun(final Extension extension) {
return getExtension(extension);
}
}));
}
return myCache;
}
}
示例5: typeAndCheck
import com.intellij.util.NullableFunction; //导入依赖的package包/类
private void typeAndCheck(VirtualFile file,
@Nullable final NonProjectFileWritingAccessProvider.UnlockOption option,
boolean fileHasBeenChanged) {
Editor editor = getEditor(file);
NullableFunction<List<VirtualFile>, NonProjectFileWritingAccessProvider.UnlockOption> unlocker =
new NullableFunction<List<VirtualFile>, NonProjectFileWritingAccessProvider.UnlockOption>() {
@Nullable
@Override
public NonProjectFileWritingAccessProvider.UnlockOption fun(List<VirtualFile> files) {
return option;
}
};
NonProjectFileWritingAccessProvider.setCustomUnlocker(unlocker);
String before = editor.getDocument().getText();
typeInChar(editor, 'a');
if (fileHasBeenChanged) {
assertEquals("Text should be changed", 'a' + before, editor.getDocument().getText());
}
else {
assertEquals("Text should not be changed", before, editor.getDocument().getText());
}
}
示例6: getRepositories
import com.intellij.util.NullableFunction; //导入依赖的package包/类
@NotNull
private List<R> getRepositories(@NotNull Collection<String> urls) {
final List<R> repositories = myRepositoryManager.getRepositories();
return ContainerUtil.mapNotNull(urls, new NullableFunction<String, R>() {
@Nullable
@Override
public R fun(final String s) {
return ContainerUtil.find(repositories, new Condition<R>() {
@Override
public boolean value(R repository) {
return s.equals(repository.getPresentableUrl());
}
});
}
});
}
示例7: CommitHelper
import com.intellij.util.NullableFunction; //导入依赖的package包/类
public CommitHelper(final Project project,
final ChangeList changeList,
final List<Change> includedChanges,
final String actionName,
final String commitMessage,
final List<CheckinHandler> handlers,
final boolean allOfDefaultChangeListChangesIncluded,
final boolean synchronously, final NullableFunction<Object, Object> additionalDataHolder,
@Nullable CommitResultHandler customResultHandler) {
myProject = project;
myChangeList = changeList;
myIncludedChanges = includedChanges;
myActionName = actionName;
myCommitMessage = commitMessage;
myHandlers = handlers;
myAllOfDefaultChangeListChangesIncluded = allOfDefaultChangeListChangesIncluded;
myForceSyncCommit = synchronously;
myAdditionalData = additionalDataHolder;
myCustomResultHandler = customResultHandler;
myConfiguration = VcsConfiguration.getInstance(myProject);
myDirtyScopeManager = VcsDirtyScopeManager.getInstance(myProject);
myFeedback = new HashSet<String>();
}
示例8: unzip
import com.intellij.util.NullableFunction; //导入依赖的package包/类
public static void unzip(@Nullable ProgressIndicator progress,
@NotNull File targetDir,
@NotNull File zipArchive,
@Nullable NullableFunction<String, String> pathConvertor,
@Nullable ContentProcessor contentProcessor,
boolean unwrapSingleTopLevelFolder) throws IOException {
File unzipToDir = getUnzipToDir(progress, targetDir, unwrapSingleTopLevelFolder);
ZipFile zipFile = new ZipFile(zipArchive, ZipFile.OPEN_READ);
try {
Enumeration<? extends ZipEntry> entries = zipFile.entries();
while (entries.hasMoreElements()) {
ZipEntry entry = entries.nextElement();
InputStream entryContentStream = zipFile.getInputStream(entry);
unzipEntryToDir(progress, entry, entryContentStream, unzipToDir, pathConvertor, contentProcessor);
entryContentStream.close();
}
}
finally {
zipFile.close();
}
doUnwrapSingleTopLevelFolder(unwrapSingleTopLevelFolder, unzipToDir, targetDir);
}
示例9: collectProducers
import com.intellij.util.NullableFunction; //导入依赖的package包/类
private MultiMap<SemKey, NullableFunction<PsiElement, ? extends SemElement>> collectProducers() {
final MultiMap<SemKey, NullableFunction<PsiElement, ? extends SemElement>> map = MultiMap.createSmart();
final SemRegistrar registrar = new SemRegistrar() {
@Override
public <T extends SemElement, V extends PsiElement> void registerSemElementProvider(SemKey<T> key,
final ElementPattern<? extends V> place,
final NullableFunction<V, T> provider) {
map.putValue(key, new NullableFunction<PsiElement, SemElement>() {
@Override
public SemElement fun(PsiElement element) {
if (place.accepts(element)) {
return provider.fun((V)element);
}
return null;
}
});
}
};
for (SemContributorEP contributor : myProject.getExtensions(SemContributor.EP_NAME)) {
contributor.registerSemProviders(myProject.getPicoContainer(), registrar);
}
return map;
}
示例10: createSemElements
import com.intellij.util.NullableFunction; //导入依赖的package包/类
@NotNull
private List<SemElement> createSemElements(SemKey key, PsiElement psi) {
List<SemElement> result = null;
final Collection<NullableFunction<PsiElement, ? extends SemElement>> producers = myProducers.get(key);
if (!producers.isEmpty()) {
for (final NullableFunction<PsiElement, ? extends SemElement> producer : producers) {
myCreatingSem.incrementAndGet();
try {
final SemElement element = producer.fun(psi);
if (element != null) {
if (result == null) result = new SmartList<SemElement>();
result.add(element);
}
}
finally {
myCreatingSem.decrementAndGet();
}
}
}
return result == null ? Collections.<SemElement>emptyList() : Collections.unmodifiableList(result);
}
示例11: getAllResources
import com.intellij.util.NullableFunction; //导入依赖的package包/类
public static <K, V extends Comparable> List<IndexedRelevantResource<K, V>> getAllResources(ID<K, V> indexId,
@Nullable final Module module,
@NotNull Project project,
@Nullable NullableFunction<List<IndexedRelevantResource<K, V>>, IndexedRelevantResource<K, V>> chooser) {
ArrayList<IndexedRelevantResource<K, V>> all = new ArrayList<IndexedRelevantResource<K, V>>();
Collection<K> allKeys = FileBasedIndex.getInstance().getAllKeys(indexId, project);
for (K key : allKeys) {
List<IndexedRelevantResource<K, V>> resources = getResources(indexId, key, module, project, null);
if (!resources.isEmpty()) {
if (chooser == null) {
all.add(resources.get(0));
}
else {
IndexedRelevantResource<K, V> resource = chooser.fun(resources);
if (resource != null) {
all.add(resource);
}
}
}
}
return all;
}
示例12: getContextHistory
import com.intellij.util.NullableFunction; //导入依赖的package包/类
private synchronized List<ContextInfo> getContextHistory(String zipPostfix) {
JBZipFile archive = null;
try {
archive = getTasksArchive(zipPostfix);
List<JBZipEntry> entries = archive.getEntries();
return ContainerUtil.mapNotNull(entries, new NullableFunction<JBZipEntry, ContextInfo>() {
public ContextInfo fun(JBZipEntry entry) {
return entry.getName().startsWith("/context") ? new ContextInfo(entry.getName(), entry.getTime(), entry.getComment()) : null;
}
});
}
catch (IOException e) {
LOG.error(e);
return Collections.emptyList();
}
finally {
closeArchive(archive);
}
}
示例13: commit
import com.intellij.util.NullableFunction; //导入依赖的package包/类
public List<VcsException> commit(List<Change> changes,
final String preparedComment,
@NotNull NullableFunction<Object, Object> parametersHolder,
final Set<String> feedback) {
final List<VcsException> exception = new ArrayList<VcsException>();
final List<FilePath> committables = getCommitables(changes);
final ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator();
if (progress != null) {
doCommit(committables, preparedComment, exception, feedback);
}
else if (ApplicationManager.getApplication().isDispatchThread()) {
ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() {
public void run() {
doCommit(committables, preparedComment, exception, feedback);
}
}, SvnBundle.message("progress.title.commit"), false, mySvnVcs.getProject());
}
else {
doCommit(committables, preparedComment, exception, feedback);
}
return exception;
}
示例14: doCopy
import com.intellij.util.NullableFunction; //导入依赖的package包/类
@Override
public void doCopy(PsiElement[] elements, PsiDirectory defaultTargetDirectory) {
final IProperty representative = PropertiesImplUtil.getProperty(elements[0]);
final String key = representative.getKey();
if (key == null) {
return;
}
final ResourceBundle resourceBundle = representative.getPropertiesFile().getResourceBundle();
final List<IProperty> properties = ContainerUtil.mapNotNull(resourceBundle.getPropertiesFiles(),
new NullableFunction<PropertiesFile, IProperty>() {
@Nullable
@Override
public IProperty fun(PropertiesFile propertiesFile) {
return propertiesFile.findPropertyByKey(key);
}
});
final PropertiesCopyDialog dlg = new PropertiesCopyDialog(properties, resourceBundle);
if (dlg.showAndGet()) {
final String propertyNewName = dlg.getCurrentPropertyName();
final ResourceBundle destinationResourceBundle = dlg.getCurrentResourceBundle();
copyPropertyToAnotherBundle(properties, propertyNewName, destinationResourceBundle);
}
}
示例15: getProperties
import com.intellij.util.NullableFunction; //导入依赖的package包/类
@NotNull
@Override
public IProperty[] getProperties() {
final List<IProperty> elements = ContainerUtil.mapNotNull(getChildren(), new NullableFunction<TreeElement, IProperty>() {
@Nullable
@Override
public IProperty fun(final TreeElement treeElement) {
if (treeElement instanceof PropertiesStructureViewElement) {
PropertiesStructureViewElement propertiesElement = (PropertiesStructureViewElement)treeElement;
return propertiesElement.getValue();
}
else if (treeElement instanceof ResourceBundlePropertyStructureViewElement) {
return ((ResourceBundlePropertyStructureViewElement)treeElement).getProperties()[0];
}
return null;
}
});
return elements.toArray(new IProperty[elements.size()]);
}