Search in sources :

Example 26 with OutputConfiguration

use of org.eclipse.xtext.generator.OutputConfiguration in project xtext-core by eclipse.

the class ResourceStorageFacade method getFileSystemAccess.

protected AbstractFileSystemAccess2 getFileSystemAccess(final StorageAwareResource resource) {
    final AbstractFileSystemAccess2 fsa = this.fileSystemAccessProvider.get();
    fsa.setContext(resource);
    final Function1<OutputConfiguration, String> _function = (OutputConfiguration it) -> {
        return it.getName();
    };
    fsa.setOutputConfigurations(IterableExtensions.<String, OutputConfiguration>toMap(this.outputConfigurationProvider.getOutputConfigurations(resource), _function));
    return fsa;
}
Also used : OutputConfiguration(org.eclipse.xtext.generator.OutputConfiguration) AbstractFileSystemAccess2(org.eclipse.xtext.generator.AbstractFileSystemAccess2)

Example 27 with OutputConfiguration

use of org.eclipse.xtext.generator.OutputConfiguration in project xtext-core by eclipse.

the class IncrementalBuilderTest method testNoCleanupBuild.

@Test
public void testNoCleanupBuild() {
    final Procedure1<BuildRequest> _function = (BuildRequest it) -> {
        final Procedure1<OutputConfiguration> _function_1 = (OutputConfiguration it_1) -> {
            it_1.setCleanUpDerivedResources(false);
        };
        this.withOutputConfig(it, _function_1);
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("foo {");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("entity B {}");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("entity A { foo.B myReference }");
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        URI _minus = this.operator_minus("src/MyFile.indextestlanguage", _builder.toString());
        it.setDirtyFiles(Collections.<URI>unmodifiableList(CollectionLiterals.<URI>newArrayList(_minus)));
    };
    final BuildRequest buildRequest = this.newBuildRequest(_function);
    this.build(buildRequest);
    Assert.assertTrue(this.issues.toString(), this.issues.isEmpty());
    Assert.assertEquals(2, this.generated.size());
    Assert.assertTrue(this.containsSuffix(this.generated.values(), "src-gen/B.txt"));
    Assert.assertTrue(this.containsSuffix(this.generated.values(), "src-gen/A.txt"));
    final Procedure1<BuildRequest> _function_1 = (BuildRequest it) -> {
        final Procedure1<OutputConfiguration> _function_2 = (OutputConfiguration it_1) -> {
            it_1.setCleanUpDerivedResources(false);
        };
        this.withOutputConfig(it, _function_2);
        URI _delete = this.delete(this.uri("src/A.indextestlanguage"));
        it.setDeletedFiles(Collections.<URI>unmodifiableList(CollectionLiterals.<URI>newArrayList(_delete)));
    };
    this.newBuildRequest(_function_1);
    Assert.assertTrue(this.issues.toString(), this.issues.isEmpty());
    Assert.assertEquals(2, this.generated.size());
    Assert.assertTrue(this.containsSuffix(this.generated.values(), "src-gen/B.txt"));
    Assert.assertTrue(this.containsSuffix(this.generated.values(), "src-gen/A.txt"));
}
Also used : OutputConfiguration(org.eclipse.xtext.generator.OutputConfiguration) Procedure1(org.eclipse.xtext.xbase.lib.Procedures.Procedure1) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) BuildRequest(org.eclipse.xtext.build.BuildRequest) URI(org.eclipse.emf.common.util.URI) AbstractIncrementalBuilderTest(org.eclipse.xtext.testing.builder.AbstractIncrementalBuilderTest) Test(org.junit.Test)

Example 28 with OutputConfiguration

use of org.eclipse.xtext.generator.OutputConfiguration in project xtext-core by eclipse.

the class IncrementalBuilderTest method testGeneratedOnceBuild.

@Test
public void testGeneratedOnceBuild() {
    final Procedure1<BuildRequest> _function = (BuildRequest it) -> {
        final Procedure1<OutputConfiguration> _function_1 = (OutputConfiguration it_1) -> {
            it_1.setOverrideExistingResources(false);
        };
        this.withOutputConfig(it, _function_1);
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("foo {");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("entity B {}");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("entity A { foo.B myReference }");
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        URI _minus = this.operator_minus("src/MyFile.indextestlanguage", _builder.toString());
        it.setDirtyFiles(Collections.<URI>unmodifiableList(CollectionLiterals.<URI>newArrayList(_minus)));
    };
    final BuildRequest buildRequest = this.newBuildRequest(_function);
    this.build(buildRequest);
    Assert.assertTrue(this.issues.toString(), this.issues.isEmpty());
    Assert.assertEquals(2, this.generated.size());
    Assert.assertTrue(this.containsSuffix(this.generated.values(), "src-gen/B.txt"));
    Assert.assertTrue(this.containsSuffix(this.generated.values(), "src-gen/A.txt"));
    final Procedure1<BuildRequest> _function_1 = (BuildRequest it) -> {
        final Procedure1<OutputConfiguration> _function_2 = (OutputConfiguration it_1) -> {
            it_1.setOverrideExistingResources(false);
        };
        this.withOutputConfig(it, _function_2);
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("foo {");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("entity B {}");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("entity A { foo.B someReference }");
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        URI _minus = this.operator_minus("src/MyFile.indextestlanguage", _builder.toString());
        it.setDirtyFiles(Collections.<URI>unmodifiableList(CollectionLiterals.<URI>newArrayList(_minus)));
        final Procedure2<URI, URI> _function_3 = (URI $0, URI $1) -> {
            Assert.fail();
        };
        it.setAfterGenerateFile(_function_3);
    };
    this.newBuildRequest(_function_1);
}
Also used : OutputConfiguration(org.eclipse.xtext.generator.OutputConfiguration) Procedure2(org.eclipse.xtext.xbase.lib.Procedures.Procedure2) Procedure1(org.eclipse.xtext.xbase.lib.Procedures.Procedure1) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) BuildRequest(org.eclipse.xtext.build.BuildRequest) URI(org.eclipse.emf.common.util.URI) AbstractIncrementalBuilderTest(org.eclipse.xtext.testing.builder.AbstractIncrementalBuilderTest) Test(org.junit.Test)

Example 29 with OutputConfiguration

use of org.eclipse.xtext.generator.OutputConfiguration in project xtext-core by eclipse.

the class URIBasedFileSystemAccessTest method before.

@Before
public void before() {
    try {
        final Path tmpPath = Paths.get(StandardSystemProperty.JAVA_IO_TMPDIR.value());
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("tempFolder_");
        UUID _randomUUID = UUID.randomUUID();
        _builder.append(_randomUUID);
        final Path output = Files.createTempDirectory(tmpPath, _builder.toString());
        final Path resource = Files.createFile(output.resolve(URIBasedFileSystemAccessTest.EXISTING_RESOURCE_NAME));
        resource.toFile().deleteOnExit();
        output.toFile().deleteOnExit();
        final OutputConfiguration config = IterableExtensions.<OutputConfiguration>head(this.configProvider.getOutputConfigurations());
        config.setOutputDirectory(output.toString());
        Pair<String, OutputConfiguration> _mappedTo = Pair.<String, OutputConfiguration>of(IFileSystemAccess.DEFAULT_OUTPUT, config);
        this.fsa.setOutputConfigurations(Collections.<String, OutputConfiguration>unmodifiableMap(CollectionLiterals.<String, OutputConfiguration>newHashMap(_mappedTo)));
        this.fsa.setConverter(this.uriConverter);
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : Path(java.nio.file.Path) OutputConfiguration(org.eclipse.xtext.generator.OutputConfiguration) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) UUID(java.util.UUID) Before(org.junit.Before)

Aggregations

OutputConfiguration (org.eclipse.xtext.generator.OutputConfiguration)29 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)9 Test (org.junit.Test)9 IgnoredBySmokeTest (org.eclipse.xtext.testing.smoketest.IgnoredBySmokeTest)7 FileProjectConfig (org.eclipse.xtext.workspace.FileProjectConfig)7 FileSourceFolder (org.eclipse.xtext.workspace.FileSourceFolder)6 IContainer (org.eclipse.core.resources.IContainer)4 IFile (org.eclipse.core.resources.IFile)4 File (java.io.File)3 IMarker (org.eclipse.core.resources.IMarker)3 IProject (org.eclipse.core.resources.IProject)3 CoreException (org.eclipse.core.runtime.CoreException)3 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)3 IOException (java.io.IOException)2 IPath (org.eclipse.core.runtime.IPath)2 Path (org.eclipse.core.runtime.Path)2 SubMonitor (org.eclipse.core.runtime.SubMonitor)2 URI (org.eclipse.emf.common.util.URI)2 BuildRequest (org.eclipse.xtext.build.BuildRequest)2 AbstractIncrementalBuilderTest (org.eclipse.xtext.testing.builder.AbstractIncrementalBuilderTest)2