use of jetbrains.communicator.core.vfs.VFile in project intellij-plugins by JetBrains.
the class ProjectsDataFiller method fillProjectData.
private void fillProjectData(Project openProject, final ProjectsData result) {
VirtualFile[] openFiles = FileEditorManager.getInstance(openProject).getOpenFiles();
List<VFile> fileInfos = new ArrayList<>(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);
}
}
}
result.setProjectFiles(openProject.getName(), fileInfos.toArray(new VFile[fileInfos.size()]));
}
use of jetbrains.communicator.core.vfs.VFile in project intellij-plugins by JetBrains.
the class VFSUtil method _createFileFrom.
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;
}
use of jetbrains.communicator.core.vfs.VFile in project intellij-plugins by JetBrains.
the class CodePointerXmlMessageTest method testComplexVFile.
public void testComplexVFile() throws Throwable {
VFile expected = VFile.create("foo/bar", "bar", false);
expected.setContents("#$@#@#$что-то такое");
expected.setProjectName("project");
expected.setFQName("some FQName");
expected.setSourcePath("some source path");
_test("", expected, new CodePointer(1, 2, 3, 4));
}
use of jetbrains.communicator.core.vfs.VFile in project intellij-plugins by JetBrains.
the class ProjectsDataTest method testProjectNameInFileInfo.
public void testProjectNameInFileInfo() throws Exception {
VFile fileInfo = VFile.create("Path");
myProjectsData.setProjectFiles(VFile.PROJECT_NAME_ATTR, new VFile[] { fileInfo });
assertEquals(VFile.PROJECT_NAME_ATTR, fileInfo.getProjectName());
VFile fileInfo1 = VFile.create("Path");
myProjectsData.addNonProjectFile(fileInfo1);
assertNull(fileInfo1.getProjectName(), fileInfo1.getProjectName());
VFile vFile = myProjectsData.getProjectFiles(VFile.PROJECT_NAME_ATTR)[0];
assertEquals("Should be equal", fileInfo, vFile);
assertEquals("Project name shoud be kept", VFile.PROJECT_NAME_ATTR, vFile.getProjectName());
VFile vFile1 = myProjectsData.getNonProjectFiles()[0];
assertEquals("Should be equal", fileInfo1, vFile1);
assertNull("Project name shoud be kept", vFile1.getProjectName());
}
use of jetbrains.communicator.core.vfs.VFile in project intellij-plugins by JetBrains.
the class IncomingCodePointerMessage method createPositionCorrector.
private PositionCorrector createPositionCorrector() {
updateFacade();
VFile localFile = (VFile) myRemoteFile.clone();
myFacade.fillFileContents(localFile);
return new PositionCorrector(myFacade, myRemoteFile.getContents(), localFile.getContents());
}
Aggregations