Search in sources :

Example 6 with PackageSet

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

the class FindManagerTest method testNoFilesFromAdditionalIndexedRootsWithCustomExclusionScope.

public void testNoFilesFromAdditionalIndexedRootsWithCustomExclusionScope() throws ParsingException {
    FindModel findModel = FindManagerTestUtils.configureFindModel("Object.prototype.__defineGetter__");
    PackageSet compile = PackageSetFactory.getInstance().compile("!src[subdir]:*..*");
    findModel.setCustomScope(GlobalSearchScopesCore.filterScope(myProject, new NamedScope.UnnamedScope(compile)));
    findModel.setCustomScope(true);
    assertSize(0, findUsages(findModel));
}
Also used : PackageSet(com.intellij.psi.search.scope.packageSet.PackageSet)

Example 7 with PackageSet

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

the class HighlightNamesUtil method getScopeAttributes.

private static TextAttributes getScopeAttributes(@NotNull PsiElement element, @NotNull TextAttributesScheme colorsScheme) {
    PsiFile file = element.getContainingFile();
    if (file == null)
        return null;
    TextAttributes result = null;
    DependencyValidationManagerImpl validationManager = (DependencyValidationManagerImpl) DependencyValidationManager.getInstance(file.getProject());
    List<Pair<NamedScope, NamedScopesHolder>> scopes = validationManager.getScopeBasedHighlightingCachedScopes();
    for (Pair<NamedScope, NamedScopesHolder> scope : scopes) {
        final NamedScope namedScope = scope.getFirst();
        final TextAttributesKey scopeKey = ScopeAttributesUtil.getScopeTextAttributeKey(namedScope.getName());
        final TextAttributes attributes = colorsScheme.getAttributes(scopeKey);
        if (attributes == null || attributes.isEmpty()) {
            continue;
        }
        final PackageSet packageSet = namedScope.getValue();
        if (packageSet != null && packageSet.contains(file, scope.getSecond())) {
            result = TextAttributes.merge(attributes, result);
        }
    }
    return result;
}
Also used : NamedScope(com.intellij.psi.search.scope.packageSet.NamedScope) NamedScopesHolder(com.intellij.psi.search.scope.packageSet.NamedScopesHolder) TextAttributes(com.intellij.openapi.editor.markup.TextAttributes) TextAttributesKey(com.intellij.openapi.editor.colors.TextAttributesKey) PackageSet(com.intellij.psi.search.scope.packageSet.PackageSet) DependencyValidationManagerImpl(com.intellij.packageDependencies.DependencyValidationManagerImpl) Pair(com.intellij.openapi.util.Pair)

Example 8 with PackageSet

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

the class DependencyRule method isForbiddenToUse.

public boolean isForbiddenToUse(@NotNull PsiFile from, @NotNull PsiFile to) {
    if (myFromScope == null || myToScope == null)
        return false;
    final PackageSet fromSet = myFromScope.getValue();
    final PackageSet toSet = myToScope.getValue();
    if (fromSet == null || toSet == null)
        return false;
    DependencyValidationManager holder = DependencyValidationManager.getInstance(from.getProject());
    return (myDenyRule ? fromSet.contains(from, holder) : new ComplementPackageSet(fromSet).contains(from, holder)) && toSet.contains(to, holder);
}
Also used : ComplementPackageSet(com.intellij.psi.search.scope.packageSet.ComplementPackageSet) PackageSet(com.intellij.psi.search.scope.packageSet.PackageSet) ComplementPackageSet(com.intellij.psi.search.scope.packageSet.ComplementPackageSet)

Example 9 with PackageSet

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

the class DependencyRule method isApplicable.

public boolean isApplicable(@NotNull PsiFile file) {
    if (myFromScope == null || myToScope == null)
        return false;
    final PackageSet fromSet = myFromScope.getValue();
    if (fromSet == null)
        return false;
    DependencyValidationManager holder = DependencyValidationManager.getInstance(file.getProject());
    return myDenyRule ? fromSet.contains(file, holder) : new ComplementPackageSet(fromSet).contains(file, holder);
}
Also used : ComplementPackageSet(com.intellij.psi.search.scope.packageSet.ComplementPackageSet) PackageSet(com.intellij.psi.search.scope.packageSet.PackageSet) ComplementPackageSet(com.intellij.psi.search.scope.packageSet.ComplementPackageSet)

Example 10 with PackageSet

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

the class ScopeConfigurable method apply.

@Override
public void apply() throws ConfigurationException {
    try {
        myPanel.apply();
        final PackageSet packageSet = myPanel.getCurrentScope();
        myScope = new NamedScope(myScope.getName(), packageSet);
        myPackageSet = packageSet != null ? packageSet.getText() : null;
        myShareScope = mySharedCheckbox.isSelected();
    } catch (ConfigurationException e) {
    //was canceled - didn't change anything
    }
}
Also used : NamedScope(com.intellij.psi.search.scope.packageSet.NamedScope) ConfigurationException(com.intellij.openapi.options.ConfigurationException) 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