diff --git a/java/openapi/src/com/intellij/psi/search/scope/packageSet/PatternPackageSet.java b/java/openapi/src/com/intellij/psi/search/scope/packageSet/PatternPackageSet.java index 4f7595e003fa..ebefeef67853 100644 --- a/java/openapi/src/com/intellij/psi/search/scope/packageSet/PatternPackageSet.java +++ b/java/openapi/src/com/intellij/psi/search/scope/packageSet/PatternPackageSet.java @@ -72,12 +72,12 @@ public class PatternPackageSet extends PatternBasedPackageSet { } @Override - public boolean contains(VirtualFile file, NamedScopesHolder holder) { + public boolean contains(VirtualFile file, @NotNull NamedScopesHolder holder) { return contains(file, holder.getProject(), holder); } @Override - public boolean contains(VirtualFile file, Project project, @Nullable NamedScopesHolder holder) { + public boolean contains(VirtualFile file, @NotNull Project project, @Nullable NamedScopesHolder holder) { ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex(); return matchesScope(file, holder.getProject(), fileIndex) && (myPattern == null || myPattern.matcher(getPackageName(file, fileIndex)).matches()); } diff --git a/platform/lang-api/src/com/intellij/packageDependencies/DependencyRule.java b/platform/lang-api/src/com/intellij/packageDependencies/DependencyRule.java index 050c445330a6..fb2fdd034662 100644 --- a/platform/lang-api/src/com/intellij/packageDependencies/DependencyRule.java +++ b/platform/lang-api/src/com/intellij/packageDependencies/DependencyRule.java @@ -52,9 +52,9 @@ public class DependencyRule { if (fromSet == null) return false; DependencyValidationManager holder = DependencyValidationManager.getInstance(file.getProject()); - return (myDenyRule + return myDenyRule ? fromSet.contains(file, holder) - : new ComplementPackageSet(fromSet).contains(file, holder)); + : new ComplementPackageSet(fromSet).contains(file, holder); } public String getDisplayText() { diff --git a/platform/lang-api/src/com/intellij/packageDependencies/DependencyValidationManager.java b/platform/lang-api/src/com/intellij/packageDependencies/DependencyValidationManager.java index 9465b2914de2..d1818b3d3b0e 100644 --- a/platform/lang-api/src/com/intellij/packageDependencies/DependencyValidationManager.java +++ b/platform/lang-api/src/com/intellij/packageDependencies/DependencyValidationManager.java @@ -1,4 +1,4 @@ -/* + /* * Copyright 2000-2009 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/platform/lang-api/src/com/intellij/psi/search/scope/NonProjectFilesScope.java b/platform/lang-api/src/com/intellij/psi/search/scope/NonProjectFilesScope.java index 021b12205ddd..63fe1c8d28e5 100644 --- a/platform/lang-api/src/com/intellij/psi/search/scope/NonProjectFilesScope.java +++ b/platform/lang-api/src/com/intellij/psi/search/scope/NonProjectFilesScope.java @@ -17,7 +17,6 @@ package com.intellij.psi.search.scope; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.io.FileUtil; -import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.search.ProjectScope; import com.intellij.psi.search.scope.packageSet.AbstractPackageSet; @@ -25,6 +24,7 @@ import com.intellij.psi.search.scope.packageSet.NamedScope; import com.intellij.psi.search.scope.packageSet.NamedScopesHolder; import com.intellij.ui.Colored; import com.intellij.util.ArrayUtil; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** @@ -42,17 +42,17 @@ public class NonProjectFilesScope extends NamedScope { } @Override - public boolean contains(VirtualFile file, Project project, @Nullable NamedScopesHolder holder) { + public boolean contains(VirtualFile file, @NotNull Project project, @Nullable NamedScopesHolder holder) { if (file == null) return true; - if (file.getFileSystem() != LocalFileSystem.getInstance()) return true; + if (!file.isInLocalFileSystem()) return true; if (isInsideProjectContent(project, file)) return false; return !ProjectScope.getProjectScope(project).contains(file); } }); } - private static boolean isInsideProjectContent(Project project, VirtualFile file) { - if (file.getFileSystem() instanceof LocalFileSystem) { + private static boolean isInsideProjectContent(@NotNull Project project, @NotNull VirtualFile file) { + if (!file.isInLocalFileSystem()) { final String projectBaseDir = project.getBasePath(); if (projectBaseDir != null) { return FileUtil.isAncestor(projectBaseDir, file.getPath(), false); @@ -61,7 +61,8 @@ public class NonProjectFilesScope extends NamedScope { return false; } - public static NamedScope[] removeFromList(NamedScope[] scopes) { + @NotNull + public static NamedScope[] removeFromList(@NotNull NamedScope[] scopes) { int nonProjectIdx = -1; for (int i = 0, length = scopes.length; i < length; i++) { NamedScope scope = scopes[i]; diff --git a/platform/lang-api/src/com/intellij/psi/search/scope/packageSet/ComplementPackageSet.java b/platform/lang-api/src/com/intellij/psi/search/scope/packageSet/ComplementPackageSet.java index 6087f0d9e81f..8b341de80cfb 100644 --- a/platform/lang-api/src/com/intellij/psi/search/scope/packageSet/ComplementPackageSet.java +++ b/platform/lang-api/src/com/intellij/psi/search/scope/packageSet/ComplementPackageSet.java @@ -28,12 +28,12 @@ public class ComplementPackageSet extends PackageSetBase { } @Override - public boolean contains(VirtualFile file, NamedScopesHolder holder) { + public boolean contains(VirtualFile file, @NotNull NamedScopesHolder holder) { return contains(file, holder.getProject(), holder); } @Override - public boolean contains(VirtualFile file, Project project, @Nullable NamedScopesHolder holder) { + public boolean contains(VirtualFile file, @NotNull Project project, @Nullable NamedScopesHolder holder) { return myComplementarySet instanceof PackageSetBase ? !((PackageSetBase)myComplementarySet).contains(file, project, holder) : myComplementarySet.contains(getPsiFile(file, project), holder); } diff --git a/platform/lang-api/src/com/intellij/psi/search/scope/packageSet/FilePatternPackageSet.java b/platform/lang-api/src/com/intellij/psi/search/scope/packageSet/FilePatternPackageSet.java index f7da83933d02..b2d0d5bb51fe 100644 --- a/platform/lang-api/src/com/intellij/psi/search/scope/packageSet/FilePatternPackageSet.java +++ b/platform/lang-api/src/com/intellij/psi/search/scope/packageSet/FilePatternPackageSet.java @@ -68,12 +68,12 @@ public class FilePatternPackageSet extends PatternBasedPackageSet { } @Override - public boolean contains(VirtualFile file, NamedScopesHolder holder) { + public boolean contains(VirtualFile file, @NotNull NamedScopesHolder holder) { return contains(file, holder.getProject(), holder); } @Override - public boolean contains(VirtualFile file, Project project, @Nullable NamedScopesHolder holder) { + public boolean contains(VirtualFile file, @NotNull Project project, @Nullable NamedScopesHolder holder) { ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex(); return file != null && fileMatcher(file, fileIndex, holder.getProjectBaseDir()) && matchesModule(myModuleGroupPattern, myModulePattern, file, fileIndex); diff --git a/platform/lang-api/src/com/intellij/psi/search/scope/packageSet/IntersectionPackageSet.java b/platform/lang-api/src/com/intellij/psi/search/scope/packageSet/IntersectionPackageSet.java index f7a32c7c276e..970cd992fffc 100644 --- a/platform/lang-api/src/com/intellij/psi/search/scope/packageSet/IntersectionPackageSet.java +++ b/platform/lang-api/src/com/intellij/psi/search/scope/packageSet/IntersectionPackageSet.java @@ -30,12 +30,12 @@ public class IntersectionPackageSet extends PackageSetBase { } @Override - public boolean contains(VirtualFile file, NamedScopesHolder holder) { + public boolean contains(VirtualFile file, @NotNull NamedScopesHolder holder) { return contains(file, holder.getProject(), holder); } @Override - public boolean contains(VirtualFile file, Project project, @Nullable NamedScopesHolder holder) { + public boolean contains(VirtualFile file, @NotNull Project project, @Nullable NamedScopesHolder holder) { if (myFirstSet instanceof PackageSetBase ? ((PackageSetBase)myFirstSet).contains(file, project, holder) : myFirstSet.contains(getPsiFile(file, project), holder)) { if (mySecondSet instanceof PackageSetBase ? ((PackageSetBase)mySecondSet).contains(file, project, holder) : mySecondSet.contains(getPsiFile(file, project), holder)) { return true; diff --git a/platform/lang-api/src/com/intellij/psi/search/scope/packageSet/PackageSet.java b/platform/lang-api/src/com/intellij/psi/search/scope/packageSet/PackageSet.java index 5e59d8c7bbf4..2393584ed104 100644 --- a/platform/lang-api/src/com/intellij/psi/search/scope/packageSet/PackageSet.java +++ b/platform/lang-api/src/com/intellij/psi/search/scope/packageSet/PackageSet.java @@ -20,7 +20,7 @@ import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; public interface PackageSet { - boolean contains(PsiFile file, NamedScopesHolder holder); + boolean contains(@NotNull PsiFile file, NamedScopesHolder holder); @NotNull PackageSet createCopy(); @NonNls @NotNull diff --git a/platform/lang-api/src/com/intellij/psi/search/scope/packageSet/PackageSetBase.java b/platform/lang-api/src/com/intellij/psi/search/scope/packageSet/PackageSetBase.java index 7f022a4b1f7f..f7a7de340625 100644 --- a/platform/lang-api/src/com/intellij/psi/search/scope/packageSet/PackageSetBase.java +++ b/platform/lang-api/src/com/intellij/psi/search/scope/packageSet/PackageSetBase.java @@ -19,6 +19,7 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiFile; import com.intellij.psi.PsiManager; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** @@ -26,16 +27,17 @@ import org.jetbrains.annotations.Nullable; */ public abstract class PackageSetBase implements PackageSet { /** - * @see PackageSetBase#contains(com.intellij.openapi.vfs.VirtualFile, com.intellij.psi.search.scope.packageSet.NamedScopesHolder) + * @see PackageSetBase#contains(VirtualFile, Project, NamedScopesHolder) */ @Deprecated public abstract boolean contains(VirtualFile file, NamedScopesHolder holder); - public boolean contains(VirtualFile file, Project project, @Nullable NamedScopesHolder holder) { + + public boolean contains(VirtualFile file, @NotNull Project project, @Nullable NamedScopesHolder holder) { return contains(file, holder); } @Override - public boolean contains(PsiFile file, NamedScopesHolder holder) { + public boolean contains(@NotNull PsiFile file, NamedScopesHolder holder) { return contains(file.getVirtualFile(), file.getProject(), holder); } @@ -47,9 +49,9 @@ public abstract class PackageSetBase implements PackageSet { public static PsiFile getPsiFile(VirtualFile file, NamedScopesHolder holder) { return PsiManager.getInstance(holder.getProject()).findFile(file); } - + @Nullable - public static PsiFile getPsiFile(VirtualFile file, Project project) { + public static PsiFile getPsiFile(@NotNull VirtualFile file, @NotNull Project project) { return PsiManager.getInstance(project).findFile(file); } } diff --git a/platform/lang-api/src/com/intellij/psi/search/scope/packageSet/UnionPackageSet.java b/platform/lang-api/src/com/intellij/psi/search/scope/packageSet/UnionPackageSet.java index f1ca5caa0a0d..3b51d8c52b6d 100644 --- a/platform/lang-api/src/com/intellij/psi/search/scope/packageSet/UnionPackageSet.java +++ b/platform/lang-api/src/com/intellij/psi/search/scope/packageSet/UnionPackageSet.java @@ -30,12 +30,12 @@ public class UnionPackageSet extends PackageSetBase { } @Override - public boolean contains(VirtualFile file, NamedScopesHolder holder) { + public boolean contains(VirtualFile file, @NotNull NamedScopesHolder holder) { return contains(file, holder.getProject(), holder); } @Override - public boolean contains(VirtualFile file, Project project, @Nullable NamedScopesHolder holder) { + public boolean contains(VirtualFile file, @NotNull Project project, @Nullable NamedScopesHolder holder) { return (myFirstSet instanceof PackageSetBase ? ((PackageSetBase)myFirstSet).contains(file, project, holder) : myFirstSet.contains(getPsiFile(file, project), holder)) || (mySecondSet instanceof PackageSetBase ? ((PackageSetBase)mySecondSet).contains(file, project, holder) : mySecondSet.contains(getPsiFile(file, project), holder)); } diff --git a/platform/lang-impl/src/com/intellij/packageDependencies/ChangeListsScopesProvider.java b/platform/lang-impl/src/com/intellij/packageDependencies/ChangeListsScopesProvider.java index d6954f577b20..479783ded4fc 100644 --- a/platform/lang-impl/src/com/intellij/packageDependencies/ChangeListsScopesProvider.java +++ b/platform/lang-impl/src/com/intellij/packageDependencies/ChangeListsScopesProvider.java @@ -33,13 +33,14 @@ import java.util.List; * @author anna */ public class ChangeListsScopesProvider extends CustomScopesProviderEx { - private Project myProject; + @NotNull + private final Project myProject; public static ChangeListsScopesProvider getInstance(Project project) { return Extensions.findExtension(CUSTOM_SCOPES_PROVIDER, project, ChangeListsScopesProvider.class); } - public ChangeListsScopesProvider(Project project) { + public ChangeListsScopesProvider(@NotNull Project project) { myProject = project; } @@ -97,7 +98,8 @@ public class ChangeListsScopesProvider extends CustomScopesProviderEx { return false; } - private static NamedScope createScope(final List files, String changeListName) { + @NotNull + private static NamedScope createScope(@NotNull final List files, @NotNull String changeListName) { return new NamedScope(changeListName, new PackageSetBase() { @Override public boolean contains(VirtualFile file, NamedScopesHolder holder) { diff --git a/platform/lang-impl/src/com/intellij/packageDependencies/DefaultScopesProvider.java b/platform/lang-impl/src/com/intellij/packageDependencies/DefaultScopesProvider.java index a0672a15e7e8..66d8b4c65b78 100644 --- a/platform/lang-impl/src/com/intellij/packageDependencies/DefaultScopesProvider.java +++ b/platform/lang-impl/src/com/intellij/packageDependencies/DefaultScopesProvider.java @@ -22,7 +22,6 @@ import com.intellij.openapi.vfs.VirtualFile; import com.intellij.problems.WolfTheProblemSolver; import com.intellij.psi.search.scope.NonProjectFilesScope; import com.intellij.psi.search.scope.ProjectFilesScope; -import com.intellij.psi.search.scope.TestsScope; import com.intellij.psi.search.scope.packageSet.*; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -44,19 +43,19 @@ public class DefaultScopesProvider extends CustomScopesProviderEx { return Extensions.findExtension(CUSTOM_SCOPES_PROVIDER, project, DefaultScopesProvider.class); } - public DefaultScopesProvider(Project project) { + public DefaultScopesProvider(@NotNull Project project) { myProject = project; final NamedScope projectScope = new ProjectFilesScope(); final NamedScope nonProjectScope = new NonProjectFilesScope(); final String text = FilePatternPackageSet.SCOPE_FILE + ":*//*"; myProblemsScope = new NamedScope(IdeBundle.message("predefined.scope.problems.name"), new AbstractPackageSet(text) { @Override - public boolean contains(VirtualFile file, NamedScopesHolder holder) { + public boolean contains(VirtualFile file, @NotNull NamedScopesHolder holder) { return contains(file, holder.getProject(), holder); } @Override - public boolean contains(VirtualFile file, Project project, @Nullable NamedScopesHolder holder) { + public boolean contains(VirtualFile file, @NotNull Project project, @Nullable NamedScopesHolder holder) { return project == myProject && WolfTheProblemSolver.getInstance(myProject).isProblemFile(file); } @@ -72,23 +71,28 @@ public class DefaultScopesProvider extends CustomScopesProviderEx { @SuppressWarnings({"UtilityClassWithoutPrivateConstructor"}) private static class AllScopeHolder { + @NotNull private static final String TEXT = FilePatternPackageSet.SCOPE_FILE + ":*//*"; + @NotNull private static final NamedScope ALL = new NamedScope("All", new AbstractPackageSet(TEXT, 0) { @Override - public boolean contains(final VirtualFile file, final NamedScopesHolder scopesHolder) { + public boolean contains(final VirtualFile file, @NotNull final NamedScopesHolder scopesHolder) { return true; } }); } + @NotNull public static NamedScope getAllScope() { return AllScopeHolder.ALL; } + @NotNull public NamedScope getProblemsScope() { return myProblemsScope; } + @NotNull public List getAllCustomScopes() { final List scopes = new ArrayList(); for (CustomScopesProvider provider : Extensions.getExtensions(CUSTOM_SCOPES_PROVIDER, myProject)) { diff --git a/platform/lang-impl/src/com/intellij/packageDependencies/ui/PanelProgressIndicator.java b/platform/lang-impl/src/com/intellij/packageDependencies/ui/PanelProgressIndicator.java index b7c91275c47b..008c1173e5a6 100644 --- a/platform/lang-impl/src/com/intellij/packageDependencies/ui/PanelProgressIndicator.java +++ b/platform/lang-impl/src/com/intellij/packageDependencies/ui/PanelProgressIndicator.java @@ -33,7 +33,7 @@ public class PanelProgressIndicator extends ProgressIndicatorBase { private final MyProgressPanel myProgressPanel; private boolean myPaintInQueue; private final Consumer myComponentUpdater; - private Alarm myAlarm = new Alarm(Alarm.ThreadToUse.SHARED_THREAD); + private final Alarm myAlarm = new Alarm(Alarm.ThreadToUse.SHARED_THREAD); public PanelProgressIndicator(Consumer componentUpdater) { myProgressPanel = new MyProgressPanel();