Search in sources :

Example 1 with NamedScopesHolder

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);
}
Also used : NamedScope(com.intellij.psi.search.scope.packageSet.NamedScope) NonProjectFilesScope(com.intellij.psi.search.scope.NonProjectFilesScope) NamedScopesHolder(com.intellij.psi.search.scope.packageSet.NamedScopesHolder) ArrayList(java.util.ArrayList)

Example 2 with NamedScopesHolder

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;
}
Also used : NamedScope(com.intellij.psi.search.scope.packageSet.NamedScope) GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) NamedScopesHolder(com.intellij.psi.search.scope.packageSet.NamedScopesHolder) ArrayList(java.util.ArrayList) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with NamedScopesHolder

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);
    }
}
Also used : NamedScopesHolder(com.intellij.psi.search.scope.packageSet.NamedScopesHolder) PackageSet(com.intellij.psi.search.scope.packageSet.PackageSet) THashSet(gnu.trove.THashSet) DependencyValidationManagerImpl(com.intellij.packageDependencies.DependencyValidationManagerImpl) Project(com.intellij.openapi.project.Project) NamedScope(com.intellij.psi.search.scope.packageSet.NamedScope) TextAttributes(com.intellij.openapi.editor.markup.TextAttributes) Pair(com.intellij.openapi.util.Pair)

Example 4 with NamedScopesHolder

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);
}
Also used : NamedScope(com.intellij.psi.search.scope.packageSet.NamedScope) NamedScopesHolder(com.intellij.psi.search.scope.packageSet.NamedScopesHolder) PsiFile(com.intellij.psi.PsiFile) PsiFileSystemItem(com.intellij.psi.PsiFileSystemItem) PackageSet(com.intellij.psi.search.scope.packageSet.PackageSet)

Example 5 with NamedScopesHolder

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;
}
Also used : ActionEvent(java.awt.event.ActionEvent) NamedScopesHolder(com.intellij.psi.search.scope.packageSet.NamedScopesHolder) ArrayList(java.util.ArrayList) Project(com.intellij.openapi.project.Project) NamedScope(com.intellij.psi.search.scope.packageSet.NamedScope) ActionListener(java.awt.event.ActionListener) ComboboxSpeedSearch(com.intellij.ui.ComboboxSpeedSearch)

Aggregations

NamedScope (com.intellij.psi.search.scope.packageSet.NamedScope)10 NamedScopesHolder (com.intellij.psi.search.scope.packageSet.NamedScopesHolder)10 PackageSet (com.intellij.psi.search.scope.packageSet.PackageSet)4 ArrayList (java.util.ArrayList)4 TextAttributes (com.intellij.openapi.editor.markup.TextAttributes)3 TextAttributesKey (com.intellij.openapi.editor.colors.TextAttributesKey)2 Project (com.intellij.openapi.project.Project)2 Pair (com.intellij.openapi.util.Pair)2 DependencyValidationManagerImpl (com.intellij.packageDependencies.DependencyValidationManagerImpl)2 NonProjectFilesScope (com.intellij.psi.search.scope.NonProjectFilesScope)2 NotNull (org.jetbrains.annotations.NotNull)2 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)1 DefaultActionGroup (com.intellij.openapi.actionSystem.DefaultActionGroup)1 EditorColorsManager (com.intellij.openapi.editor.colors.EditorColorsManager)1 EditorColorsScheme (com.intellij.openapi.editor.colors.EditorColorsScheme)1 DumbAwareAction (com.intellij.openapi.project.DumbAwareAction)1 PsiFile (com.intellij.psi.PsiFile)1 PsiFileSystemItem (com.intellij.psi.PsiFileSystemItem)1 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)1 PackageSetBase (com.intellij.psi.search.scope.packageSet.PackageSetBase)1