@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; }
@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; }
@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; }
@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; }
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); } }
@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; } }
@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; }
@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; }
@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; }
@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; }
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; }
@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; }
@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; }
public final void addCustomUpdater(@NotNull AnActionButtonUpdater updater) { if (myUpdaters == null) { myUpdaters = new SmartHashSet<AnActionButtonUpdater>(); } myUpdaters.add(updater); }
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); } }