Search in sources :

Example 31 with Path

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

the class JavaIoFileSystemTest method testGetFileURI.

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

Example 32 with Path

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

the class JavaIoFileSystemTest method testGetProjectURI.

@Test
public void testGetProjectURI() {
    final Path path = new Path("/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 33 with Path

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

the class AbstractFileSystemSupport method getPath.

protected Path getPath(final URI absoluteURI, final URI baseURI, final Path basePath) {
    Path _xblockexpression = null;
    {
        URI _xifexpression = null;
        if ((baseURI.isPlatformResource() && absoluteURI.isPlatformResource())) {
            URI _xifexpression_1 = null;
            String _segment = baseURI.segment(1);
            String _segment_1 = absoluteURI.segment(1);
            boolean _notEquals = (!Objects.equal(_segment, _segment_1));
            if (_notEquals) {
                URI _xblockexpression_1 = null;
                {
                    String _platformString = absoluteURI.toPlatformString(true);
                    final org.eclipse.core.runtime.Path p = new org.eclipse.core.runtime.Path(_platformString);
                    String _string = p.toString();
                    String _plus = (".." + _string);
                    _xblockexpression_1 = URI.createURI(_plus);
                }
                _xifexpression_1 = _xblockexpression_1;
            } else {
                _xifexpression_1 = absoluteURI.deresolve(baseURI);
            }
            _xifexpression = _xifexpression_1;
        } else {
            _xifexpression = absoluteURI.deresolve(baseURI);
        }
        final URI relativeURI = _xifexpression;
        if ((relativeURI.isEmpty() || Objects.equal(relativeURI, absoluteURI))) {
            return null;
        }
        _xblockexpression = basePath.getAbsolutePath(relativeURI.toString());
    }
    return _xblockexpression;
}
Also used : Path(org.eclipse.xtend.lib.macro.file.Path) URI(org.eclipse.emf.common.util.URI)

Example 34 with Path

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

the class AbstractFileSystemSupport method getChildren.

@Override
public Iterable<? extends Path> getChildren(final Path path) {
    boolean _equals = Objects.equal(path, Path.ROOT);
    if (_equals) {
        Path _absolutePath = path.getAbsolutePath(this.projectConfigProvider.getProjectConfig(this.context).getName());
        return Collections.<Path>unmodifiableList(CollectionLiterals.<Path>newArrayList(_absolutePath));
    }
    final URI uri = this.getURI(path);
    if ((((uri == null) || (!this.exists(uri))) || (!(this.isFolder(uri)).booleanValue()))) {
        return CollectionLiterals.<Path>emptyList();
    }
    return this.getChildren(uri, path);
}
Also used : Path(org.eclipse.xtend.lib.macro.file.Path) URI(org.eclipse.emf.common.util.URI)

Example 35 with Path

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

the class JavaIoFileSystemTest method testModificationStamp_01.

@Test
public void testModificationStamp_01() {
    try {
        final Path path = new Path("/foo/src/my/pack/Foo.txt");
        Assert.assertEquals(0L, this.fs.getLastModification(path));
        this.fs.setContents(path, "Hello Foo");
        final long mod = this.fs.getLastModification(path);
        Assert.assertEquals("Hello Foo", this.fs.getContents(path));
        Assert.assertEquals(mod, this.fs.getLastModification(path));
        Thread.sleep(1000);
        this.fs.setContents(path, "Hello Foo");
        Assert.assertEquals(mod, this.fs.getLastModification(path));
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : Path(org.eclipse.xtend.lib.macro.file.Path) Test(org.junit.Test)

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