use of com.intellij.psi.search.scope.packageSet.NamedScope in project intellij-community by JetBrains.
the class InspectionProfileImpl method convert.
public void convert(@NotNull Element element, @NotNull Project project) {
final Element scopes = element.getChild("scopes");
if (scopes == null) {
return;
}
initInspectionTools(project);
for (Element scopeElement : scopes.getChildren(SCOPE)) {
final String profile = scopeElement.getAttributeValue(PROFILE);
InspectionProfileImpl inspectionProfile = profile == null ? null : getProfileManager().getProfile(profile);
NamedScope scope = inspectionProfile == null ? null : getProfileManager().getScopesManager().getScope(scopeElement.getAttributeValue(NAME));
if (scope == null) {
continue;
}
for (InspectionToolWrapper toolWrapper : inspectionProfile.getInspectionTools(null)) {
final HighlightDisplayKey key = HighlightDisplayKey.find(toolWrapper.getShortName());
try {
InspectionToolWrapper toolWrapperCopy = copyToolSettings(toolWrapper);
HighlightDisplayLevel errorLevel = inspectionProfile.getErrorLevel(key, null, project);
getTools(toolWrapper.getShortName(), project).addTool(scope, toolWrapperCopy, inspectionProfile.isToolEnabled(key), errorLevel);
} catch (Exception e) {
LOG.error(e);
}
}
}
reduceConvertedScopes();
}
use of com.intellij.psi.search.scope.packageSet.NamedScope 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.NamedScope 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();
}
}
use of com.intellij.psi.search.scope.packageSet.NamedScope in project intellij-community by JetBrains.
the class SuppressForTestsScopeFix method addRemoveTestsScope.
private void addRemoveTestsScope(Project project, boolean add) {
final InspectionProfileImpl profile = InspectionProjectProfileManager.getInstance(project).getCurrentProfile();
final String shortName = myInspection.getShortName();
final InspectionToolWrapper tool = profile.getInspectionTool(shortName, project);
if (tool == null) {
return;
}
if (add) {
final NamedScope namedScope = NamedScopesHolder.getScope(project, "Tests");
final HighlightDisplayKey key = HighlightDisplayKey.find(shortName);
final HighlightDisplayLevel level = profile.getErrorLevel(key, namedScope, project);
profile.addScope(tool, namedScope, level, false, project);
} else {
profile.removeScope(shortName, "Tests", project);
}
profile.scopesChanged();
}
use of com.intellij.psi.search.scope.packageSet.NamedScope in project intellij-community by JetBrains.
the class ProjectSettingsPanel method isModified.
public boolean isModified() {
CopyrightProfile defaultCopyright = myManager.getDefaultCopyright();
final Object selected = myProfilesComboBox.getSelectedItem();
if (defaultCopyright != selected && (selected == null || defaultCopyright == null || !defaultCopyright.equals(selected))) {
return true;
}
final Map<String, String> map = myManager.getScopeToCopyright();
if (map.size() != myScopeMappingModel.getItems().size())
return true;
final Iterator<String> iterator = map.keySet().iterator();
for (ScopeSetting setting : myScopeMappingModel.getItems()) {
final NamedScope scope = setting.getScope();
if (!iterator.hasNext())
return true;
final String scopeName = iterator.next();
if (scope == null || !Comparing.strEqual(scopeName, scope.getName()))
return true;
final String profileName = map.get(scope.getName());
if (profileName == null)
return true;
if (!profileName.equals(setting.getProfileName()))
return true;
}
return false;
}
Aggregations