Search in sources :

Example 1 with PackageSet

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

the class PackageSetChooserCombo method createModel.

protected NamedScope[] createModel() {
    final Collection<NamedScope> model = new ArrayList<>();
    final DependencyValidationManager manager = DependencyValidationManager.getInstance(myProject);
    model.addAll(Arrays.asList(manager.getScopes()));
    for (PackageSet unnamedScope : manager.getUnnamedScopes().values()) {
        model.add(new NamedScope.UnnamedScope(unnamedScope));
    }
    model.remove(DefaultScopesProvider.getInstance(myProject).getProblemsScope());
    return model.toArray(new NamedScope[model.size()]);
}
Also used : DependencyValidationManager(com.intellij.packageDependencies.DependencyValidationManager) NamedScope(com.intellij.psi.search.scope.packageSet.NamedScope) ArrayList(java.util.ArrayList) PackageSet(com.intellij.psi.search.scope.packageSet.PackageSet)

Example 2 with PackageSet

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

the class ScopeConfigurable method setDisplayName.

@Override
public void setDisplayName(final String name) {
    if (Comparing.strEqual(myScope.getName(), name)) {
        return;
    }
    final PackageSet packageSet = myScope.getValue();
    myScope = new NamedScope(name, packageSet != null ? packageSet.createCopy() : null);
}
Also used : NamedScope(com.intellij.psi.search.scope.packageSet.NamedScope) PackageSet(com.intellij.psi.search.scope.packageSet.PackageSet)

Example 3 with PackageSet

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

the class ScopeConfigurable method reset.

@Override
public void reset() {
    mySharedCheckbox.setSelected(myShareScope);
    myPanel.reset(myScope.getValue(), null);
    final PackageSet packageSet = myScope.getValue();
    myPackageSet = packageSet != null ? packageSet.getText() : null;
}
Also used : PackageSet(com.intellij.psi.search.scope.packageSet.PackageSet)

Example 4 with PackageSet

use of com.intellij.psi.search.scope.packageSet.PackageSet 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 5 with PackageSet

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

Aggregations

PackageSet (com.intellij.psi.search.scope.packageSet.PackageSet)13 NamedScope (com.intellij.psi.search.scope.packageSet.NamedScope)9 NamedScopesHolder (com.intellij.psi.search.scope.packageSet.NamedScopesHolder)4 DependencyValidationManager (com.intellij.packageDependencies.DependencyValidationManager)3 TextAttributes (com.intellij.openapi.editor.markup.TextAttributes)2 Project (com.intellij.openapi.project.Project)2 Pair (com.intellij.openapi.util.Pair)2 DependencyValidationManagerImpl (com.intellij.packageDependencies.DependencyValidationManagerImpl)2 ComplementPackageSet (com.intellij.psi.search.scope.packageSet.ComplementPackageSet)2 ArrayList (java.util.ArrayList)2 TextAttributesKey (com.intellij.openapi.editor.colors.TextAttributesKey)1 ConfigurationException (com.intellij.openapi.options.ConfigurationException)1 InputValidator (com.intellij.openapi.ui.InputValidator)1 DependencyRule (com.intellij.packageDependencies.DependencyRule)1 PsiFile (com.intellij.psi.PsiFile)1 PsiFileSystemItem (com.intellij.psi.PsiFileSystemItem)1 PackageSetBase (com.intellij.psi.search.scope.packageSet.PackageSetBase)1 THashSet (gnu.trove.THashSet)1 HashMap (java.util.HashMap)1 Nullable (org.jetbrains.annotations.Nullable)1