本文整理汇总了Java中com.intellij.openapi.roots.FileIndexFacade类的典型用法代码示例。如果您正苦于以下问题:Java FileIndexFacade类的具体用法?Java FileIndexFacade怎么用?Java FileIndexFacade使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FileIndexFacade类属于com.intellij.openapi.roots包,在下文中一共展示了FileIndexFacade类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mapClass
import com.intellij.openapi.roots.FileIndexFacade; //导入依赖的package包/类
@Nullable
private PsiClass mapClass(@NotNull PsiClass psiClass) {
String qualifiedName = psiClass.getQualifiedName();
if (qualifiedName == null) {
return psiClass;
}
PsiFile file = psiClass.getContainingFile();
if (file == null || !file.getViewProvider().isPhysical()) {
return psiClass;
}
final VirtualFile vFile = file.getVirtualFile();
if (vFile == null) {
return psiClass;
}
final FileIndexFacade index = FileIndexFacade.getInstance(file.getProject());
if (!index.isInSource(vFile) && !index.isInLibrarySource(vFile) && !index.isInLibraryClasses(vFile)) {
return psiClass;
}
return JavaPsiFacade.getInstance(psiClass.getProject()).findClass(qualifiedName, myResolveScope);
}
示例2: getNavigationElement
import com.intellij.openapi.roots.FileIndexFacade; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@Override
@NotNull
public PsiElement getNavigationElement() {
for (ClsCustomNavigationPolicy customNavigationPolicy : Extensions.getExtensions(ClsCustomNavigationPolicy.EP_NAME)) {
if (customNavigationPolicy instanceof ClsCustomNavigationPolicyEx) {
PsiFile navigationElement = ((ClsCustomNavigationPolicyEx)customNavigationPolicy).getFileNavigationElement(this);
if (navigationElement != null) {
return navigationElement;
}
}
}
return CachedValuesManager.getCachedValue(this, new CachedValueProvider<PsiElement>() {
@Nullable
@Override
public Result<PsiElement> compute() {
PsiElement target = JavaPsiImplementationHelper.getInstance(getProject()).getClsFileNavigationElement(ClsFileImpl.this);
ModificationTracker tracker = FileIndexFacade.getInstance(getProject()).getRootModificationTracker();
return Result.create(target, ClsFileImpl.this, target.getContainingFile(), tracker);
}
});
}
示例3: getPsiClasses
import com.intellij.openapi.roots.FileIndexFacade; //导入依赖的package包/类
@NotNull
public static PsiClass[] getPsiClasses(@NotNull PsiDirectory dir, PsiFile[] psiFiles) {
FileIndexFacade index = FileIndexFacade.getInstance(dir.getProject());
VirtualFile virtualDir = dir.getVirtualFile();
boolean onlyCompiled = index.isInLibraryClasses(virtualDir) && !index.isInSourceContent(virtualDir);
List<PsiClass> classes = null;
for (PsiFile file : psiFiles) {
if (onlyCompiled && !(file instanceof ClsFileImpl)) {
continue;
}
if (file instanceof PsiClassOwner && file.getViewProvider().getLanguages().size() == 1) {
PsiClass[] psiClasses = ((PsiClassOwner)file).getClasses();
if (psiClasses.length == 0) continue;
if (classes == null) classes = new ArrayList<PsiClass>();
ContainerUtil.addAll(classes, psiClasses);
}
}
return classes == null ? PsiClass.EMPTY_ARRAY : classes.toArray(new PsiClass[classes.size()]);
}
示例4: processFilesContainingAllKeys
import com.intellij.openapi.roots.FileIndexFacade; //导入依赖的package包/类
private static boolean processFilesContainingAllKeys(@NotNull Project project,
@NotNull final GlobalSearchScope scope,
@Nullable final Condition<Integer> checker,
@NotNull final Collection<IdIndexEntry> keys,
@NotNull final Processor<VirtualFile> processor) {
final FileIndexFacade index = FileIndexFacade.getInstance(project);
return DumbService.getInstance(project).runReadActionInSmartMode(new Computable<Boolean>() {
@Override
public Boolean compute() {
return FileBasedIndex.getInstance().processFilesContainingAllKeys(IdIndex.NAME, keys, scope, checker, new Processor<VirtualFile>() {
@Override
public boolean process(VirtualFile file) {
return !index.shouldBeFound(scope, file) || processor.process(file);
}
});
}
});
}
示例5: FileManagerImpl
import com.intellij.openapi.roots.FileIndexFacade; //导入依赖的package包/类
public FileManagerImpl(PsiManagerImpl manager, FileDocumentManager fileDocumentManager, FileIndexFacade fileIndex) {
myManager = manager;
myFileIndex = fileIndex;
myConnection = manager.getProject().getMessageBus().connect();
myFileDocumentManager = fileDocumentManager;
myConnection.subscribe(DumbService.DUMB_MODE, new DumbService.DumbModeListener() {
@Override
public void enteredDumbMode() {
updateAllViewProviders();
}
@Override
public void exitDumbMode() {
updateAllViewProviders();
}
});
Disposer.register(manager.getProject(), this);
LowMemoryWatcher.register(new Runnable() {
@Override
public void run() {
processQueue();
}
}, this);
}
示例6: getVcsRootFor
import com.intellij.openapi.roots.FileIndexFacade; //导入依赖的package包/类
@Override
@Nullable
public VirtualFile getVcsRootFor(final VirtualFile file) {
if (myBaseDir != null && PeriodicalTasksCloser.getInstance().safeGetService(myProject, FileIndexFacade.class)
.isValidAncestor(myBaseDir, file)) {
return myBaseDir;
}
final VirtualFile contentRoot = ProjectRootManager.getInstance(myProject).getFileIndex().getContentRootForFile(file, Registry.is("ide.hide.excluded.files"));
if (contentRoot != null) {
return contentRoot;
}
if (ProjectUtil.isDirectoryBased(myProject) && (myBaseDir != null)) {
final VirtualFile ideaDir = myBaseDir.findChild(Project.DIRECTORY_STORE_FOLDER);
if (ideaDir != null && ideaDir.isValid() && ideaDir.isDirectory()) {
if (VfsUtilCore.isAncestor(ideaDir, file, false)) {
return ideaDir;
}
}
}
return null;
}
示例7: addRelativeImportResultsFromSkeletons
import com.intellij.openapi.roots.FileIndexFacade; //导入依赖的package包/类
/**
* Resolve relative imports from sdk root to the skeleton dir
*/
private void addRelativeImportResultsFromSkeletons(@NotNull final PsiFile foothold) {
final boolean inSource = FileIndexFacade.getInstance(foothold.getProject()).isInContent(foothold.getVirtualFile());
if (inSource) return;
PsiDirectory containingDirectory = foothold.getContainingDirectory();
if (myRelativeLevel > 0) {
containingDirectory = ResolveImportUtil.stepBackFrom(foothold, myRelativeLevel);
}
if (containingDirectory != null) {
final QualifiedName containingQName = QualifiedNameFinder.findCanonicalImportPath(containingDirectory, null);
if (containingQName != null && containingQName.getComponentCount() > 0) {
final QualifiedName absoluteQName = containingQName.append(myQualifiedName.toString());
final QualifiedNameResolverImpl absoluteVisitor =
(QualifiedNameResolverImpl)new QualifiedNameResolverImpl(absoluteQName).fromElement(foothold);
final Sdk sdk = PythonSdkType.getSdk(foothold);
if (sdk == null) return;
final VirtualFile skeletonsDir = PySdkUtil.findSkeletonsDir(sdk);
if (skeletonsDir == null) return;
final PsiDirectory directory = myContext.getPsiManager().findDirectory(skeletonsDir);
final PsiElement psiElement = absoluteVisitor.resolveModuleAt(directory);
if (psiElement != null)
myLibResults.add(psiElement);
}
}
}
示例8: resolveRelativeImportAsAbsolute
import com.intellij.openapi.roots.FileIndexFacade; //导入依赖的package包/类
/**
* Try to resolve relative import as absolute in roots, not in its parent directory.
*
* This may be useful for resolving to child skeleton modules located in other directories.
*
* @param foothold foothold file.
* @param qualifiedName relative import name.
* @return list of resolved elements.
*/
@NotNull
private static List<PsiElement> resolveRelativeImportAsAbsolute(@NotNull PsiFile foothold,
@NotNull QualifiedName qualifiedName) {
final VirtualFile virtualFile = foothold.getVirtualFile();
if (virtualFile == null) return Collections.emptyList();
final boolean inSource = FileIndexFacade.getInstance(foothold.getProject()).isInContent(virtualFile);
if (inSource) return Collections.emptyList();
final PsiDirectory containingDirectory = foothold.getContainingDirectory();
if (containingDirectory != null) {
final QualifiedName containingPath = QualifiedNameFinder.findCanonicalImportPath(containingDirectory, null);
if (containingPath != null && containingPath.getComponentCount() > 0) {
final QualifiedName absolutePath = containingPath.append(qualifiedName.toString());
final QualifiedNameResolver absoluteVisitor = new QualifiedNameResolverImpl(absolutePath).fromElement(foothold);
return absoluteVisitor.resultsAsList();
}
}
return Collections.emptyList();
}
示例9: createFile
import com.intellij.openapi.roots.FileIndexFacade; //导入依赖的package包/类
@Override
protected PsiFile createFile(@NotNull final Project project, @NotNull final VirtualFile vFile, @NotNull final FileType fileType) {
final FileIndexFacade fileIndex = ServiceManager.getService(project, FileIndexFacade.class);
if (fileIndex.isInLibraryClasses(vFile) || !fileIndex.isInSource(vFile)) {
String name = vFile.getName();
// skip inners & anonymous (todo: read actual class name from file)
int dotIndex = name.lastIndexOf('.');
if (dotIndex < 0) dotIndex = name.length();
int index = name.lastIndexOf('$', dotIndex);
if (index <= 0 || index == dotIndex - 1) {
return new ClsFileImpl((PsiManagerImpl)PsiManager.getInstance(project), this);
}
}
return null;
}
示例10: getClasses
import com.intellij.openapi.roots.FileIndexFacade; //导入依赖的package包/类
@NotNull
@Override
public PsiClass[] getClasses(@NotNull PsiDirectory dir) {
LOG.assertTrue(dir.isValid());
FileIndexFacade index = FileIndexFacade.getInstance(dir.getProject());
VirtualFile virtualDir = dir.getVirtualFile();
boolean onlyCompiled = index.isInLibraryClasses(virtualDir) && !index.isInSourceContent(virtualDir);
List<PsiClass> classes = null;
for (PsiFile file : dir.getFiles()) {
if (onlyCompiled && !(file instanceof ClsFileImpl)) {
continue;
}
if (file instanceof PsiClassOwner && file.getViewProvider().getLanguages().size() == 1) {
PsiClass[] psiClasses = ((PsiClassOwner)file).getClasses();
if (psiClasses.length == 0) continue;
if (classes == null) classes = new ArrayList<PsiClass>();
ContainerUtil.addAll(classes, psiClasses);
}
}
return classes == null ? PsiClass.EMPTY_ARRAY : classes.toArray(new PsiClass[classes.size()]);
}
示例11: processFilesWithText
import com.intellij.openapi.roots.FileIndexFacade; //导入依赖的package包/类
public boolean processFilesWithText(@NotNull final GlobalSearchScope scope,
final short searchContext,
final boolean caseSensitively,
@NotNull String text,
@NotNull final Processor<VirtualFile> processor) {
List<IdIndexEntry> entries = getWordEntries(text, caseSensitively);
if (entries.isEmpty()) return true;
final CommonProcessors.CollectProcessor<VirtualFile> collectProcessor = new CommonProcessors.CollectProcessor<VirtualFile>();
processFilesContainingAllKeys(scope, new Condition<Integer>() {
@Override
public boolean value(Integer integer) {
return (integer.intValue() & searchContext) != 0;
}
}, collectProcessor, entries);
final FileIndexFacade index = FileIndexFacade.getInstance(myManager.getProject());
return ContainerUtil.process(collectProcessor.getResults(), new ReadActionProcessor<VirtualFile>() {
@Override
public boolean processInReadAction(VirtualFile virtualFile) {
return !index.shouldBeFound(scope, virtualFile) || processor.process(virtualFile);
}
});
}
示例12: FileManagerImpl
import com.intellij.openapi.roots.FileIndexFacade; //导入依赖的package包/类
public FileManagerImpl(PsiManagerImpl manager, FileDocumentManager fileDocumentManager, FileIndexFacade fileIndex) {
myManager = manager;
myFileIndex = fileIndex;
myConnection = manager.getProject().getMessageBus().connect();
myFileDocumentManager = fileDocumentManager;
myConnection.subscribe(DumbService.DUMB_MODE, new DumbService.DumbModeListener() {
@Override
public void enteredDumbMode() {
updateAllViewProviders();
}
@Override
public void exitDumbMode() {
updateAllViewProviders();
}
});
Disposer.register(manager.getProject(), this);
}
示例13: MyRootIterator
import com.intellij.openapi.roots.FileIndexFacade; //导入依赖的package包/类
private MyRootIterator(final Project project,
final VirtualFile root,
@Nullable final Processor<FilePath> pathProcessor,
@Nullable final Processor<VirtualFile> fileProcessor,
@Nullable VirtualFileFilter directoryFilter) {
myProject = project;
myPathProcessor = pathProcessor;
myFileProcessor = fileProcessor;
myDirectoryFilter = directoryFilter;
myRoot = root;
final ProjectLevelVcsManager plVcsManager = ProjectLevelVcsManager.getInstance(project);
final AbstractVcs vcs = plVcsManager.getVcsFor(root);
myRootPresentFilter = (vcs == null) ? null : new MyRootFilter(root, vcs.getName());
if (myRootPresentFilter != null) {
myRootPresentFilter.init(ProjectLevelVcsManager.getInstance(myProject).getAllVcsRoots());
}
myExcludedFileIndex = PeriodicalTasksCloser.getInstance().safeGetService(project, FileIndexFacade.class);
}
示例14: startProcessingChanges
import com.intellij.openapi.roots.FileIndexFacade; //导入依赖的package包/类
Collection<Change> startProcessingChanges(final Project project, @Nullable final VcsDirtyScope scope) {
createReadChangesCache();
final Collection<Change> result = new ArrayList<Change>();
myChangesBeforeUpdate = new OpenTHashSet<Change>(myChanges);
final FileIndexFacade fileIndex = PeriodicalTasksCloser.getInstance().safeGetService(project, FileIndexFacade.class);
for (Change oldBoy : myChangesBeforeUpdate) {
final ContentRevision before = oldBoy.getBeforeRevision();
final ContentRevision after = oldBoy.getAfterRevision();
if (scope == null || before != null && scope.belongsTo(before.getFile()) || after != null && scope.belongsTo(after.getFile())
|| isIgnoredChange(oldBoy, fileIndex)) {
result.add(oldBoy);
myChanges.remove(oldBoy);
myReadChangesCache = null;
}
}
return result;
}
示例15: getVcsRootFor
import com.intellij.openapi.roots.FileIndexFacade; //导入依赖的package包/类
@Override
@Nullable
public VirtualFile getVcsRootFor(final VirtualFile file) {
if (myBaseDir != null && PeriodicalTasksCloser.getInstance().safeGetService(myProject, FileIndexFacade.class)
.isValidAncestor(myBaseDir, file)) {
return myBaseDir;
}
final VirtualFile contentRoot = ProjectRootManager.getInstance(myProject).getFileIndex().getContentRootForFile(file);
if (contentRoot != null) {
return contentRoot;
}
final StorageScheme storageScheme = ((ProjectEx) myProject).getStateStore().getStorageScheme();
if (StorageScheme.DIRECTORY_BASED.equals(storageScheme) && (myBaseDir != null)) {
final VirtualFile ideaDir = myBaseDir.findChild(Project.DIRECTORY_STORE_FOLDER);
if (ideaDir != null && ideaDir.isValid() && ideaDir.isDirectory()) {
if (VfsUtilCore.isAncestor(ideaDir, file, false)) {
return ideaDir;
}
}
}
return null;
}