Search in sources :

Example 1 with FileProjectConfig

use of org.eclipse.xtext.workspace.FileProjectConfig in project xtext-xtend by eclipse.

the class ActiveAnnotationsRuntimeTest method compileMacroResourceSet.

public XtextResourceSet compileMacroResourceSet(final Pair<String, String> macroFile, final Pair<String, String> clientFile) {
    final URI macroURI = this.copyToDisk(this.macroProject, macroFile);
    final URI clientURI = this.copyToDisk(this.clientProject, clientFile);
    File _file = new File(this.workspaceRoot, this.macroProject);
    FileProjectConfig _fileProjectConfig = new FileProjectConfig(_file);
    final Procedure1<FileProjectConfig> _function = (FileProjectConfig it) -> {
        it.addSourceFolder("src");
    };
    final FileProjectConfig macroProjectConfig = ObjectExtensions.<FileProjectConfig>operator_doubleArrow(_fileProjectConfig, _function);
    File _file_1 = new File(this.workspaceRoot, this.clientProject);
    FileProjectConfig _fileProjectConfig_1 = new FileProjectConfig(_file_1);
    final Procedure1<FileProjectConfig> _function_1 = (FileProjectConfig it) -> {
        it.addSourceFolder("src");
    };
    final FileProjectConfig clientProjectConfig = ObjectExtensions.<FileProjectConfig>operator_doubleArrow(_fileProjectConfig_1, _function_1);
    final XtextResourceSet macroResourceSet = this.resourceSetProvider.get();
    ProjectConfigAdapter.install(macroResourceSet, macroProjectConfig);
    macroResourceSet.setClasspathURIContext(this.getClass().getClassLoader());
    macroResourceSet.createResource(macroURI);
    final XtextResourceSet resourceSet = this.resourceSetProvider.get();
    ProjectConfigAdapter.install(resourceSet, clientProjectConfig);
    resourceSet.createResource(clientURI);
    final IAcceptor<CompilationTestHelper.Result> _function_2 = (CompilationTestHelper.Result result) -> {
        ClassLoader _classLoader = this.getClass().getClassLoader();
        final DelegatingClassloader classLoader = new DelegatingClassloader(_classLoader, result);
        resourceSet.setClasspathURIContext(classLoader);
        this.compiler.setJavaCompilerClassPath(classLoader);
    };
    this.compiler.compile(macroResourceSet, _function_2);
    return resourceSet;
}
Also used : CompilationTestHelper(org.eclipse.xtext.xbase.testing.CompilationTestHelper) XtextResourceSet(org.eclipse.xtext.resource.XtextResourceSet) DelegatingClassloader(org.eclipse.xtend.core.tests.macro.DelegatingClassloader) FileProjectConfig(org.eclipse.xtext.workspace.FileProjectConfig) URI(org.eclipse.emf.common.util.URI) XtendFile(org.eclipse.xtend.core.xtend.XtendFile) File(java.io.File)

Example 2 with FileProjectConfig

use of org.eclipse.xtext.workspace.FileProjectConfig in project xtext-xtend by eclipse.

the class JavaIoFileSystemTest method setUp.

@Before
public void setUp() {
    try {
        final File tempDir = this.temporaryFolder.newFolder();
        JavaIOFileSystemSupport _javaIOFileSystemSupport = new JavaIOFileSystemSupport();
        final Procedure1<JavaIOFileSystemSupport> _function = (JavaIOFileSystemSupport it) -> {
            final IProjectConfigProvider _function_1 = (ResourceSet it_1) -> {
                File _file = new File(tempDir, "foo");
                FileProjectConfig _fileProjectConfig = new FileProjectConfig(_file);
                final Procedure1<FileProjectConfig> _function_2 = (FileProjectConfig it_2) -> {
                    it_2.addSourceFolder("src");
                };
                return ObjectExtensions.<FileProjectConfig>operator_doubleArrow(_fileProjectConfig, _function_2);
            };
            it.setProjectConfigProvider(_function_1);
            IEncodingProvider.Runtime _runtime = new IEncodingProvider.Runtime();
            it.setEncodingProvider(_runtime);
            XtextResourceSet _xtextResourceSet = new XtextResourceSet();
            it.setContext(_xtextResourceSet);
        };
        JavaIOFileSystemSupport _doubleArrow = ObjectExtensions.<JavaIOFileSystemSupport>operator_doubleArrow(_javaIOFileSystemSupport, _function);
        this.fs = _doubleArrow;
        this.createProject("foo");
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : JavaIOFileSystemSupport(org.eclipse.xtend.core.macro.JavaIOFileSystemSupport) XtextResourceSet(org.eclipse.xtext.resource.XtextResourceSet) IEncodingProvider(org.eclipse.xtext.parser.IEncodingProvider) IProjectConfigProvider(org.eclipse.xtext.workspace.IProjectConfigProvider) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) XtextResourceSet(org.eclipse.xtext.resource.XtextResourceSet) FileProjectConfig(org.eclipse.xtext.workspace.FileProjectConfig) File(java.io.File) Before(org.junit.Before)

Example 3 with FileProjectConfig

use of org.eclipse.xtext.workspace.FileProjectConfig in project xtext-xtend by eclipse.

the class TestBatchCompiler method testProjectConfigMultipleSourceDirs4.

@Test
public void testProjectConfigMultipleSourceDirs4() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("ws/prj1/src");
    _builder.append(File.pathSeparator);
    _builder.append("ws/prj1/dir1/src-gen");
    this.batchCompiler.setSourcePath(_builder.toString());
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("ws/prj1/bin");
    this.batchCompiler.setOutputPath(_builder_1.toString());
    this.batchCompiler.compile();
    final FileProjectConfig project = this.batchCompiler.getProjectConfig();
    Assert.assertEquals("prj1", project.getName());
    final OutputConfiguration output = this.batchCompiler.getOutputConfiguration();
    Assert.assertEquals(2, project.getSourceFolders().size());
    final Function1<FileSourceFolder, String> _function = (FileSourceFolder it) -> {
        return it.getName();
    };
    final List<String> keyPaths = IterableExtensions.<String>sort(IterableExtensions.<FileSourceFolder, String>map(project.getSourceFolders(), _function));
    String _get = keyPaths.get(0);
    final Procedure1<String> _function_1 = (String it) -> {
        Assert.assertEquals("dir1/src-gen", it);
        Assert.assertEquals("bin", output.getOutputDirectory(it));
    };
    ObjectExtensions.<String>operator_doubleArrow(_get, _function_1);
    String _get_1 = keyPaths.get(1);
    final Procedure1<String> _function_2 = (String it) -> {
        Assert.assertEquals("src", it);
        Assert.assertEquals("bin", output.getOutputDirectory(it));
    };
    ObjectExtensions.<String>operator_doubleArrow(_get_1, _function_2);
}
Also used : OutputConfiguration(org.eclipse.xtext.generator.OutputConfiguration) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) FileProjectConfig(org.eclipse.xtext.workspace.FileProjectConfig) FileSourceFolder(org.eclipse.xtext.workspace.FileSourceFolder) IgnoredBySmokeTest(org.eclipse.xtext.testing.smoketest.IgnoredBySmokeTest) Test(org.junit.Test)

Example 4 with FileProjectConfig

use of org.eclipse.xtext.workspace.FileProjectConfig in project xtext-xtend by eclipse.

the class TestBatchCompiler method testProjectConfigMultipleSourceDirs1.

@Test
public void testProjectConfigMultipleSourceDirs1() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("ws/prj1/src");
    _builder.append(File.pathSeparator);
    _builder.append("ws/prj1/src-gen");
    this.batchCompiler.setSourcePath(_builder.toString());
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("ws/prj1/bin");
    this.batchCompiler.setOutputPath(_builder_1.toString());
    this.batchCompiler.compile();
    final FileProjectConfig project = this.batchCompiler.getProjectConfig();
    Assert.assertEquals("prj1", project.getName());
    final OutputConfiguration output = this.batchCompiler.getOutputConfiguration();
    Assert.assertEquals(2, project.getSourceFolders().size());
    final Function1<FileSourceFolder, String> _function = (FileSourceFolder it) -> {
        return it.getName();
    };
    final List<String> keyPaths = IterableExtensions.<String>sort(IterableExtensions.<FileSourceFolder, String>map(project.getSourceFolders(), _function));
    String _get = keyPaths.get(0);
    final Procedure1<String> _function_1 = (String it) -> {
        Assert.assertEquals("src", it);
        Assert.assertEquals("bin", output.getOutputDirectory(it).toString());
    };
    ObjectExtensions.<String>operator_doubleArrow(_get, _function_1);
    String _get_1 = keyPaths.get(1);
    final Procedure1<String> _function_2 = (String it) -> {
        Assert.assertEquals("src-gen", it);
        Assert.assertEquals("bin", output.getOutputDirectory(it).toString());
    };
    ObjectExtensions.<String>operator_doubleArrow(_get_1, _function_2);
}
Also used : OutputConfiguration(org.eclipse.xtext.generator.OutputConfiguration) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) FileProjectConfig(org.eclipse.xtext.workspace.FileProjectConfig) FileSourceFolder(org.eclipse.xtext.workspace.FileSourceFolder) IgnoredBySmokeTest(org.eclipse.xtext.testing.smoketest.IgnoredBySmokeTest) Test(org.junit.Test)

Example 5 with FileProjectConfig

use of org.eclipse.xtext.workspace.FileProjectConfig in project xtext-xtend by eclipse.

the class TestBatchCompiler method testProjectConfigMultipleSourceDirs5.

@Test
public void testProjectConfigMultipleSourceDirs5() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("ws/prj1/dir1/dir1a/src");
    _builder.append(File.pathSeparator);
    _builder.append("ws/prj1/dir3/dir3a/src-gen");
    this.batchCompiler.setSourcePath(_builder.toString());
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("ws/prj1/dir2/dir2a/bin");
    this.batchCompiler.setOutputPath(_builder_1.toString());
    this.batchCompiler.compile();
    final FileProjectConfig project = this.batchCompiler.getProjectConfig();
    Assert.assertEquals("prj1", project.getName());
    final OutputConfiguration output = this.batchCompiler.getOutputConfiguration();
    Assert.assertEquals(2, project.getSourceFolders().size());
    final Function1<FileSourceFolder, String> _function = (FileSourceFolder it) -> {
        return it.getName();
    };
    final List<String> keyPaths = IterableExtensions.<String>sort(IterableExtensions.<FileSourceFolder, String>map(project.getSourceFolders(), _function));
    String _get = keyPaths.get(0);
    final Procedure1<String> _function_1 = (String it) -> {
        Assert.assertEquals("dir1/dir1a/src", it);
        Assert.assertEquals("dir2/dir2a/bin", output.getOutputDirectory(it));
    };
    ObjectExtensions.<String>operator_doubleArrow(_get, _function_1);
    String _get_1 = keyPaths.get(1);
    final Procedure1<String> _function_2 = (String it) -> {
        Assert.assertEquals("dir3/dir3a/src-gen", it);
        Assert.assertEquals("dir2/dir2a/bin", output.getOutputDirectory(it));
    };
    ObjectExtensions.<String>operator_doubleArrow(_get_1, _function_2);
}
Also used : OutputConfiguration(org.eclipse.xtext.generator.OutputConfiguration) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) FileProjectConfig(org.eclipse.xtext.workspace.FileProjectConfig) FileSourceFolder(org.eclipse.xtext.workspace.FileSourceFolder) IgnoredBySmokeTest(org.eclipse.xtext.testing.smoketest.IgnoredBySmokeTest) Test(org.junit.Test)

Aggregations

FileProjectConfig (org.eclipse.xtext.workspace.FileProjectConfig)13 OutputConfiguration (org.eclipse.xtext.generator.OutputConfiguration)7 IgnoredBySmokeTest (org.eclipse.xtext.testing.smoketest.IgnoredBySmokeTest)7 Test (org.junit.Test)7 File (java.io.File)6 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)6 FileSourceFolder (org.eclipse.xtext.workspace.FileSourceFolder)6 XtextResourceSet (org.eclipse.xtext.resource.XtextResourceSet)4 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)3 JavaIOFileSystemSupport (org.eclipse.xtend.core.macro.JavaIOFileSystemSupport)2 XtendFile (org.eclipse.xtend.core.xtend.XtendFile)2 IEncodingProvider (org.eclipse.xtext.parser.IEncodingProvider)2 IProjectConfigProvider (org.eclipse.xtext.workspace.IProjectConfigProvider)2 Before (org.junit.Before)2 CharMatcher (com.google.common.base.CharMatcher)1 Set (java.util.Set)1 URI (org.eclipse.emf.common.util.URI)1 DelegatingClassloader (org.eclipse.xtend.core.tests.macro.DelegatingClassloader)1 OutputConfigurationAdapter (org.eclipse.xtext.generator.OutputConfigurationAdapter)1 CompilationTestHelper (org.eclipse.xtext.xbase.testing.CompilationTestHelper)1