Java 类com.intellij.util.containers.hash.HashSet 实例源码

项目:intellij-ce-playground    文件:JavaAnonymousClassesNodeProvider.java   
@NotNull
@Override
public Collection<JavaAnonymousClassTreeElement> provideNodes(@NotNull TreeElement node) {
  if (node instanceof PsiMethodTreeElement || node instanceof PsiFieldTreeElement || node instanceof ClassInitializerTreeElement) {
    final PsiElement el = ((PsiTreeElementBase)node).getElement();
    if (el != null) {
      for (AnonymousElementProvider provider : Extensions.getExtensions(AnonymousElementProvider.EP_NAME)) {
        final PsiElement[] elements = provider.getAnonymousElements(el);
        if (elements.length > 0) {
          List<JavaAnonymousClassTreeElement> result = new ArrayList<JavaAnonymousClassTreeElement>(elements.length);
          for (PsiElement element : elements) {
            result.add(new JavaAnonymousClassTreeElement((PsiAnonymousClass)element, new HashSet<PsiClass>()));
          }
          return result;
        }
      }
    }
  }
  return Collections.emptyList();
}
项目:intellij-ce-playground    文件:StringExpressionHelper.java   
@NotNull
public static Set<Pair<PsiElement, String>> searchStringExpressions(@NotNull final PsiMethod psiMethod,
                                                                    @NotNull SearchScope searchScope,
                                                                    int expNum) {
  Set<Pair<PsiElement, String>> pairs = new com.intellij.util.containers.HashSet<Pair<PsiElement, String>>();
  for (PsiMethodCallExpression methodCallExpression : searchMethodCalls(psiMethod, searchScope)) {
    final PsiExpression[] expressions = methodCallExpression.getArgumentList().getExpressions();
    if (expressions.length > expNum) {
      final PsiExpression expression = expressions[expNum];
      Pair<PsiElement, String> pair = evaluateExpression(expression);
      if (pair != null) {
        pairs.add(pair);
      }
    }
  }

  return pairs;
}
项目:intellij-ce-playground    文件:StringExpressionHelper.java   
@NotNull
public static Set<PsiMethodCallExpression> searchMethodCalls(@NotNull final PsiMethod psiMethod, @NotNull SearchScope searchScope) {
  final Set<PsiMethodCallExpression> callExpressions = new com.intellij.util.containers.HashSet<PsiMethodCallExpression>();
  final CommonProcessors.CollectUniquesProcessor<PsiReference> consumer = new CommonProcessors.CollectUniquesProcessor<PsiReference>();

  MethodReferencesSearch.search(psiMethod, searchScope, true).forEach(consumer);

  for (PsiReference psiReference : consumer.getResults()) {
    final PsiMethodCallExpression methodCallExpression =
      PsiTreeUtil.getParentOfType(psiReference.getElement(), PsiMethodCallExpression.class);

    if (methodCallExpression != null) {
      callExpressions.add(methodCallExpression);
    }
  }


  return callExpressions;
}
项目:intellij-ce-playground    文件:ModuleManagerImpl.java   
@Override
public void dispose() {
  assertWritable();
  ApplicationManager.getApplication().assertWriteAccessAllowed();
  final Set<Module> set = new HashSet<Module>();
  set.addAll(myModuleModel.myModules.values());
  for (Module thisModule : myModules.values()) {
    if (!set.contains(thisModule)) {
      Disposer.dispose(thisModule);
    }
  }
  for (Module moduleToDispose : myModulesToDispose) {
    if (!set.contains(moduleToDispose)) {
      Disposer.dispose(moduleToDispose);
    }
  }
  clearRenamingStuff();
}
项目:intellij-ce-playground    文件:CustomFoldingBuilder.java   
@NotNull
@Override
public final FoldingDescriptor[] buildFoldRegions(@NotNull PsiElement root, @NotNull Document document, boolean quick) {
  List<FoldingDescriptor> descriptors = new ArrayList<FoldingDescriptor>();
  ourCustomRegionElements.set(new HashSet<ASTNode>());
  try {
    if (CustomFoldingProvider.getAllProviders().length > 0) {
      myDefaultProvider = null;
      ASTNode rootNode = root.getNode();
      if (rootNode != null) {
        addCustomFoldingRegionsRecursively(new FoldingStack(rootNode), rootNode, descriptors, 0);
      }
    }
    buildLanguageFoldRegions(descriptors, root, document, quick);
  }
  finally {
    ourCustomRegionElements.set(null);
  }
  return descriptors.toArray(new FoldingDescriptor[descriptors.size()]);
}
项目:intellij-ce-playground    文件:IdeSettingsStatisticsUtils.java   
public static Set<UsageDescriptor> getUsages(@NotNull IdeSettingsDescriptor descriptor, @NotNull Object componentInstance) {
  Set<UsageDescriptor> descriptors = new HashSet<UsageDescriptor>();

  String providerName = descriptor.myProviderName;

  List<String> propertyNames = descriptor.getPropertyNames();
  if (providerName != null && propertyNames.size() > 0) {
      for (String propertyName : propertyNames) {
        Object propertyValue = getPropertyValue(componentInstance, propertyName);

        if (propertyValue != null) {
          descriptors.add(new UsageDescriptor(getUsageDescriptorKey(providerName, propertyName, propertyValue.toString()), 1));
        }
    }
  }
  return descriptors;
}
项目:intellij-ce-playground    文件:ChangeSignatureProcessorBase.java   
protected List<UsageInfo> filterUsages(List<UsageInfo> infos) {
  Map<PsiElement, MoveRenameUsageInfo> moveRenameInfos = new HashMap<PsiElement, MoveRenameUsageInfo>();
  Set<PsiElement> usedElements = new HashSet<PsiElement>();

  List<UsageInfo> result = new ArrayList<UsageInfo>(infos.size() / 2);
  for (UsageInfo info : infos) {
    LOG.assertTrue(info != null, getClass());
    PsiElement element = info.getElement();
    if (info instanceof MoveRenameUsageInfo) {
      if (usedElements.contains(element)) continue;
      moveRenameInfos.put(element, (MoveRenameUsageInfo)info);
    }
    else {
      moveRenameInfos.remove(element);
      usedElements.add(element);
      if (!(info instanceof PossiblyIncorrectUsage) || ((PossiblyIncorrectUsage)info).isCorrect()) {
        result.add(info);
      }
    }
  }
  result.addAll(moveRenameInfos.values());
  return result;
}
项目:intellij-ce-playground    文件:MavenDuplicateDependenciesInspection.java   
private static void addProblem(@NotNull MavenDomDependency dependency,
                               @NotNull Collection<MavenDomDependency> dependencies,
                               @NotNull DomElementAnnotationHolder holder) {
  StringBuilder sb = new StringBuilder();
  Set<MavenDomProjectModel> processed = new HashSet<MavenDomProjectModel>();
  for (MavenDomDependency domDependency : dependencies) {
    if (dependency.equals(domDependency)) continue;
    MavenDomProjectModel model = domDependency.getParentOfType(MavenDomProjectModel.class, false);
    if (model != null && !processed.contains(model)) {
      if (processed.size() > 0) sb.append(", ");
      sb.append(createLinkText(model, domDependency));

      processed.add(model);
    }
  }
  holder.createProblem(dependency, HighlightSeverity.WARNING,
                       MavenDomBundle.message("MavenDuplicateDependenciesInspection.has.duplicates", sb.toString()));
}
项目:intellij-ce-playground    文件:MavenDomProjectProcessorUtils.java   
public static Set<XmlTag> collectProperties(@NotNull MavenDomProjectModel projectDom, @NotNull final Project project) {
  final Set<XmlTag> properties = new HashSet<XmlTag>();

  Processor<MavenDomProperties> collectProcessor = new Processor<MavenDomProperties>() {
    public boolean process(MavenDomProperties mavenDomProperties) {
      XmlTag propertiesTag = mavenDomProperties.getXmlTag();
      if (propertiesTag != null) {
        ContainerUtil.addAll(properties, propertiesTag.getSubTags());
      }
      return false;
    }
  };

  processProperties(projectDom, collectProcessor, project);

  return properties;
}
项目:intellij-ce-playground    文件:MavenDomProjectProcessorUtils.java   
@NotNull
public static Set<MavenDomDependency> searchDependencyUsages(@NotNull final MavenDomProjectModel model,
                                                             @NotNull final DependencyConflictId dependencyId,
                                                             @NotNull final Set<MavenDomDependency> excludes) {
  Project project = model.getManager().getProject();
  final Set<MavenDomDependency> usages = new HashSet<MavenDomDependency>();
  Processor<MavenDomProjectModel> collectProcessor = new Processor<MavenDomProjectModel>() {
    public boolean process(MavenDomProjectModel mavenDomProjectModel) {
      for (MavenDomDependency domDependency : mavenDomProjectModel.getDependencies().getDependencies()) {
        if (excludes.contains(domDependency)) continue;

        if (dependencyId.equals(DependencyConflictId.create(domDependency))) {
          usages.add(domDependency);
        }
      }
      return false;
    }
  };

  processChildrenRecursively(model, collectProcessor, project, new HashSet<MavenDomProjectModel>(), true);

  return usages;
}
项目:intellij-ce-playground    文件:MavenDomProjectProcessorUtils.java   
@NotNull
public static Collection<MavenDomPlugin> searchManagedPluginUsages(@NotNull final MavenDomProjectModel model,
                                                                   @Nullable final String groupId,
                                                                   @NotNull final String artifactId) {
  Project project = model.getManager().getProject();

  final Set<MavenDomPlugin> usages = new HashSet<MavenDomPlugin>();

  Processor<MavenDomProjectModel> collectProcessor = new Processor<MavenDomProjectModel>() {
    public boolean process(MavenDomProjectModel mavenDomProjectModel) {
      for (MavenDomPlugin domPlugin : mavenDomProjectModel.getBuild().getPlugins().getPlugins()) {
        if (MavenPluginDomUtil.isPlugin(domPlugin, groupId, artifactId)) {
          usages.add(domPlugin);
        }
      }
      return false;
    }
  };

  processChildrenRecursively(model, collectProcessor, project, new HashSet<MavenDomProjectModel>(), true);

  return usages;
}
项目:intellij-ce-playground    文件:ApplicationLevelNumberConnectionsGuardImpl.java   
public ApplicationLevelNumberConnectionsGuardImpl() {
  myDelay = DELAY;
  mySet = new HashSet<CachingSvnRepositoryPool>();
  myService = Executors.newSingleThreadScheduledExecutor(ConcurrencyUtil.newNamedThreadFactory("SVN connection"));
  myLock = new Object();
  myDisposed = false;
  myRecheck = new Runnable() {
    @Override
    public void run() {
      HashSet<CachingSvnRepositoryPool> pools = new HashSet<CachingSvnRepositoryPool>();
      synchronized (myLock) {
        pools.addAll(mySet);
      }
      for (CachingSvnRepositoryPool pool : pools) {
        pool.check();
      }
    }
  };
  myCurrentlyActiveConnections = 0;
  myCurrentlyOpenedConnections = 0;
}
项目:intellij-ce-playground    文件:ApplicationLevelNumberConnectionsGuardImpl.java   
@Override
public void waitForTotalNumberOfConnectionsOk() throws SVNException {
  synchronized (myLock) {
    if (myCurrentlyActiveConnections >= CachingSvnRepositoryPool.ourMaxTotal) {
      waitForFreeConnections();
    }
  }
  // maybe too many opened? reduce request
  final Set<CachingSvnRepositoryPool> copy = new HashSet<CachingSvnRepositoryPool>();
  synchronized (myLock) {
    if (myCurrentlyOpenedConnections >= CachingSvnRepositoryPool.ourMaxTotal) {
      copy.addAll(mySet);
    }
  }
  for (CachingSvnRepositoryPool pool : copy) {
    pool.closeInactive();
  }
  synchronized (myLock) {
    waitForFreeConnections();
  }
}
项目:intellij-ce-playground    文件:CachingSvnRepositoryPool.java   
private RepoGroup(ThrowableConvertor<SVNURL, SVNRepository, SVNException> creator, int cached, int concurrent,
                  final ThrowableConsumer<Pair<SVNURL, SVNRepository>, SVNException> adjuster,
                  final ApplicationLevelNumberConnectionsGuard guard, final Object waitObj, final long connectionTimeout) {
  myCreator = creator;
  myMaxCached = cached;
  myMaxConcurrent = concurrent;
  myAdjuster = adjuster;
  myGuard = guard;
  myConnectionTimeout = connectionTimeout;

  myInactive = new TreeMap<Long, SVNRepository>();
  myUsed = new HashSet<SVNRepository>();

  myDisposed = false;
  myWait = waitObj;
}
项目:intellij-ce-playground    文件:DelegatedMethodsContributor.java   
@Override
public void collectMethods(@NotNull final GrTypeDefinition clazz, @NotNull Collection<PsiMethod> collector) {
  Set<PsiClass> processed = new HashSet<PsiClass>();

  if (!checkForDelegate(clazz)) return;

  Map<MethodSignature, PsiMethod> signatures = new THashMap<MethodSignature, PsiMethod>(MethodSignatureUtil.METHOD_PARAMETERS_ERASURE_EQUALITY);
  initializeSignatures(clazz, PsiSubstitutor.EMPTY, signatures, processed);

  List<PsiMethod> methods = new ArrayList<PsiMethod>();
  process(clazz, PsiSubstitutor.EMPTY, true, new HashSet<PsiClass>(), processed, methods, clazz, false);

  final Set<PsiMethod> result = new LinkedHashSet<PsiMethod>();
  for (PsiMethod method : methods) {
    addMethodChecked(signatures, method, PsiSubstitutor.EMPTY, result);
  }

  collector.addAll(result);
}
项目:intellij-ce-playground    文件:GroovyParameterInfoHandler.java   
private static void filterOutReflectedMethods(List toShow) {
  Set<GrMethod> methods = new HashSet<GrMethod>();

  for (Iterator iterator = toShow.iterator(); iterator.hasNext(); ) {
    Object next = iterator.next();
    if (next instanceof GroovyResolveResult) {
      final PsiElement element = ((GroovyResolveResult)next).getElement();
      if (element instanceof GrReflectedMethod) {
        final GrMethod base = ((GrReflectedMethod)element).getBaseMethod();
        if (!methods.add(base)) {
          iterator.remove();
        }
      }
    }
  }
}
项目:intellij-ce-playground    文件:CompleteReferenceExpression.java   
@NotNull
private Set<String> addAllRestrictedProperties() {
  if (myRefExpr.getQualifier() != null) {
    return Collections.emptySet();
  }

  Set<String> propertyNames = new HashSet<String>();
  for (GrTypeDefinition containingClass = PsiTreeUtil.getParentOfType(myRefExpr, GrTypeDefinition.class);
       containingClass != null;
       containingClass = PsiTreeUtil.getParentOfType(containingClass, GrTypeDefinition.class)) {
    for (PsiField field : containingClass.getFields()) {
      propertyNames.add(field.getName());
    }
  }
  return propertyNames;
}
项目:intellij-ce-playground    文件:ConvertToJavaProcessor.java   
private static String getNewFileName(GroovyFile file) {
  final PsiDirectory dir = file.getContainingDirectory();
  LOG.assertTrue(dir != null);


  final PsiFile[] files = dir.getFiles();
  Set<String> fileNames = new HashSet<String>();
  for (PsiFile psiFile : files) {
    fileNames.add(psiFile.getName());
  }
  String prefix = FileUtil.getNameWithoutExtension(file.getName());
  String fileName = prefix + ".java";
  int index = 1;
  while (fileNames.contains(fileName)) {
    fileName = prefix + index + ".java";
  }
  return fileName;
}
项目:intellij-ce-playground    文件:GenerationUtil.java   
static Set<String> getVarTypes(GrVariableDeclaration variableDeclaration) {
  GrVariable[] variables = variableDeclaration.getVariables();
  final GrTypeElement typeElement = variableDeclaration.getTypeElementGroovy();
  Set<String> types = new HashSet<String>(variables.length);
  if (typeElement == null) {
    if (variables.length > 1) {
      for (GrVariable variable : variables) {
        final GrExpression initializer = variable.getInitializerGroovy();
        if (initializer != null) {
          final PsiType varType = initializer.getType();
          if (varType != null) {
            types.add(getTypeText(varType, variableDeclaration));
          }
        }
      }
    }
  }
  return types;
}
项目:tools-idea    文件:JavaAnonymousClassesNodeProvider.java   
@Override
public Collection<JavaAnonymousClassTreeElement> provideNodes(TreeElement node) {
  if (node instanceof PsiMethodTreeElement || node instanceof PsiFieldTreeElement || node instanceof ClassInitializerTreeElement) {
    final PsiElement el = ((PsiTreeElementBase)node).getElement();
    for (AnonymousElementProvider provider : Extensions.getExtensions(AnonymousElementProvider.EP_NAME)) {
      final PsiElement[] elements = provider.getAnonymousElements(el);
      if (elements != null && elements.length > 0) {
        List<JavaAnonymousClassTreeElement> result = new ArrayList<JavaAnonymousClassTreeElement>(elements.length);
        for (PsiElement element : elements) {
          result.add(new JavaAnonymousClassTreeElement((PsiAnonymousClass)element, new HashSet<PsiClass>()));
        }
        return result;
      }
    }
  }
  return Collections.emptyList();
}
项目:tools-idea    文件:IdeSettingsStatisticsUtils.java   
public static Set<UsageDescriptor> getUsages(@NotNull IdeSettingsDescriptor descriptor, @NotNull Object componentInstance) {
  Set<UsageDescriptor> descriptors = new HashSet<UsageDescriptor>();

  String providerName = descriptor.myProviderName;

  List<String> propertyNames = descriptor.getPropertyNames();
  if (providerName != null && propertyNames.size() > 0) {
      for (String propertyName : propertyNames) {
        Object propertyValue = getPropertyValue(componentInstance, propertyName);

        if (propertyValue != null) {
          descriptors.add(new UsageDescriptor(getUsageDescriptorKey(providerName, propertyName, propertyValue.toString()), 1));
        }
    }
  }
  return descriptors;
}
项目:tools-idea    文件:ChangeSignatureProcessorBase.java   
protected List<UsageInfo> filterUsages(List<UsageInfo> infos) {
  Map<PsiElement, MoveRenameUsageInfo> moveRenameInfos = new HashMap<PsiElement, MoveRenameUsageInfo>();
  Set<PsiElement> usedElements = new HashSet<PsiElement>();

  List<UsageInfo> result = new ArrayList<UsageInfo>(infos.size() / 2);
  for (UsageInfo info : infos) {
    LOG.assertTrue(info != null, getClass());
    PsiElement element = info.getElement();
    if (info instanceof MoveRenameUsageInfo) {
      if (usedElements.contains(element)) continue;
      moveRenameInfos.put(element, (MoveRenameUsageInfo)info);
    }
    else {
      moveRenameInfos.remove(element);
      usedElements.add(element);
      if (!(info instanceof PossiblyIncorrectUsage) || ((PossiblyIncorrectUsage)info).isCorrect()) {
        result.add(info);
      }
    }
  }
  result.addAll(moveRenameInfos.values());
  return result;
}
项目:tools-idea    文件:MavenDuplicateDependenciesInspection.java   
private static void addProblem(@NotNull MavenDomDependency dependency,
                               @NotNull Collection<MavenDomDependency> dependencies,
                               @NotNull DomElementAnnotationHolder holder) {
  StringBuilder sb = new StringBuilder();
  Set<MavenDomProjectModel> processed = new HashSet<MavenDomProjectModel>();
  for (MavenDomDependency domDependency : dependencies) {
    if (dependency.equals(domDependency)) continue;
    MavenDomProjectModel model = domDependency.getParentOfType(MavenDomProjectModel.class, false);
    if (model != null && !processed.contains(model)) {
      if (processed.size() > 0) sb.append(", ");
      sb.append(createLinkText(model, domDependency));

      processed.add(model);
    }
  }
  holder.createProblem(dependency, HighlightSeverity.WARNING,
                       MavenDomBundle.message("MavenDuplicateDependenciesInspection.has.duplicates", sb.toString()));
}
项目:tools-idea    文件:MavenDomProjectProcessorUtils.java   
public static Set<XmlTag> collectProperties(@NotNull MavenDomProjectModel projectDom, @NotNull final Project project) {
  final Set<XmlTag> properties = new HashSet<XmlTag>();

  Processor<MavenDomProperties> collectProcessor = new Processor<MavenDomProperties>() {
    public boolean process(MavenDomProperties mavenDomProperties) {
      XmlTag propertiesTag = mavenDomProperties.getXmlTag();
      if (propertiesTag != null) {
        ContainerUtil.addAll(properties, propertiesTag.getSubTags());
      }
      return false;
    }
  };

  processProperties(projectDom, collectProcessor, project);

  return properties;
}
项目:tools-idea    文件:MavenDomProjectProcessorUtils.java   
@NotNull
public static Set<MavenDomDependency> searchDependencyUsages(@NotNull final MavenDomProjectModel model,
                                                             @NotNull final DependencyConflictId dependencyId,
                                                             @NotNull final Set<MavenDomDependency> excludes) {
  Project project = model.getManager().getProject();
  final Set<MavenDomDependency> usages = new HashSet<MavenDomDependency>();
  Processor<MavenDomProjectModel> collectProcessor = new Processor<MavenDomProjectModel>() {
    public boolean process(MavenDomProjectModel mavenDomProjectModel) {
      if (!model.equals(mavenDomProjectModel)) {
        for (MavenDomDependency domDependency : mavenDomProjectModel.getDependencies().getDependencies()) {
          if (excludes.contains(domDependency)) continue;

          if (dependencyId.equals(DependencyConflictId.create(domDependency))) {
            usages.add(domDependency);
          }
        }
      }
      return false;
    }
  };

  processChildrenRecursively(model, collectProcessor, project, new HashSet<MavenDomProjectModel>(), true);

  return usages;
}
项目:tools-idea    文件:MavenDomProjectProcessorUtils.java   
@NotNull
public static Collection<MavenDomPlugin> searchManagedPluginUsages(@NotNull final MavenDomProjectModel model,
                                                                   @Nullable final String groupId,
                                                                   @NotNull final String artifactId) {
  Project project = model.getManager().getProject();

  final Set<MavenDomPlugin> usages = new HashSet<MavenDomPlugin>();

  Processor<MavenDomProjectModel> collectProcessor = new Processor<MavenDomProjectModel>() {
    public boolean process(MavenDomProjectModel mavenDomProjectModel) {
      for (MavenDomPlugin domPlugin : mavenDomProjectModel.getBuild().getPlugins().getPlugins()) {
        if (MavenPluginDomUtil.isPlugin(domPlugin, groupId, artifactId)) {
          usages.add(domPlugin);
        }
      }
      return false;
    }
  };

  processChildrenRecursively(model, collectProcessor, project, new HashSet<MavenDomProjectModel>(), true);

  return usages;
}
项目:tools-idea    文件:VcsStructureChooser.java   
private void calculateRoots() {
  final ModuleManager moduleManager = ModuleManager.getInstance(myVcs.getProject());
  // assertion for read access inside
  final Module[] modules = ApplicationManager.getApplication().runReadAction(new Computable<Module[]>() {
    public Module[] compute() {
      return moduleManager.getModules();
    }
  });

  final TreeSet<VirtualFile> checkSet = new TreeSet<VirtualFile>(FilePathComparator.getInstance());
  myRoots = new HashSet<VirtualFile>();
  myRoots.addAll(myInitialRoots);
  checkSet.addAll(myInitialRoots);
  myModulesSet = new HashMap<VirtualFile, String>();
  for (Module module : modules) {
    final VirtualFile[] files = ModuleRootManager.getInstance(module).getContentRoots();
    for (VirtualFile file : files) {
      final VirtualFile floor = checkSet.floor(file);
      if (floor != null) {
        myModulesSet.put(file, module.getName());
        myRoots.add(file);
      }
    }
  }
}
项目:tools-idea    文件:GitShelveUnshelveTest.java   
private void unshelve(ShelvedChangeList list) {
  final LocalChangeList changeList = myChangeListManager.addChangeList("another list", "");
  myShelveChangesManager.unshelveChangeList(list, null, null, changeList);
  refreshChanges();

  final List<LocalChangeList> lists = myChangeListManager.getChangeLists();
  Assert.assertEquals(2, lists.size());

  LocalChangeList newList = null;
  final Set<String> listNames = new HashSet<String>();
  listNames.addAll(Arrays.asList("Default", "another list"));
  for (LocalChangeList localChangeList : lists) {
    listNames.remove(localChangeList.getName());
    if ("another list".equals(localChangeList.getName())) {
      newList = localChangeList;
    }
  }
  Assert.assertEquals(0, listNames.size());

  checkListContents(newList);
}
项目:tools-idea    文件:ApplicationLevelNumberConnectionsGuardImpl.java   
public ApplicationLevelNumberConnectionsGuardImpl() {
  myDelay = DELAY;
  mySet = new HashSet<CachingSvnRepositoryPool>();
  myService = Executors.newSingleThreadScheduledExecutor();
  myLock = new Object();
  myDisposed = false;
  myRecheck = new Runnable() {
    @Override
    public void run() {
      HashSet<CachingSvnRepositoryPool> pools = new HashSet<CachingSvnRepositoryPool>();
      synchronized (myLock) {
        pools.addAll(mySet);
      }
      for (CachingSvnRepositoryPool pool : pools) {
        pool.check();
      }
    }
  };
  myCurrentlyActiveConnections = 0;
  myCurrentlyOpenedConnections = 0;
}
项目:tools-idea    文件:ApplicationLevelNumberConnectionsGuardImpl.java   
@Override
public void waitForTotalNumberOfConnectionsOk() throws SVNException {
  synchronized (myLock) {
    if (myCurrentlyActiveConnections >= CachingSvnRepositoryPool.ourMaxTotal) {
      waitForFreeConnections();
    }
  }
  // maybe too many opened? reduce request
  final Set<CachingSvnRepositoryPool> copy = new HashSet<CachingSvnRepositoryPool>();
  synchronized (myLock) {
    if (myCurrentlyOpenedConnections >= CachingSvnRepositoryPool.ourMaxTotal) {
      copy.addAll(mySet);
    }
  }
  for (CachingSvnRepositoryPool pool : copy) {
    pool.closeInactive();
  }
  synchronized (myLock) {
    waitForFreeConnections();
  }
}
项目:tools-idea    文件:CachingSvnRepositoryPool.java   
private RepoGroup(ThrowableConvertor<SVNURL, SVNRepository, SVNException> creator, int cached, int concurrent,
                  final ThrowableConsumer<Pair<SVNURL, SVNRepository>, SVNException> adjuster,
                  final ApplicationLevelNumberConnectionsGuard guard, final Object waitObj, final long connectionTimeout) {
  myCreator = creator;
  myMaxCached = cached;
  myMaxConcurrent = concurrent;
  myAdjuster = adjuster;
  myGuard = guard;
  myConnectionTimeout = connectionTimeout;

  myInactive = new TreeMap<Long, SVNRepository>();
  myUsed = new HashSet<SVNRepository>();

  myDisposed = false;
  myWait = waitObj;
}
项目:tools-idea    文件:DelegatedMethodsContributor.java   
@Override
public void collectMethods(@NotNull final GrTypeDefinition clazz, @NotNull Collection<PsiMethod> collector) {
  Set<PsiClass> processed = new HashSet<PsiClass>();

  if (!checkForDelegate(clazz)) return;

  Map<MethodSignature, PsiMethod> signatures = new THashMap<MethodSignature, PsiMethod>(MethodSignatureUtil.METHOD_PARAMETERS_ERASURE_EQUALITY);
  initializeSignatures(clazz, PsiSubstitutor.EMPTY, signatures, processed);

  List<PsiMethod> methods = new ArrayList<PsiMethod>();
  process(clazz, PsiSubstitutor.EMPTY, true, new HashSet<PsiClass>(), processed, methods, clazz);

  final Set<PsiMethod> result = new LinkedHashSet<PsiMethod>();
  for (PsiMethod method : methods) {
    addMethodChecked(signatures, method, PsiSubstitutor.EMPTY, result);
  }

  collector.addAll(result);
}
项目:tools-idea    文件:GroovyParameterInfoHandler.java   
private static void filterOutReflectedMethods(List toShow) {
  Set<GrMethod> methods = new HashSet<GrMethod>();

  for (Iterator iterator = toShow.iterator(); iterator.hasNext(); ) {
    Object next = iterator.next();
    if (next instanceof GroovyResolveResult) {
      final PsiElement element = ((GroovyResolveResult)next).getElement();
      if (element instanceof GrReflectedMethod) {
        final GrMethod base = ((GrReflectedMethod)element).getBaseMethod();
        if (!methods.add(base)) {
          iterator.remove();
        }
      }
    }
  }
}
项目:tools-idea    文件:ConvertToJavaProcessor.java   
private static String getNewFileName(GroovyFile file) {
  final PsiDirectory dir = file.getContainingDirectory();
  LOG.assertTrue(dir != null);


  final PsiFile[] files = dir.getFiles();
  Set<String> fileNames = new HashSet<String>();
  for (PsiFile psiFile : files) {
    fileNames.add(psiFile.getName());
  }
  String prefix = FileUtil.getNameWithoutExtension(file.getName());
  String fileName = prefix + ".java";
  int index = 1;
  while (fileNames.contains(fileName)) {
    fileName = prefix + index + ".java";
  }
  return fileName;
}
项目:tools-idea    文件:GenerationUtil.java   
static Set<String> getVarTypes(GrVariableDeclaration variableDeclaration) {
  GrVariable[] variables = variableDeclaration.getVariables();
  final GrTypeElement typeElement = variableDeclaration.getTypeElementGroovy();
  Set<String> types = new HashSet<String>(variables.length);
  if (typeElement == null) {
    if (variables.length > 1) {
      for (GrVariable variable : variables) {
        final GrExpression initializer = variable.getInitializerGroovy();
        if (initializer != null) {
          final PsiType varType = initializer.getType();
          if (varType != null) {
            types.add(getTypeText(varType, variableDeclaration));
          }
        }
      }
    }
  }
  return types;
}
项目:consulo    文件:CustomFoldingBuilder.java   
@RequiredReadAction
@Nonnull
@Override
public final FoldingDescriptor[] buildFoldRegions(@Nonnull PsiElement root, @Nonnull Document document, boolean quick) {
  List<FoldingDescriptor> descriptors = new ArrayList<FoldingDescriptor>();
  ourCustomRegionElements.set(new HashSet<ASTNode>());
  try {
    if (CustomFoldingProvider.getAllProviders().length > 0) {
      myDefaultProvider = null;
      ASTNode rootNode = root.getNode();
      if (rootNode != null) {
        addCustomFoldingRegionsRecursively(new FoldingStack(rootNode), rootNode, descriptors, 0);
      }
    }
    buildLanguageFoldRegions(descriptors, root, document, quick);
  }
  finally {
    ourCustomRegionElements.set(null);
  }
  return descriptors.toArray(new FoldingDescriptor[descriptors.size()]);
}
项目:consulo    文件:ChangeSignatureProcessorBase.java   
protected List<UsageInfo> filterUsages(List<UsageInfo> infos) {
  Map<PsiElement, MoveRenameUsageInfo> moveRenameInfos = new HashMap<PsiElement, MoveRenameUsageInfo>();
  Set<PsiElement> usedElements = new HashSet<PsiElement>();

  List<UsageInfo> result = new ArrayList<UsageInfo>(infos.size() / 2);
  for (UsageInfo info : infos) {
    LOG.assertTrue(info != null, getClass());
    PsiElement element = info.getElement();
    if (info instanceof MoveRenameUsageInfo) {
      if (usedElements.contains(element)) continue;
      moveRenameInfos.put(element, (MoveRenameUsageInfo)info);
    }
    else {
      moveRenameInfos.remove(element);
      usedElements.add(element);
      if (!(info instanceof PossiblyIncorrectUsage) || ((PossiblyIncorrectUsage)info).isCorrect()) {
        result.add(info);
      }
    }
  }
  result.addAll(moveRenameInfos.values());
  return result;
}
项目:consulo-java    文件:TestUtils.java   
private static boolean testInstancePerClass(@NotNull PsiClass containingClass, HashSet<PsiClass> classes)
{
    PsiAnnotation annotation = MetaAnnotationUtil.findMetaAnnotations(containingClass, Collections.singletonList(JUnitCommonClassNames.ORG_JUNIT_JUPITER_API_TEST_INSTANCE)).findFirst().orElse
            (null);
    if(annotation != null)
    {
        PsiAnnotationMemberValue value = annotation.findDeclaredAttributeValue(PsiAnnotation.DEFAULT_REFERENCED_METHOD_NAME);
        if(value != null && value.getText().contains("PER_CLASS"))
        {
            return true;
        }
    }
    else
    {
        for(PsiClass superClass : containingClass.getSupers())
        {
            if(classes.add(superClass) && testInstancePerClass(superClass, classes))
            {
                return true;
            }
        }
    }
    return false;
}
项目:consulo-java    文件:JavaAnonymousClassesNodeProvider.java   
@Override
public Collection<JavaAnonymousClassTreeElement> provideNodes(TreeElement node) {
  if (node instanceof PsiMethodTreeElement || node instanceof PsiFieldTreeElement || node instanceof ClassInitializerTreeElement) {
    final PsiElement el = ((PsiTreeElementBase)node).getElement();
    for (AnonymousElementProvider provider : Extensions.getExtensions(AnonymousElementProvider.EP_NAME)) {
      final PsiElement[] elements = provider.getAnonymousElements(el);
      if (elements != null && elements.length > 0) {
        List<JavaAnonymousClassTreeElement> result = new ArrayList<JavaAnonymousClassTreeElement>(elements.length);
        for (PsiElement element : elements) {
          result.add(new JavaAnonymousClassTreeElement((PsiAnonymousClass)element, new HashSet<PsiClass>()));
        }
        return result;
      }
    }
  }
  return Collections.emptyList();
}
项目:educational-plugin    文件:EduUsagesCollector.java   
@NotNull
@Override
public Set<UsageDescriptor> getUsages() throws CollectUsagesException {
  HashSet<UsageDescriptor> descriptors = new HashSet<>();
  myUsageDescriptors.forEachEntry((key, value) -> {
    descriptors.add(new UsageDescriptor(key, value));
    return true;
  });
  myUsageDescriptors.clear();
  return descriptors;
}