本文整理汇总了Java中com.intellij.openapi.roots.FileIndexFacade类的典型用法代码示例。如果您正苦于以下问题:Java FileIndexFacade类的具体用法?Java FileIndexFacade怎么用?Java FileIndexFacade使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FileIndexFacade类属于com.intellij.openapi.roots包,在下文中一共展示了FileIndexFacade类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:TypeCorrector.java
示例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);
}
});
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:ClsFileImpl.java
示例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()]);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:CoreJavaDirectoryService.java
示例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);
}
});
}
});
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:PsiSearchHelperImpl.java
示例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);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:FileManagerImpl.java
示例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;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:ModuleDefaultVcsRootPolicy.java
示例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);
}
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:QualifiedNameResolverImpl.java
示例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();
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:28,代码来源:ResolveImportUtil.java
示例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;
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:18,代码来源:ClassFileViewProvider.java
示例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()]);
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:24,代码来源:CoreJavaDirectoryService.java
示例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);
}
});
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:25,代码来源:PsiSearchHelperImpl.java
示例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);
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:21,代码来源:FileManagerImpl.java
示例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);
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:20,代码来源:VcsRootIterator.java
示例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;
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:18,代码来源:LocalChangeListImpl.java
示例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;
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:23,代码来源:ModuleDefaultVcsRootPolicy.java
示例16: handleCommitWithoutPsi
import com.intellij.openapi.roots.FileIndexFacade; //导入依赖的package包/类
void handleCommitWithoutPsi(@Nonnull Document document) {
final UncommittedInfo prevInfo = clearUncommittedInfo(document);
if (prevInfo == null) {
return;
}
if (!myProject.isInitialized() || myProject.isDisposed()) {
return;
}
myUncommittedDocuments.remove(document);
VirtualFile virtualFile = FileDocumentManager.getInstance().getFile(document);
if (virtualFile == null || !FileIndexFacade.getInstance(myProject).isInContent(virtualFile)) {
return;
}
final PsiFile psiFile = getPsiFile(document);
if (psiFile == null) {
return;
}
// we can end up outside write action here if the document has forUseInNonAWTThread=true
ApplicationManager.getApplication().runWriteAction((ExternalChangeAction)((AbstractFileViewProvider)psiFile.getViewProvider())::onContentReload);
}
开发者ID:consulo,项目名称:consulo,代码行数:26,代码来源:PsiDocumentManagerBase.java
示例17: PsiManagerImpl
import com.intellij.openapi.roots.FileIndexFacade; //导入依赖的package包/类
public PsiManagerImpl(Project project,
FileDocumentManager fileDocumentManager,
PsiBuilderFactory psiBuilderFactory,
FileIndexFacade fileIndex,
MessageBus messageBus,
PsiModificationTracker modificationTracker) {
myProject = project;
myFileIndex = fileIndex;
myMessageBus = messageBus;
myModificationTracker = modificationTracker;
//We need to initialize PsiBuilderFactory service so it won't initialize under PsiLock from ChameleonTransform
@SuppressWarnings({"UnusedDeclaration", "UnnecessaryLocalVariable"}) Object used = psiBuilderFactory;
myFileManager = new FileManagerImpl(this, fileDocumentManager, fileIndex);
myTreeChangePreprocessors.add((PsiTreeChangePreprocessor)modificationTracker);
Disposer.register(project, () -> myIsDisposed = true);
}
开发者ID:consulo,项目名称:consulo,代码行数:21,代码来源:PsiManagerImpl.java
示例18: 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;
Disposer.register(manager.getProject(), this);
LowMemoryWatcher.register(this::processQueue, this);
myConnection.subscribe(DumbService.DUMB_MODE, new DumbService.DumbModeListener() {
@Override
public void enteredDumbMode() {
processFileTypesChanged();
}
@Override
public void exitDumbMode() {
processFileTypesChanged();
}
});
}
开发者ID:consulo,项目名称:consulo,代码行数:23,代码来源:FileManagerImpl.java
示例19: createFile
import com.intellij.openapi.roots.FileIndexFacade; //导入依赖的package包/类
@Override
protected PsiFile createFile(@NotNull Project project, @NotNull VirtualFile file, @NotNull FileType fileType)
{
FileIndexFacade fileIndex = ServiceManager.getService(project, FileIndexFacade.class);
if(!fileIndex.isInLibraryClasses(file) && fileIndex.isInSource(file) || fileIndex.isExcludedFile(file))
{
return new PsiBinaryFileImpl((PsiManagerImpl) getManager(), this);
}
// skip inner, anonymous, missing and corrupted classes
try
{
if(!isInnerClass(file))
{
return new ClsFileImpl(this);
}
}
catch(Exception e)
{
Logger.getInstance(ClassFileViewProvider.class).debug(file.getPath(), e);
}
return null;
}
开发者ID:consulo,项目名称:consulo-java,代码行数:25,代码来源:ClassFileViewProvider.java
示例20: resolve
import com.intellij.openapi.roots.FileIndexFacade; //导入依赖的package包/类
@Override
public LuaPsiElement resolve(LuaReferenceElement luaReferenceElement, boolean incompleteCode) {
final Project project = luaReferenceElement.getProject();
final FileIndexFacade fileIndexFacade = ProjectFileIndexFacade.getInstance(project);
final PsiManager psiManager = PsiManager.getInstance(luaReferenceElement.getProject());
final PsiFile psiFile = luaReferenceElement.getContainingFile();
final VirtualFile virtualFile = psiFile.getVirtualFile();
String path = luaReferenceElement.getName();
if (path != null) {
path = path.replace('.', '/').concat(".").concat(LuaFileType.DEFAULT_EXTENSION);
final VirtualFile file = project.getBaseDir().findFileByRelativePath(path);
if (file != null) {
final PsiFile resolvedPsiFile = psiManager.findFile(file);
if (resolvedPsiFile != null && resolvedPsiFile instanceof LuaPsiFile) {
final LuaExpressionList returnedValue = ((LuaPsiFile) resolvedPsiFile).getReturnedValue();
LuaExpression expression = null;
if (returnedValue != null) {
expression = returnedValue .getLuaExpressions().get(0);
}
if (expression instanceof LuaReferenceElement) {
return (LuaPsiElement) ((LuaReferenceElement) expression).resolve();
}
return expression;
}
}
}
return null;
}
开发者ID:internetisalie,项目名称:lua-for-idea,代码行数:33,代码来源:LuaRequireResolver.java
注:本文中的com.intellij.openapi.roots.FileIndexFacade类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论