Search in sources :

Example 21 with NamedScope

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

the class EditScopesDialog method doOKAction.

@Override
public void doOKAction() {
    Object selectedObject = myConfigurable.getSelectedObject();
    mySelectedScope = selectedObject instanceof NamedScope ? (NamedScope) selectedObject : null;
    super.doOKAction();
    if (myCheckShared && mySelectedScope != null) {
        final Project project = myProject;
        final DependencyValidationManager manager = DependencyValidationManager.getInstance(project);
        NamedScope scope = manager.getScope(mySelectedScope.getName());
        if (scope == null) {
            if (Messages.showYesNoDialog(IdeBundle.message("scope.unable.to.save.scope.message"), IdeBundle.message("scope.unable.to.save.scope.title"), Messages.getErrorIcon()) == Messages.YES) {
                final String newName = Messages.showInputDialog(project, IdeBundle.message("add.scope.name.label"), IdeBundle.message("scopes.save.dialog.title.shared"), Messages.getQuestionIcon(), mySelectedScope.getName(), new InputValidator() {

                    @Override
                    public boolean checkInput(String inputString) {
                        return inputString != null && inputString.length() > 0 && manager.getScope(inputString) == null;
                    }

                    @Override
                    public boolean canClose(String inputString) {
                        return checkInput(inputString);
                    }
                });
                if (newName != null) {
                    final PackageSet packageSet = mySelectedScope.getValue();
                    scope = new NamedScope(newName, packageSet != null ? packageSet.createCopy() : null);
                    mySelectedScope = scope;
                    manager.addScope(mySelectedScope);
                }
            }
        }
    }
}
Also used : Project(com.intellij.openapi.project.Project) DependencyValidationManager(com.intellij.packageDependencies.DependencyValidationManager) NamedScope(com.intellij.psi.search.scope.packageSet.NamedScope) InputValidator(com.intellij.openapi.ui.InputValidator) PackageSet(com.intellij.psi.search.scope.packageSet.PackageSet)

Example 22 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 23 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 24 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 25 with NamedScope

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

the class VcsUpdateInfoScopeFilterConfigurable method reset.

@Override
public void reset() {
    myComboBox.removeAllItems();
    boolean selection = false;
    for (NamedScopesHolder holder : myNamedScopeHolders) {
        for (NamedScope scope : holder.getEditableScopes()) {
            myComboBox.addItem(scope.getName());
            if (!selection && scope.getName().equals(myVcsConfiguration.UPDATE_FILTER_SCOPE_NAME)) {
                selection = true;
            }
        }
    }
    if (selection) {
        myComboBox.setSelectedItem(myVcsConfiguration.UPDATE_FILTER_SCOPE_NAME);
    }
    myCheckbox.setSelected(selection);
}
Also used : NamedScope(com.intellij.psi.search.scope.packageSet.NamedScope) NamedScopesHolder(com.intellij.psi.search.scope.packageSet.NamedScopesHolder)

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