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.vfs.VirtualFile;
22 import org.jetbrains.annotations.Nullable;
27 public abstract class FileIndexFacade {
28 protected final Project myProject;
30 protected FileIndexFacade(final Project project) {
34 public static FileIndexFacade getInstance(Project project) {
35 return ServiceManager.getService(project, FileIndexFacade.class);
38 public abstract boolean isInContent(VirtualFile file);
39 public abstract boolean isInSource(VirtualFile file);
40 public abstract boolean isInLibraryClasses(VirtualFile file);
41 public abstract boolean isInLibrarySource(VirtualFile file);
42 public abstract boolean isExcludedFile(VirtualFile file);
45 public abstract Module getModuleForFile(VirtualFile file);
48 * Checks if <code>file</code> is an ancestor of <code>baseDir</code> and none of the files
49 * between them are excluded from the project.
51 * @param baseDir the parent directory to check for ancestry.
52 * @param child the child directory or file to check for ancestry.
53 * @return true if it's a valid ancestor, false otherwise.
55 public abstract boolean isValidAncestor(final VirtualFile baseDir, final VirtualFile child);