mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
dependencies reduced
This commit is contained in:
+6
-6
@@ -19,9 +19,7 @@
|
||||
*/
|
||||
package com.intellij.codeInsight.daemon.impl.analysis;
|
||||
|
||||
import com.intellij.application.options.colors.ColorAndFontOptions;
|
||||
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer;
|
||||
import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl;
|
||||
import com.intellij.application.options.colors.ScopeAttributesUtil;
|
||||
import com.intellij.codeInsight.daemon.impl.HighlightInfo;
|
||||
import com.intellij.codeInsight.daemon.impl.HighlightInfoType;
|
||||
import com.intellij.lang.ASTNode;
|
||||
@@ -31,6 +29,8 @@ import com.intellij.openapi.editor.colors.TextAttributesScheme;
|
||||
import com.intellij.openapi.editor.markup.TextAttributes;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.packageDependencies.DependencyValidationManager;
|
||||
import com.intellij.packageDependencies.DependencyValidationManagerImpl;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.source.tree.ElementType;
|
||||
import com.intellij.psi.impl.source.tree.TreeUtil;
|
||||
@@ -231,14 +231,14 @@ public class HighlightNamesUtil {
|
||||
PsiFile file = element.getContainingFile();
|
||||
if (file == null) return null;
|
||||
TextAttributes result = null;
|
||||
final DaemonCodeAnalyzerImpl daemonCodeAnalyzer = (DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(file.getProject());
|
||||
List<Pair<NamedScope,NamedScopesHolder>> scopes = daemonCodeAnalyzer.getScopeBasedHighlightingCachedScopes();
|
||||
DependencyValidationManagerImpl validationManager = (DependencyValidationManagerImpl)DependencyValidationManager.getInstance(file.getProject());
|
||||
List<Pair<NamedScope,NamedScopesHolder>> scopes = validationManager.getScopeBasedHighlightingCachedScopes();
|
||||
for (Pair<NamedScope, NamedScopesHolder> scope : scopes) {
|
||||
NamedScope namedScope = scope.getFirst();
|
||||
NamedScopesHolder scopesHolder = scope.getSecond();
|
||||
PackageSet packageSet = namedScope.getValue();
|
||||
if (packageSet != null && packageSet.contains(file, scopesHolder)) {
|
||||
TextAttributesKey scopeKey = ColorAndFontOptions.getScopeTextAttributeKey(namedScope.getName());
|
||||
TextAttributesKey scopeKey = ScopeAttributesUtil.getScopeTextAttributeKey(namedScope.getName());
|
||||
TextAttributes attributes = colorsScheme.getAttributes(scopeKey);
|
||||
if (attributes == null || attributes.isEmpty()) {
|
||||
continue;
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
package com.intellij.codeInsight.daemon;
|
||||
|
||||
import com.intellij.analysis.PackagesScopesProvider;
|
||||
import com.intellij.application.options.colors.ColorAndFontOptions;
|
||||
import com.intellij.application.options.colors.ScopeAttributesUtil;
|
||||
import com.intellij.codeInsight.daemon.impl.HighlightInfo;
|
||||
import com.intellij.openapi.application.ex.PathManagerEx;
|
||||
import com.intellij.openapi.editor.colors.EditorColorsManager;
|
||||
@@ -188,11 +188,11 @@ public class AdvHighlightingTest extends DaemonAnalyzerTestCase {
|
||||
EditorColorsScheme scheme = (EditorColorsScheme)manager.getGlobalScheme().clone();
|
||||
manager.addColorsScheme(scheme);
|
||||
EditorColorsManager.getInstance().setGlobalScheme(scheme);
|
||||
TextAttributesKey xKey = ColorAndFontOptions.getScopeTextAttributeKey(xScope.getName());
|
||||
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 = ColorAndFontOptions.getScopeTextAttributeKey(utilScope.getName());
|
||||
TextAttributesKey utilKey = ScopeAttributesUtil.getScopeTextAttributeKey(utilScope.getName());
|
||||
TextAttributes utilAttributes = new TextAttributes(Color.gray, Color.magenta, Color.orange, EffectType.STRIKEOUT, Font.BOLD);
|
||||
scheme.setAttributes(utilKey, utilAttributes);
|
||||
|
||||
@@ -215,16 +215,16 @@ public class AdvHighlightingTest extends DaemonAnalyzerTestCase {
|
||||
EditorColorsScheme scheme = (EditorColorsScheme)manager.getGlobalScheme().clone();
|
||||
manager.addColorsScheme(scheme);
|
||||
EditorColorsManager.getInstance().setGlobalScheme(scheme);
|
||||
TextAttributesKey xKey = ColorAndFontOptions.getScopeTextAttributeKey(xScope.getName());
|
||||
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 = ColorAndFontOptions.getScopeTextAttributeKey(utilScope.getName());
|
||||
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 = ColorAndFontOptions.getScopeTextAttributeKey(projectScope.getName());
|
||||
TextAttributesKey projectKey = ScopeAttributesUtil.getScopeTextAttributeKey(projectScope.getName());
|
||||
TextAttributes projectAttributes = new TextAttributes(null, null, Color.blue, EffectType.BOXED, Font.ITALIC);
|
||||
scheme.setAttributes(projectKey, projectAttributes);
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.search.scope.packageSet.ComplementPackageSet;
|
||||
import com.intellij.psi.search.scope.packageSet.NamedScope;
|
||||
import com.intellij.psi.search.scope.packageSet.PackageSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class DependencyRule {
|
||||
@@ -34,7 +35,7 @@ public class DependencyRule {
|
||||
myDenyRule = isDenyRule;
|
||||
}
|
||||
|
||||
public boolean isForbiddenToUse(PsiFile from, PsiFile to) {
|
||||
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();
|
||||
@@ -46,7 +47,7 @@ public class DependencyRule {
|
||||
&& toSet.contains(to, holder);
|
||||
}
|
||||
|
||||
public boolean isApplicable(PsiFile file){
|
||||
public boolean isApplicable(@NotNull PsiFile file){
|
||||
if (myFromScope == null || myToScope == null) return false;
|
||||
final PackageSet fromSet = myFromScope.getValue();
|
||||
if (fromSet == null) return false;
|
||||
|
||||
+6
-4
@@ -41,24 +41,26 @@ public abstract class DependencyValidationManager extends NamedScopesHolder {
|
||||
public abstract boolean hasRules();
|
||||
|
||||
@Nullable
|
||||
public abstract DependencyRule getViolatorDependencyRule(PsiFile from, PsiFile to);
|
||||
public abstract DependencyRule getViolatorDependencyRule(@NotNull PsiFile from, @NotNull PsiFile to);
|
||||
|
||||
@NotNull
|
||||
public abstract DependencyRule[] getViolatorDependencyRules(PsiFile from, PsiFile to);
|
||||
public abstract DependencyRule[] getViolatorDependencyRules(@NotNull PsiFile from, @NotNull PsiFile to);
|
||||
|
||||
@NotNull
|
||||
public abstract DependencyRule[] getApplicableRules(PsiFile file);
|
||||
public abstract DependencyRule[] getApplicableRules(@NotNull PsiFile file);
|
||||
|
||||
@NotNull
|
||||
public abstract DependencyRule[] getAllRules();
|
||||
|
||||
public abstract void removeAllRules();
|
||||
|
||||
public abstract void addRule(DependencyRule rule);
|
||||
public abstract void addRule(@NotNull DependencyRule rule);
|
||||
|
||||
public abstract boolean skipImportStatements();
|
||||
|
||||
public abstract void setSkipImportStatements(boolean skip);
|
||||
|
||||
@NotNull
|
||||
public abstract Map<String,PackageSet> getUnnamedScopes();
|
||||
|
||||
public abstract void reloadRules();
|
||||
|
||||
+49
-6
@@ -18,6 +18,7 @@ package com.intellij.packageDependencies;
|
||||
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.ide.IdeBundle;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.components.*;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -25,6 +26,7 @@ import com.intellij.openapi.util.*;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.search.scope.packageSet.*;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.text.UniqueNameGenerator;
|
||||
import org.jdom.Attribute;
|
||||
import org.jdom.Element;
|
||||
@@ -46,6 +48,7 @@ public class DependencyValidationManagerImpl extends DependencyValidationManager
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.packageDependencies.DependencyValidationManagerImpl");
|
||||
|
||||
private final List<DependencyRule> myRules = new ArrayList<DependencyRule>();
|
||||
private final NamedScopeManager myNamedScopeManager;
|
||||
|
||||
public boolean SKIP_IMPORT_STATEMENTS = false;
|
||||
|
||||
@@ -59,8 +62,15 @@ public class DependencyValidationManagerImpl extends DependencyValidationManager
|
||||
|
||||
private final Map<String, PackageSet> myUnnamedScopes = new HashMap<String, PackageSet>();
|
||||
|
||||
public DependencyValidationManagerImpl(final Project project) {
|
||||
public DependencyValidationManagerImpl(final Project project, NamedScopeManager namedScopeManager) {
|
||||
super(project);
|
||||
myNamedScopeManager = namedScopeManager;
|
||||
namedScopeManager.addScopeListener(new ScopeListener() {
|
||||
@Override
|
||||
public void scopesChanged() {
|
||||
reloadScopes();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -95,7 +105,7 @@ public class DependencyValidationManagerImpl extends DependencyValidationManager
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public DependencyRule getViolatorDependencyRule(PsiFile from, PsiFile to) {
|
||||
public DependencyRule getViolatorDependencyRule(@NotNull PsiFile from, @NotNull PsiFile to) {
|
||||
for (DependencyRule dependencyRule : myRules) {
|
||||
if (dependencyRule.isForbiddenToUse(from, to)) return dependencyRule;
|
||||
}
|
||||
@@ -105,7 +115,7 @@ public class DependencyValidationManagerImpl extends DependencyValidationManager
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public DependencyRule[] getViolatorDependencyRules(PsiFile from, PsiFile to) {
|
||||
public DependencyRule[] getViolatorDependencyRules(@NotNull PsiFile from, @NotNull PsiFile to) {
|
||||
ArrayList<DependencyRule> result = new ArrayList<DependencyRule>();
|
||||
for (DependencyRule dependencyRule : myRules) {
|
||||
if (dependencyRule.isForbiddenToUse(from, to)) {
|
||||
@@ -117,7 +127,7 @@ public class DependencyValidationManagerImpl extends DependencyValidationManager
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public DependencyRule[] getApplicableRules(PsiFile file) {
|
||||
public DependencyRule[] getApplicableRules(@NotNull PsiFile file) {
|
||||
ArrayList<DependencyRule> result = new ArrayList<DependencyRule>();
|
||||
for (DependencyRule dependencyRule : myRules) {
|
||||
if (dependencyRule.isApplicable(file)) {
|
||||
@@ -137,11 +147,13 @@ public class DependencyValidationManagerImpl extends DependencyValidationManager
|
||||
SKIP_IMPORT_STATEMENTS = skip;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Map<String, PackageSet> getUnnamedScopes() {
|
||||
return myUnnamedScopes;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public DependencyRule[] getAllRules() {
|
||||
return myRules.toArray(new DependencyRule[myRules.size()]);
|
||||
@@ -153,7 +165,7 @@ public class DependencyValidationManagerImpl extends DependencyValidationManager
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRule(DependencyRule rule) {
|
||||
public void addRule(@NotNull DependencyRule rule) {
|
||||
appendUnnamedScope(rule.getFromScope());
|
||||
appendUnnamedScope(rule.getToScope());
|
||||
myRules.add(rule);
|
||||
@@ -193,7 +205,6 @@ public class DependencyValidationManagerImpl extends DependencyValidationManager
|
||||
catch (InvalidDataException e) {
|
||||
LOG.info(e);
|
||||
}
|
||||
super.loadState(element);
|
||||
|
||||
myUnnamedScopes.clear();
|
||||
final List unnamedScopes = element.getChildren(UNNAMED_SCOPE);
|
||||
@@ -209,6 +220,7 @@ public class DependencyValidationManagerImpl extends DependencyValidationManager
|
||||
}
|
||||
|
||||
readRules(element);
|
||||
super.loadState(element); // fire listeners after all reads
|
||||
}
|
||||
|
||||
private void readRules(Element element) {
|
||||
@@ -336,4 +348,35 @@ public class DependencyValidationManagerImpl extends DependencyValidationManager
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private final List<Pair<NamedScope, NamedScopesHolder>> myScopes = ContainerUtil.createLockFreeCopyOnWriteList();
|
||||
|
||||
private void reloadScopes() {
|
||||
ApplicationManager.getApplication().assertIsDispatchThread();
|
||||
List<Pair<NamedScope, NamedScopesHolder>> scopeList = new ArrayList<Pair<NamedScope, NamedScopesHolder>>();
|
||||
addScopesToList(scopeList, this);
|
||||
addScopesToList(scopeList, myNamedScopeManager);
|
||||
myScopes.clear();
|
||||
myScopes.addAll(scopeList);
|
||||
reloadRules();
|
||||
}
|
||||
|
||||
private static void addScopesToList(@NotNull final List<Pair<NamedScope, NamedScopesHolder>> scopeList,
|
||||
@NotNull final NamedScopesHolder holder) {
|
||||
NamedScope[] scopes = holder.getScopes();
|
||||
for (NamedScope scope : scopes) {
|
||||
scopeList.add(Pair.create(scope, holder));
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public List<Pair<NamedScope, NamedScopesHolder>> getScopeBasedHighlightingCachedScopes() {
|
||||
return myScopes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fireScopeListeners() {
|
||||
super.fireScopeListeners();
|
||||
reloadScopes();
|
||||
}
|
||||
}
|
||||
|
||||
+55
-49
@@ -19,7 +19,6 @@ package com.intellij.application.options.colors;
|
||||
import com.intellij.application.options.OptionsContainingConfigurable;
|
||||
import com.intellij.application.options.editor.EditorOptionsProvider;
|
||||
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer;
|
||||
import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl;
|
||||
import com.intellij.execution.impl.ConsoleViewUtil;
|
||||
import com.intellij.ide.ui.LafManager;
|
||||
import com.intellij.ide.ui.laf.darcula.DarculaInstaller;
|
||||
@@ -56,6 +55,8 @@ import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.vcs.FileStatus;
|
||||
import com.intellij.openapi.vcs.FileStatusFactory;
|
||||
import com.intellij.openapi.vcs.FileStatusManager;
|
||||
import com.intellij.packageDependencies.DependencyValidationManager;
|
||||
import com.intellij.packageDependencies.DependencyValidationManagerImpl;
|
||||
import com.intellij.psi.codeStyle.DisplayPriority;
|
||||
import com.intellij.psi.codeStyle.DisplayPrioritySortable;
|
||||
import com.intellij.psi.search.scope.packageSet.NamedScope;
|
||||
@@ -151,15 +152,16 @@ public class ColorAndFontOptions extends SearchableConfigurable.Parent.Abstract
|
||||
return mySelectedScheme.getDescriptors();
|
||||
}
|
||||
|
||||
public static boolean isReadOnly(final EditorColorsScheme scheme) {
|
||||
public static boolean isReadOnly(@NotNull final EditorColorsScheme scheme) {
|
||||
return ((MyColorScheme)scheme).isReadOnly();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String[] getSchemeNames() {
|
||||
ArrayList<MyColorScheme> schemes = new ArrayList<MyColorScheme>(mySchemes.values());
|
||||
List<MyColorScheme> schemes = new ArrayList<MyColorScheme>(mySchemes.values());
|
||||
Collections.sort(schemes, new Comparator<MyColorScheme>() {
|
||||
@Override
|
||||
public int compare(MyColorScheme o1, MyColorScheme o2) {
|
||||
public int compare(@NotNull MyColorScheme o1, @NotNull MyColorScheme o2) {
|
||||
if (isReadOnly(o1) && !isReadOnly(o2)) return -1;
|
||||
if (!isReadOnly(o1) && isReadOnly(o2)) return 1;
|
||||
|
||||
@@ -167,7 +169,7 @@ public class ColorAndFontOptions extends SearchableConfigurable.Parent.Abstract
|
||||
}
|
||||
});
|
||||
|
||||
ArrayList<String> names = new ArrayList<String>(schemes.size());
|
||||
List<String> names = new ArrayList<String>(schemes.size());
|
||||
for (MyColorScheme scheme : schemes) {
|
||||
names.add(scheme.getName());
|
||||
}
|
||||
@@ -175,6 +177,7 @@ public class ColorAndFontOptions extends SearchableConfigurable.Parent.Abstract
|
||||
return ArrayUtil.toStringArray(names);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Collection<EditorColorsScheme> getSchemes() {
|
||||
return new ArrayList<EditorColorsScheme>(mySchemes.values());
|
||||
}
|
||||
@@ -198,7 +201,7 @@ public class ColorAndFontOptions extends SearchableConfigurable.Parent.Abstract
|
||||
resetSchemesCombo(null);
|
||||
}
|
||||
|
||||
public void addImportedScheme(final EditorColorsScheme imported) {
|
||||
public void addImportedScheme(@NotNull final EditorColorsScheme imported) {
|
||||
MyColorScheme newScheme = new MyColorScheme(imported);
|
||||
initScheme(newScheme);
|
||||
|
||||
@@ -312,6 +315,7 @@ public class ColorAndFontOptions extends SearchableConfigurable.Parent.Abstract
|
||||
return true;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Configurable[] buildConfigurables() {
|
||||
myDisposeCompleted = false;
|
||||
@@ -329,6 +333,7 @@ public class ColorAndFontOptions extends SearchableConfigurable.Parent.Abstract
|
||||
return result.toArray(new Configurable[result.size()]);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Set<NewColorAndFontPanel> getPanels() {
|
||||
Set<NewColorAndFontPanel> result = new HashSet<NewColorAndFontPanel>();
|
||||
for (InnerSearchableConfigurable configurable : mySubPanelFactories.values()) {
|
||||
@@ -341,7 +346,7 @@ public class ColorAndFontOptions extends SearchableConfigurable.Parent.Abstract
|
||||
}
|
||||
|
||||
protected List<ColorAndFontPanelFactory> createPanelFactories() {
|
||||
ArrayList<ColorAndFontPanelFactory> result = new ArrayList<ColorAndFontPanelFactory>();
|
||||
List<ColorAndFontPanelFactory> result = new ArrayList<ColorAndFontPanelFactory>();
|
||||
result.add(new FontConfigurableFactory());
|
||||
|
||||
List<ColorAndFontPanelFactory> extensions = new ArrayList<ColorAndFontPanelFactory>();
|
||||
@@ -443,6 +448,7 @@ public class ColorAndFontOptions extends SearchableConfigurable.Parent.Abstract
|
||||
return "Console Font";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public DisplayPriority getPriority() {
|
||||
return DisplayPriority.COMMON_SETTINGS;
|
||||
@@ -499,8 +505,8 @@ public class ColorAndFontOptions extends SearchableConfigurable.Parent.Abstract
|
||||
assert mySelectedScheme != null : EditorColorsManager.getInstance().getGlobalScheme().getName() + "; myschemes=" + mySchemes;
|
||||
}
|
||||
|
||||
private static void initScheme(MyColorScheme scheme) {
|
||||
ArrayList<EditorSchemeAttributeDescriptor> descriptions = new ArrayList<EditorSchemeAttributeDescriptor>();
|
||||
private static void initScheme(@NotNull MyColorScheme scheme) {
|
||||
List<EditorSchemeAttributeDescriptor> descriptions = new ArrayList<EditorSchemeAttributeDescriptor>();
|
||||
initPluggedDescriptions(descriptions, scheme);
|
||||
initDiffDescriptors(descriptions, scheme);
|
||||
initFileStatusDescriptors(descriptions, scheme);
|
||||
@@ -509,7 +515,7 @@ public class ColorAndFontOptions extends SearchableConfigurable.Parent.Abstract
|
||||
scheme.setDescriptors(descriptions.toArray(new EditorSchemeAttributeDescriptor[descriptions.size()]));
|
||||
}
|
||||
|
||||
private static void initPluggedDescriptions(ArrayList<EditorSchemeAttributeDescriptor> descriptions, MyColorScheme scheme) {
|
||||
private static void initPluggedDescriptions(@NotNull List<EditorSchemeAttributeDescriptor> descriptions, @NotNull MyColorScheme scheme) {
|
||||
ColorSettingsPage[] pages = ColorSettingsPages.getInstance().getRegisteredPages();
|
||||
for (ColorSettingsPage page : pages) {
|
||||
initDescriptions(page, descriptions, scheme);
|
||||
@@ -519,9 +525,9 @@ public class ColorAndFontOptions extends SearchableConfigurable.Parent.Abstract
|
||||
}
|
||||
}
|
||||
|
||||
private static void initDescriptions(ColorAndFontDescriptorsProvider provider,
|
||||
ArrayList<EditorSchemeAttributeDescriptor> descriptions,
|
||||
MyColorScheme scheme) {
|
||||
private static void initDescriptions(@NotNull ColorAndFontDescriptorsProvider provider,
|
||||
@NotNull List<EditorSchemeAttributeDescriptor> descriptions,
|
||||
@NotNull MyColorScheme scheme) {
|
||||
String group = provider.getDisplayName();
|
||||
List<AttributesDescriptor> attributeDescriptors = ColorSettingsUtil.getAllAttributeDescriptors(provider);
|
||||
for (AttributesDescriptor descriptor : attributeDescriptors) {
|
||||
@@ -536,11 +542,11 @@ public class ColorAndFontOptions extends SearchableConfigurable.Parent.Abstract
|
||||
}
|
||||
}
|
||||
|
||||
private static void initDiffDescriptors(ArrayList<EditorSchemeAttributeDescriptor> descriptions, MyColorScheme scheme) {
|
||||
private static void initDiffDescriptors(@NotNull List<EditorSchemeAttributeDescriptor> descriptions, @NotNull MyColorScheme scheme) {
|
||||
DiffOptionsPanel.addSchemeDescriptions(descriptions, scheme);
|
||||
}
|
||||
|
||||
private static void initFileStatusDescriptors(ArrayList<EditorSchemeAttributeDescriptor> descriptions, MyColorScheme scheme) {
|
||||
private static void initFileStatusDescriptors(@NotNull List<EditorSchemeAttributeDescriptor> descriptions, MyColorScheme scheme) {
|
||||
|
||||
FileStatus[] statuses = FileStatusFactory.getInstance().getAllFileStatuses();
|
||||
|
||||
@@ -554,22 +560,22 @@ public class ColorAndFontOptions extends SearchableConfigurable.Parent.Abstract
|
||||
|
||||
}
|
||||
}
|
||||
private static void initScopesDescriptors(ArrayList<EditorSchemeAttributeDescriptor> descriptions, MyColorScheme scheme) {
|
||||
private static void initScopesDescriptors(@NotNull List<EditorSchemeAttributeDescriptor> descriptions, @NotNull MyColorScheme scheme) {
|
||||
Set<Pair<NamedScope,NamedScopesHolder>> namedScopes = new THashSet<Pair<NamedScope,NamedScopesHolder>>(new TObjectHashingStrategy<Pair<NamedScope,NamedScopesHolder>>() {
|
||||
@Override
|
||||
public int computeHashCode(final Pair<NamedScope, NamedScopesHolder> object) {
|
||||
public int computeHashCode(@NotNull final Pair<NamedScope, NamedScopesHolder> object) {
|
||||
return object.getFirst().getName().hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Pair<NamedScope, NamedScopesHolder> o1, final Pair<NamedScope, NamedScopesHolder> o2) {
|
||||
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) {
|
||||
DaemonCodeAnalyzerImpl codeAnalyzer = (DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(project);
|
||||
List<Pair<NamedScope,NamedScopesHolder>> cachedScopes = codeAnalyzer.getScopeBasedHighlightingCachedScopes();
|
||||
DependencyValidationManagerImpl validationManager = (DependencyValidationManagerImpl)DependencyValidationManager.getInstance(project);
|
||||
List<Pair<NamedScope,NamedScopesHolder>> cachedScopes = validationManager.getScopeBasedHighlightingCachedScopes();
|
||||
namedScopes.addAll(cachedScopes);
|
||||
}
|
||||
|
||||
@@ -577,14 +583,14 @@ public class ColorAndFontOptions extends SearchableConfigurable.Parent.Abstract
|
||||
|
||||
Collections.sort(list, new Comparator<Pair<NamedScope,NamedScopesHolder>>() {
|
||||
@Override
|
||||
public int compare(final Pair<NamedScope,NamedScopesHolder> o1, final Pair<NamedScope,NamedScopesHolder> o2) {
|
||||
public int compare(@NotNull final Pair<NamedScope,NamedScopesHolder> o1, @NotNull final Pair<NamedScope,NamedScopesHolder> o2) {
|
||||
return o1.getFirst().getName().compareToIgnoreCase(o2.getFirst().getName());
|
||||
}
|
||||
});
|
||||
for (Pair<NamedScope,NamedScopesHolder> pair : list) {
|
||||
NamedScope namedScope = pair.getFirst();
|
||||
String name = namedScope.getName();
|
||||
TextAttributesKey textAttributesKey = getScopeTextAttributeKey(name);
|
||||
TextAttributesKey textAttributesKey = ScopeAttributesUtil.getScopeTextAttributeKey(name);
|
||||
if (scheme.getAttributes(textAttributesKey) == null) {
|
||||
scheme.setAttributes(textAttributesKey, new TextAttributes());
|
||||
}
|
||||
@@ -600,16 +606,12 @@ public class ColorAndFontOptions extends SearchableConfigurable.Parent.Abstract
|
||||
}
|
||||
}
|
||||
|
||||
public static TextAttributesKey getScopeTextAttributeKey(final String scope) {
|
||||
return TextAttributesKey.find("SCOPE_KEY_" + scope);
|
||||
}
|
||||
|
||||
private static void addEditorSettingDescription(ArrayList<EditorSchemeAttributeDescriptor> array,
|
||||
String name,
|
||||
String group,
|
||||
ColorKey backgroundKey,
|
||||
ColorKey foregroundKey,
|
||||
EditorColorsScheme scheme) {
|
||||
private static void addEditorSettingDescription(@NotNull List<EditorSchemeAttributeDescriptor> array,
|
||||
String name,
|
||||
String group,
|
||||
@Nullable ColorKey backgroundKey,
|
||||
@Nullable ColorKey foregroundKey,
|
||||
EditorColorsScheme scheme) {
|
||||
String type = null;
|
||||
if (foregroundKey != null) {
|
||||
type = foregroundKey.getExternalName();
|
||||
@@ -623,8 +625,11 @@ public class ColorAndFontOptions extends SearchableConfigurable.Parent.Abstract
|
||||
array.add(descr);
|
||||
}
|
||||
|
||||
private static void addSchemedDescription(ArrayList<EditorSchemeAttributeDescriptor> array, String name, String group, TextAttributesKey key,
|
||||
MyColorScheme scheme,
|
||||
private static void addSchemedDescription(@NotNull List<EditorSchemeAttributeDescriptor> array,
|
||||
String name,
|
||||
String group,
|
||||
@NotNull TextAttributesKey key,
|
||||
@NotNull MyColorScheme scheme,
|
||||
Icon icon,
|
||||
String toolTip) {
|
||||
ColorAndFontDescription descr = new SchemeTextAttributesDescription(name, group, key, scheme, icon, toolTip);
|
||||
@@ -757,12 +762,12 @@ public class ColorAndFontOptions extends SearchableConfigurable.Parent.Abstract
|
||||
|
||||
|
||||
private static class SchemeTextAttributesDescription extends TextAttributesDescription {
|
||||
private final TextAttributes myAttributesToApply;
|
||||
private final TextAttributesKey key;
|
||||
@NotNull private final TextAttributes myAttributesToApply;
|
||||
@NotNull private final TextAttributesKey key;
|
||||
private TextAttributes myFallbackAttributes;
|
||||
private Pair<ColorSettingsPage,AttributesDescriptor> myBaseAttributeDescriptor;
|
||||
|
||||
private SchemeTextAttributesDescription(String name, String group, TextAttributesKey key, MyColorScheme scheme, Icon icon,
|
||||
private SchemeTextAttributesDescription(String name, String group, @NotNull TextAttributesKey key, @NotNull MyColorScheme scheme, Icon icon,
|
||||
String toolTip) {
|
||||
super(name, group,
|
||||
getInitialAttributes(scheme, key).clone(),
|
||||
@@ -783,7 +788,7 @@ public class ColorAndFontOptions extends SearchableConfigurable.Parent.Abstract
|
||||
|
||||
|
||||
@NotNull
|
||||
private static TextAttributes getInitialAttributes(MyColorScheme scheme, TextAttributesKey key) {
|
||||
private static TextAttributes getInitialAttributes(@NotNull MyColorScheme scheme, @NotNull TextAttributesKey key) {
|
||||
TextAttributes attributes = scheme.getAttributes(key);
|
||||
TextAttributesKey fallbackKey = key.getFallbackAttributeKey();
|
||||
if (fallbackKey != null && !scheme.containsKey(key)) {
|
||||
@@ -798,9 +803,7 @@ public class ColorAndFontOptions extends SearchableConfigurable.Parent.Abstract
|
||||
@Override
|
||||
public void apply(EditorColorsScheme scheme) {
|
||||
if (scheme == null) scheme = getScheme();
|
||||
if (myAttributesToApply != null) {
|
||||
scheme.setAttributes(key, getTextAttributes());
|
||||
}
|
||||
scheme.setAttributes(key, getTextAttributes());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -900,6 +903,7 @@ public class ColorAndFontOptions extends SearchableConfigurable.Parent.Abstract
|
||||
public void setExternalEffectType(EffectType type) {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public EffectType getExternalEffectType() {
|
||||
return EffectType.LINE_UNDERSCORE;
|
||||
@@ -995,7 +999,7 @@ public class ColorAndFontOptions extends SearchableConfigurable.Parent.Abstract
|
||||
private String myName;
|
||||
private boolean myIsNew = false;
|
||||
|
||||
private MyColorScheme(EditorColorsScheme parentScheme) {
|
||||
private MyColorScheme(@NotNull EditorColorsScheme parentScheme) {
|
||||
super(parentScheme, DefaultColorSchemesManager.getInstance());
|
||||
parentScheme.getFontPreferences().copyTo(getFontPreferences());
|
||||
setLineSpacing(parentScheme.getLineSpacing());
|
||||
@@ -1052,21 +1056,19 @@ public class ColorAndFontOptions extends SearchableConfigurable.Parent.Abstract
|
||||
private boolean isFontModified() {
|
||||
if (!getFontPreferences().equals(myParentScheme.getFontPreferences())) return true;
|
||||
if (getLineSpacing() != myParentScheme.getLineSpacing()) return true;
|
||||
if (getQuickDocFontSize() != myParentScheme.getQuickDocFontSize()) return true;
|
||||
return false;
|
||||
return getQuickDocFontSize() != myParentScheme.getQuickDocFontSize();
|
||||
}
|
||||
|
||||
private boolean isConsoleFontModified() {
|
||||
if (!getConsoleFontPreferences().equals(myParentScheme.getConsoleFontPreferences())) return true;
|
||||
if (getConsoleLineSpacing() != myParentScheme.getConsoleLineSpacing()) return true;
|
||||
return false;
|
||||
return getConsoleLineSpacing() != myParentScheme.getConsoleLineSpacing();
|
||||
}
|
||||
|
||||
public void apply() {
|
||||
apply(myParentScheme);
|
||||
}
|
||||
|
||||
public void apply(EditorColorsScheme scheme) {
|
||||
public void apply(@NotNull EditorColorsScheme scheme) {
|
||||
scheme.setFontPreferences(getFontPreferences());
|
||||
scheme.setLineSpacing(myLineSpacing);
|
||||
scheme.setQuickDocFontSize(getQuickDocFontSize());
|
||||
@@ -1095,6 +1097,7 @@ public class ColorAndFontOptions extends SearchableConfigurable.Parent.Abstract
|
||||
return myIsNew;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String toString() {
|
||||
return "temporary scheme for " + myName;
|
||||
@@ -1114,7 +1117,7 @@ public class ColorAndFontOptions extends SearchableConfigurable.Parent.Abstract
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public InnerSearchableConfigurable findSubConfigurable(final Class pageClass) {
|
||||
public InnerSearchableConfigurable findSubConfigurable(@NotNull final Class pageClass) {
|
||||
if (mySubPanelFactories == null) {
|
||||
buildConfigurables();
|
||||
}
|
||||
@@ -1142,12 +1145,13 @@ public class ColorAndFontOptions extends SearchableConfigurable.Parent.Abstract
|
||||
private class InnerSearchableConfigurable implements SearchableConfigurable, OptionsContainingConfigurable, NoScroll {
|
||||
private NewColorAndFontPanel mySubPanel;
|
||||
private boolean mySubInitInvoked = false;
|
||||
private final ColorAndFontPanelFactory myFactory;
|
||||
@NotNull private final ColorAndFontPanelFactory myFactory;
|
||||
|
||||
private InnerSearchableConfigurable(@NotNull ColorAndFontPanelFactory factory) {
|
||||
myFactory = factory;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
@Nls
|
||||
public String getDisplayName() {
|
||||
@@ -1255,11 +1259,13 @@ public class ColorAndFontOptions extends SearchableConfigurable.Parent.Abstract
|
||||
return createPanel().showOption(option);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<String> processListOptions() {
|
||||
return createPanel().processListOptions();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@NonNls
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.application.options.colors;
|
||||
|
||||
import com.intellij.openapi.editor.colors.TextAttributesKey;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ScopeAttributesUtil {
|
||||
@NotNull
|
||||
public static TextAttributesKey getScopeTextAttributeKey(@NotNull String scope) {
|
||||
return TextAttributesKey.find("SCOPE_KEY_" + scope);
|
||||
}
|
||||
}
|
||||
-36
@@ -57,15 +57,12 @@ import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiFileSystemItem;
|
||||
import com.intellij.psi.impl.PsiDocumentManagerImpl;
|
||||
import com.intellij.psi.search.scope.packageSet.NamedScope;
|
||||
import com.intellij.psi.search.scope.packageSet.NamedScopeManager;
|
||||
import com.intellij.psi.search.scope.packageSet.NamedScopesHolder;
|
||||
import com.intellij.psi.util.PsiUtilCore;
|
||||
import com.intellij.util.Alarm;
|
||||
import com.intellij.util.CommonProcessors;
|
||||
import com.intellij.util.Processor;
|
||||
import com.intellij.util.SmartList;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import gnu.trove.THashMap;
|
||||
import gnu.trove.THashSet;
|
||||
@@ -146,14 +143,6 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx
|
||||
assert !myInitialized : "Double Initializing";
|
||||
Disposer.register(myProject, new StatusBarUpdater(myProject));
|
||||
|
||||
ApplicationManager.getApplication().invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
reloadScopes(dependencyValidationManager, namedScopeManager);
|
||||
}
|
||||
}, project.getDisposed());
|
||||
|
||||
|
||||
myInitialized = true;
|
||||
myDisposed = false;
|
||||
myFileStatusMap.markAllFilesDirty();
|
||||
@@ -323,31 +312,6 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx
|
||||
TrafficLightRenderer.setOrRefreshErrorStripeRenderer(markup, myProject, document, psiFile);
|
||||
}
|
||||
|
||||
private final List<Pair<NamedScope, NamedScopesHolder>> myScopes = ContainerUtil.createLockFreeCopyOnWriteList();
|
||||
|
||||
void reloadScopes(@NotNull DependencyValidationManager dependencyValidationManager, @NotNull NamedScopeManager namedScopeManager) {
|
||||
ApplicationManager.getApplication().assertIsDispatchThread();
|
||||
List<Pair<NamedScope, NamedScopesHolder>> scopeList = new ArrayList<Pair<NamedScope, NamedScopesHolder>>();
|
||||
addScopesToList(scopeList, namedScopeManager);
|
||||
addScopesToList(scopeList, dependencyValidationManager);
|
||||
myScopes.clear();
|
||||
myScopes.addAll(scopeList);
|
||||
dependencyValidationManager.reloadRules();
|
||||
}
|
||||
|
||||
private static void addScopesToList(@NotNull final List<Pair<NamedScope, NamedScopesHolder>> scopeList,
|
||||
@NotNull final NamedScopesHolder holder) {
|
||||
NamedScope[] scopes = holder.getScopes();
|
||||
for (NamedScope scope : scopes) {
|
||||
scopeList.add(Pair.create(scope, holder));
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public List<Pair<NamedScope, NamedScopesHolder>> getScopeBasedHighlightingCachedScopes() {
|
||||
return myScopes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void settingsChanged() {
|
||||
DaemonCodeAnalyzerSettings settings = DaemonCodeAnalyzerSettings.getInstance();
|
||||
|
||||
@@ -71,11 +71,9 @@ import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.PsiDocumentManagerImpl;
|
||||
import com.intellij.psi.impl.PsiManagerEx;
|
||||
import com.intellij.psi.search.scope.packageSet.NamedScopeManager;
|
||||
import com.intellij.psi.search.scope.packageSet.NamedScopesHolder;
|
||||
import com.intellij.util.messages.MessageBus;
|
||||
import com.intellij.util.messages.MessageBusConnection;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import gnu.trove.THashSet;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -85,7 +83,6 @@ import java.beans.PropertyChangeListener;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
/**
|
||||
@@ -328,21 +325,6 @@ public class DaemonListeners implements Disposable {
|
||||
|
||||
((EditorEventMulticasterEx)eventMulticaster).addErrorStripeListener(new ErrorStripeHandler(myProject), this);
|
||||
|
||||
Set<NamedScopesHolder> holders = new THashSet<NamedScopesHolder>(Arrays.asList(NamedScopesHolder.getAllNamedScopeHolders(project)));
|
||||
// to ensure initialization dependency
|
||||
holders.add(namedScopeManager);
|
||||
holders.add(dependencyValidationManager);
|
||||
|
||||
NamedScopesHolder.ScopeListener scopeListener = new NamedScopesHolder.ScopeListener() {
|
||||
@Override
|
||||
public void scopesChanged() {
|
||||
myDaemonCodeAnalyzer.reloadScopes(dependencyValidationManager, namedScopeManager);
|
||||
}
|
||||
};
|
||||
for (NamedScopesHolder holder : holders) {
|
||||
holder.addScopeListener(scopeListener);
|
||||
}
|
||||
|
||||
ModalityStateListener modalityStateListener = new ModalityStateListener() {
|
||||
@Override
|
||||
public void beforeModalityStateChanged(boolean entering) {
|
||||
|
||||
Reference in New Issue
Block a user