Search in sources :

Example 11 with Path

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

the class PathTest method testPathGetAbsolutePath.

@Test
public void testPathGetAbsolutePath() {
    Path _path = new Path("/foo");
    Assert.assertEquals(_path, new Path("/foo/bar/baz.txt").getAbsolutePath("../.."));
}
Also used : Path(org.eclipse.xtend.lib.macro.file.Path) Test(org.junit.Test)

Example 12 with Path

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

the class PathTest method testAppend.

@Test
public void testAppend() {
    Path _path = new Path("/foo/bar");
    Assert.assertEquals(_path, new Path("/foo").append("bar"));
    Path _path_1 = new Path("/foo/bar");
    Assert.assertEquals(_path_1, new Path("/foo").append("/bar"));
    Path _path_2 = new Path("foo/bar");
    Assert.assertEquals(_path_2, new Path("foo").append("/bar"));
    Path _path_3 = new Path("foo");
    Assert.assertEquals(_path_3, new Path("foo/bar").append(".."));
    Path _path_4 = new Path("foo/file.txt");
    Assert.assertEquals(_path_4, new Path("foo/bar").append("../xfoo/../file.txt"));
}
Also used : Path(org.eclipse.xtend.lib.macro.file.Path) Test(org.junit.Test)

Example 13 with Path

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

the class PathTest method testRelativizeBothDirections.

@Test
public void testRelativizeBothDirections() {
    final Path base = new Path("/hubba/bubba");
    final Path child = new Path("/hubba/bubba/bar");
    Path _path = new Path("bar");
    Assert.assertEquals(_path, base.relativize(child));
    Path _path_1 = new Path("bar");
    Assert.assertEquals(_path_1, child.relativize(base));
}
Also used : Path(org.eclipse.xtend.lib.macro.file.Path) Test(org.junit.Test)

Example 14 with Path

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

the class _TESTDATA_InternalClassProcessor method doGenerateCode.

@Override
public void doGenerateCode(final ClassDeclaration annotatedClass, @Extension final CodeGenerationContext context) {
    final Path tF = context.getTargetFolder(annotatedClass.getCompilationUnit().getFilePath());
    Path _append = tF.append("/Test.txt");
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("Hello");
    _builder.newLine();
    context.setContents(_append, _builder);
}
Also used : Path(org.eclipse.xtend.lib.macro.file.Path) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation)

Example 15 with Path

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

the class FileProcessor method doTransform.

@Override
public void doTransform(final MutableClassDeclaration annotatedClass, @Extension final TransformationContext context) {
    final Path path = annotatedClass.getCompilationUnit().getFilePath();
    final String contents = context.getContents(context.getProjectFolder(path).append("res/template.txt")).toString();
    final String[] segments = contents.trim().split(",");
    for (final String segment : segments) {
        final Procedure1<MutableFieldDeclaration> _function = (MutableFieldDeclaration it) -> {
            it.setType(context.getString());
        };
        annotatedClass.addField(segment, _function);
    }
}
Also used : Path(org.eclipse.xtend.lib.macro.file.Path) MutableFieldDeclaration(org.eclipse.xtend.lib.macro.declaration.MutableFieldDeclaration)

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