Package jetbrains.communicator.core.vfs

Examples of jetbrains.communicator.core.vfs.VFile


  }

  public void testInSourceRoot() throws Exception {
    VirtualFile file = mySourceRoot.createChildData(this, "some.file");

    VFile vFile = checkVFile(file, getProject(), "/src/some.file", file.getPath());
    assertEquals("Wrong src path", "/some.file", vFile.getSourcePath());

    // Change our source path:
    final VirtualFile newSrc = myContentRoot.createChildDirectory(this, "new_src");
    updateRoots(new Updater() {
      @Override
View Full Code Here


  private interface Updater {
    void update(ModifiableRootModel modifiableModel);
  }

  private VFile checkVFile(VirtualFile file, Project project, String expectedPath, String expectedFullPath) {
    VFile vFile = VFSUtil.createFileFrom(file, project);

    if (project != null) {
      assertEquals("Wrong project", project.getName(), vFile.getProjectName());
    }
    else {
      assertNull("No project expected", vFile.getProjectName());
    }

    assertEquals("Wrong content path", expectedPath, vFile.getContentPath());
    assertEquals("Wrong full path", expectedFullPath, vFile.getFullPath());
    assertEquals("Should restore Virtual File from " + vFile,
        file, VFSUtil.getVirtualFile(vFile));

    return vFile;
  }
View Full Code Here

  public void fillRequest(Element element) {
    myFile.saveTo(element);
  }

  public void processResponse(Element responseElement) {
    VFile from = VFile.createFrom(responseElement);
    if (from != null) {
      myFile.setContents(from.getContents());
    }
  }
View Full Code Here

    return result[0];
  }

  private static VFile _createFileFrom(Project project, VirtualFile file) {
    VFile result = null;

    Document document = FileDocumentManager.getInstance().getDocument(file);

    Project[] openProjects = getOpenProjects();
    for (int i = 0; i < openProjects.length && result == null; i++) {
      Project openProject = openProjects[i];
      if (!openProject.isInitialized() && !ApplicationManager.getApplication().isUnitTestMode()) continue;

      if (document != null) {
        PsiFile psiFile = PsiDocumentManager.getInstance(openProject).getPsiFile(document);
        if (isJavaFile(psiFile)) {
          PsiJavaFile psiJavaFile = (PsiJavaFile) psiFile;
          assert psiJavaFile != null;
          final PsiClass[] classes = psiJavaFile.getClasses();
          if (classes.length > 0) {
            result = createResultIfNeeded(result, file);
            result.setFQName(classes[0].getQualifiedName());
          }
        }
      }

      ProjectFileIndex projectFileIndex = ProjectRootManager.getInstance(openProject).getFileIndex();
      if (projectFileIndex.isInSource(file)) {
        VirtualFile sourceRoot = projectFileIndex.getSourceRootForFile(file);
        result = createResultIfNeeded(result, file);
        result.setSourcePath(getRelativePath(file, sourceRoot));
      }

      if (projectFileIndex.isInContent(file)) {
        VirtualFile contentRoot = projectFileIndex.getContentRootForFile(file);
        result = createResultIfNeeded(result, file);
        result.setContentPath(getRelativePath(file, contentRoot));
      }
    }

    if (result == null) {
      result = VFile.create(file.getPath(), null, file.isWritable());
    }

    if (project != null) {
      result.setProjectName(project.getName());
    }

    return result;
  }
View Full Code Here

    }
  }

  private PositionCorrector createPositionCorrector() {
    updateFacade();
    VFile localFile = (VFile) myRemoteFile.clone();
    myFacade.fillFileContents(localFile);
    return new PositionCorrector(myFacade, myRemoteFile.getContents(), localFile.getContents());
  }
View Full Code Here

  private void fillProjectData(Project openProject, final ProjectsData result) {
    VirtualFile[] openFiles = FileEditorManager.getInstance(openProject).getOpenFiles();

    List<VFile> fileInfos = new ArrayList<VFile>(openFiles.length);
    for (VirtualFile openFile : openFiles) {
      VFile vFile = VFSUtil.createFileFrom(openFile, openProject);
      if (vFile != null) {
        if (vFile.getProjectName() != null) {
          fileInfos.add(vFile);
        } else {
          result.addNonProjectFile(vFile);
        }
      }
View Full Code Here

TOP

Related Classes of jetbrains.communicator.core.vfs.VFile

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.