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

项目:intellij-ce-playground    文件:PushedFilePropertiesUpdaterImpl.java   
private static void reloadPsi(final VirtualFile file, final Project project) {
  final FileManagerImpl fileManager = (FileManagerImpl)((PsiManagerEx)PsiManager.getInstance(project)).getFileManager();
  if (fileManager.findCachedViewProvider(file) != null) {
    UIUtil.invokeLaterIfNeeded(new Runnable() {
      @Override
      public void run() {
        if (project.isDisposed()) {
          return;
        }
        ApplicationManager.getApplication().runWriteAction(new Runnable() {
          @Override
          public void run() {
            fileManager.forceReload(file);
          }
        });
      }
    });
  }
}
项目:consulo    文件:PsiManagerImpl.java   
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);
}
项目:consulo    文件:PushedFilePropertiesUpdaterImpl.java   
private static void reloadPsi(final VirtualFile file, final Project project) {
  final FileManagerImpl fileManager = (FileManagerImpl)((PsiManagerEx)PsiManager.getInstance(project)).getFileManager();
  if (fileManager.findCachedViewProvider(file) != null) {
    Runnable runnable = new Runnable() {
      @Override
      public void run() {
        WriteAction.run(new ThrowableRunnable<RuntimeException>() {
          @Override
          public void run() throws RuntimeException {
            fileManager.forceReload(file);
          }
        });
      }
    };
    if (ApplicationManager.getApplication().isDispatchThread()) {
      runnable.run();
    } else {
      TransactionGuard.submitTransaction(project, runnable);
    }
  }
}
项目:intellij-ce-playground    文件:PsiModificationTrackerTest.java   
public void testClassShouldNotAppearWithoutEvents_NoPsiDirectory() throws IOException {
  PsiModificationTracker tracker = PsiManager.getInstance(getProject()).getModificationTracker();
  long count0 = tracker.getJavaStructureModificationCount();

  final PsiManagerEx psiManager = (PsiManagerEx)PsiManager.getInstance(getProject());
  VirtualFile parentDir = myFixture.getTempDirFixture().getFile("");
  assertNull(((FileManagerImpl)psiManager.getFileManager()).getCachedDirectory(parentDir));

  File file = new File(myFixture.getTempDirPath(), "Foo.java");
  FileUtil.writeToFile(file, "class Foo {}");
  assertNotNull(LocalFileSystem.getInstance().refreshAndFindFileByIoFile(file));

  assertNotNull(JavaPsiFacade.getInstance(getProject()).findClass("Foo", GlobalSearchScope.allScope(getProject())));
  assertFalse(count0 == tracker.getJavaStructureModificationCount());
}
项目:intellij-ce-playground    文件:PsiModificationTrackerTest.java   
public void testClassShouldNotAppearWithoutEvents_NoPsiGrandParentDirectory() throws IOException {
  PsiModificationTracker tracker = PsiManager.getInstance(getProject()).getModificationTracker();
  long count0 = tracker.getJavaStructureModificationCount();

  final PsiManagerEx psiManager = (PsiManagerEx)PsiManager.getInstance(getProject());
  VirtualFile parentDir = myFixture.getTempDirFixture().getFile("");
  assertNull(((FileManagerImpl)psiManager.getFileManager()).getCachedDirectory(parentDir));

  File file = new File(myFixture.getTempDirPath() + "/foo", "Foo.java");
  FileUtil.writeToFile(file, "package foo; class Foo {}");
  assertNotNull(LocalFileSystem.getInstance().refreshAndFindFileByIoFile(file));

  assertNotNull(JavaPsiFacade.getInstance(getProject()).findClass("foo.Foo", GlobalSearchScope.allScope(getProject())));
  assertFalse(count0 == tracker.getJavaStructureModificationCount());
}
项目:intellij-ce-playground    文件:PsiManagerImpl.java   
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;

  boolean isProjectDefault = project.isDefault();

  myFileManager = isProjectDefault ? new EmptyFileManager(this) : new FileManagerImpl(this, fileDocumentManager, fileIndex);

  myTreeChangePreprocessors.add((PsiTreeChangePreprocessor)modificationTracker);
  Collections.addAll(myTreeChangePreprocessors, Extensions.getExtensions(PsiTreeChangePreprocessor.EP_NAME, myProject));

  Disposer.register(project, new Disposable() {
    @Override
    public void dispose() {
      myIsDisposed = true;
    }
  });
}
项目: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    文件:CoreProjectEnvironment.java   
public CoreProjectEnvironment(@NotNull Disposable parentDisposable, @NotNull CoreApplicationEnvironment applicationEnvironment) {
  myParentDisposable = parentDisposable;
  myEnvironment = applicationEnvironment;
  myProject = createProject(myEnvironment.getApplication().getPicoContainer(), myParentDisposable);

  preregisterServices();

  myFileIndexFacade = createFileIndexFacade();
  myMessageBus = MessageBusFactory.newMessageBus("CoreProjectEnvironment");

  PsiModificationTrackerImpl modificationTracker = new PsiModificationTrackerImpl(myProject);
  myProject.registerService(PsiModificationTracker.class, modificationTracker);
  myProject.registerService(FileIndexFacade.class, myFileIndexFacade);
  myProject.registerService(ResolveCache.class, new ResolveCache(myMessageBus));

  myPsiManager = new PsiManagerImpl(myProject, null, null, myFileIndexFacade, myMessageBus, modificationTracker);
  ((FileManagerImpl) myPsiManager.getFileManager()).markInitialized();
  registerProjectComponent(PsiManager.class, myPsiManager);
  myProject.registerService(SmartPointerManager.class, SmartPointerManagerImpl.class);
  registerProjectComponent(PsiDocumentManager.class, new CorePsiDocumentManager(myProject, myPsiManager,
                                                                                myMessageBus,
                                                                                new MockDocumentCommitProcessor()));

  myProject.registerService(ResolveScopeManager.class, createResolveScopeManager(myPsiManager));

  myProject.registerService(PsiFileFactory.class, new PsiFileFactoryImpl(myPsiManager));
  myProject.registerService(CachedValuesManager.class, new CachedValuesManagerImpl(myProject, new PsiCachedValuesFactory(myPsiManager)));
  myProject.registerService(PsiDirectoryFactory.class, new PsiDirectoryFactoryImpl(myPsiManager));
  myProject.registerService(ProjectScopeBuilder.class, createProjectScopeBuilder());
  myProject.registerService(DumbService.class, new MockDumbService(myProject));
  myProject.registerService(CoreEncodingProjectManager.class, CoreEncodingProjectManager.class);
}
项目:tools-idea    文件:PsiManagerImpl.java   
public PsiManagerImpl(Project project,
                      FileDocumentManager fileDocumentManager,
                      PsiBuilderFactory psiBuilderFactory,
                      FileIndexFacade excludedFileIndex,
                      MessageBus messageBus,
                      PsiModificationTracker modificationTracker) {
  myProject = project;
  myExcludedFileIndex = excludedFileIndex;
  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;

  boolean isProjectDefault = project.isDefault();

  myFileManager = isProjectDefault ? new EmptyFileManager(this) : new FileManagerImpl(this, fileDocumentManager, excludedFileIndex);

  myTreeChangePreprocessors.add((PsiTreeChangePreprocessor)modificationTracker);
  Collections.addAll(myTreeChangePreprocessors, Extensions.getExtensions(PsiTreeChangePreprocessor.EP_NAME, myProject));

  Disposer.register(project, new Disposable() {
    @Override
    public void dispose() {
      myIsDisposed = true;
    }
  });
}
项目: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    文件:CoreProjectEnvironment.java   
public CoreProjectEnvironment(Disposable parentDisposable, CoreApplicationEnvironment applicationEnvironment) {
  myParentDisposable = parentDisposable;
  myEnvironment = applicationEnvironment;
  myProject = new MockProject(myEnvironment.getApplication().getPicoContainer(), myParentDisposable);

  preregisterServices();

  myFileIndexFacade = createFileIndexFacade();
  myMessageBus = new MessageBusImpl("CoreProjectEnvironment", null);

  PsiModificationTrackerImpl modificationTracker = new PsiModificationTrackerImpl(myProject);
  myProject.registerService(PsiModificationTracker.class, modificationTracker);
  myProject.registerService(FileIndexFacade.class, myFileIndexFacade);
  myProject.registerService(ResolveCache.class, new ResolveCache(myMessageBus));

  registerProjectExtensionPoint(PsiTreeChangePreprocessor.EP_NAME, PsiTreeChangePreprocessor.class);
  myPsiManager = new PsiManagerImpl(myProject, null, null, myFileIndexFacade, myMessageBus, modificationTracker);
  ((FileManagerImpl) myPsiManager.getFileManager()).markInitialized();
  registerProjectComponent(PsiManager.class, myPsiManager);

  myProject.registerService(ResolveScopeManager.class, createResolveScopeManager(myPsiManager));

  myProject.registerService(PsiFileFactory.class, new PsiFileFactoryImpl(myPsiManager));
  myProject.registerService(CachedValuesManager.class, new CachedValuesManagerImpl(myProject, new PsiCachedValuesFactory(myPsiManager)));
  myProject.registerService(PsiDirectoryFactory.class, new PsiDirectoryFactoryImpl(myPsiManager));
  myProject.registerService(ProjectScopeBuilder.class, createProjectScopeBuilder());
  myProject.registerService(DumbService.class, new MockDumbService(myProject));
}
项目:consulo    文件:PsiDocumentManagerBase.java   
void forceReload(VirtualFile virtualFile, @Nullable FileViewProvider viewProvider) {
  if (viewProvider != null) {
    ((AbstractFileViewProvider)viewProvider).markInvalidated();
  }
  if (virtualFile != null) {
    ((FileManagerImpl)((PsiManagerEx)myPsiManager).getFileManager()).forceReload(virtualFile);
  }
}
项目:consulo    文件:CoreProjectEnvironment.java   
public CoreProjectEnvironment(Disposable parentDisposable, CoreApplicationEnvironment applicationEnvironment) {
  myParentDisposable = parentDisposable;
  myEnvironment = applicationEnvironment;
  myProject = new MockProject(myEnvironment.getApplication().getPicoContainer(), myParentDisposable);

  preregisterServices();

  myFileIndexFacade = createFileIndexFacade();
  myMessageBus = (MessageBusImpl)myProject.getMessageBus();

  PsiModificationTrackerImpl modificationTracker = new PsiModificationTrackerImpl(myProject);
  myProject.registerService(PsiModificationTracker.class, modificationTracker);
  myProject.registerService(FileIndexFacade.class, myFileIndexFacade);
  myProject.registerService(ResolveCache.class, new ResolveCache(myMessageBus));

  registerProjectExtensionPoint(PsiTreeChangePreprocessor.EP_NAME, PsiTreeChangePreprocessor.class);
  myPsiManager = new PsiManagerImpl(myProject, null, null, myFileIndexFacade, myMessageBus, modificationTracker);
  ((FileManagerImpl)myPsiManager.getFileManager()).markInitialized();
  registerProjectComponent(PsiManager.class, myPsiManager);

  registerProjectComponent(PsiDocumentManager.class, new CorePsiDocumentManager(myProject, myPsiManager, myMessageBus, new MockDocumentCommitProcessor()));

  myProject.registerService(ResolveScopeManager.class, createResolveScopeManager(myPsiManager));

  myProject.registerService(PsiFileFactory.class, new PsiFileFactoryImpl(myPsiManager));
  myProject.registerService(CachedValuesManager.class, new CachedValuesManagerImpl(myProject, new PsiCachedValuesFactory(myPsiManager)));
  myProject.registerService(ProjectScopeBuilder.class, createProjectScopeBuilder());
  myProject.registerService(DumbService.class, new MockDumbService(myProject));
}