コード例 #1
0
 protected SingleRootFileViewProvider(
     @NotNull PsiManager manager,
     @NotNull VirtualFile virtualFile,
     final boolean physical,
     @NotNull Language language) {
   myManager = manager;
   myVirtualFile = virtualFile;
   myEventSystemEnabled = physical;
   myBaseLanguage = language;
   setContent(new VirtualFileContent());
   myPhysical =
       isEventSystemEnabled()
           && !(virtualFile instanceof LightVirtualFile)
           && !(virtualFile.getFileSystem() instanceof NonPhysicalFileSystem);
   myExclusionManager = ProjectFileExclusionManager.SERVICE.getInstance(manager.getProject());
 }
コード例 #2
0
  private PsiFile createFile() {
    try {
      final VirtualFile vFile = getVirtualFile();
      if (vFile.isDirectory()) return null;
      if (isIgnored()) return null;

      final Project project = myManager.getProject();
      if (isPhysical()) { // check directories consistency
        final VirtualFile parent = vFile.getParent();
        if (parent == null) return null;
        final PsiDirectory psiDir = getManager().findDirectory(parent);
        if (psiDir == null) return null;
      }

      FileType fileType = vFile.getFileType();
      PsiFile file = null;
      if (fileType.isBinary() || vFile.isSpecialFile()) {
        // TODO check why ClsFileImpl doesn't created automatically with create method
        file = new ClsFileImpl((PsiManagerImpl) getManager(), this);
        // file = new PsiBinaryFileImpl((PsiManagerImpl) getManager(), this);
      } else {
        if (!isTooLarge(vFile)) {
          final PsiFile psiFile = createFile(getBaseLanguage());
          if (psiFile != null) file = psiFile;
        } else {
          file = new PsiPlainTextFileImpl(this);
        }
      }
      return file;
    } catch (ProcessCanceledException e) {
      e.printStackTrace();
      throw e;

    } catch (Throwable e) {
      e.printStackTrace();
      LOG.error(e);
      return null;
    }
  }
コード例 #3
0
 public SingleRootFileViewProvider(
     @NotNull PsiManager manager, @NotNull VirtualFile virtualFile, final boolean physical) {
   this(manager, virtualFile, physical, calcBaseLanguage(virtualFile, manager.getProject()));
 }