Search in sources :

Example 6 with NamedScopesHolder

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

the class AdvHighlightingTest method testSharedScopeBased.

public void testSharedScopeBased() throws Exception {
    NamedScope xScope = new NamedScope("xxx", new PatternPackageSet("x..*", PatternPackageSet.SCOPE_ANY, null));
    NamedScope utilScope = new NamedScope("util", new PatternPackageSet("java.util.*", PatternPackageSet.SCOPE_LIBRARY, null));
    NamedScopesHolder scopeManager = DependencyValidationManager.getInstance(getProject());
    scopeManager.addScope(xScope);
    scopeManager.addScope(utilScope);
    EditorColorsManager manager = EditorColorsManager.getInstance();
    EditorColorsScheme scheme = (EditorColorsScheme) manager.getGlobalScheme().clone();
    manager.addColorsScheme(scheme);
    EditorColorsManager.getInstance().setGlobalScheme(scheme);
    TextAttributesKey xKey = ScopeAttributesUtil.getScopeTextAttributeKey(xScope.getName());
    TextAttributes xAttributes = new TextAttributes(Color.cyan, Color.darkGray, Color.blue, null, Font.ITALIC);
    scheme.setAttributes(xKey, xAttributes);
    TextAttributesKey utilKey = ScopeAttributesUtil.getScopeTextAttributeKey(utilScope.getName());
    TextAttributes utilAttributes = new TextAttributes(Color.gray, Color.magenta, Color.orange, EffectType.STRIKEOUT, Font.BOLD);
    scheme.setAttributes(utilKey, utilAttributes);
    NamedScope projectScope = PackagesScopesProvider.getInstance(myProject).getProjectProductionScope();
    TextAttributesKey projectKey = ScopeAttributesUtil.getScopeTextAttributeKey(projectScope.getName());
    TextAttributes projectAttributes = new TextAttributes(null, null, Color.blue, EffectType.BOXED, Font.ITALIC);
    scheme.setAttributes(projectKey, projectAttributes);
    try {
        testFile(BASE_PATH + "/scopeBased/x/Shared.java").projectRoot(BASE_PATH + "/scopeBased").checkSymbolNames().test();
    } finally {
        scopeManager.removeAllSets();
    }
}
Also used : NamedScope(com.intellij.psi.search.scope.packageSet.NamedScope) PatternPackageSet(com.intellij.psi.search.scope.packageSet.PatternPackageSet) NamedScopesHolder(com.intellij.psi.search.scope.packageSet.NamedScopesHolder) TextAttributes(com.intellij.openapi.editor.markup.TextAttributes) EditorColorsScheme(com.intellij.openapi.editor.colors.EditorColorsScheme) EditorColorsManager(com.intellij.openapi.editor.colors.EditorColorsManager) TextAttributesKey(com.intellij.openapi.editor.colors.TextAttributesKey)

Example 7 with NamedScopesHolder

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

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

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

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