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


Java HashSet.contains方法代码示例

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


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

示例1: setChanges

import com.intellij.util.containers.HashSet; //导入方法依赖的package包/类
public void setChanges(@NotNull ArrayList<Change> changes) {
  if (myChanges != null) {
    HashSet<Change> newChanges = new HashSet<Change>(changes);
    LOG.assertTrue(newChanges.size() == changes.size());
    for (Iterator<Change> iterator = myChanges.iterator(); iterator.hasNext();) {
      Change oldChange = iterator.next();
      if (!newChanges.contains(oldChange)) {
        iterator.remove();
        oldChange.onRemovedFromList();
      }
    }
  }
  for (Change change : changes) {
    LOG.assertTrue(change.isValid());
  }
  myChanges = new ArrayList<Change>(changes);
  myAppliedChanges = new ArrayList<Change>();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:ChangeList.java

示例2: isOK

import com.intellij.util.containers.HashSet; //导入方法依赖的package包/类
public boolean isOK(IntroduceVariableSettings settings) {
  String name = settings.getEnteredName();
  final PsiElement anchor;
  final boolean replaceAllOccurrences = settings.isReplaceAllOccurrences();
  if (replaceAllOccurrences) {
    anchor = myAnchorStatementIfAll;
  } else {
    anchor = myAnchorStatement;
  }
  final PsiElement scope = anchor.getParent();
  if(scope == null) return true;
  final MultiMap<PsiElement, String> conflicts = new MultiMap<PsiElement, String>();
  final HashSet<PsiVariable> reportedVariables = new HashSet<PsiVariable>();
  JavaUnresolvableLocalCollisionDetector.CollidingVariableVisitor visitor = new JavaUnresolvableLocalCollisionDetector.CollidingVariableVisitor() {
    public void visitCollidingElement(PsiVariable collidingVariable) {
      if (!reportedVariables.contains(collidingVariable)) {
        reportedVariables.add(collidingVariable);
        String message = RefactoringBundle.message("introduced.variable.will.conflict.with.0", RefactoringUIUtil.getDescription(collidingVariable, true));
        conflicts.putValue(collidingVariable, message);
      }
    }
  };
  JavaUnresolvableLocalCollisionDetector.visitLocalsCollisions(anchor, name, scope, anchor, visitor);
  if (replaceAllOccurrences) {
    final PsiExpression[] occurences = myOccurenceManager.getOccurrences();
    for (PsiExpression occurence : occurences) {
      IntroduceVariableBase.checkInLoopCondition(occurence, conflicts);
    }
  } else {
    IntroduceVariableBase.checkInLoopCondition(myOccurenceManager.getMainOccurence(), conflicts);
  }

  if (conflicts.size() > 0) {
    return myIntroduceVariableBase.reportConflicts(conflicts, myProject, settings);
  } else {
    return true;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:39,代码来源:InputValidator.java

示例3: getRootContextFile

import com.intellij.util.containers.HashSet; //导入方法依赖的package包/类
@NotNull
public
BaseJspFile getRootContextFile(@NotNull BaseJspFile file) {
  BaseJspFile rootContext = file;
  HashSet<BaseJspFile> recursionPreventer = new HashSet<BaseJspFile>();
  do {
    recursionPreventer.add(rootContext);
    BaseJspFile context = getContextFile(rootContext);
    if (context == null || recursionPreventer.contains(context)) break;
    rootContext = context;
  }
  while (true);

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

示例4: createUniqueName

import com.intellij.util.containers.HashSet; //导入方法依赖的package包/类
private String createUniqueName() {
  String str = InspectionsBundle.message("inspection.profile.unnamed");
  final HashSet<String> treeScopes = new HashSet<String>();
  obtainCurrentScopes(treeScopes);
  if (!treeScopes.contains(str)) return str;
  int i = 1;
  while (true) {
    if (!treeScopes.contains(str + i)) return str + i;
    i++;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:ScopeChooserConfigurable.java

示例5: buildSubClassesMapImpl

import com.intellij.util.containers.HashSet; //导入方法依赖的package包/类
private void buildSubClassesMapImpl(PyClass aClass, HashSet<PyClass> visited) {
  visited.add(aClass);
  for (PyClass clazz : aClass.getSuperClasses()) {
    getSubclasses(clazz).add(aClass);
    if (!visited.contains(clazz)) {
      buildSubClassesMapImpl(clazz, visited);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:PyMemberInfoStorage.java

示例6: doTest

import com.intellij.util.containers.HashSet; //导入方法依赖的package包/类
private void doTest(MemberInfo[] members,
                    @NonNls String newClassName,
                    String targetPackageName,
                    VirtualFile rootDir,
                    PsiClass psiClass,
                    String[] conflicts) throws IOException {
  PsiDirectory targetDirectory;
  if (targetPackageName == null) {
    targetDirectory = psiClass.getContainingFile().getContainingDirectory();
  } else {
    final PsiPackage aPackage = myJavaFacade.findPackage(targetPackageName);
    assertNotNull(aPackage);
    targetDirectory = aPackage.getDirectories()[0];
  }
  ExtractSuperClassProcessor processor = new ExtractSuperClassProcessor(myProject,
                                                                        targetDirectory,
                                                                        newClassName,
                                                                        psiClass, members,
                                                                        false,
                                                                        new DocCommentPolicy<>(DocCommentPolicy.ASIS));
  final PsiPackage targetPackage;
  if (targetDirectory != null) {
    targetPackage = JavaDirectoryService.getInstance().getPackage(targetDirectory);
  }
  else {
    targetPackage = null;
  }
  final PsiClass superClass = psiClass.getExtendsListTypes().length > 0 ? psiClass.getSuperClass() : null;
  final MultiMap<PsiElement, String> conflictsMap =
    PullUpConflictsUtil.checkConflicts(members, psiClass, superClass, targetPackage, targetDirectory,
                                       psiMethod -> PullUpProcessor.checkedInterfacesContain(Arrays.asList(members), psiMethod), false);
  if (conflicts != null) {
    if (conflictsMap.isEmpty()) {
      fail("Conflicts were not detected");
    }
    final HashSet<String> expectedConflicts = new HashSet<>(Arrays.asList(conflicts));
    final HashSet<String> actualConflicts = new HashSet<>(conflictsMap.values());
    assertEquals(expectedConflicts.size(), actualConflicts.size());
    for (String actualConflict : actualConflicts) {
      if (!expectedConflicts.contains(actualConflict)) {
        fail("Unexpected conflict: " + actualConflict);
      }
    }
  } else if (!conflictsMap.isEmpty()) {
    fail("Unexpected conflicts!!!");
  }
  processor.run();
  PsiDocumentManager.getInstance(myProject).commitAllDocuments();
  FileDocumentManager.getInstance().saveAllDocuments();

  String rootAfter = getRoot() + "/after";
  VirtualFile rootDir2 = LocalFileSystem.getInstance().findFileByPath(rootAfter.replace(File.separatorChar, '/'));
  myProject.getComponent(PostprocessReformattingAspect.class).doPostponedFormatting();
  IdeaTestUtil.assertDirectoriesEqual(rootDir2, rootDir);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:56,代码来源:ExtractSuperClassTest.java

示例7: getChildrenFor

import com.intellij.util.containers.HashSet; //导入方法依赖的package包/类
private Object[] getChildrenFor(final Object element) {
  final Ref<Object[]> passOne = new Ref<Object[]>();
  try {
    acquireLock();
    execute(new TreeRunnable("AbstractTreeUi.getChildrenFor") {
      @Override
      public void perform() {
        passOne.set(getTreeStructure().getChildElements(element));
      }
    });
  }
  catch (IndexNotReadyException e) {
    warnOnIndexNotReady();
    return ArrayUtil.EMPTY_OBJECT_ARRAY;
  }
  finally {
    releaseLock();
  }

  if (!Registry.is("ide.tree.checkStructure")) return passOne.get();

  final Object[] passTwo = getTreeStructure().getChildElements(element);

  final HashSet<Object> two = new HashSet<Object>(Arrays.asList(passTwo));

  if (passOne.get().length != passTwo.length) {
    LOG.error(
      "AbstractTreeStructure.getChildren() must either provide same objects or new objects but with correct hashCode() and equals() methods. Wrong parent element=" +
      element);
  }
  else {
    for (Object eachInOne : passOne.get()) {
      if (!two.contains(eachInOne)) {
        LOG.error(
          "AbstractTreeStructure.getChildren() must either provide same objects or new objects but with correct hashCode() and equals() methods. Wrong parent element=" +
          element);
        break;
      }
    }
  }

  return passOne.get();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:44,代码来源:AbstractTreeUi.java

示例8: processFile

import com.intellij.util.containers.HashSet; //导入方法依赖的package包/类
@NotNull
@Override
public Runnable processFile(final PsiFile file) {
  VirtualFile vFile = file.getVirtualFile();
  if (vFile instanceof VirtualFileWindow) vFile = ((VirtualFileWindow)vFile).getDelegate();
  final Project project = file.getProject();
  if (vFile == null || !ProjectRootManager.getInstance(project).getFileIndex().isInSourceContent(vFile)) {
    return EmptyRunnable.INSTANCE;
  }
  final List<Pair<String, Boolean>> names = new ArrayList<Pair<String, Boolean>>();
  collectNamesToImport(names, (XmlFile)file);
  Collections.sort(names, new Comparator<Pair<String, Boolean>>() {
    @Override
    public int compare(Pair<String, Boolean> o1, Pair<String, Boolean> o2) {
      return StringUtil.compare(o1.first, o2.first, true);
    }
  });
  final CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(project);
  final List<Pair<String, Boolean>> sortedNames = ImportHelper.sortItemsAccordingToSettings(names, settings);
  final HashSet<String> onDemand = new HashSet<String>();
  ImportHelper.collectOnDemandImports(sortedNames, onDemand, settings);
  final Set<String> imported = new HashSet<String>();
  final List<String> imports = new ArrayList<String>();
  for (Pair<String, Boolean> pair : sortedNames) {
    final String qName = pair.first;
    final String packageName = StringUtil.getPackageName(qName);
    if (imported.contains(packageName) || imported.contains(qName)) {
      continue;
    }
    if (onDemand.contains(packageName)) {
      imported.add(packageName);
      imports.add("<?import " + packageName + ".*?>");
    } else {
      imported.add(qName);
      imports.add("<?import " + qName + "?>");
    }
  }
  final PsiFileFactory factory = PsiFileFactory.getInstance(file.getProject());
  
  final XmlFile dummyFile = (XmlFile)factory.createFileFromText("_Dummy_.fxml", StdFileTypes.XML, StringUtil.join(imports, "\n"));
  final XmlDocument document = dummyFile.getDocument();
  final XmlProlog newImportList = document.getProlog();
  if (newImportList == null) return EmptyRunnable.getInstance();
  return new Runnable() {
    @Override
    public void run() {
      final XmlDocument xmlDocument = ((XmlFile)file).getDocument();
      final XmlProlog prolog = xmlDocument.getProlog();
      if (prolog != null) {
        final Collection<XmlProcessingInstruction> instructions = PsiTreeUtil.findChildrenOfType(prolog, XmlProcessingInstruction.class);
        for (final XmlProcessingInstruction instruction : instructions) {
          final ASTNode node = instruction.getNode();
          final ASTNode nameNode = node.findChildByType(XmlTokenType.XML_NAME);
          if (nameNode != null && nameNode.getText().equals("import")) {
            instruction.delete();
          }
        }
        prolog.add(newImportList);
      } else {
        document.addBefore(newImportList, document.getRootTag());
      }
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:65,代码来源:JavaFxImportsOptimizer.java


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