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();
}
}
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;
}
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;
}
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;
}
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);
}
Aggregations