Search in sources :

Example 1 with NamedScopeManager

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

the class AdvHighlightingTest method testScopeBased.

public void testScopeBased() throws Exception {
    NamedScope xScope = new NamedScope("xxx", new PatternPackageSet("x..*", PatternPackageSet.SCOPE_SOURCE, null));
    NamedScope utilScope = new NamedScope("util", new PatternPackageSet("java.util.*", PatternPackageSet.SCOPE_LIBRARY, null));
    NamedScopeManager scopeManager = NamedScopeManager.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, EffectType.BOXED, 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);
    try {
        testFile(BASE_PATH + "/scopeBased/x/X.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) 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) NamedScopeManager(com.intellij.psi.search.scope.packageSet.NamedScopeManager)

Aggregations

EditorColorsManager (com.intellij.openapi.editor.colors.EditorColorsManager)1 EditorColorsScheme (com.intellij.openapi.editor.colors.EditorColorsScheme)1 TextAttributesKey (com.intellij.openapi.editor.colors.TextAttributesKey)1 TextAttributes (com.intellij.openapi.editor.markup.TextAttributes)1 NamedScope (com.intellij.psi.search.scope.packageSet.NamedScope)1 NamedScopeManager (com.intellij.psi.search.scope.packageSet.NamedScopeManager)1 PatternPackageSet (com.intellij.psi.search.scope.packageSet.PatternPackageSet)1