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


Java ContainerUtil.addIfNotNull方法代码示例

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


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

示例1: addCustomRootsForModule

import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
boolean addCustomRootsForModule(OrderRootType type,
                                ModuleRootModel rootModel,
                                Collection<VirtualFile> result,
                                boolean includeProduction,
                                boolean includeTests) {
  for (OrderEnumerationHandler handler : myCustomHandlers) {
    final List<String> urls = new ArrayList<String>();
    final boolean added = handler.addCustomModuleRoots(type, rootModel, urls, includeProduction, includeTests);
    for (String url : urls) {
      ContainerUtil.addIfNotNull(VirtualFileManager.getInstance().findFileByUrl(url), result);
    }

    if (added) return true;
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:OrderEnumeratorBase.java

示例2: compute

import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
@Override
public Result<PsiModifierList> compute() {
  List<PsiModifierList> modifiers = ContainerUtil.newArrayList();
  for(PsiDirectory directory: getDirectories()) {
    PsiFile file = directory.findFile(PACKAGE_INFO_FILE);
    PsiPackageStatement stmt = file == null ? null : PsiTreeUtil.getChildOfType(file, PsiPackageStatement.class);
    PsiModifierList modifierList = stmt == null ? null : stmt.getAnnotationList();
    ContainerUtil.addIfNotNull(modifiers, modifierList);
  }

  for (PsiClass aClass : getFacade().findClasses(getQualifiedName() + ".package-info", allScope())) {
    ContainerUtil.addIfNotNull(modifiers, aClass.getModifierList());
  }

  PsiCompositeModifierList result = modifiers.isEmpty() ? null : new PsiCompositeModifierList(getManager(), modifiers);
  return new Result<PsiModifierList>(result, PsiModificationTracker.OUT_OF_CODE_BLOCK_MODIFICATION_COUNT);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:PsiPackageImpl.java

示例3: computeCombinedModel

import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
@Nullable
protected M computeCombinedModel(@NotNull Scope scope) {
  final List<M> models = getAllModels(scope);
  switch (models.size()) {
    case 0:
      return null;
    case 1:
      return models.get(0);
  }
  final Set<XmlFile> configFiles = new LinkedHashSet<XmlFile>();
  final LinkedHashSet<DomFileElement<T>> list = new LinkedHashSet<DomFileElement<T>>(models.size());
  for (M model: models) {
    final Set<XmlFile> files = model.getConfigFiles();
    for (XmlFile file: files) {
      ContainerUtil.addIfNotNull(getDomRoot(file), list);
    }
    configFiles.addAll(files);
  }
  final DomFileElement<T> mergedModel = getModelMerger().mergeModels(DomFileElement.class, list);
  final M firstModel = models.get(0);
  return createCombinedModel(configFiles, mergedModel, firstModel, scope);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:CachedMultipleDomModelFactory.java

示例4: createEditorField

import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
private static EditorTextField createEditorField(final Project project, final int defaultLines) {
  final EditorTextFieldProvider service = ServiceManager.getService(project, EditorTextFieldProvider.class);
  final EditorTextField editorField;

  final Set<EditorCustomization> editorFeatures = ContainerUtil.newHashSet();
  ContainerUtil.addIfNotNull(editorFeatures, SpellCheckingEditorCustomizationProvider.getInstance().getEnabledCustomization());

  if (defaultLines == 1) {
    editorFeatures.add(HorizontalScrollBarEditorCustomization.DISABLED);
    editorFeatures.add(OneLineEditorCustomization.ENABLED);
  } else {
    editorFeatures.add(SoftWrapsEditorCustomization.ENABLED);
  }
  editorField = service.getEditorField(FileTypes.PLAIN_TEXT.getLanguage(), project, editorFeatures);
  final int height = editorField.getFontMetrics(editorField.getFont()).getHeight();
  editorField.getComponent().setMinimumSize(new Dimension(100, (int)(height * 1.3)));
  return editorField;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:NewEditChangelistPanel.java

示例5: getAdditionalRootsToIndex

import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
@NotNull
@Override
public Set<VirtualFile> getAdditionalRootsToIndex() {
  Set<VirtualFile> roots = new THashSet<VirtualFile>();
  for (String url : myStandardResources.getValue()) {
    VirtualFile file = VfsUtilCore.findRelativeFile(url, null);
    if (file != null) {
      roots.add(file);
    }
  }

  String path = FetchExtResourceAction.getExternalResourcesPath();
  VirtualFile extResources = LocalFileSystem.getInstance().findFileByPath(path);
  ContainerUtil.addIfNotNull(extResources, roots);

  return roots;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:ExternalResourcesRootsProvider.java

示例6: addItemsForMarkers

import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
private static void addItemsForMarkers(List<RelatedItemLineMarkerInfo> markers,
                                       List<GotoRelatedItem> result) {
  Set<PsiFile> addedFiles = new HashSet<PsiFile>();
  for (RelatedItemLineMarkerInfo<?> marker : markers) {
    Collection<? extends GotoRelatedItem> items = marker.createGotoRelatedItems();
    for (GotoRelatedItem item : items) {
      PsiElement element = item.getElement();
      if (element instanceof PsiFile) {
        PsiFile file = (PsiFile)element;
        if (addedFiles.contains(file)) {
          continue;
        }
      }
      if (element != null) {
        ContainerUtil.addIfNotNull(element.getContainingFile(), addedFiles);
      }
      result.add(item);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:RelatedItemLineMarkerGotoAdapter.java

示例7: collectNewParameterNames

import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
@Override
@NotNull
protected List<String> collectNewParameterNames() {
  final Set<String> enclosingScopeReads = new LinkedHashSet<String>();
  for (ScopeOwner owner : PsiTreeUtil.collectElementsOfType(myFunction, ScopeOwner.class)) {
    final AnalysisResult result = analyseScope(owner);
    if (!result.nonlocalWritesToEnclosingScope.isEmpty()) {
      throw new IncorrectOperationException(PyBundle.message("refactoring.make.function.top.level.error.nonlocal.writes"));
    }
    if (!result.readsOfSelfParametersFromEnclosingScope.isEmpty()) {
      throw new IncorrectOperationException(PyBundle.message("refactoring.make.function.top.level.error.self.reads"));
    }
    for (PsiElement element : result.readsFromEnclosingScope) {
      if (element instanceof PyElement) {
        ContainerUtil.addIfNotNull(enclosingScopeReads, ((PyElement)element).getName());
      }
    }
  }
  return Lists.newArrayList(enclosingScopeReads);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:PyMakeLocalFunctionTopLevelProcessor.java

示例8: calcRoots

import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
private static List<VirtualFile> calcRoots(@Nullable VirtualFile home) {
  if (home == null) {
    return Collections.emptyList();
  }

  final VirtualFile lib = home.findChild("lib");
  if (lib == null) {
    return Collections.emptyList();
  }

  List<VirtualFile> result = new ArrayList<VirtualFile>();
  for (VirtualFile file : lib.getChildren()) {
    if ("jar".equals(file.getExtension())) {
      ContainerUtil.addIfNotNull(StandardFileSystems.getJarRootForLocalFile(file), result);
    }
  }
  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:SdkHomeSettings.java

示例9: addConstantsFromReferencedClassesInSwitch

import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
private void addConstantsFromReferencedClassesInSwitch(final Consumer<LookupElement> results) {
  final Set<PsiField> fields = ReferenceExpressionCompletionContributor.findConstantsUsedInSwitch(myPlace);
  final Set<PsiClass> classes = new HashSet<PsiClass>();
  for (PsiField field : fields) {
    ContainerUtil.addIfNotNull(classes, field.getContainingClass());
  }
  for (PsiClass aClass : classes) {
    processMembers(new Consumer<LookupElement>() {
      @Override
      public void consume(LookupElement element) {
        //noinspection SuspiciousMethodCalls
        if (!fields.contains(element.getObject())) {
          results.consume(TailTypeDecorator.withTail(element, TailType.CASE_COLON));
        }
      }
    }, aClass, true, false);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:JavaMembersGetter.java

示例10: addCustomRootsForLibrary

import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
boolean addCustomRootsForLibrary(OrderEntry forOrderEntry, OrderRootType type, Collection<VirtualFile> result) {
  for (OrderEnumerationHandler handler : myCustomHandlers) {
    final List<String> urls = new ArrayList<String>();
    final boolean added =
      handler.addCustomRootsForLibrary(forOrderEntry, type, urls);
    for (String url : urls) {
      ContainerUtil.addIfNotNull(VirtualFileManager.getInstance().findFileByUrl(url), result);
    }
    if (added) {
      return true;
    }
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:OrderEnumeratorBase.java

示例11: classify

import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
@Override
public Iterable<T> classify(final Iterable<T> source, final ProcessingContext context) {
  List<T> nulls = null;
  TreeMap<Comparable, List<T>> map = new TreeMap<Comparable, List<T>>();
  for (T t : source) {
    final Comparable weight = getWeight(t, context);
    if (weight == null) {
      if (nulls == null) nulls = new SmartList<T>();
      nulls.add(t);
    } else {
      List<T> list = map.get(weight);
      if (list == null) {
        map.put(weight, list = new SmartList<T>());
      }
      list.add(t);
    }
  }

  final List<List<T>> values = new ArrayList<List<T>>();
  values.addAll(myNegated ? map.descendingMap().values() : map.values());
  ContainerUtil.addIfNotNull(values, nulls);

  return new Iterable<T>() {
    @Override
    public Iterator<T> iterator() {
      return new FlatteningIterator<List<T>, T>(values.iterator()) {
        @Override
        protected Iterator<T> createValueIterator(List<T> group) {
          return myNext.classify(group, context).iterator();
        }
      };
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:35,代码来源:ComparingClassifier.java

示例12: getLibrariesCompositionSettingsList

import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
private List<LibraryCompositionSettings> getLibrariesCompositionSettingsList() {
  List<LibraryCompositionSettings> list = new ArrayList<LibraryCompositionSettings>();
  List<FrameworkSupportNode> selected = getSelectedNodes();
  for (FrameworkSupportNode node : selected) {
    ContainerUtil.addIfNotNull(list, getLibraryCompositionSettings(node));
  }
  return list;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:AddSupportForFrameworksPanel.java

示例13: IgnoreBaseClassQuickFix

import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
public IgnoreBaseClassQuickFix(@NotNull PyClass baseClass, @NotNull TypeEvalContext context) {
  myBaseClassNames = new ArrayList<String>();
  ContainerUtil.addIfNotNull(myBaseClassNames, baseClass.getQualifiedName());
  for (PyClass ancestor : baseClass.getAncestorClasses(context)) {
    ContainerUtil.addIfNotNull(myBaseClassNames, ancestor.getQualifiedName());
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:PyPep8NamingInspection.java

示例14: createNPEFixes

import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
@Nullable
private LocalQuickFix[] createNPEFixes(PsiExpression qualifier, PsiExpression expression, boolean onTheFly) {
  if (qualifier == null || expression == null) return null;
  if (qualifier instanceof PsiMethodCallExpression) return null;

  try {
    final List<LocalQuickFix> fixes = new SmartList<LocalQuickFix>();

    if (isVolatileFieldReference(qualifier)) {
      ContainerUtil.addIfNotNull(fixes, createIntroduceVariableFix(qualifier));
    }
    else if (!(qualifier instanceof PsiLiteralExpression && ((PsiLiteralExpression)qualifier).getValue() == null))  {
      if (PsiUtil.getLanguageLevel(qualifier).isAtLeast(LanguageLevel.JDK_1_4)) {
        final Project project = qualifier.getProject();
        final PsiElementFactory elementFactory = JavaPsiFacade.getInstance(project).getElementFactory();
        final PsiBinaryExpression binary = (PsiBinaryExpression)elementFactory.createExpressionFromText("a != null", null);
        binary.getLOperand().replace(qualifier);
        ContainerUtil.addIfNotNull(fixes, createAssertFix(binary, expression));
      }

      addSurroundWithIfFix(qualifier, fixes, onTheFly);

      if (ReplaceWithTernaryOperatorFix.isAvailable(qualifier, expression)) {
        fixes.add(new ReplaceWithTernaryOperatorFix(qualifier));
      }
    }

    ContainerUtil.addIfNotNull(fixes, DfaOptionalSupport.registerReplaceOptionalOfWithOfNullableFix(qualifier));
    return fixes.isEmpty() ? null : fixes.toArray(new LocalQuickFix[fixes.size()]);
  }
  catch (IncorrectOperationException e) {
    LOG.error(e);
    return null;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:36,代码来源:DataFlowInspectionBase.java

示例15: loadRoots

import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
@NotNull
public List<WCInfoWithBranches> loadRoots() {
  List<WCInfoWithBranches> result = ContainerUtil.newArrayList();

  for (WCInfo info : myVcs.getAllWcInfos()) {
    ContainerUtil.addIfNotNull(result, createInfo(info));
  }

  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:WcInfoLoader.java


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