use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.
the class MemoryLuceneSearcherTest method initializesIndexForExistedFiles.
@Test
public void initializesIndexForExistedFiles() throws Exception {
VirtualFileSystem virtualFileSystem = virtualFileSystem();
VirtualFile folder = virtualFileSystem.getRoot().createFolder("folder");
folder.createFile("xxx.txt", TEST_CONTENT[2]);
folder.createFile("zzz.txt", TEST_CONTENT[1]);
searcher.init(virtualFileSystem);
List<String> paths = searcher.search(new QueryExpression().setText("think")).getFilePaths();
assertEquals(newArrayList("/folder/zzz.txt"), paths);
}
use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.
the class WorkspaceTest method testAddingNewModule.
@Test
public void testAddingNewModule() throws Exception {
String pom = "<groupId>test</groupId>" + "<artifactId>testArtifact</artifactId>" + "<version>42</version>" + "<modules>" + " <module>module1</module>" + "</modules>";
FolderEntry parentFolder = createTestProject("parent", pom);
String pomModule1 = "<groupId>test</groupId>" + "<artifactId>testModule1</artifactId>" + "<version>1</version>" + "<dependencies>" + " <dependency>" + " <groupId>junit</groupId>" + " <artifactId>junit</artifactId>" + " <version>4.12</version>" + " </dependency>" + "</dependencies>";
createTestProject("parent/module1", pomModule1);
IProject parent = ResourcesPlugin.getWorkspace().getRoot().getProject("parent");
mavenWorkspace.update(Collections.singletonList(parent));
mavenWorkspace.waitForUpdate();
assertThat(projectRegistry.getProjects()).hasSize(2).onProperty("path").containsOnly("/parent", "/parent/module1");
VirtualFile parentPom = parentFolder.getChild("pom.xml").getVirtualFile();
Model model = Model.readFrom(parentPom);
List<String> modules = new ArrayList<>(model.getModules());
modules.add("module2");
model.setModules(modules);
model.writeTo(parentPom);
String pomModule2 = "<groupId>module2</groupId>" + "<artifactId>testModule2</artifactId>" + "<version>2</version>" + "<dependencies>" + " <dependency>" + " <groupId>junit</groupId>" + " <artifactId>junit</artifactId>" + " <version>4.12</version>" + " </dependency>" + "</dependencies>";
createTestProject("parent/module2", pomModule2);
mavenWorkspace.update(Collections.singletonList(parent));
mavenWorkspace.waitForUpdate();
assertThat(projectRegistry.getProjects()).hasSize(3).onProperty("path").containsOnly("/parent", "/parent/module1", "/parent/module2");
}
use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.
the class FolderEntry method getChildren.
public List<VirtualFileEntry> getChildren(VirtualFileFilter filter) throws ServerException {
final List<VirtualFile> vfChildren = getVirtualFile().getChildren(filter);
final List<VirtualFileEntry> children = new ArrayList<>();
for (VirtualFile vf : vfChildren) {
if (vf.isFile()) {
children.add(new FileEntry(vf, projectRegistry));
} else {
children.add(new FolderEntry(vf, projectRegistry));
}
}
return children;
}
use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.
the class FolderEntry method getChildFiles.
/**
* Get child files of this folder. If current user doesn't have read access to some child they aren't added in result list.
*
* @throws ServerException
* if an error occurs
*/
public List<FileEntry> getChildFiles() throws ServerException {
List<VirtualFile> vfChildren = getVirtualFile().getChildren(FILES_FILTER);
final List<FileEntry> children = new ArrayList<>();
for (VirtualFile c : vfChildren) {
children.add(new FileEntry(c, projectRegistry));
}
return children;
}
use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.
the class FolderEntry method getChildFolders.
/**
* Gets child folders of this folder. If current user doesn't have read access to some child they aren't added in result list.
*
* @throws ServerException
* if an error occurs
*/
public List<FolderEntry> getChildFolders() throws ServerException {
List<VirtualFile> vfChildren = getVirtualFile().getChildren(FOLDER_FILTER);
final List<FolderEntry> children = new ArrayList<>();
for (VirtualFile c : vfChildren) {
children.add(new FolderEntry(c, projectRegistry));
}
return children;
}
Aggregations