mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
EA-53845 fixed NPE.
ProjectRootManager obviously cannot be obtained if delegate.getProject() == null. Some @NotNull & @Nullable added in relative places
This commit is contained in:
+11
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -30,13 +30,18 @@ import com.intellij.psi.SdkResolveScopeProvider;
|
||||
import com.intellij.psi.search.DelegatingGlobalSearchScope;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class JavaSourceFilterScope extends DelegatingGlobalSearchScope {
|
||||
@Nullable
|
||||
private final ProjectFileIndex myIndex;
|
||||
|
||||
public JavaSourceFilterScope(@NotNull final GlobalSearchScope delegate) {
|
||||
super(delegate);
|
||||
myIndex = ProjectRootManager.getInstance(getProject()).getFileIndex();
|
||||
|
||||
Project project = getProject();
|
||||
myIndex = project != null ? ProjectRootManager.getInstance(project).getFileIndex()
|
||||
: null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -45,6 +50,10 @@ public class JavaSourceFilterScope extends DelegatingGlobalSearchScope {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (myIndex == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (JavaClassFileType.INSTANCE == file.getFileType()) {
|
||||
return myIndex.isInLibraryClasses(file);
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ public abstract class GlobalSearchScope extends SearchScope implements ProjectAw
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.search.GlobalSearchScope");
|
||||
@Nullable private final Project myProject;
|
||||
|
||||
protected GlobalSearchScope(Project project) {
|
||||
protected GlobalSearchScope(@Nullable Project project) {
|
||||
myProject = project;
|
||||
}
|
||||
|
||||
@@ -49,6 +49,7 @@ public abstract class GlobalSearchScope extends SearchScope implements ProjectAw
|
||||
|
||||
public abstract boolean contains(@NotNull VirtualFile file);
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Project getProject() {
|
||||
return myProject;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -39,7 +39,7 @@ public abstract class ProjectRootManager implements ModificationTracker {
|
||||
* @param project the project for which the instance is requested.
|
||||
* @return the instance.
|
||||
*/
|
||||
public static ProjectRootManager getInstance(Project project) {
|
||||
public static ProjectRootManager getInstance(@NotNull Project project) {
|
||||
final ProjectRootManager service = ServiceManager.getService(project, ProjectRootManager.class);
|
||||
if (service != null) return service;
|
||||
return project.getComponent(ProjectRootManager.class);
|
||||
|
||||
Reference in New Issue
Block a user