Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package org.xtext.gradle.tasks;
 
 import java.io.File;
 import  org.eclipse.xtend2.lib.StringConcatenation;
 import  org.eclipse.xtext.xbase.lib.Exceptions;
 import  org.eclipse.xtext.xbase.lib.IterableExtensions;
 import  org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
 import  org.gradle.api.DefaultTask;
 import  org.gradle.api.NamedDomainObjectContainer;
import  org.gradle.api.Project;
import  org.gradle.api.tasks.TaskAction;
public class XtextEclipseSettings extends DefaultTask {
  private XtextExtension xtext;
  
  public XtextExtension configure(final XtextExtension xtext) {
    return this. = xtext;
  }
  
  @TaskAction
  public void writeSettings() {
    NamedDomainObjectContainer<Language_languages = this..getLanguages();
    final Procedure1<Language_function = new Procedure1<Language>() {
      public void apply(final Language language) {
        try {
          Project _project = XtextEclipseSettings.this.getProject();
          String _name = language.getName();
          final XtextEclipsePreferences prefs = new XtextEclipsePreferences(_project_name);
          prefs.load();
          prefs.putBoolean("is_project_specific"true);
          NamedDomainObjectContainer<OutputConfiguration_outputs = language.getOutputs();
          final Procedure1<OutputConfiguration_function = new Procedure1<OutputConfiguration>() {
            public void apply(final OutputConfiguration output) {
              String _key = XtextEclipseSettings.this.getKey(output"directory");
              Project _project = XtextEclipseSettings.this.getProject();
              Object _dir = output.getDir();
              File _file = _project.file(_dir);
              String _absolutePath = _file.getAbsolutePath();
              prefs.put(_key_absolutePath);
            }
          };
          IterableExtensions.<OutputConfiguration>forEach(_outputs_function);
          prefs.save();
        } catch (Throwable _e) {
          throw Exceptions.sneakyThrow(_e);
        }
      }
    };
    IterableExtensions.<Language>forEach(_languages_function);
  }
  
  public String getKey(final OutputConfiguration outputfinal String preferenceName) {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("outlet.");
    String _name = output.getName();
    _builder.append(_name"");
    _builder.append(".");
    _builder.append(preferenceName"");
    return _builder.toString();
  }
New to GrepCode? Check out our FAQ X