Java 类com.intellij.util.Function 实例源码

项目:hybris-integration-intellij-idea-plugin    文件:TSStructureViewTreeModel.java   
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;
}
项目:intellij-ce-playground    文件:LinearGraphUtils.java   
@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;
        }
      });
    }
  };
}
项目:intellij-ce-playground    文件:YouTrackIntellisense.java   
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);
    }
  });
}
项目:intellij-ce-playground    文件:CreateModuleLibraryChooser.java   
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);
    }
  }
}
项目:intellij-ce-playground    文件:VcsLogUserFilterImpl.java   
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;
    }
  });
}
项目:intellij-ce-playground    文件:TestProjectBuilderLogger.java   
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");
}
项目:intellij-ce-playground    文件:JavaFxRelatedItemLineMarkerProvider.java   
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;
      }
  });
}
项目:intellij-ce-playground    文件:UpdaterTreeState.java   
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);
    }
  }
}
项目:intellij-ce-playground    文件:PsiDiamondTypeUtil.java   
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));
}
项目:intellij-ce-playground    文件:CCFileDeletedListener.java   
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);
}
项目:intellij-ce-playground    文件:ProjectViewTestUtil.java   
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);
      }
    }
  }
}
项目:intellij-ce-playground    文件:ConfigureTasksActivationDialog.java   
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);
    }
  });
}
项目:intellij-ce-playground    文件:GitBranchOperation.java   
@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/>");
}
项目:intellij-ce-playground    文件:LibrariesDownloadAssistant.java   
@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());
    }
  });
}
项目:intellij-ce-playground    文件:AbstractModelBuilderTest.java   
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;
}
项目:intellij-ce-playground    文件:StateMerger.java   
boolean stripAndMerge(Collection<DfaMemoryStateImpl> group,
                           Function<DfaMemoryStateImpl, DfaMemoryStateImpl> stripper) {
  if (group.size() <= 1) return false;

  boolean hasMerges = false;
  MultiMap<DfaMemoryStateImpl, DfaMemoryStateImpl> strippedToOriginals = MultiMap.create();
  for (DfaMemoryStateImpl original : group) {
    strippedToOriginals.putValue(stripper.fun(original), original);
  }
  for (Map.Entry<DfaMemoryStateImpl, Collection<DfaMemoryStateImpl>> entry : strippedToOriginals.entrySet()) {
    Collection<DfaMemoryStateImpl> merged = entry.getValue();
    if (merged.size() > 1) {
      myRemovedStates.addAll(merged);
      myMerged.add(entry.getKey());
      hasMerges = true;
    }
  }
  return hasMerges;
}
项目:intellij-ce-playground    文件:ValueModifierUtil.java   
@NotNull
public static Promise<Value> evaluateGet(@NotNull final Variable variable,
                                         @NotNull Object host,
                                         @NotNull EvaluateContext evaluateContext,
                                         @NotNull String selfName) {
  StringBuilder builder = new StringBuilder(selfName);
  appendUnquotedName(builder, variable.getName());
  return evaluateContext.evaluate(builder.toString(), Collections.singletonMap(selfName, host), false)
    .then(new Function<EvaluateResult, Value>() {
      @Override
      public Value fun(EvaluateResult result) {
        variable.setValue(result.value);
        return result.value;
      }
    });
}
项目:intellij-ce-playground    文件:NullableStuffInspectionBase.java   
private void checkNullableStuffForMethod(PsiMethod method, final ProblemsHolder holder) {
  Annotated annotated = check(method, holder, method.getReturnType());

  List<PsiMethod> superMethods = ContainerUtil.map(
    method.findSuperMethodSignaturesIncludingStatic(true), new Function<MethodSignatureBackedByPsiMethod, PsiMethod>() {
      @Override
      public PsiMethod fun(MethodSignatureBackedByPsiMethod signature) {
        return signature.getMethod();
      }
    });

  final NullableNotNullManager nullableManager = NullableNotNullManager.getInstance(holder.getProject());

  checkSupers(method, holder, annotated, superMethods, nullableManager);
  checkParameters(method, holder, superMethods, nullableManager);
  checkOverriders(method, holder, annotated, nullableManager);
}
项目:intellij-ce-playground    文件:DebugLogManager.java   
@NotNull
private static List<String> getCurrentCategories() {
  Enumeration currentLoggers = LogManager.getCurrentLoggers();
  return ContainerUtil.mapNotNull(ContainerUtil.toList(currentLoggers), new Function<Object, String>() {
    @Override
    public String fun(Object o) {
      if (o instanceof org.apache.log4j.Logger) {
        String category = ((org.apache.log4j.Logger)o).getName();
        if (Logger.getInstance(category).isDebugEnabled()) {
          return category;
        }
      }
      return null;
    }
  });
}
项目:intellij-ce-playground    文件:GitBranchOperation.java   
protected GitBranchOperation(@NotNull Project project, @NotNull GitPlatformFacade facade, @NotNull Git git,
                             @NotNull GitBranchUiHandler uiHandler, @NotNull Collection<GitRepository> repositories) {
  myProject = project;
  myFacade = facade;
  myGit = git;
  myUiHandler = uiHandler;
  myRepositories = repositories;
  myCurrentHeads = ContainerUtil.map2Map(repositories, new Function<GitRepository, Pair<GitRepository, String>>() {
    @Override
    public Pair<GitRepository, String> fun(GitRepository repository) {
      GitLocalBranch currentBranch = repository.getCurrentBranch();
      return Pair.create(repository, currentBranch == null ? repository.getCurrentRevision() : currentBranch.getName());
    }
  });
  mySuccessfulRepositories = new ArrayList<GitRepository>();
  myRemainingRepositories = new ArrayList<GitRepository>(myRepositories);
  mySettings = myFacade.getSettings(myProject);
}
项目:intellij-ce-playground    文件:FileReferenceSet.java   
@NotNull
public Collection<PsiFileSystemItem> computeDefaultContexts() {
  final PsiFile file = getContainingFile();
  if (file == null) return Collections.emptyList();

  if (myOptions != null) {
    final Function<PsiFile, Collection<PsiFileSystemItem>> value = DEFAULT_PATH_EVALUATOR_OPTION.getValue(myOptions);
    if (value != null) {
      final Collection<PsiFileSystemItem> roots = value.fun(file);
      if (roots != null) {
        for (PsiFileSystemItem root : roots) {
          LOG.assertTrue(root != null, "Default path evaluator " + value + " produced a null root for " + file);
        }
        return roots;
      }
    }
  }

  if (isAbsolutePathReference()) {
    return getAbsoluteTopLevelDirLocations(file);
  }

  return getContextByFile(file);
}
项目:intellij-ce-playground    文件:PyUnreachableCodeInspection.java   
public static boolean hasAnyInterruptedControlFlowPaths(@NotNull PsiElement element) {
  final ScopeOwner owner = ScopeUtil.getScopeOwner(element);
  if (owner != null) {
    final ControlFlow flow = ControlFlowCache.getControlFlow(owner);
    final Instruction[] instructions = flow.getInstructions();
    final int start = ControlFlowUtil.findInstructionNumberByElement(instructions, element);
    if (start >= 0) {
      final Ref<Boolean> resultRef = Ref.create(false);
      ControlFlowUtil.iteratePrev(start, instructions, new Function<Instruction, ControlFlowUtil.Operation>() {
        @Override
        public ControlFlowUtil.Operation fun(Instruction instruction) {
          if (instruction.allPred().isEmpty() && !isFirstInstruction(instruction)) {
            resultRef.set(true);
            return ControlFlowUtil.Operation.BREAK;
          }
          return ControlFlowUtil.Operation.NEXT;
        }
      });
      return resultRef.get();
    }
  }
  return false;
}
项目:intellij-ce-playground    文件:PopupFactoryImpl.java   
protected void handleToggleAction() {
  final Object[] selectedValues = getList().getSelectedValues();

  ListPopupStep<Object> listStep = getListStep();
  final ActionPopupStep actionPopupStep = ObjectUtils.tryCast(listStep, ActionPopupStep.class);
  if (actionPopupStep == null) return;

  List<ToggleAction> filtered = ContainerUtil.mapNotNull(selectedValues, new Function<Object, ToggleAction>() {
    @Override
    public ToggleAction fun(Object o) {
      return getActionByClass(o, actionPopupStep, ToggleAction.class);
    }
  });

  for (ToggleAction action : filtered) {
    actionPopupStep.performAction(action, 0);
  }

  for (ActionItem item : actionPopupStep.myItems) {
    updateActionItem(item);
  }

  getList().repaint();
}
项目:intellij-ce-playground    文件:IconDeferrerImpl.java   
private <T> Icon deferImpl(Icon base, T param, @NotNull Function<T, Icon> f, final boolean autoupdatable) {
  if (myEvaluationIsInProgress.get().booleanValue()) {
    return f.fun(param);
  }

  synchronized (LOCK) {
    Icon result = myIconsCache.get(param);
    if (result == null) {
      final long started = myLastClearTimestamp;
      result = new DeferredIconImpl<T>(base, param, f, new DeferredIconImpl.IconListener<T>() {
        @Override
        public void evalDone(DeferredIconImpl<T> source, T key, @NotNull Icon r) {
          synchronized (LOCK) {
            // check if our results is not outdated yet
            if (started == myLastClearTimestamp) {
              myIconsCache.put(key, autoupdatable ? source: r);
            }
          }
        }
      }, autoupdatable);
      myIconsCache.put(param, result);
    }

    return result;
  }
}
项目:hybris-integration-intellij-idea-plugin    文件:TSStructureTreeElement.java   
public <T extends DomElement> TSStructureTreeElement(
    final T stableCopy,
    final Function<DomElement, DomService.StructureViewMode> myDescriptor,
    final DomElementNavigationProvider myNavigationProvider
) {
    super(stableCopy, myDescriptor, myNavigationProvider);
    this.myDescriptor = myDescriptor;
    this.myNavigationProvider = myNavigationProvider;
}
项目:hybris-integration-intellij-idea-plugin    文件:TSStructureViewBuilder.java   
public TSStructureViewBuilder(
    final XmlFile file,
    final Function<DomElement, DomService.StructureViewMode> descriptor
) {
    super(file, descriptor);
    myFile = file;
    myDescriptor = descriptor;
}
项目:educational-plugin    文件:CCCreateLesson.java   
@Override
protected Function<VirtualFile, ? extends StudyItem> getStudyOrderable(@NotNull final StudyItem item) {
  return (Function<VirtualFile, StudyItem>)file -> {
    if (item instanceof Lesson) {
      return ((Lesson)item).getCourse().getLesson(file.getName());
    }
    return null;
  };
}
项目:educational-plugin    文件:CCCreateTask.java   
@Override
protected Function<VirtualFile, ? extends StudyItem> getStudyOrderable(@NotNull final StudyItem item) {
  return (Function<VirtualFile, StudyItem>)file -> {
    if (item instanceof Task) {
      return ((Task)item).getLesson().getTask(file.getName());
    }
    return null;
  };
}
项目:intellij-ce-playground    文件:CertificateTreeBuilder.java   
private static List<X509Certificate> extract(Collection<CertificateWrapper> wrappers) {
  return ContainerUtil.map(wrappers, new Function<CertificateWrapper, X509Certificate>() {
    @Override
    public X509Certificate fun(CertificateWrapper wrapper) {
      return wrapper.getCertificate();
    }
  });
}
项目:intellij-ce-playground    文件:AnalysisScope.java   
@NotNull
public String getShortenName(){
  switch (myType) {
    case CUSTOM:
      return myScope.getDisplayName();

    case MODULE:
      return AnalysisScopeBundle.message("scope.option.module", myModule.getName());

    case MODULES:
      String modules = StringUtil.join(myModules, new Function<Module, String>() {
        @Override
        @NotNull
        public String fun(@NotNull final Module module) {
          return module.getName();
        }
      }, ", ");
      return AnalysisScopeBundle.message("scope.module.list", modules, Integer.valueOf(myModules.size()));

    case PROJECT:
      return AnalysisScopeBundle.message("scope.project", myProject.getName());

    case FILE:
      final String relativePath = getRelativePath();
      return relativePath != null ? AnalysisScopeBundle.message("scope.file", relativePath) : "Current File";

    case DIRECTORY:
      final String relativeDirPath = getRelativePath();
      return relativeDirPath != null ? AnalysisScopeBundle.message("scope.directory", relativeDirPath) : "Current Directory";


    case VIRTUAL_FILES:
      return AnalysisScopeBundle.message("scope.selected.files");
  }

  return "";
}
项目:intellij-ce-playground    文件:ApplicationStatisticsPersistenceComponent.java   
private static String joinUsages(@NotNull Set<UsageDescriptor> usages) {
  // for instance, usage can be: "_foo"(equals "_foo=1") or "_foo=2"
  return StringUtil.join(usages, new Function<UsageDescriptor, String>() {
    @Override
    public String fun(UsageDescriptor usageDescriptor) {
      final String key = usageDescriptor.getKey();
      final int value = usageDescriptor.getValue();
      return value != 1 ? key + "=" + value : key;
    }
  }, TOKENIZER);
}
项目:intellij-ce-playground    文件:AddModuleWizard.java   
/**
 * Allows to ask current wizard to move to the desired step.
 *
 * @param filter  closure that allows to indicate target step - is called with each of registered steps and is expected
 *                to return <code>true</code> for the step to go to
 * @return        <code>true</code> if current wizard is navigated to the target step; <code>false</code> otherwise
 */
public boolean navigateToStep(@NotNull Function<Step, Boolean> filter) {
  for (int i = 0, myStepsSize = mySteps.size(); i < myStepsSize; i++) {
    ModuleWizardStep step = mySteps.get(i);
    if (filter.fun(step) != Boolean.TRUE) {
      continue;
    }

    // Update current step.
    myCurrentStep = i;
    updateStep();
    return true;
  }
  return false;
}
项目:intellij-ce-playground    文件:CCCreateLesson.java   
@Override
protected Function<VirtualFile, ? extends StudyItem> getStudyOrderable(@NotNull final StudyItem item) {
  return new Function<VirtualFile, StudyItem>() {
    @Override
    public StudyItem fun(VirtualFile file) {
      if (item instanceof Lesson) {
        return ((Lesson)item).getCourse().getLesson(file.getName());
      }
      return null;
    }
  };
}
项目:intellij-ce-playground    文件:BuildResult.java   
public void assertSuccessful() {
  if (!isSuccessful()) {
    Function<BuildMessage, String> toStringFunction = StringUtil.createToStringFunction(BuildMessage.class);
    fail("Build failed.\n" +
         "Errors:\n" + StringUtil.join(myErrorMessages, toStringFunction, "\n") + "\n" +
         "Info messages:\n" + StringUtil.join(myInfoMessages, toStringFunction, "\n"));
  }
}
项目:intellij-ce-playground    文件:ModuleManagerImpl.java   
protected void fireModulesRenamed(@NotNull List<Module> modules, @NotNull final Map<Module, String> oldNames) {
  if (!modules.isEmpty()) {
    myMessageBus.syncPublisher(ProjectTopics.MODULES).modulesRenamed(myProject, modules, new Function<Module, String>() {
      @Override
      public String fun(Module module) {
        return oldNames.get(module);
      }
    });
  }
}
项目:intellij-ce-playground    文件:MavenProjectReaderTest.java   
public void testInheritingParentProfiles() throws Exception {
  createProjectPom("<groupId>test</groupId>" +
                   "<artifactId>parent</artifactId>" +
                   "<version>1</version>" +

                   "<profiles>" +
                   "  <profile>" +
                   "    <id>profileFromParent</id>" +
                   "  </profile>" +
                   "</profiles>");

  VirtualFile module = createModulePom("module",
                                       "<groupId>test</groupId>" +
                                       "<artifactId>module</artifactId>" +
                                       "<version>1</version>" +

                                       "<parent>" +
                                       "  <groupId>test</groupId>" +
                                       "  <artifactId>parent</artifactId>" +
                                       "  <version>1</version>" +
                                       "</parent>" +

                                       "<profiles>" +
                                       "  <profile>" +
                                       "    <id>profileFromChild</id>" +
                                       "  </profile>" +
                                       "</profiles>");

  MavenModel p = readProject(module);
  assertOrderedElementsAreEqual(ContainerUtil.map(p.getProfiles(), new Function<MavenProfile, Object>() {
    @Override
    public Object fun(MavenProfile profile) {
      return profile.getId();
    }
  }), "profileFromChild", "profileFromParent");
}
项目:intellij-ce-playground    文件:GlobalSearchScopesCore.java   
@NotNull
@Override
public String getDisplayName() {
  if (myDirectories.length == 1) {
    VirtualFile root = myDirectories[0];
    return "Directory '" + root.getName() + "'";
  }
  return "Directories " + StringUtil.join(myDirectories, new Function<VirtualFile, String>() {
    @Override
    public String fun(VirtualFile file) {
      return "'" + file.getName() + "'";
    }
  }, ", ");
}
项目:intellij-ce-playground    文件:SliceTreeTest.java   
private Set<String> groupByLeaves() throws Exception {
  SliceTreeStructure treeStructure = configureTree(getTestName(false));
  final SliceRootNode root = (SliceRootNode)treeStructure.getRootElement();
  Map<SliceNode, Collection<PsiElement>> map = SliceLeafAnalyzer.createMap();
  Collection<PsiElement> leaves = SliceLeafAnalyzer.calcLeafExpressions(root, treeStructure, map);
  return ContainerUtil.map2Set(leaves, new Function<PsiElement, String>() {
    @Override
    public String fun(PsiElement element) {
      return element.getText();
    }
  });
}
项目:intellij-ce-playground    文件:StandardPatterns.java   
public static <T> ElementPattern<T> instanceOf(@NotNull Class<T>... classes) {
  ElementPattern[] patterns = ContainerUtil.map(classes, new Function<Class<T>, ElementPattern>() {
    @Override
    public ElementPattern fun(Class<T> aClass) {
      return instanceOf(aClass);
    }
  }, new ElementPattern[0]);
  return or(patterns);
}
项目:intellij-ce-playground    文件:ExtractManagedDependenciesAction.java   
private static Function<MavenDomProjectModel, Set<MavenDomDependency>> getOccurencesFunction(final MavenDomDependency dependency) {

      return new Function<MavenDomProjectModel, Set<MavenDomDependency>>() {
        public Set<MavenDomDependency> fun(MavenDomProjectModel model) {
          DependencyConflictId dependencyId = DependencyConflictId.create(dependency);
          if (dependencyId == null) return Collections.emptySet();

          return MavenDomProjectProcessorUtils.searchDependencyUsages(model, dependencyId, Collections.singleton(dependency));
        }
      };
    }