com.intellij.psi.impl.file.impl.FileManager Java Examples

The following examples show how to use com.intellij.psi.impl.file.impl.FileManager. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GlobFindUsagesTest.java    From intellij with Apache License 2.0 6 votes vote down vote up
@Test
public void testInMemoryFileHandledGracefully() {
  createBuildFile(new WorkspacePath("java/com/google/BUILD"), "glob(['**/*.java'])");

  LightVirtualFile inMemoryFile =
      new LightVirtualFile("mockProjectViewFile", ProjectViewLanguage.INSTANCE, "");

  FileManager fileManager =
      ((PsiManagerEx) PsiManager.getInstance(getProject())).getFileManager();
  fileManager.setViewProvider(
      inMemoryFile, fileManager.createFileViewProvider(inMemoryFile, true));

  PsiFile psiFile = fileManager.findFile(inMemoryFile);

  FindUsages.findAllReferences(psiFile);
}
 
Example #2
Source File: AbstractFileViewProvider.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
@Nullable
public final PsiFile getPsi(@Nonnull Language target) {
  if (!isPhysical()) {
    FileManager fileManager = getManager().getFileManager();
    VirtualFile virtualFile = getVirtualFile();
    if (fileManager.findCachedViewProvider(virtualFile) == null && getCachedPsiFiles().isEmpty()) {
      fileManager.setViewProvider(virtualFile, this);
    }
  }
  return getPsiInner(target);
}
 
Example #3
Source File: PsiDocumentManagerBase.java    From consulo with Apache License 2.0 5 votes vote down vote up
void handleCommitWithoutPsi(@Nonnull Document document) {
  final UncommittedInfo prevInfo = clearUncommittedInfo(document);
  if (prevInfo == null) {
    return;
  }

  myUncommittedDocuments.remove(document);

  if (!myProject.isInitialized() || myProject.isDisposed() || myProject.isDefault()) {
    return;
  }

  VirtualFile virtualFile = FileDocumentManager.getInstance().getFile(document);
  if (virtualFile != null) {
    FileManager fileManager = getFileManager();
    FileViewProvider viewProvider = fileManager.findCachedViewProvider(virtualFile);
    if (viewProvider != null) {
      // we can end up outside write action here if the document has forUseInNonAWTThread=true
      ApplicationManager.getApplication().runWriteAction((ExternalChangeAction)() -> ((AbstractFileViewProvider)viewProvider).onContentReload());
    }
    else if (FileIndexFacade.getInstance(myProject).isInContent(virtualFile)) {
      ApplicationManager.getApplication().runWriteAction((ExternalChangeAction)() -> ((FileManagerImpl)fileManager).firePropertyChangedForUnloadedPsi());
    }
  }

  runAfterCommitActions(document);
}
 
Example #4
Source File: MockPsiManager.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
@Nonnull
public FileManager getFileManager() {
  if (myMockFileManager == null) {
    myMockFileManager = new MockFileManager(this);
  }
  return myMockFileManager;
}
 
Example #5
Source File: PsiDocumentManagerBase.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
private FileManager getFileManager() {
  return ((PsiManagerEx)myPsiManager).getFileManager();
}
 
Example #6
Source File: PsiManagerEx.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
public abstract FileManager getFileManager();
 
Example #7
Source File: PsiManagerImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
@Nonnull
public FileManager getFileManager() {
  return myFileManager;
}