Search in sources :

Example 1 with Path

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

the class FileLocationsImpl method getTargetFolder.

@Override
public Path getTargetFolder(final Path path) {
    Path _xblockexpression = null;
    {
        final Path projectFolder = this.getProjectFolder(path);
        if ((projectFolder == null)) {
            return null;
        }
        final OutputConfiguration outputConfiguration = IterableExtensions.<OutputConfiguration>head(this.outputConfigurationProvider.getOutputConfigurations(this.context));
        final Path sourceFolder = this.getSourceFolder(path);
        String _xifexpression = null;
        if ((sourceFolder == null)) {
            _xifexpression = outputConfiguration.getOutputDirectory();
        } else {
            String _xblockexpression_1 = null;
            {
                final String projectRelativeSourceFolder = IterableExtensions.join(IterableExtensions.<String>tail(sourceFolder.getSegments()), "/");
                _xblockexpression_1 = outputConfiguration.getOutputDirectory(projectRelativeSourceFolder);
            }
            _xifexpression = _xblockexpression_1;
        }
        final String outputFolder = _xifexpression;
        _xblockexpression = projectFolder.append(outputFolder);
    }
    return _xblockexpression;
}
Also used : Path(org.eclipse.xtend.lib.macro.file.Path) OutputConfiguration(org.eclipse.xtext.generator.OutputConfiguration)

Example 2 with Path

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

the class JavaIOFileSystemSupport method getChildren.

@Override
public Iterable<? extends Path> getChildren(final URI uri, final Path path) {
    java.net.URI _uRI = this.toURI(uri);
    final Function1<String, Path> _function = (String it) -> {
        return path.getAbsolutePath(it);
    };
    return ListExtensions.<String, Path>map(((List<String>) Conversions.doWrapArray(new File(_uRI).list())), _function);
}
Also used : Path(org.eclipse.xtend.lib.macro.file.Path) List(java.util.List) File(java.io.File)

Example 3 with Path

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

the class __GeneratedSourceModifingAnnotationProcessor method doGenerateCode.

@Override
public void doGenerateCode(final ClassDeclaration annotatedClass, @Extension final CodeGenerationContext context) {
    final Path targetFolder = context.getTargetFolder(annotatedClass.getCompilationUnit().getFilePath());
    String _lastSegment = targetFolder.getLastSegment();
    boolean _equals = Objects.equal(_lastSegment, "xtend-gen");
    Assert.assertTrue(_equals);
}
Also used : Path(org.eclipse.xtend.lib.macro.file.Path)

Example 4 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 5 with Path

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

the class JavaIoFileSystemTest method createProject.

protected Object createProject(final String name) {
    URI _uRI = this.fs.toURI(new Path(name));
    final File file = new File(_uRI);
    file.mkdirs();
    return file;
}
Also used : Path(org.eclipse.xtend.lib.macro.file.Path) URI(java.net.URI) File(java.io.File)

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