use of com.intellij.packageDependencies.DependencyValidationManager in project intellij-community by JetBrains.
the class DependencyConfigurable method isModified.
@Override
public boolean isModified() {
final DependencyValidationManager validationManager = DependencyValidationManager.getInstance(myProject);
if (validationManager.skipImportStatements() != mySkipImports.isSelected())
return true;
final List<DependencyRule> rules = new ArrayList<>();
rules.addAll(myDenyRulesModel.getItems());
rules.addAll(myAllowRulesModel.getItems());
return !Arrays.asList(validationManager.getAllRules()).equals(rules);
}
use of com.intellij.packageDependencies.DependencyValidationManager in project intellij-community by JetBrains.
the class DependencyConfigurable method apply.
@Override
public void apply() throws ConfigurationException {
stopTableEditing();
DependencyValidationManager validationManager = DependencyValidationManager.getInstance(myProject);
validationManager.removeAllRules();
final HashMap<String, PackageSet> unUsed = new HashMap<>(validationManager.getUnnamedScopes());
List<DependencyRule> modelItems = new ArrayList<>();
modelItems.addAll(myDenyRulesModel.getItems());
modelItems.addAll(myAllowRulesModel.getItems());
for (DependencyRule rule : modelItems) {
validationManager.addRule(rule);
final NamedScope fromScope = rule.getFromScope();
if (fromScope instanceof NamedScope.UnnamedScope) {
final PackageSet fromPackageSet = fromScope.getValue();
LOG.assertTrue(fromPackageSet != null);
unUsed.remove(fromPackageSet.getText());
}
final NamedScope toScope = rule.getToScope();
if (toScope instanceof NamedScope.UnnamedScope) {
final PackageSet toPackageSet = toScope.getValue();
LOG.assertTrue(toPackageSet != null);
unUsed.remove(toPackageSet.getText());
}
}
for (String text : unUsed.keySet()) {
//cleanup
validationManager.getUnnamedScopes().remove(text);
}
validationManager.setSkipImportStatements(mySkipImports.isSelected());
DaemonCodeAnalyzer.getInstance(myProject).restart();
}
use of com.intellij.packageDependencies.DependencyValidationManager in project intellij-community by JetBrains.
the class DependencyConfigurable method reset.
@Override
public void reset() {
final DependencyValidationManager validationManager = DependencyValidationManager.getInstance(myProject);
DependencyRule[] rules = validationManager.getAllRules();
final ArrayList<DependencyRule> denyList = new ArrayList<>();
final ArrayList<DependencyRule> allowList = new ArrayList<>();
for (DependencyRule rule : rules) {
if (rule.isDenyRule()) {
denyList.add(rule.createCopy());
} else {
allowList.add(rule.createCopy());
}
}
myDenyRulesModel.setItems(denyList);
myAllowRulesModel.setItems(allowList);
mySkipImports.setSelected(validationManager.skipImportStatements());
}
Aggregations