use of com.intellij.psi.search.scope.packageSet.NamedScopesHolder in project intellij-community by JetBrains.
the class ScopesOrderDialog method fillList.
private void fillList() {
DefaultListModel model = new DefaultListModel();
model.removeAllElements();
final List<String> scopes = new ArrayList<>();
for (final NamedScopesHolder holder : NamedScopesHolder.getAllNamedScopeHolders(myProject)) {
for (final NamedScope scope : holder.getScopes()) {
if (!(scope instanceof NonProjectFilesScope)) {
scopes.add(scope.getName());
}
}
}
scopes.remove(CustomScopesProviderEx.getAllScope().getName());
Collections.sort(scopes, new ScopeOrderComparator(myInspectionProfile));
for (String scopeName : scopes) {
model.addElement(scopeName);
}
myOptionsList.setModel(model);
myOptionsList.setSelectedIndex(0);
}
use of com.intellij.psi.search.scope.packageSet.NamedScopesHolder in project intellij-community by JetBrains.
the class ScopeChooserCombo method createModel.
@NotNull
private DefaultComboBoxModel<ScopeDescriptor> createModel() {
final DefaultComboBoxModel<ScopeDescriptor> model = new DefaultComboBoxModel<>();
createPredefinedScopeDescriptors(model);
final List<NamedScope> changeLists = ChangeListsScopesProvider.getInstance(myProject).getFilteredScopes();
if (!changeLists.isEmpty()) {
model.addElement(new ScopeSeparator("VCS Scopes"));
for (NamedScope changeListScope : changeLists) {
final GlobalSearchScope scope = GlobalSearchScopesCore.filterScope(myProject, changeListScope);
addScopeDescriptor(model, new ScopeDescriptor(scope));
}
}
final List<ScopeDescriptor> customScopes = new ArrayList<>();
final NamedScopesHolder[] holders = NamedScopesHolder.getAllNamedScopeHolders(myProject);
for (NamedScopesHolder holder : holders) {
// predefined scopes already included
final NamedScope[] scopes = holder.getEditableScopes();
for (NamedScope scope : scopes) {
final GlobalSearchScope searchScope = GlobalSearchScopesCore.filterScope(myProject, scope);
customScopes.add(new ScopeDescriptor(searchScope));
}
}
if (!customScopes.isEmpty()) {
model.addElement(new ScopeSeparator("Custom Scopes"));
for (ScopeDescriptor scope : customScopes) {
addScopeDescriptor(model, scope);
}
}
return model;
}
use of com.intellij.psi.search.scope.packageSet.NamedScopesHolder in project intellij-community by JetBrains.
the class ColorAndFontOptions method initScopesDescriptors.
private static void initScopesDescriptors(@NotNull List<EditorSchemeAttributeDescriptor> descriptions, @NotNull MyColorScheme scheme) {
Set<Pair<NamedScope, NamedScopesHolder>> namedScopes = new THashSet<>(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<>(namedScopes);
Collections.sort(list, (o1, o2) -> 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);
}
}
use of com.intellij.psi.search.scope.packageSet.NamedScopesHolder in project intellij-community by JetBrains.
the class ScopePaneSelectInTarget method isSubIdSelectable.
@Override
public boolean isSubIdSelectable(@NotNull String subId, @NotNull SelectInContext context) {
PsiFileSystemItem file = getContextPsiFile(context);
if (!(file instanceof PsiFile))
return false;
final NamedScope scope = NamedScopesHolder.getScope(myProject, subId);
PackageSet packageSet = scope != null ? scope.getValue() : null;
if (packageSet == null)
return false;
NamedScopesHolder holder = NamedScopesHolder.getHolder(myProject, subId, DependencyValidationManager.getInstance(myProject));
return packageSet.contains((PsiFile) file, holder);
}
use of com.intellij.psi.search.scope.packageSet.NamedScopesHolder in project intellij-community by JetBrains.
the class FileColorConfigurationEditDialog method createNorthPanel.
@Override
protected JComponent createNorthPanel() {
final List<NamedScope> scopeList = new ArrayList<>();
final Project project = myManager.getProject();
final NamedScopesHolder[] scopeHolders = NamedScopeManager.getAllNamedScopeHolders(project);
for (final NamedScopesHolder scopeHolder : scopeHolders) {
final NamedScope[] scopes = scopeHolder.getScopes();
Collections.addAll(scopeList, scopes);
}
CustomScopesProviderEx.filterNoSettingsScopes(project, scopeList);
for (final NamedScope scope : scopeList) {
myScopeNames.put(scope.getName(), scope);
}
myScopeComboBox = new JComboBox(ArrayUtil.toStringArray(myScopeNames.keySet()));
myScopeComboBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
updateCustomButton();
updateOKButton();
}
});
new ComboboxSpeedSearch(myScopeComboBox);
final JLabel pathLabel = new JLabel("Scope:");
pathLabel.setDisplayedMnemonic('S');
pathLabel.setLabelFor(myScopeComboBox);
final JLabel colorLabel = new JLabel("Color:");
JPanel result = new JPanel(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.fill = GridBagConstraints.BOTH;
gbc.insets = JBUI.insets(5);
gbc.gridx = 0;
result.add(pathLabel, gbc);
result.add(colorLabel, gbc);
gbc.gridx = 1;
gbc.weightx = 1;
result.add(myScopeComboBox, gbc);
result.add(myColorSelectionComponent, gbc);
return result;
}
Aggregations