• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java NullableFunction类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.intellij.util.NullableFunction的典型用法代码示例。如果您正苦于以下问题:Java NullableFunction类的具体用法?Java NullableFunction怎么用?Java NullableFunction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



NullableFunction类属于com.intellij.util包,在下文中一共展示了NullableFunction类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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];
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:ExpectedTypesProvider.java


示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:SliceLeafAnalyzer.java


示例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;
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:RemoteTemplatesFactory.java


示例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;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:SmartExtensionPoint.java


示例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());
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:NonProjectFileAccessTest.java


示例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());
        }
      });
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:DvcsTaskHandler.java


示例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>();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:CommitHelper.java


示例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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:ZipUtil.java


示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:SemServiceImpl.java


示例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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:SemServiceImpl.java


示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:IndexedRelevantResource.java


示例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);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:WorkingContextManager.java


示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:SvnCheckinEnvironment.java


示例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);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:PropertiesCopyHandler.java


示例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()]);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:PropertiesPrefixGroup.java


示例16: collectLibraryLanguages

import com.intellij.util.NullableFunction; //导入依赖的package包/类
private static List<LanguageDefinition> collectLibraryLanguages(final ConvertContext context,
                                                                final Collection<PsiClass> allLanguages) {
  return ContainerUtil.mapNotNull(Language.getRegisteredLanguages(), new NullableFunction<Language, LanguageDefinition>() {
    @Override
    public LanguageDefinition fun(Language language) {
      if (language.getID().isEmpty() ||
          language instanceof DependentLanguage) {
        return null;
      }
      final PsiClass psiClass = DomJavaUtil.findClass(language.getClass().getName(), context.getInvocationElement());
      if (psiClass == null) {
        return null;
      }

      if (!allLanguages.contains(psiClass)) {
        return null;
      }

      final LanguageFileType type = language.getAssociatedFileType();
      final Icon icon = type != null ? type.getIcon() : null;
      return new LanguageDefinition(language.getID(),
                                    psiClass,
                                    icon, language.getDisplayName());
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:LanguageResolvingUtil.java


示例17: removeInjectionInPlace

import com.intellij.util.NullableFunction; //导入依赖的package包/类
@Override
public boolean removeInjectionInPlace(@Nullable final PsiLanguageInjectionHost psiElement) {
  if (!isStringLiteral(psiElement)) return false;

  GrLiteralContainer host = (GrLiteralContainer)psiElement;
  final HashMap<BaseInjection, Pair<PsiMethod, Integer>> injectionsMap = ContainerUtil.newHashMap();
  final ArrayList<PsiElement> annotations = new ArrayList<PsiElement>();
  final Project project = host.getProject();
  final Configuration configuration = Configuration.getProjectInstance(project);
  collectInjections(host, configuration, this, injectionsMap, annotations);

  if (injectionsMap.isEmpty() && annotations.isEmpty()) return false;
  final ArrayList<BaseInjection> originalInjections = new ArrayList<BaseInjection>(injectionsMap.keySet());
  final List<BaseInjection> newInjections = ContainerUtil.mapNotNull(originalInjections, new NullableFunction<BaseInjection, BaseInjection>() {
    @Override
    public BaseInjection fun(final BaseInjection injection) {
      final Pair<PsiMethod, Integer> pair = injectionsMap.get(injection);
      final String placeText = JavaLanguageInjectionSupport.getPatternStringForJavaPlace(pair.first, pair.second);
      final BaseInjection newInjection = injection.copy();
      newInjection.setPlaceEnabled(placeText, false);
      return InjectorUtils.canBeRemoved(newInjection) ? null : newInjection;
    }
  });
  configuration.replaceInjectionsWithUndo(project, newInjections, originalInjections, annotations);
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:GroovyLanguageInjectionSupport.java


示例18: _process

import com.intellij.util.NullableFunction; //导入依赖的package包/类
private static boolean _process(VirtualFile[] files, Project project, Processor<XmlFile> processor) {
  final PsiManager psiManager = PsiManager.getInstance(project);
  final PsiFile[] psiFiles = ContainerUtil.map2Array(files, PsiFile.class, new NullableFunction<VirtualFile, PsiFile>() {
    public PsiFile fun(VirtualFile file) {
      return psiManager.findFile(file);
    }
  });
  for (final PsiFile psiFile : psiFiles) {
    if (XsltSupport.isXsltFile(psiFile)) {
      if (!processor.process((XmlFile)psiFile)) {
        return false;
      }
    }
  }
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:XsltIncludeIndex.java


示例19: 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;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:19,代码来源:SliceLeafAnalyzer.java


示例20: doPaintFoldingTree

import com.intellij.util.NullableFunction; //导入依赖的package包/类
private void doPaintFoldingTree(final Graphics2D g, final Rectangle clip, int firstVisibleOffset, int lastVisibleOffset) {
  final int anchorX = getFoldingAreaOffset();
  final int width = getFoldingAnchorWidth();

  doForVisibleFoldRegions(
    new NullableFunction<FoldRegion, Void>() {
      @Override
      public Void fun(FoldRegion foldRegion) {
        drawAnchor(foldRegion, width, clip, g, anchorX, false, false);
        return null;
      }
    },
    firstVisibleOffset,
    lastVisibleOffset
  );

  if (myActiveFoldRegion != null) {
    drawAnchor(myActiveFoldRegion, width, clip, g, anchorX, true, true);
    drawAnchor(myActiveFoldRegion, width, clip, g, anchorX, true, false);
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:22,代码来源:EditorGutterComponentImpl.java



注:本文中的com.intellij.util.NullableFunction类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ClassPathBeanDefinitionScanner类代码示例发布时间:2022-05-21
下一篇:
Java FileTxnLog类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap