private List<String> getAvailableScopes(Project project, List<Descriptor> descriptors) { final ArrayList<NamedScope> scopes = new ArrayList<NamedScope>(); for (NamedScopesHolder holder : NamedScopesHolder.getAllNamedScopeHolders(project)) { Collections.addAll(scopes, holder.getScopes()); } scopes.remove(DefaultScopesProvider.getAllScope()); CustomScopesProviderEx.filterNoSettingsScopes(project, scopes); final Set<NamedScope> used = new HashSet<NamedScope>(); for (Descriptor descriptor : descriptors) { final List<ScopeToolState> nonDefaultTools = getSelectedProfile().getNonDefaultTools(descriptor.getKey().toString()); if (nonDefaultTools != null) { for (ScopeToolState state : nonDefaultTools) { used.add(state.getScope(project)); } } } scopes.removeAll(used); final List<String> availableScopes = new ArrayList<String>(); for (NamedScope scope : scopes) { availableScopes.add(scope.getName()); } return availableScopes; }
private static void initScopesDescriptors( @NotNull List<EditorSchemeAttributeDescriptor> descriptions, @NotNull MyColorScheme scheme) { Set<Pair<NamedScope, NamedScopesHolder>> namedScopes = new THashSet<Pair<NamedScope, NamedScopesHolder>>( new TObjectHashingStrategy<Pair<NamedScope, NamedScopesHolder>>() { @Override public int computeHashCode( @NotNull final Pair<NamedScope, NamedScopesHolder> object) { return object.getFirst().getName().hashCode(); } @Override public boolean equals( @NotNull final Pair<NamedScope, NamedScopesHolder> o1, @NotNull final Pair<NamedScope, NamedScopesHolder> o2) { return o1.getFirst().getName().equals(o2.getFirst().getName()); } }); Project[] projects = ProjectManager.getInstance().getOpenProjects(); for (Project project : projects) { DependencyValidationManagerImpl validationManager = (DependencyValidationManagerImpl) DependencyValidationManager.getInstance(project); List<Pair<NamedScope, NamedScopesHolder>> cachedScopes = validationManager.getScopeBasedHighlightingCachedScopes(); namedScopes.addAll(cachedScopes); } List<Pair<NamedScope, NamedScopesHolder>> list = new ArrayList<Pair<NamedScope, NamedScopesHolder>>(namedScopes); Collections.sort( list, new Comparator<Pair<NamedScope, NamedScopesHolder>>() { @Override public int compare( @NotNull final Pair<NamedScope, NamedScopesHolder> o1, @NotNull final Pair<NamedScope, NamedScopesHolder> o2) { return o1.getFirst().getName().compareToIgnoreCase(o2.getFirst().getName()); } }); for (Pair<NamedScope, NamedScopesHolder> pair : list) { NamedScope namedScope = pair.getFirst(); String name = namedScope.getName(); TextAttributesKey textAttributesKey = ScopeAttributesUtil.getScopeTextAttributeKey(name); if (scheme.getAttributes(textAttributesKey) == null) { scheme.setAttributes(textAttributesKey, new TextAttributes()); } NamedScopesHolder holder = pair.getSecond(); PackageSet value = namedScope.getValue(); String toolTip = holder.getDisplayName() + (value == null ? "" : ": " + value.getText()); addSchemedDescription( descriptions, name, SCOPES_GROUP, textAttributesKey, scheme, holder.getIcon(), toolTip); } }
private Collection<String> getValidScopeNames() { List<String> result = new ArrayList<String>(); result.add(SCOPE_PROJECT); result.add(SCOPE_TEST); result.add(SCOPE_ALL); result.add(SCOPE_CLASS); final NamedScopesHolder[] holders = NamedScopesHolder.getAllNamedScopeHolders(myProject); for (NamedScopesHolder holder : holders) { NamedScope[] scopes = holder.getEditableScopes(); // predefined scopes already included for (NamedScope scope : scopes) { result.add(scope.getName()); } } return result; }