Search in sources :

Example 16 with NamedScope

use of com.intellij.psi.search.scope.packageSet.NamedScope 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)

Example 17 with NamedScope

use of com.intellij.psi.search.scope.packageSet.NamedScope in project intellij-community by JetBrains.

the class FileColorsModel method findConfiguration.

@Nullable
private FileColorConfiguration findConfiguration(@NotNull final VirtualFile colored) {
    for (FileColorConfiguration configuration : getConfigurations()) {
        NamedScope scope = NamedScopesHolder.getScope(myProject, configuration.getScopeName());
        if (scope != null) {
            NamedScopesHolder namedScopesHolder = NamedScopesHolder.getHolder(myProject, configuration.getScopeName(), null);
            PackageSet packageSet = scope.getValue();
            if (packageSet instanceof PackageSetBase && namedScopesHolder != null && ((PackageSetBase) packageSet).contains(colored, myProject, namedScopesHolder)) {
                return configuration;
            }
        }
    }
    return null;
}
Also used : NamedScope(com.intellij.psi.search.scope.packageSet.NamedScope) NamedScopesHolder(com.intellij.psi.search.scope.packageSet.NamedScopesHolder) PackageSet(com.intellij.psi.search.scope.packageSet.PackageSet) PackageSetBase(com.intellij.psi.search.scope.packageSet.PackageSetBase) Nullable(org.jetbrains.annotations.Nullable)

Example 18 with NamedScope

use of com.intellij.psi.search.scope.packageSet.NamedScope in project intellij-community by JetBrains.

the class ScopesChooser method createPopupActionGroup.

@NotNull
@Override
public DefaultActionGroup createPopupActionGroup(final JComponent component) {
    final DefaultActionGroup group = new DefaultActionGroup();
    final List<NamedScope> predefinedScopes = new ArrayList<>();
    final List<NamedScope> customScopes = new ArrayList<>();
    for (final NamedScopesHolder holder : NamedScopesHolder.getAllNamedScopeHolders(myProject)) {
        Collections.addAll(customScopes, holder.getEditableScopes());
        predefinedScopes.addAll(holder.getPredefinedScopes());
    }
    predefinedScopes.remove(CustomScopesProviderEx.getAllScope());
    for (NamedScope predefinedScope : predefinedScopes) {
        if (predefinedScope instanceof NonProjectFilesScope) {
            predefinedScopes.remove(predefinedScope);
            break;
        }
    }
    fillActionGroup(group, predefinedScopes, myDefaultDescriptors, myInspectionProfile, myExcludedScopeNames);
    group.addSeparator();
    fillActionGroup(group, customScopes, myDefaultDescriptors, myInspectionProfile, myExcludedScopeNames);
    group.addSeparator();
    group.add(new DumbAwareAction("Edit Scopes Order...") {

        @Override
        public void actionPerformed(final AnActionEvent e) {
            final ScopesOrderDialog dlg = new ScopesOrderDialog(component, myInspectionProfile, myProject);
            if (dlg.showAndGet()) {
                onScopesOrderChanged();
            }
        }
    });
    return group;
}
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) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup) DumbAwareAction(com.intellij.openapi.project.DumbAwareAction) NotNull(org.jetbrains.annotations.NotNull)

Example 19 with NamedScope

use of com.intellij.psi.search.scope.packageSet.NamedScope in project intellij-community by JetBrains.

the class DependencyConfigurable method apply.

@Override
public void apply() throws ConfigurationException {
    stopTableEditing();
    DependencyValidationManager validationManager = DependencyValidationManager.getInstance(myProject);
    validationManager.removeAllRules();
    final HashMap<String, PackageSet> unUsed = new HashMap<>(validationManager.getUnnamedScopes());
    List<DependencyRule> modelItems = new ArrayList<>();
    modelItems.addAll(myDenyRulesModel.getItems());
    modelItems.addAll(myAllowRulesModel.getItems());
    for (DependencyRule rule : modelItems) {
        validationManager.addRule(rule);
        final NamedScope fromScope = rule.getFromScope();
        if (fromScope instanceof NamedScope.UnnamedScope) {
            final PackageSet fromPackageSet = fromScope.getValue();
            LOG.assertTrue(fromPackageSet != null);
            unUsed.remove(fromPackageSet.getText());
        }
        final NamedScope toScope = rule.getToScope();
        if (toScope instanceof NamedScope.UnnamedScope) {
            final PackageSet toPackageSet = toScope.getValue();
            LOG.assertTrue(toPackageSet != null);
            unUsed.remove(toPackageSet.getText());
        }
    }
    for (String text : unUsed.keySet()) {
        //cleanup
        validationManager.getUnnamedScopes().remove(text);
    }
    validationManager.setSkipImportStatements(mySkipImports.isSelected());
    DaemonCodeAnalyzer.getInstance(myProject).restart();
}
Also used : DependencyValidationManager(com.intellij.packageDependencies.DependencyValidationManager) NamedScope(com.intellij.psi.search.scope.packageSet.NamedScope) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) DependencyRule(com.intellij.packageDependencies.DependencyRule) PackageSet(com.intellij.psi.search.scope.packageSet.PackageSet)

Example 20 with NamedScope

use of com.intellij.psi.search.scope.packageSet.NamedScope in project intellij-community by JetBrains.

the class ScopeChooserUtils method findScopeByName.

@NotNull
public static GlobalSearchScope findScopeByName(@NotNull Project project, @Nullable String scopeName) {
    NamedScope namedScope = scopeName == null ? null : ChangeListsScopesProvider.getInstance(project).getCustomScope(scopeName);
    if (namedScope == null) {
        namedScope = NamedScopesHolder.getScope(project, scopeName);
    }
    if (namedScope == null && OPEN_FILES_SCOPE_NAME.equals(scopeName)) {
        return intersectWithContentScope(project, GlobalSearchScopes.openFilesScope(project));
    }
    if (namedScope == null && CURRENT_FILE_SCOPE_NAME.equals(scopeName)) {
        VirtualFile[] array = FileEditorManager.getInstance(project).getSelectedFiles();
        List<VirtualFile> files = ContainerUtil.createMaybeSingletonList(ArrayUtil.getFirstElement(array));
        GlobalSearchScope scope = GlobalSearchScope.filesScope(project, files, CURRENT_FILE_SCOPE_NAME);
        return intersectWithContentScope(project, scope);
    }
    if (namedScope == null) {
        namedScope = new ProjectFilesScope();
    }
    GlobalSearchScope scope = GlobalSearchScopesCore.filterScope(project, namedScope);
    if (namedScope instanceof ProjectFilesScope || namedScope instanceof ProjectProductionScope) {
        return scope;
    }
    return intersectWithContentScope(project, scope);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) NamedScope(com.intellij.psi.search.scope.packageSet.NamedScope) GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) ProjectFilesScope(com.intellij.psi.search.scope.ProjectFilesScope) ProjectProductionScope(com.intellij.psi.search.scope.ProjectProductionScope) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

NamedScope (com.intellij.psi.search.scope.packageSet.NamedScope)26 NamedScopesHolder (com.intellij.psi.search.scope.packageSet.NamedScopesHolder)10 PackageSet (com.intellij.psi.search.scope.packageSet.PackageSet)9 ArrayList (java.util.ArrayList)6 TextAttributes (com.intellij.openapi.editor.markup.TextAttributes)5 TextAttributesKey (com.intellij.openapi.editor.colors.TextAttributesKey)4 Project (com.intellij.openapi.project.Project)4 DependencyValidationManager (com.intellij.packageDependencies.DependencyValidationManager)4 NotNull (org.jetbrains.annotations.NotNull)4 HighlightDisplayLevel (com.intellij.codeHighlighting.HighlightDisplayLevel)3 HighlightDisplayKey (com.intellij.codeInsight.daemon.HighlightDisplayKey)3 DumbAwareAction (com.intellij.openapi.project.DumbAwareAction)3 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)2 EditorColorsManager (com.intellij.openapi.editor.colors.EditorColorsManager)2 EditorColorsScheme (com.intellij.openapi.editor.colors.EditorColorsScheme)2 PatternPackageSet (com.intellij.psi.search.scope.packageSet.PatternPackageSet)2 THashSet (gnu.trove.THashSet)2 IOException (java.io.IOException)2 Element (org.jdom.Element)2 AnalysisScope (com.intellij.analysis.AnalysisScope)1