mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Cleanup (formatting)
This commit is contained in:
+35
-31
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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.
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.intellij.codeInspection.dependencyViolation;
|
||||
|
||||
import com.intellij.codeHighlighting.HighlightDisplayLevel;
|
||||
import com.intellij.codeInsight.daemon.GroupNames;
|
||||
import com.intellij.codeInspection.*;
|
||||
import com.intellij.lang.java.JavaLanguage;
|
||||
import com.intellij.packageDependencies.DependenciesBuilder;
|
||||
@@ -23,81 +24,84 @@ import com.intellij.packageDependencies.DependencyRule;
|
||||
import com.intellij.packageDependencies.DependencyValidationManager;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.FactoryMap;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class DependencyInspectionBase extends BaseJavaBatchLocalInspectionTool {
|
||||
private static final String GROUP_DISPLAY_NAME = "";
|
||||
private static final String DISPLAY_NAME = InspectionsBundle.message("illegal.package.dependencies");
|
||||
@NonNls private static final String SHORT_NAME = "Dependency";
|
||||
|
||||
@Override
|
||||
public boolean isEnabledByDefault() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public HighlightDisplayLevel getDefaultLevel() {
|
||||
return HighlightDisplayLevel.ERROR;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getGroupDisplayName() {
|
||||
return GROUP_DISPLAY_NAME;
|
||||
return GroupNames.DEPENDENCY_GROUP_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getDisplayName() {
|
||||
return DISPLAY_NAME;
|
||||
return InspectionsBundle.message("illegal.package.dependencies");
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getShortName() {
|
||||
return SHORT_NAME;
|
||||
return "Dependency";
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public ProblemDescriptor[] checkFile(@NotNull final PsiFile file, @NotNull final InspectionManager manager, final boolean isOnTheFly) {
|
||||
if (file.getViewProvider().getPsi(JavaLanguage.INSTANCE) == null) return null;
|
||||
if (file.getViewProvider().getPsi(JavaLanguage.INSTANCE) == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final DependencyValidationManager validationManager = DependencyValidationManager.getInstance(file.getProject());
|
||||
if (!validationManager.hasRules()) return null;
|
||||
if (validationManager.getApplicableRules(file).length == 0) return null;
|
||||
final List<ProblemDescriptor> problems = new ArrayList<ProblemDescriptor>();
|
||||
final FactoryMap<PsiFile, DependencyRule[]> violations = new FactoryMap<PsiFile, DependencyRule[]>() {
|
||||
@Nullable
|
||||
@Override
|
||||
protected DependencyRule[] create(PsiFile dependencyFile) {
|
||||
return validationManager.getViolatorDependencyRules(file, dependencyFile);
|
||||
}
|
||||
};
|
||||
if (!validationManager.hasRules() || validationManager.getApplicableRules(file).length == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final List<ProblemDescriptor> problems = ContainerUtil.newSmartList();
|
||||
DependenciesBuilder.analyzeFileDependencies(file, new DependenciesBuilder.DependencyProcessor() {
|
||||
@SuppressWarnings("MismatchedQueryAndUpdateOfCollection")
|
||||
private final Map<PsiFile, DependencyRule[]> violations = new FactoryMap<PsiFile, DependencyRule[]>() {
|
||||
@Nullable
|
||||
@Override
|
||||
protected DependencyRule[] create(PsiFile dependencyFile) {
|
||||
return validationManager.getViolatorDependencyRules(file, dependencyFile);
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void process(PsiElement place, PsiElement dependency) {
|
||||
PsiFile dependencyFile = dependency.getContainingFile();
|
||||
if (dependencyFile != null && dependencyFile.isPhysical() && dependencyFile.getVirtualFile() != null) {
|
||||
for (DependencyRule dependencyRule : violations.get(dependencyFile)) {
|
||||
problems.add(manager.createProblemDescriptor(place, InspectionsBundle
|
||||
.message("inspection.dependency.violator.problem.descriptor", dependencyRule.getDisplayText()), isOnTheFly,
|
||||
createEditDependencyFixes(dependencyRule),
|
||||
ProblemHighlightType.GENERIC_ERROR_OR_WARNING));
|
||||
String message = InspectionsBundle.message("inspection.dependency.violator.problem.descriptor", dependencyRule.getDisplayText());
|
||||
LocalQuickFix[] fixes = createEditDependencyFixes(dependencyRule);
|
||||
problems.add(manager.createProblemDescriptor(place, message, isOnTheFly, fixes, ProblemHighlightType.GENERIC_ERROR_OR_WARNING));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return problems.isEmpty() ? null : problems.toArray(new ProblemDescriptor[problems.size()]);
|
||||
}
|
||||
|
||||
protected LocalQuickFix[] createEditDependencyFixes(DependencyRule dependencyRule) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public HighlightDisplayLevel getDefaultLevel() {
|
||||
return HighlightDisplayLevel.ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user