Java 类com.intellij.psi.impl.file.impl.FileManager 实例源码

项目:intellij    文件:GlobFindUsagesTest.java   
@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);
}
项目:intellij    文件:StubOCWorkspaceManager.java   
private static void enableLanguageSupport(Project project) {
  OCLanguage.LANGUAGE_SUPPORT_DISABLED.set(project, false);
  UIUtil.invokeLaterIfNeeded(
      () ->
          ApplicationManager.getApplication()
              .runWriteAction(
                  () -> {
                    if (project.isDisposed()) {
                      return;
                    }
                    Language langToReset = PlainTextLanguage.INSTANCE;
                    FileManager fileManager =
                        ((PsiManagerEx) PsiManager.getInstance(project)).getFileManager();
                    for (PsiFile file : fileManager.getAllCachedFiles()) {
                      if (file.getLanguage() == langToReset) {
                        VirtualFile vf = OCInclusionContextUtil.getVirtualFile(file);
                        if (vf != null) {
                          fileManager.setViewProvider(vf, null);
                        }
                      }
                    }
                  }));
}
项目:consulo-java    文件:PackageUtil.java   
public static PsiDirectory[] convertRoots(final FileManager fileManager, VirtualFile[] roots)
{
    ArrayList<PsiDirectory> dirs = new ArrayList<PsiDirectory>();

    for(VirtualFile root : roots)
    {
        if(!root.isValid())
        {
            LOG.error("Root " + root + " is not valid!");
        }
        PsiDirectory dir = fileManager.findDirectory(root);
        if(dir != null)
        {
            dirs.add(dir);
        }
    }

    return dirs.toArray(new PsiDirectory[dirs.size()]);
}
项目:intellij-ce-playground    文件:ProjectRootUtil.java   
public static PsiDirectory[] convertRoots(final FileManager fileManager, VirtualFile[] roots) {
  ArrayList<PsiDirectory> dirs = new ArrayList<PsiDirectory>();

  for (VirtualFile root : roots) {
    if (!root.isValid()) {
      LOG.error("Root " + root + " is not valid!");
    }
    PsiDirectory dir = fileManager.findDirectory(root);
    if (dir != null) {
      dirs.add(dir);
    }
  }

  return dirs.toArray(new PsiDirectory[dirs.size()]);
}
项目:intellij-ce-playground    文件:SingleRootFileViewProvider.java   
@Override
@Nullable
public final PsiFile getPsi(@NotNull Language target) {
  if (!isPhysical()) {
    FileManager fileManager = ((PsiManagerEx)myManager).getFileManager();
    VirtualFile virtualFile = getVirtualFile();
    if (fileManager.findCachedViewProvider(virtualFile) == null) {
      fileManager.setViewProvider(virtualFile, this);
    }
  }
  return getPsiInner(target);
}
项目:intellij-ce-playground    文件:PsiManagerImpl.java   
@Override
public void dropResolveCaches() {
  FileManager fileManager = myFileManager;
  if (fileManager instanceof FileManagerImpl) { // mock tests
    ((FileManagerImpl)fileManager).processQueue();
  }
  beforeChange(true);
  beforeChange(false);
}
项目:intellij-ce-playground    文件:MockPsiManager.java   
@Override
@NotNull
public FileManager getFileManager() {
  if (myMockFileManager == null) {
    myMockFileManager = new MockFileManager(this);
  }
  return myMockFileManager;
}
项目:intellij    文件:ProjectViewUi.java   
private static EditorEx createEditor(String tooltip) {
  Project project = getProject();
  LightVirtualFile virtualFile =
      new LightVirtualFile("mockProjectViewFile", ProjectViewLanguage.INSTANCE, "");
  final Document document =
      ((EditorFactoryImpl) EditorFactory.getInstance()).createDocument(true);
  ((DocumentImpl) document).setAcceptSlashR(true);
  FileDocumentManagerImpl.registerDocument(document, virtualFile);

  FileManager fileManager = ((PsiManagerEx) PsiManager.getInstance(project)).getFileManager();
  fileManager.setViewProvider(virtualFile, fileManager.createFileViewProvider(virtualFile, true));

  if (project.isDefault()) {
    // Undo-redo doesn't work with the default project.
    // Explicitly turn it off to avoid error dialogs.
    UndoUtil.disableUndoFor(document);
  }

  EditorEx editor =
      (EditorEx)
          EditorFactory.getInstance()
              .createEditor(document, project, ProjectViewFileType.INSTANCE, false);
  final EditorSettings settings = editor.getSettings();
  settings.setLineNumbersShown(false);
  settings.setLineMarkerAreaShown(false);
  settings.setFoldingOutlineShown(false);
  settings.setRightMarginShown(false);
  settings.setAdditionalPageAtBottom(false);
  editor.getComponent().setMinimumSize(getEditorSize());
  editor.getComponent().setPreferredSize(getEditorSize());
  editor.getComponent().setToolTipText(tooltip);
  editor.getComponent().setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, null);
  editor.getComponent().setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, null);
  return editor;
}
项目:tools-idea    文件:ProjectRootUtil.java   
public static PsiDirectory[] convertRoots(final FileManager fileManager, VirtualFile[] roots) {
  ArrayList<PsiDirectory> dirs = new ArrayList<PsiDirectory>();

  for (VirtualFile root : roots) {
    if (!root.isValid()) {
      LOG.error("Root " + root + " is not valid!");
    }
    PsiDirectory dir = fileManager.findDirectory(root);
    if (dir != null) {
      dirs.add(dir);
    }
  }

  return dirs.toArray(new PsiDirectory[dirs.size()]);
}
项目:tools-idea    文件:SingleRootFileViewProvider.java   
@Override
@Nullable
public final PsiFile getPsi(@NotNull Language target) {
  if (!isPhysical()) {
    FileManager fileManager = ((PsiManagerEx)myManager).getFileManager();
    VirtualFile virtualFile = getVirtualFile();
    if (fileManager.findCachedViewProvider(virtualFile) == null) {
      fileManager.setViewProvider(virtualFile, this);
    }
  }
  return getPsiInner(target);
}
项目:tools-idea    文件:PsiManagerImpl.java   
@Override
public void dropResolveCaches() {
  FileManager fileManager = myFileManager;
  if (fileManager instanceof FileManagerImpl) { // mock tests
    ((FileManagerImpl)fileManager).processQueue();
  }
  beforeChange(true);
  beforeChange(false);
}
项目:tools-idea    文件:MockPsiManager.java   
@Override
@NotNull
public FileManager getFileManager() {
  if (myMockFileManager == null) {
    myMockFileManager = new MockFileManager(this);
  }
  return myMockFileManager;
}
项目:consulo    文件:AbstractFileViewProvider.java   
@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);
}
项目:consulo    文件:MockPsiManager.java   
@Override
@Nonnull
public FileManager getFileManager() {
  if (myMockFileManager == null) {
    myMockFileManager = new MockFileManager(this);
  }
  return myMockFileManager;
}
项目:intellij-ce-playground    文件:PsiManagerEx.java   
@NotNull
public abstract FileManager getFileManager();
项目:intellij-ce-playground    文件:PsiManagerImpl.java   
@Override
@NotNull
public FileManager getFileManager() {
  return myFileManager;
}
项目:intellij-ce-playground    文件:PostprocessReformattingAspect.java   
private void doPostponedFormattingInner(@NotNull FileViewProvider key) {
  final List<ASTNode> astNodes = getContext().myReformatElements.remove(key);
  final Document document = key.getDocument();
  // Sort ranges by end offsets so that we won't need any offset adjustment after reformat or reindent
  if (document == null) return;

  final VirtualFile virtualFile = key.getVirtualFile();
  if (!virtualFile.isValid()) return;

  PsiManager manager = key.getManager();
  if (manager instanceof PsiManagerEx) {
    FileManager fileManager = ((PsiManagerEx)manager).getFileManager();
    FileViewProvider viewProvider = fileManager.findCachedViewProvider(virtualFile);
    if (viewProvider != key) { // viewProvider was invalidated e.g. due to language level change
      if (viewProvider == null) viewProvider = fileManager.findViewProvider(virtualFile);
      if (viewProvider != null) {
        key = viewProvider;
      }
    }
  }

  final TreeSet<PostprocessFormattingTask> postProcessTasks = new TreeSet<PostprocessFormattingTask>();
  Collection<Disposable> toDispose = ContainerUtilRt.newArrayList();
  try {
    // process all roots in viewProvider to find marked for reformat before elements and create appropriate range markers
    handleReformatMarkers(key, postProcessTasks);
    toDispose.addAll(postProcessTasks);

    // then we create ranges by changed nodes. One per node. There ranges can intersect. Ranges are sorted by end offset.
    if (astNodes != null) createActionsMap(astNodes, key, postProcessTasks);

    if (Boolean.getBoolean("check.psi.is.valid") && ApplicationManager.getApplication().isUnitTestMode()) {
      checkPsiIsCorrect(key);
    }

    while (!postProcessTasks.isEmpty()) {
      // now we have to normalize actions so that they not intersect and ordered in most appropriate way
      // (free reformatting -> reindent -> formatting under reindent)
      final List<PostponedAction> normalizedActions = normalizeAndReorderPostponedActions(postProcessTasks, document);
      toDispose.addAll(normalizedActions);

      // only in following loop real changes in document are made
      for (final PostponedAction normalizedAction : normalizedActions) {
        CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(myPsiManager.getProject());
        boolean old = settings.ENABLE_JAVADOC_FORMATTING;
        settings.ENABLE_JAVADOC_FORMATTING = false;
        try {
          normalizedAction.execute(key);
        }
        finally {
          settings.ENABLE_JAVADOC_FORMATTING = old;
        }
      }
    }
  }
  finally {
    for (Disposable disposable : toDispose) {
      //noinspection SSBasedInspection
      disposable.dispose();
    }
  }
}
项目:TheRPlugin    文件:TheRCodeFragment.java   
@NotNull
private static FileManager getFileManager(@NotNull final Project project) {
  return ((PsiManagerEx)PsiManager.getInstance(project)).getFileManager();
}
项目:tools-idea    文件:PsiManagerEx.java   
@NotNull
public abstract FileManager getFileManager();
项目:tools-idea    文件:PsiManagerImpl.java   
@Override
@NotNull
public FileManager getFileManager() {
  return myFileManager;
}
项目:consulo    文件:PsiManagerEx.java   
@Nonnull
public abstract FileManager getFileManager();
项目:consulo    文件:PsiManagerImpl.java   
@Override
@Nonnull
public FileManager getFileManager() {
  return myFileManager;
}