use of org.eclipse.xtend.lib.macro.file.Path in project xtext-xtend by eclipse.
the class FileProcessor method doGenerateCode.
@Override
public void doGenerateCode(final ClassDeclaration annotatedClass, @Extension final CodeGenerationContext context) {
final Path path = annotatedClass.getCompilationUnit().getFilePath();
final Path result = context.getTargetFolder(path).append("out.txt");
final String[] segments = context.getContents(context.getProjectFolder(path).append("res/template.txt")).toString().split(",");
StringConcatenation _builder = new StringConcatenation();
{
boolean _hasElements = false;
for (final String seg : segments) {
if (!_hasElements) {
_hasElements = true;
} else {
_builder.appendImmediate("|", "");
}
_builder.append(seg);
}
}
context.setContents(result, _builder);
}
use of org.eclipse.xtend.lib.macro.file.Path in project xtext-xtend by eclipse.
the class EclipseFileSystemTest method testGetURIForImportedProject.
@Test
public void testGetURIForImportedProject() {
try {
final IWorkspace ws = ResourcesPlugin.getWorkspace();
final IWorkspaceRoot root = ws.getRoot();
final IProjectDescription description = ws.newProjectDescription("bar");
description.setLocation(root.getLocation().append("foo/bar"));
final IProject project = root.getProject("bar");
project.create(description, null);
project.open(null);
final Path file = new Path("/bar/Foo.text");
Assert.assertFalse(this.fs.exists(file));
Assert.assertNull(this.fs.toURI(file));
try {
this.fs.setContents(file, "Hello Foo");
Assert.fail();
} catch (final Throwable _t) {
if (_t instanceof IllegalArgumentException) {
} else {
throw Exceptions.sneakyThrow(_t);
}
}
Assert.assertFalse(this.fs.exists(file));
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
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;
}
use of org.eclipse.xtend.lib.macro.file.Path in project xtext-xtend by eclipse.
the class JavaIoFileSystemTest method testGetFileChildren.
@Test
public void testGetFileChildren() {
final Path file = new Path("/foo/bar/Foo.text");
Assert.assertFalse(this.fs.exists(file));
Assert.assertEquals(0, IterableExtensions.size(this.fs.getChildren(file)));
this.fs.setContents(file, "Hello Foo");
Assert.assertTrue(this.fs.exists(file));
Assert.assertEquals(0, IterableExtensions.size(this.fs.getChildren(file)));
}
use of org.eclipse.xtend.lib.macro.file.Path in project xtext-xtend by eclipse.
the class JavaIoFileSystemTest method testModificationStamp_02.
@Test
public void testModificationStamp_02() {
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 Bar");
long _lastModification = this.fs.getLastModification(path);
boolean _lessThan = (mod < _lastModification);
Assert.assertTrue(_lessThan);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
Aggregations