mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
notnull
This commit is contained in:
@@ -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());
|
||||
}
|
||||
|
||||
@@ -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() {
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
||||
@@ -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];
|
||||
|
||||
+2
-2
@@ -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);
|
||||
}
|
||||
|
||||
+2
-2
@@ -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);
|
||||
|
||||
+2
-2
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
+5
-3
@@ -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<VirtualFile> files, String changeListName) {
|
||||
@NotNull
|
||||
private static NamedScope createScope(@NotNull final List<VirtualFile> files, @NotNull String changeListName) {
|
||||
return new NamedScope(changeListName, new PackageSetBase() {
|
||||
@Override
|
||||
public boolean contains(VirtualFile file, NamedScopesHolder holder) {
|
||||
|
||||
@@ -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<NamedScope> getAllCustomScopes() {
|
||||
final List<NamedScope> scopes = new ArrayList<NamedScope>();
|
||||
for (CustomScopesProvider provider : Extensions.getExtensions(CUSTOM_SCOPES_PROVIDER, myProject)) {
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ public class PanelProgressIndicator extends ProgressIndicatorBase {
|
||||
private final MyProgressPanel myProgressPanel;
|
||||
private boolean myPaintInQueue;
|
||||
private final Consumer<JComponent> myComponentUpdater;
|
||||
private Alarm myAlarm = new Alarm(Alarm.ThreadToUse.SHARED_THREAD);
|
||||
private final Alarm myAlarm = new Alarm(Alarm.ThreadToUse.SHARED_THREAD);
|
||||
|
||||
public PanelProgressIndicator(Consumer<JComponent> componentUpdater) {
|
||||
myProgressPanel = new MyProgressPanel();
|
||||
|
||||
Reference in New Issue
Block a user