use of com.intellij.packageDependencies.DependencyValidationManagerImpl 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);
}
}
use of com.intellij.packageDependencies.DependencyValidationManagerImpl 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.packageDependencies.DependencyValidationManagerImpl in project ActiveTabHighlighterPlugin by tobszarny.
the class MyColorScheme 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());
descriptions.add(new SchemeTextAttributesDescription(name, ColorAndFontOptions.SCOPES_GROUP, textAttributesKey, scheme, holder.getIcon(), toolTip));
}
}
Aggregations