Search in sources :

Example 6 with PsiClassOwner

use of com.intellij.psi.PsiClassOwner in project intellij-plugins by JetBrains.

the class PackageAccessibilityInspection method checkFile.

@Nullable
@Override
public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull final InspectionManager manager, final boolean isOnTheFly) {
    if (!(file instanceof PsiClassOwner) || !checkTests && ProjectRootsUtil.isInTestSource(file)) {
        return null;
    }
    final OsmorcFacet facet = OsmorcFacet.getInstance(file);
    if (facet == null) {
        return null;
    }
    final List<ProblemDescriptor> problems = ContainerUtil.newSmartList();
    DependenciesBuilder.analyzeFileDependencies(file, new DependenciesBuilder.DependencyProcessor() {

        @Override
        public void process(PsiElement place, PsiElement dependency) {
            if (dependency instanceof PsiClass) {
                Problem problem = checkAccessibility((PsiClass) dependency, facet);
                if (problem != null) {
                    problems.add(manager.createProblemDescriptor(place, problem.message, isOnTheFly, problem.fixes, problem.type));
                }
            }
        }
    }, DependencyVisitorFactory.VisitorOptions.SKIP_IMPORTS);
    return problems.isEmpty() ? null : problems.toArray(new ProblemDescriptor[problems.size()]);
}
Also used : PsiClassOwner(com.intellij.psi.PsiClassOwner) DependenciesBuilder(com.intellij.packageDependencies.DependenciesBuilder) OsmorcFacet(org.osmorc.facet.OsmorcFacet) PsiClass(com.intellij.psi.PsiClass) PsiElement(com.intellij.psi.PsiElement) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

PsiClassOwner (com.intellij.psi.PsiClassOwner)6 PsiClass (com.intellij.psi.PsiClass)3 PsiFile (com.intellij.psi.PsiFile)3 StructureViewTreeElement (com.intellij.ide.structureView.StructureViewTreeElement)1 ColoredItemPresentation (com.intellij.navigation.ColoredItemPresentation)1 Module (com.intellij.openapi.module.Module)1 IndexNotReadyException (com.intellij.openapi.project.IndexNotReadyException)1 DependenciesBuilder (com.intellij.packageDependencies.DependenciesBuilder)1 PsiElement (com.intellij.psi.PsiElement)1 LightClass (com.intellij.psi.impl.light.LightClass)1 RetentionPolicy (java.lang.annotation.RetentionPolicy)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 NotNull (org.jetbrains.annotations.NotNull)1 Nullable (org.jetbrains.annotations.Nullable)1 BundleManifest (org.jetbrains.osgi.project.BundleManifest)1 OsmorcFacet (org.osmorc.facet.OsmorcFacet)1