Java 类com.intellij.util.containers.SmartHashSet 实例源码

项目:intellij-ce-playground    文件:PathMacrosCollector.java   
@NotNull
public static Set<String> getMacroNames(Element root, @Nullable PathMacroFilter filter, @NotNull PathMacros pathMacros) {
  final PathMacrosCollector collector = new PathMacrosCollector();
  collector.substitute(root, true, false, filter);
  Set<String> preResult = collector.myMacroMap.keySet();
  if (preResult.isEmpty()) {
    return Collections.emptySet();
  }

  Set<String> result = new SmartHashSet<String>(preResult);
  result.removeAll(pathMacros.getSystemMacroNames());
  result.removeAll(pathMacros.getLegacyMacroNames());
  result.removeAll(PathMacrosImpl.getToolMacroNames());
  result.removeAll(pathMacros.getIgnoredMacroNames());
  return result;
}
项目:intellij-ce-playground    文件:InspectionEngine.java   
@Nullable("null means not specified")
private static Set<String> getDialectIdsSpecifiedForTool(@NotNull LocalInspectionToolWrapper wrapper) {
  String langId = wrapper.getLanguage();
  if (langId == null) {
    return null;
  }
  Language language = Language.findLanguageByID(langId);
  Set<String> result;
  if (language != null) {
    List<Language> dialects = language.getDialects();
    boolean applyToDialects = wrapper.applyToDialects();
    result = applyToDialects && !dialects.isEmpty() ? new THashSet<String>(1 + dialects.size()) : new SmartHashSet<String>();
    result.add(langId);
    if (applyToDialects) {
      for (Language dialect : dialects) {
        result.add(dialect.getID());
      }
    }
  }
  else {
    // unknown language in plugin.xml, ignore
    result = Collections.singleton(langId);
  }
  return result;
}
项目:consulo    文件:InspectionEngine.java   
@Nullable
public static Set<String> getDialectIdsSpecifiedForTool(@Nonnull LocalInspectionToolWrapper wrapper) {
  String langId = wrapper.getLanguage();
  if (langId == null) {
    return null;
  }
  Language language = Language.findLanguageByID(langId);
  Set<String> result;
  if (language != null) {
    result = new SmartHashSet<String>();
    result.add(langId);
  }
  else {
    // unknown language in plugin.xml, ignore
    result = Collections.singleton(langId);
  }
  return result;
}
项目:intellij-ce-playground    文件:SuspendManagerUtil.java   
@NotNull
public static Set<SuspendContextImpl> getSuspendingContexts(@NotNull SuspendManager suspendManager, ThreadReferenceProxyImpl thread) {
  DebuggerManagerThreadImpl.assertIsManagerThread();
  Set<SuspendContextImpl> result = new SmartHashSet<SuspendContextImpl>();
  for (SuspendContextImpl suspendContext : suspendManager.getEventContexts()) {
    if (suspendContext.suspends(thread)) {
      result.add(suspendContext);
    }
  }
  return result;
}
项目:intellij-ce-playground    文件:DebuggerTreeNodeExpression.java   
public static PsiExpression castToRuntimeType(PsiExpression expression, Value value) throws EvaluateException {
  if (!(value instanceof ObjectReference)) {
    return expression;
  }

  ReferenceType valueType = ((ObjectReference)value).referenceType();
  if (valueType == null) {
    return expression;
  }

  Project project = expression.getProject();

  PsiType type = RuntimeTypeEvaluator.getCastableRuntimeType(project, value);
  if (type == null) {
    return expression;
  }

  PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(project);
  String typeName = type.getCanonicalText();
  try {
    PsiParenthesizedExpression parenthExpression = (PsiParenthesizedExpression)elementFactory.createExpressionFromText(
      "((" + typeName + ")expression)", null);
    //noinspection ConstantConditions
    ((PsiTypeCastExpression)parenthExpression.getExpression()).getOperand().replace(expression);
    Set<String> imports = expression.getUserData(ADDITIONAL_IMPORTS_KEY);
    if (imports == null) {
      imports = new SmartHashSet<String>();
    }
    imports.add(typeName);
    parenthExpression.putUserData(ADDITIONAL_IMPORTS_KEY, imports);
    return parenthExpression;
  }
  catch (IncorrectOperationException e) {
    throw new EvaluateException(DebuggerBundle.message("error.invalid.type.name", typeName), e);
  }
}
项目:intellij-ce-playground    文件:BasePathMacroManager.java   
@NotNull
@Override
public Set<String> getComponents(@NotNull Collection<String> macros) {
  synchronized (myLock) {
    Set<String> result = new SmartHashSet<String>();
    for (String macro : macros) {
      result.addAll(myMacroToComponentNames.get(macro));
    }
    return result;
  }
}
项目:intellij-ce-playground    文件:InspectionEngine.java   
@NotNull
public static Set<String> calcElementDialectIds(@NotNull List<PsiElement> inside, @NotNull List<PsiElement> outside) {
  Set<String> dialectIds = new SmartHashSet<String>();
  Set<Language> processedLanguages = new SmartHashSet<Language>();
  addDialects(inside, processedLanguages, dialectIds);
  addDialects(outside, processedLanguages, dialectIds);
  return dialectIds;
}
项目:intellij-ce-playground    文件:InspectionEngine.java   
@NotNull
public static Set<String> calcElementDialectIds(@NotNull List<PsiElement> elements) {
  Set<String> dialectIds = new SmartHashSet<String>();
  Set<Language> processedLanguages = new SmartHashSet<Language>();
  addDialects(elements, processedLanguages, dialectIds);
  return dialectIds;
}
项目:consulo    文件:InspectionEngine.java   
@Nonnull
public static Set<String> calcElementDialectIds(@Nonnull List<PsiElement> inside, @Nonnull List<PsiElement> outside) {
  Set<String> dialectIds = new SmartHashSet<>();
  Set<Language> processedLanguages = new SmartHashSet<>();
  addDialects(inside, processedLanguages, dialectIds);
  addDialects(outside, processedLanguages, dialectIds);
  return dialectIds;
}
项目:consulo    文件:InspectionEngine.java   
@Nonnull
public static Set<String> calcElementDialectIds(@Nonnull List<PsiElement> elements) {
  Set<String> dialectIds = new SmartHashSet<>();
  Set<Language> processedLanguages = new SmartHashSet<>();
  addDialects(elements, processedLanguages, dialectIds);
  return dialectIds;
}
项目:consulo    文件:StorageData.java   
public Set<String> getChangedComponentNames(@Nonnull StorageData newStorageData, @Nullable PathMacroSubstitutor substitutor) {
  Set<String> bothStates = new SmartHashSet<String>(myStates.keys());
  bothStates.retainAll(newStorageData.myStates.keys());

  Set<String> diffs = new SmartHashSet<String>();
  diffs.addAll(newStorageData.myStates.keys());
  diffs.addAll(myStates.keys());
  diffs.removeAll(bothStates);

  for (String componentName : bothStates) {
    myStates.compare(componentName, newStorageData.myStates, diffs);
  }
  return diffs;
}
项目:consulo    文件:ComponentStoreImpl.java   
@Override
@Nullable
public final Collection<String> reload(@Nonnull Collection<? extends StateStorage> changedStorages) {
  if (changedStorages.isEmpty()) {
    return Collections.emptySet();
  }

  Set<String> componentNames = new SmartHashSet<>();
  for (StateStorage storage : changedStorages) {
    try {
      // we must update (reload in-memory storage data) even if non-reloadable component will be detected later
      // not saved -> user does own modification -> new (on disk) state will be overwritten and not applied
      storage.analyzeExternalChangesAndUpdateIfNeed(componentNames);
    }
    catch (Throwable e) {
      LOG.error(e);
    }
  }

  if (componentNames.isEmpty()) {
    return Collections.emptySet();
  }

  Collection<String> notReloadableComponents = getNotReloadableComponents(componentNames);
  reinitComponents(componentNames, notReloadableComponents, changedStorages);
  return notReloadableComponents.isEmpty() ? null : notReloadableComponents;
}
项目:consulo-java    文件:SuspendManagerUtil.java   
@NotNull
public static Set<SuspendContextImpl> getSuspendingContexts(@NotNull SuspendManager suspendManager, ThreadReferenceProxyImpl thread)
{
    DebuggerManagerThreadImpl.assertIsManagerThread();
    Set<SuspendContextImpl> result = new SmartHashSet<SuspendContextImpl>();
    for(SuspendContextImpl suspendContext : suspendManager.getEventContexts())
    {
        if(suspendContext.suspends(thread))
        {
            result.add(suspendContext);
        }
    }
    return result;
}
项目:intellij-ce-playground    文件:AnActionButton.java   
public final void addCustomUpdater(@NotNull AnActionButtonUpdater updater) {
  if (myUpdaters == null) {
    myUpdaters = new SmartHashSet<AnActionButtonUpdater>();
  }
  myUpdaters.add(updater);
}
项目:consulo-java    文件:DebuggerTreeNodeExpression.java   
public static PsiExpression castToRuntimeType(PsiExpression expression, Value value) throws EvaluateException
{
    if(!(value instanceof ObjectReference))
    {
        return expression;
    }

    ReferenceType valueType = ((ObjectReference) value).referenceType();
    if(valueType == null)
    {
        return expression;
    }

    Project project = expression.getProject();

    PsiType type = RuntimeTypeEvaluator.getCastableRuntimeType(project, value);
    if(type == null)
    {
        return expression;
    }

    PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(project);
    String typeName = type.getCanonicalText();
    try
    {
        PsiParenthesizedExpression parenthExpression = (PsiParenthesizedExpression) elementFactory.createExpressionFromText("((" + typeName + ")expression)", null);
        //noinspection ConstantConditions
        ((PsiTypeCastExpression) parenthExpression.getExpression()).getOperand().replace(expression);
        Set<String> imports = expression.getUserData(ADDITIONAL_IMPORTS_KEY);
        if(imports == null)
        {
            imports = new SmartHashSet<String>();
        }
        imports.add(typeName);
        parenthExpression.putUserData(ADDITIONAL_IMPORTS_KEY, imports);
        return parenthExpression;
    }
    catch(IncorrectOperationException e)
    {
        throw new EvaluateException(DebuggerBundle.message("error.invalid.type.name", typeName), e);
    }
}