当前位置: 首页>>代码示例>>Java>>正文


Java Function类代码示例

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


Function类属于com.intellij.util包,在下文中一共展示了Function类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: TSStructureViewTreeModel

import com.intellij.util.Function; //导入依赖的package包/类
public TSStructureViewTreeModel(
    @NotNull XmlFile file,
    @NotNull Function<DomElement, DomService.StructureViewMode> descriptor,
    @Nullable Editor editor
) {
    super(
        file,
        DomElementsNavigationManager.getManager(file.getProject())
                                    .getDomElementsNavigateProvider(DomElementsNavigationManager.DEFAULT_PROVIDER_NAME),
        descriptor,
        editor
    );
    myNavigationProvider = DomElementsNavigationManager.getManager(file.getProject())
                                                       .getDomElementsNavigateProvider(DomElementsNavigationManager.DEFAULT_PROVIDER_NAME);
    myDescriptor = descriptor;
}
 
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:17,代码来源:TSStructureViewTreeModel.java

示例2: asLiteLinearGraph

import com.intellij.util.Function; //导入依赖的package包/类
@NotNull
public static LiteLinearGraph asLiteLinearGraph(@NotNull final LinearGraph graph) {
  return new LiteLinearGraph() {
    @Override
    public int nodesCount() {
      return graph.nodesCount();
    }

    @NotNull
    @Override
    public List<Integer> getNodes(final int nodeIndex, @NotNull final NodeFilter filter) {
      return ContainerUtil.mapNotNull(graph.getAdjacentEdges(nodeIndex, filter.edgeFilter), new Function<GraphEdge, Integer>() {
        @Override
        public Integer fun(GraphEdge edge) {
          if (isEdgeUp(edge, nodeIndex)) return edge.getUpNodeIndex();
          if (isEdgeDown(edge, nodeIndex)) return edge.getDownNodeIndex();

          return null;
        }
      });
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:LinearGraphUtils.java

示例3: Response

import com.intellij.util.Function; //导入依赖的package包/类
public Response(@NotNull InputStream stream) throws Exception {
  final Element root = new SAXBuilder().build(stream).getRootElement();
  TaskUtil.prettyFormatXmlToLog(LOG, root);
  @NotNull final Element highlight = root.getChild("highlight");
  //assert highlight != null : "no '/IntelliSense/highlight' element in YouTrack response";
  myHighlightRanges = ContainerUtil.map(highlight.getChildren("range"), new Function<Element, HighlightRange>() {
    @Override
    public HighlightRange fun(Element range) {
      return new HighlightRange(range);
    }
  });

  @NotNull final Element suggest = root.getChild("suggest");
  //assert suggest != null : "no '/IntelliSense/suggest' element in YouTrack response";
  myCompletionItems = ContainerUtil.map(suggest.getChildren("item"), new Function<Element, CompletionItem>() {
    @Override
    public CompletionItem fun(Element item) {
      return new CompletionItem(item);
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:YouTrackIntellisense.java

示例4: CreateModuleLibraryChooser

import com.intellij.util.Function; //导入依赖的package包/类
public CreateModuleLibraryChooser(List<? extends LibraryType> libraryTypes, JComponent parentComponent,
                                  Module module,
                                  final LibraryTable.ModifiableModel moduleLibrariesModel,
                                  @Nullable final Function<LibraryType, LibraryProperties> defaultPropertiesFactory) {
  myParentComponent = parentComponent;
  myModule = module;
  myModuleLibrariesModel = moduleLibrariesModel;
  myDefaultPropertiesFactory = defaultPropertiesFactory;
  myLibraryTypes = new HashMap<LibraryRootsComponentDescriptor, LibraryType>();
  myDefaultDescriptor = new DefaultLibraryRootsComponentDescriptor();
  for (LibraryType<?> libraryType : libraryTypes) {
    LibraryRootsComponentDescriptor descriptor = null;
    if (libraryType != null) {
      descriptor = libraryType.createLibraryRootsComponentDescriptor();
    }
    if (descriptor == null) {
      descriptor = myDefaultDescriptor;
    }
    if (!myLibraryTypes.containsKey(descriptor)) {
      myLibraryTypes.put(descriptor, libraryType);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:CreateModuleLibraryChooser.java

示例5: VcsLogUserFilterImpl

import com.intellij.util.Function; //导入依赖的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;
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:VcsLogUserFilterImpl.java

示例6: getFullLog

import com.intellij.util.Function; //导入依赖的package包/类
public String getFullLog(final File... baseDirs) {
  return StringUtil.join(myLogLines, new Function<String, String>() {
    @Override
    public String fun(String s) {
      for (File dir : baseDirs) {
        if (dir != null) {
          String path = FileUtil.toSystemIndependentName(dir.getAbsolutePath()) + "/";
          if (s.startsWith(path)) {
            return s.substring(path.length());
          }
        }
      }
      return s;
    }
  }, "\n");
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:TestProjectBuilderLogger.java

示例7: collectTargets

import com.intellij.util.Function; //导入依赖的package包/类
private static <T> void collectTargets(PsiField field, final ArrayList<T> targets, final Function<PsiElement, T> fun, final boolean stopAtFirst) {
  final PsiClass containingClass = field.getContainingClass();
  LOG.assertTrue(containingClass != null);
  final String qualifiedName = containingClass.getQualifiedName();
  LOG.assertTrue(qualifiedName != null);
  final List<VirtualFile> fxmls = JavaFxControllerClassIndex.findFxmlsWithController(field.getProject(), qualifiedName);
  if (fxmls.isEmpty()) return;
  ReferencesSearch.search(field, GlobalSearchScope.filesScope(field.getProject(), fxmls)).forEach(
    new Processor<PsiReference>() {
      @Override
      public boolean process(PsiReference reference) {
        final PsiElement referenceElement = reference.getElement();
        if (referenceElement == null) return true;
        final PsiFile containingFile = referenceElement.getContainingFile();
        if (containingFile == null) return true;
        if (!JavaFxFileTypeFactory.isFxml(containingFile)) return true;
        if (!(referenceElement instanceof XmlAttributeValue)) return true;
        final XmlAttributeValue attributeValue = (XmlAttributeValue)referenceElement;
        final PsiElement parent = attributeValue.getParent();
        if (!(parent instanceof XmlAttribute)) return true;
        if (!FxmlConstants.FX_ID.equals(((XmlAttribute)parent).getName())) return true;
        targets.add(fun.fun(parent));
        return !stopAtFirst;
      }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:JavaFxRelatedItemLineMarkerProvider.java

示例8: processUnsuccessfulSelections

import com.intellij.util.Function; //导入依赖的package包/类
private void processUnsuccessfulSelections(final Object[] toSelect, Function<Object, Object> restore, Set<Object> originallySelected) {
  final Set<Object> selected = myUi.getSelectedElements();

  boolean wasFullyRejected = false;
  if (toSelect.length > 0 && !selected.isEmpty() && !originallySelected.containsAll(selected)) {
    final Set<Object> successfulSelections = new HashSet<Object>();
    ContainerUtil.addAll(successfulSelections, toSelect);

    successfulSelections.retainAll(selected);
    wasFullyRejected = successfulSelections.isEmpty();
  } else if (selected.isEmpty() && originallySelected.isEmpty()) {
    wasFullyRejected = true;
  }

  if (wasFullyRejected && !selected.isEmpty()) return;

  for (Object eachToSelect : toSelect) {
    if (!selected.contains(eachToSelect)) {
      restore.fun(eachToSelect);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:UpdaterTreeState.java

示例9: replaceDiamondWithExplicitTypes

import com.intellij.util.Function; //导入依赖的package包/类
public static PsiElement replaceDiamondWithExplicitTypes(PsiElement element) {
  final PsiElement parent = element.getParent();
  if (!(parent instanceof PsiJavaCodeReferenceElement)) {
    return parent;
  }
  final PsiJavaCodeReferenceElement javaCodeReferenceElement = (PsiJavaCodeReferenceElement) parent;
  final StringBuilder text = new StringBuilder();
  text.append(javaCodeReferenceElement.getQualifiedName());
  text.append('<');
  final PsiNewExpression newExpression = PsiTreeUtil.getParentOfType(element, PsiNewExpression.class);
  final PsiDiamondType.DiamondInferenceResult result = PsiDiamondTypeImpl.resolveInferredTypesNoCheck(newExpression, newExpression);
  text.append(StringUtil.join(result.getInferredTypes(), new Function<PsiType, String>() {
    @Override
    public String fun(PsiType psiType) {
      return psiType.getCanonicalText();
    }
  }, ","));
  text.append('>');
  final PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(element.getProject());
  final PsiJavaCodeReferenceElement newReference = elementFactory.createReferenceFromText(text.toString(), element);
  return CodeStyleManager.getInstance(javaCodeReferenceElement.getProject()).reformat(javaCodeReferenceElement.replace(newReference));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:PsiDiamondTypeUtil.java

示例10: deleteTask

import com.intellij.util.Function; //导入依赖的package包/类
private static void deleteTask(@NotNull final Course course, @NotNull final VirtualFile removedTask, @NotNull final Project project) {
  VirtualFile lessonDir = removedTask.getParent();
  if (lessonDir == null || !lessonDir.getName().contains(EduNames.LESSON)) {
    return;
  }
  final Lesson lesson = course.getLesson(lessonDir.getName());
  if (lesson == null) {
    return;
  }
  Task task = lesson.getTask(removedTask.getName());
  if (task == null) {
    return;
  }
  CCUtils.updateHigherElements(lessonDir.getChildren(), new Function<VirtualFile, StudyItem>() {
    @Override
    public StudyItem fun(VirtualFile file) {
      return lesson.getTask(file.getName());
    }
  }, task.getIndex(), EduNames.TASK, -1);
  lesson.getTaskList().remove(task);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:CCFileDeletedListener.java

示例11: checkContainsMethod

import com.intellij.util.Function; //导入依赖的package包/类
public static void checkContainsMethod(final Object rootElement,
                                       final AbstractTreeStructure structure,
                                       Function<AbstractTreeNode, VirtualFile[]> converterFunction) {
  MultiValuesMap<VirtualFile, AbstractTreeNode> map = new MultiValuesMap<VirtualFile, AbstractTreeNode>();
  collect((AbstractTreeNode)rootElement, map, structure, converterFunction);

  for (VirtualFile eachFile : map.keySet()) {
    Collection<AbstractTreeNode> nodes = map.values();
    for (final AbstractTreeNode node : nodes) {
      ProjectViewNode eachNode = (ProjectViewNode)node;
      boolean actual = eachNode.contains(eachFile);
      boolean expected = map.get(eachFile).contains(eachNode);
      if (actual != expected) {
        boolean actual1 = eachNode.contains(eachFile);
        boolean expected1 = map.get(eachFile).contains(eachNode);

        Assert.assertTrue("file=" + eachFile + " node=" + eachNode.getTestPresentation() + " expected:" + expected, false);
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:ProjectViewTestUtil.java

示例12: setUpDialog

import com.intellij.util.Function; //导入依赖的package包/类
private void setUpDialog(@NotNull String projectPath) {
  final AbstractExternalSystemSettings externalSystemSettings = ExternalSystemApiUtil.getSettings(myProject, myProjectSystemId);
  //noinspection unchecked
  Collection<ExternalProjectSettings> projectsSettings = externalSystemSettings.getLinkedProjectsSettings();
  List<ProjectItem> projects = ContainerUtil.map(projectsSettings, new Function<ExternalProjectSettings, ProjectItem>() {
    @Override
    public ProjectItem fun(ExternalProjectSettings settings) {
      return new ProjectItem(uiAware.getProjectRepresentationName(settings.getExternalProjectPath(), null), settings);
    }
  });

  myTree = new SimpleTree();
  myRootNode = new RootNode();
  treeBuilder = createTreeBuilder(myProject, myRootNode, myTree);
  final ExternalProjectSettings currentProjectSettings = externalSystemSettings.getLinkedProjectSettings(projectPath);
  if (currentProjectSettings != null) {
    SwingHelper.updateItems(projectCombobox, projects,
                            new ProjectItem(uiAware.getProjectRepresentationName(projectPath, null), currentProjectSettings));
  }
  projectCombobox.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      updateTree(myRootNode);
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:ConfigureTasksActivationDialog.java

示例13: stringifyBranchesByRepos

import com.intellij.util.Function; //导入依赖的package包/类
@NotNull
protected static String stringifyBranchesByRepos(@NotNull Map<GitRepository, String> heads) {
  MultiMap<String, VirtualFile> grouped = groupByBranches(heads);
  if (grouped.size() == 1) {
    return grouped.keySet().iterator().next();
  }
  return StringUtil.join(grouped.entrySet(), new Function<Map.Entry<String, Collection<VirtualFile>>, String>() {
    @Override
    public String fun(Map.Entry<String, Collection<VirtualFile>> entry) {
      String roots = StringUtil.join(entry.getValue(), new Function<VirtualFile, String>() {
        @Override
        public String fun(VirtualFile file) {
          return file.getName();
        }
      }, ", ");
      return entry.getKey() + " (in " + roots + ")";
    }
  }, "<br/>");
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:GitBranchOperation.java

示例14: convert

import com.intellij.util.Function; //导入依赖的package包/类
@NotNull
private static List<LibraryInfo> convert(final String urlPrefix, @NotNull ArtifactItem[] jars) {
  return ContainerUtil.mapNotNull(jars, new Function<ArtifactItem, LibraryInfo>() {
    @Override
    public LibraryInfo fun(ArtifactItem artifactItem) {
      String downloadUrl = artifactItem.getUrl();
      if (urlPrefix != null) {
        if (downloadUrl == null) {
          downloadUrl = artifactItem.getName();
        }
        if (!downloadUrl.startsWith("http://")) {
          downloadUrl = urlPrefix + downloadUrl;
        }
      }
      return new LibraryInfo(artifactItem.getName(), downloadUrl, downloadUrl, artifactItem.getMD5(), artifactItem.getRequiredClasses());
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:LibrariesDownloadAssistant.java

示例15: getModulesMap

import com.intellij.util.Function; //导入依赖的package包/类
protected <T> Map<String, T> getModulesMap(final Class<T> aClass) {
  final DomainObjectSet<? extends IdeaModule> ideaModules = allModels.getIdeaProject().getModules();

  final String filterKey = "to_filter";
  final Map<String, T> map = ContainerUtil.map2Map(ideaModules, new Function<IdeaModule, Pair<String, T>>() {
    @Override
    public Pair<String, T> fun(IdeaModule module) {
      final T value = allModels.getExtraProject(module, aClass);
      final String key = value != null ? module.getGradleProject().getPath() : filterKey;
      return Pair.create(key, value);
    }
  });

  map.remove(filterKey);
  return map;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:AbstractModelBuilderTest.java


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