Search in sources :

Example 21 with Path

use of org.eclipse.xtend.lib.macro.file.Path in project xtext-xtend by eclipse.

the class JavaIoFileSystemTest method testMakeAndDeleteFile.

@Test
public void testMakeAndDeleteFile() {
    final Path path = new Path("/foo/src/my/pack/Foo.txt");
    Assert.assertFalse(this.fs.exists(path));
    this.fs.setContents(path, "Hello Foo");
    Assert.assertTrue(this.fs.exists(path));
    Assert.assertEquals("Hello Foo", this.fs.getContents(path));
    Assert.assertTrue(this.fs.isFile(path));
    Assert.assertFalse(this.fs.isFolder(path));
    this.fs.delete(path);
    Assert.assertFalse(this.fs.exists(path));
    Assert.assertFalse(this.fs.isFile(path));
    Assert.assertFalse(this.fs.isFolder(path));
}
Also used : Path(org.eclipse.xtend.lib.macro.file.Path) Test(org.junit.Test)

Example 22 with Path

use of org.eclipse.xtend.lib.macro.file.Path in project xtext-xtend by eclipse.

the class JavaIoFileSystemTest method testGetFolderURI.

@Test
public void testGetFolderURI() {
    final Path path = new Path("/foo/bar");
    Assert.assertFalse(this.fs.exists(path));
    Assert.assertNotNull(this.fs.toURI(path));
    Path _append = path.append("Foo.txt");
    this.fs.setContents(_append, "Hello Foo");
    Assert.assertTrue(this.fs.exists(path));
    Assert.assertNotNull(this.fs.toURI(path));
}
Also used : Path(org.eclipse.xtend.lib.macro.file.Path) Test(org.junit.Test)

Example 23 with Path

use of org.eclipse.xtend.lib.macro.file.Path in project xtext-xtend by eclipse.

the class ChangeListenerAddingFileSystemSupportTest method setup.

@Before
public void setup() {
    UIResourceChangeRegistry _uIResourceChangeRegistry = new UIResourceChangeRegistry();
    this.registry = _uIResourceChangeRegistry;
    this.uri = org.eclipse.emf.common.util.URI.createPlatformResourceURI("myProject/src/com/acme/C.xtend", true);
    ChangeListenerAddingFileSystemSupportTest.NoopFileSystemSupport _noopFileSystemSupport = new ChangeListenerAddingFileSystemSupportTest.NoopFileSystemSupport();
    ChangeListenerAddingFileSystemSupport _changeListenerAddingFileSystemSupport = new ChangeListenerAddingFileSystemSupport(this.uri, _noopFileSystemSupport, this.registry);
    this.fsa = _changeListenerAddingFileSystemSupport;
    Path _path = new Path("a");
    this.path = _path;
}
Also used : Path(org.eclipse.xtend.lib.macro.file.Path) UIResourceChangeRegistry(org.eclipse.xtend.ide.builder.UIResourceChangeRegistry) ChangeListenerAddingFileSystemSupport(org.eclipse.xtend.core.macro.declaration.ChangeListenerAddingFileSystemSupport) Before(org.junit.Before)

Example 24 with Path

use of org.eclipse.xtend.lib.macro.file.Path in project xtext-xtend by eclipse.

the class ChangeListenerAddingFileSystemSupportTest method discardCreateAndModifyInformation.

@Test
public void discardCreateAndModifyInformation() {
    this.fsa.mkdir(this.path);
    Path _path = new Path("b");
    this.fsa.mkdir(_path);
    Assert.assertTrue(this.registry.getChangesNotRelevantListeners().containsEntry(this.path.toString(), this.uri));
    Assert.assertTrue(this.registry.getChangesNotRelevantListeners().containsEntry("b", this.uri));
    this.registry.discardCreateOrModifyInformation(this.uri);
    Assert.assertTrue(this.registry.getChangesNotRelevantListeners().isEmpty());
}
Also used : Path(org.eclipse.xtend.lib.macro.file.Path) Test(org.junit.Test)

Example 25 with Path

use of org.eclipse.xtend.lib.macro.file.Path in project xtext-xtend by eclipse.

the class EclipseFileSystemTest method testIssue383.

@Test
public void testIssue383() {
    if ((this.fs instanceof AbstractFileSystemSupport)) {
        final AbstractFileSystemSupport afs = ((AbstractFileSystemSupport) this.fs);
        final IProject px = this.createProject("px");
        this.createProject("py");
        final ResourceSet rs = this.resourceSetProvider.get(px);
        final Resource rx = rs.createResource(URI.createPlatformResourceURI("px/foo/xxxx", true));
        final Resource rxb = rs.createResource(URI.createPlatformResourceURI("px/bar/yyyy", true));
        final Resource ry = rs.createResource(URI.createPlatformResourceURI("py/bar/xxxx", true));
        Path pathx = afs.getPath(rx);
        Assert.assertEquals("/px/foo/xxxx", pathx.toString());
        Path pathxb = afs.getPath(rxb);
        Assert.assertEquals("/px/bar/yyyy", pathxb.toString());
        Path pathy = afs.getPath(ry);
        Assert.assertEquals("/py/bar/xxxx", pathy.toString());
    } else {
        Assert.fail("fs is no AbstractFileSystemSupport");
    }
}
Also used : Path(org.eclipse.xtend.lib.macro.file.Path) AbstractFileSystemSupport(org.eclipse.xtend.core.macro.AbstractFileSystemSupport) Resource(org.eclipse.emf.ecore.resource.Resource) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) IProject(org.eclipse.core.resources.IProject) Test(org.junit.Test) JavaIoFileSystemTest(org.eclipse.xtend.ide.tests.macros.JavaIoFileSystemTest)

Aggregations

Path (org.eclipse.xtend.lib.macro.file.Path)42 Test (org.junit.Test)31 File (java.io.File)3 URI (java.net.URI)2 IProject (org.eclipse.core.resources.IProject)2 URI (org.eclipse.emf.common.util.URI)2 JavaIoFileSystemTest (org.eclipse.xtend.ide.tests.macros.JavaIoFileSystemTest)2 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)2 List (java.util.List)1 IProjectDescription (org.eclipse.core.resources.IProjectDescription)1 IWorkspace (org.eclipse.core.resources.IWorkspace)1 IWorkspaceRoot (org.eclipse.core.resources.IWorkspaceRoot)1 Resource (org.eclipse.emf.ecore.resource.Resource)1 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)1 AbstractFileSystemSupport (org.eclipse.xtend.core.macro.AbstractFileSystemSupport)1 ChangeListenerAddingFileSystemSupport (org.eclipse.xtend.core.macro.declaration.ChangeListenerAddingFileSystemSupport)1 UIResourceChangeRegistry (org.eclipse.xtend.ide.builder.UIResourceChangeRegistry)1 MutableFieldDeclaration (org.eclipse.xtend.lib.macro.declaration.MutableFieldDeclaration)1 OutputConfiguration (org.eclipse.xtext.generator.OutputConfiguration)1 Before (org.junit.Before)1