Search in sources :

Example 11 with OutputConfiguration

use of org.eclipse.xtext.generator.OutputConfiguration 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)

Example 12 with OutputConfiguration

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

the class TestBatchCompiler method testProjectConfigMultipleSourceDirs3.

@Test
public void testProjectConfigMultipleSourceDirs3() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("ws/prj1/dir1/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/dir2/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", it);
        Assert.assertEquals("dir2/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-gen", it);
        Assert.assertEquals("dir2/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 13 with OutputConfiguration

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

the class XtendParallelBuilderParticipant method getGeneratorMarkers.

@Override
protected Map<OutputConfiguration, Iterable<IMarker>> getGeneratorMarkers(IProject builtProject, Collection<OutputConfiguration> outputConfigurations) throws CoreException {
    Map<OutputConfiguration, Iterable<IMarker>> generatorMarkers = newHashMap();
    List<IPath> sourcePath = getSourceFolderPathes(builtProject);
    for (OutputConfiguration config : outputConfigurations) {
        if (config.isCleanUpDerivedResources()) {
            List<IContainer> containerToSearchIn = Lists.newArrayList();
            for (IPath sourceFolder : sourcePath) {
                if (sourceFolder.segmentCount() == 1) {
                    containerToSearchIn.add(builtProject);
                } else {
                    IContainer sourcePathBasedContainer = builtProject.getWorkspace().getRoot().getFolder(sourceFolder);
                    containerToSearchIn.add(sourcePathBasedContainer);
                }
            }
            Collection<IMarker> markers = Lists.newArrayList();
            for (IContainer container : containerToSearchIn) {
                Iterables.addAll(markers, getDerivedResourceMarkers().findDerivedResourceMarkers(container, getGeneratorIdProvider().getGeneratorIdentifier()));
            }
            generatorMarkers.put(config, markers);
        }
    }
    return buildGeneratorMarkersReverseLookupMap(generatorMarkers);
}
Also used : IPath(org.eclipse.core.runtime.IPath) OutputConfiguration(org.eclipse.xtext.generator.OutputConfiguration) IMarker(org.eclipse.core.resources.IMarker) IContainer(org.eclipse.core.resources.IContainer)

Example 14 with OutputConfiguration

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

the class XtendProjectConfigurator method configure.

@Override
public void configure(ProjectConfigurationRequest request, IProgressMonitor monitor) throws CoreException {
    addNature(request.getProject(), XtextProjectHelper.NATURE_ID, monitor);
    OutputConfiguration config = new XtendOutputConfigurationProvider().getOutputConfigurations().iterator().next();
    for (MojoExecution execution : getMojoExecutions(request, monitor)) {
        String goal = execution.getGoal();
        if (goal.equals("compile")) {
            readCompileConfig(config, request, execution);
        } else if (goal.equals("testCompile")) {
            readTestCompileConfig(config, request, execution);
        } else if (goal.equals("xtend-install-debug-info")) {
            readDebugInfoConfig(config, request, execution);
        } else if (goal.equals("xtend-test-install-debug-info")) {
            readTestDebugInfoConfig(config, request, execution);
        }
    }
    writePreferences(config, request.getProject());
}
Also used : MojoExecution(org.apache.maven.plugin.MojoExecution) OutputConfiguration(org.eclipse.xtext.generator.OutputConfiguration) XtendOutputConfigurationProvider(org.eclipse.xtend.core.compiler.XtendOutputConfigurationProvider)

Example 15 with OutputConfiguration

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

the class AbstractIncrementalBuilderTest method withOutputConfig.

protected void withOutputConfig(final BuildRequest it, final Procedure1<? super OutputConfiguration> init) {
    final OutputConfiguration config = IterableExtensions.<OutputConfiguration>head(this.configurationProvider.getOutputConfigurations());
    init.apply(config);
    Pair<String, Set<OutputConfiguration>> _mappedTo = Pair.<String, Set<OutputConfiguration>>of(this.languageName, Collections.<OutputConfiguration>unmodifiableSet(CollectionLiterals.<OutputConfiguration>newHashSet(config)));
    final OutputConfigurationAdapter adapter = new OutputConfigurationAdapter(Collections.<String, Set<OutputConfiguration>>unmodifiableMap(CollectionLiterals.<String, Set<OutputConfiguration>>newHashMap(_mappedTo)));
    EList<Adapter> _eAdapters = it.getResourceSet().eAdapters();
    _eAdapters.add(adapter);
}
Also used : Set(java.util.Set) XtextResourceSet(org.eclipse.xtext.resource.XtextResourceSet) OutputConfiguration(org.eclipse.xtext.generator.OutputConfiguration) Adapter(org.eclipse.emf.common.notify.Adapter) OutputConfigurationAdapter(org.eclipse.xtext.generator.OutputConfigurationAdapter) OutputConfigurationAdapter(org.eclipse.xtext.generator.OutputConfigurationAdapter)

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