use of com.intellij.packageDependencies.DependencyValidationManager in project intellij-community by JetBrains.
the class PackageSetChooserCombo method createModel.
protected NamedScope[] createModel() {
final Collection<NamedScope> model = new ArrayList<>();
final DependencyValidationManager manager = DependencyValidationManager.getInstance(myProject);
model.addAll(Arrays.asList(manager.getScopes()));
for (PackageSet unnamedScope : manager.getUnnamedScopes().values()) {
model.add(new NamedScope.UnnamedScope(unnamedScope));
}
model.remove(DefaultScopesProvider.getInstance(myProject).getProblemsScope());
return model.toArray(new NamedScope[model.size()]);
}
use of com.intellij.packageDependencies.DependencyValidationManager in project intellij-community by JetBrains.
the class ToolsImpl method disableTool.
public void disableTool(@NotNull PsiElement element) {
final Project project = element.getProject();
final DependencyValidationManager validationManager = DependencyValidationManager.getInstance(project);
if (myTools != null) {
for (ScopeToolState state : myTools) {
final NamedScope scope = state.getScope(project);
if (scope != null) {
final PackageSet packageSet = scope.getValue();
if (packageSet != null) {
final PsiFile file = element.getContainingFile();
if (file != null) {
if (packageSet.contains(file, validationManager)) {
state.setEnabled(false);
return;
}
} else {
if (packageSet instanceof PackageSetBase && ((PackageSetBase) packageSet).contains(PsiUtilCore.getVirtualFile(element), project, validationManager)) {
state.setEnabled(false);
return;
}
}
}
}
}
myDefaultState.setEnabled(false);
} else {
myDefaultState.setEnabled(false);
setEnabled(false);
}
}
use of com.intellij.packageDependencies.DependencyValidationManager in project intellij-community by JetBrains.
the class ToolsImpl method getEnabledTool.
@Nullable
@Override
public InspectionToolWrapper getEnabledTool(@Nullable PsiElement element, boolean includeDoNotShow) {
if (!myEnabled)
return null;
if (myTools != null && element != null) {
final Project project = element.getProject();
final DependencyValidationManager manager = DependencyValidationManager.getInstance(project);
for (ScopeToolState state : myTools) {
final NamedScope scope = state.getScope(project);
if (scope != null) {
final PackageSet set = scope.getValue();
if (set != null && set.contains(element.getContainingFile(), manager)) {
return state.isEnabled() && (includeDoNotShow || !HighlightDisplayLevel.DO_NOT_SHOW.equals(state.getLevel())) ? state.getTool() : null;
}
}
}
}
return myDefaultState.isEnabled() && (includeDoNotShow || !HighlightDisplayLevel.DO_NOT_SHOW.equals(myDefaultState.getLevel())) ? myDefaultState.getTool() : null;
}
use of com.intellij.packageDependencies.DependencyValidationManager in project intellij-community by JetBrains.
the class OrderEntryFix method filterAllowedDependencies.
private static List<PsiClass> filterAllowedDependencies(PsiElement element, PsiClass[] classes) {
DependencyValidationManager dependencyValidationManager = DependencyValidationManager.getInstance(element.getProject());
PsiFile fromFile = element.getContainingFile();
List<PsiClass> result = new ArrayList<>();
for (PsiClass psiClass : classes) {
PsiFile containingFile = psiClass.getContainingFile();
if (containingFile != null && dependencyValidationManager.getViolatorDependencyRule(fromFile, containingFile) == null) {
result.add(psiClass);
}
}
return result;
}
use of com.intellij.packageDependencies.DependencyValidationManager in project intellij-community by JetBrains.
the class ProjectSettingsPanel method reset.
public void reset() {
myProfilesComboBox.setSelectedItem(myManager.getDefaultCopyright());
final List<ScopeSetting> mappings = new ArrayList<>();
final Map<String, String> copyrights = myManager.getScopeToCopyright();
final DependencyValidationManager manager = DependencyValidationManager.getInstance(myProject);
final Set<String> scopes2Unmap = new HashSet<>();
for (final String scopeName : copyrights.keySet()) {
final NamedScope scope = manager.getScope(scopeName);
if (scope != null) {
mappings.add(new ScopeSetting(scope, copyrights.get(scopeName)));
} else {
scopes2Unmap.add(scopeName);
}
}
for (String scopeName : scopes2Unmap) {
myManager.unmapCopyright(scopeName);
}
myScopeMappingModel.setItems(mappings);
}
Aggregations