2 * Copyright 2000-2011 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package com.intellij.openapi.roots;
18 import com.intellij.openapi.components.ServiceManager;
19 import com.intellij.openapi.module.Module;
20 import com.intellij.openapi.project.Project;
21 import com.intellij.openapi.util.ModificationTracker;
22 import com.intellij.openapi.vfs.VirtualFile;
23 import com.intellij.psi.search.GlobalSearchScope;
24 import org.jetbrains.annotations.NotNull;
25 import org.jetbrains.annotations.Nullable;
30 public abstract class FileIndexFacade {
31 protected final Project myProject;
33 protected FileIndexFacade(final Project project) {
37 public static FileIndexFacade getInstance(Project project) {
38 return ServiceManager.getService(project, FileIndexFacade.class);
41 public abstract boolean isInContent(@NotNull VirtualFile file);
42 public abstract boolean isInSource(@NotNull VirtualFile file);
43 public abstract boolean isInSourceContent(@NotNull VirtualFile file);
44 public abstract boolean isInLibraryClasses(@NotNull VirtualFile file);
46 public abstract boolean isInLibrarySource(@NotNull VirtualFile file);
47 public abstract boolean isExcludedFile(@NotNull VirtualFile file);
48 public abstract boolean isUnderIgnored(@NotNull VirtualFile file);
51 public abstract Module getModuleForFile(@NotNull VirtualFile file);
54 * Checks if <code>file</code> is an ancestor of <code>baseDir</code> and none of the files
55 * between them are excluded from the project.
57 * @param baseDir the parent directory to check for ancestry.
58 * @param child the child directory or file to check for ancestry.
59 * @return true if it's a valid ancestor, false otherwise.
61 public abstract boolean isValidAncestor(@NotNull VirtualFile baseDir, @NotNull VirtualFile child);
63 public boolean shouldBeFound(GlobalSearchScope scope, VirtualFile virtualFile) {
64 return (scope.isSearchOutsideRootModel() || isInContent(virtualFile) || isInLibrarySource(virtualFile)) && !virtualFile.getFileType().isBinary();
67 @NotNull public abstract ModificationTracker getRootModificationTracker();