List<NamedScopeFilter> (NamedScopesHolder... holders) { List<NamedScopeFilter> list = new ArrayList<>(); NamedScope scratchesScope = null; for (NamedScopesHolder holder : holders) { for (NamedScope scope : holder.getScopes()) { String name = scope.getScopeId(); if (null == scope.getValue()) { LOG.debug("ignore scope without package set: ", name, "; holder: ", holder); } else if (scope instanceof ScratchesNamedScope) { // the scopes here are not sorted as in scopes combobox, so we need to // add scratches scope last to fix Project/Production/Tests scopes order scratchesScope = scope; } else if (!isVisible(scope)) { LOG.debug("ignore hidden scope: ", name, "; holder: ", holder); } else { list.add(new NamedScopeFilter(holder, scope)); } } if (scratchesScope != null) { list.add(new NamedScopeFilter(holder, scratchesScope)); scratchesScope = null; } } return list; }