use of org.eclipse.xtext.xbase.lib.Procedures.Procedure2 in project xtext-eclipse by eclipse.
the class AbstractIncrementalBuilderTest method newBuildRequest.
protected BuildRequest newBuildRequest(final Procedure1<? super BuildRequest> init) {
BuildRequest _buildRequest = new BuildRequest();
final Procedure1<BuildRequest> _function = (BuildRequest it) -> {
final ResourceDescriptionsData newIndex = this.indexState.getResourceDescriptions().copy();
it.setBaseDir(this.uri(""));
XtextResourceSet _get = this.resourceSetProvider.get();
final Procedure1<XtextResourceSet> _function_1 = (XtextResourceSet it_1) -> {
it_1.getURIConverter().getURIHandlers().clear();
EList<URIHandler> _uRIHandlers = it_1.getURIConverter().getURIHandlers();
_uRIHandlers.add(this.inMemoryURIHandler);
it_1.setClasspathURIContext(AbstractIncrementalBuilderTest.class.getClassLoader());
ProjectDescription _projectDescription = new ProjectDescription();
final Procedure1<ProjectDescription> _function_2 = (ProjectDescription it_2) -> {
it_2.setName("test-project");
};
final ProjectDescription projectDescription = ObjectExtensions.<ProjectDescription>operator_doubleArrow(_projectDescription, _function_2);
projectDescription.attachToEmfObject(it_1);
Map<String, ResourceDescriptionsData> _emptyMap = CollectionLiterals.<String, ResourceDescriptionsData>emptyMap();
final ChunkedResourceDescriptions index = new ChunkedResourceDescriptions(_emptyMap, it_1);
index.setContainer(projectDescription.getName(), newIndex);
};
XtextResourceSet _doubleArrow = ObjectExtensions.<XtextResourceSet>operator_doubleArrow(_get, _function_1);
it.setResourceSet(_doubleArrow);
it.setDirtyFiles(Collections.<URI>unmodifiableList(CollectionLiterals.<URI>newArrayList()));
it.setDeletedFiles(Collections.<URI>unmodifiableList(CollectionLiterals.<URI>newArrayList()));
final BuildRequest.IPostValidationCallback _function_2 = (URI uri, Iterable<Issue> issues) -> {
Iterables.<Issue>addAll(this.issues, issues);
return IterableExtensions.isEmpty(issues);
};
it.setAfterValidate(_function_2);
final Procedure1<URI> _function_3 = (URI it_1) -> {
this.deleted.add(it_1);
};
it.setAfterDeleteFile(_function_3);
final Procedure2<URI, URI> _function_4 = (URI source, URI target) -> {
this.generated.put(source, target);
};
it.setAfterGenerateFile(_function_4);
Source2GeneratedMapping _copy = this.indexState.getFileMappings().copy();
IndexState _indexState = new IndexState(newIndex, _copy);
it.setState(_indexState);
};
final BuildRequest result = ObjectExtensions.<BuildRequest>operator_doubleArrow(_buildRequest, _function);
init.apply(result);
return result;
}
use of org.eclipse.xtext.xbase.lib.Procedures.Procedure2 in project mechanoid by robotoworks.
the class SqliteModelGenerator method doGenerate.
public void doGenerate(final Resource resource, final IFileSystemAccess fsa) {
EList<EObject> _contents = resource.getContents();
EObject _head = IterableExtensions.<EObject>head(_contents);
Model model = ((Model) _head);
SqliteDatabaseSnapshot.Builder _get = this.mDbSnapshotBuilderProvider.get();
final SqliteDatabaseSnapshot snapshot = _get.build(model);
String _packageName = model.getPackageName();
DatabaseBlock _database = model.getDatabase();
String _name = _database.getName();
String _pascalize = Strings.pascalize(_name);
String _concat = "Abstract".concat(_pascalize);
String _concat_1 = _concat.concat("OpenHelper");
String _resolveFileName = Strings.resolveFileName(_packageName, _concat_1);
CharSequence _generate = this.mOpenHelperGenerator.generate(model, snapshot);
fsa.generateFile(_resolveFileName, _generate);
String _packageName_1 = model.getPackageName();
DatabaseBlock _database_1 = model.getDatabase();
String _name_1 = _database_1.getName();
String _pascalize_1 = Strings.pascalize(_name_1);
String _concat_2 = _pascalize_1.concat("OpenHelper");
String _resolveFileName_1 = Strings.resolveFileName(_packageName_1, _concat_2);
CharSequence _generateStub = this.mOpenHelperGenerator.generateStub(model, snapshot);
fsa.generateFile(_resolveFileName_1, MechanoidOutputConfigurationProvider.DEFAULT_STUB_OUTPUT, _generateStub);
String _packageName_2 = model.getPackageName();
DatabaseBlock _database_2 = model.getDatabase();
String _name_2 = _database_2.getName();
String _pascalize_2 = Strings.pascalize(_name_2);
String _concat_3 = _pascalize_2.concat("Contract");
String _resolveFileName_2 = Strings.resolveFileName(_packageName_2, _concat_3);
CharSequence _generate_1 = this.mContentProviderContractGenerator.generate(model, snapshot);
fsa.generateFile(_resolveFileName_2, _generate_1);
String _packageName_3 = model.getPackageName();
DatabaseBlock _database_3 = model.getDatabase();
String _name_3 = _database_3.getName();
String _pascalize_3 = Strings.pascalize(_name_3);
String _concat_4 = "Abstract".concat(_pascalize_3);
String _concat_5 = _concat_4.concat("ContentProvider");
String _resolveFileName_3 = Strings.resolveFileName(_packageName_3, _concat_5);
CharSequence _generate_2 = this.mContentProviderGenerator.generate(model, snapshot);
fsa.generateFile(_resolveFileName_3, _generate_2);
String _packageName_4 = model.getPackageName();
DatabaseBlock _database_4 = model.getDatabase();
String _name_4 = _database_4.getName();
String _pascalize_4 = Strings.pascalize(_name_4);
String _concat_6 = _pascalize_4.concat("ContentProvider");
String _resolveFileName_4 = Strings.resolveFileName(_packageName_4, _concat_6);
CharSequence _generateStub_1 = this.mContentProviderGenerator.generateStub(model, snapshot);
fsa.generateFile(_resolveFileName_4, MechanoidOutputConfigurationProvider.DEFAULT_STUB_OUTPUT, _generateStub_1);
Collection<CreateTableStatement> _tables = snapshot.getTables();
final Consumer<CreateTableStatement> _function = new Consumer<CreateTableStatement>() {
public void accept(final CreateTableStatement statement) {
SqliteModelGenerator.this.generateActiveRecordEntity(resource, fsa, ((CreateTableStatement) statement));
}
};
_tables.forEach(_function);
Collection<CreateViewStatement> _views = snapshot.getViews();
final Consumer<CreateViewStatement> _function_1 = new Consumer<CreateViewStatement>() {
public void accept(final CreateViewStatement statement) {
SqliteModelGenerator.this.generateActiveRecordEntity(resource, fsa, ((CreateViewStatement) statement));
}
};
_views.forEach(_function_1);
Collection<CreateTableStatement> _configInitTables = ModelUtil.getConfigInitTables(model);
final Consumer<CreateTableStatement> _function_2 = new Consumer<CreateTableStatement>() {
public void accept(final CreateTableStatement statement) {
SqliteModelGenerator.this.generateActiveRecordEntity(resource, fsa, ((CreateTableStatement) statement));
}
};
_configInitTables.forEach(_function_2);
Collection<CreateViewStatement> _configInitViews = ModelUtil.getConfigInitViews(model);
final Consumer<CreateViewStatement> _function_3 = new Consumer<CreateViewStatement>() {
public void accept(final CreateViewStatement statement) {
SqliteModelGenerator.this.generateActiveRecordEntity(resource, fsa, ((CreateViewStatement) statement));
}
};
_configInitViews.forEach(_function_3);
DatabaseBlock _database_5 = model.getDatabase();
EList<MigrationBlock> _migrations = _database_5.getMigrations();
final Procedure2<MigrationBlock, Integer> _function_4 = new Procedure2<MigrationBlock, Integer>() {
public void apply(final MigrationBlock item, final Integer index) {
SqliteModelGenerator.this.generateMigration(resource, fsa, item, ((index).intValue() + 1));
}
};
IterableExtensions.<MigrationBlock>forEach(_migrations, _function_4);
}
use of org.eclipse.xtext.xbase.lib.Procedures.Procedure2 in project xtext-core by eclipse.
the class IncrementalBuilderTest method testIndexOnly.
@Test
public void testIndexOnly() {
final Procedure1<BuildRequest> _function = (BuildRequest it) -> {
it.setIndexOnly(true);
StringConcatenation _builder = new StringConcatenation();
_builder.append("foo {");
_builder.newLine();
_builder.append("\t");
_builder.append("entity A {}");
_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.IPostValidationCallback _function_1 = (URI $0, Iterable<Issue> $1) -> {
throw new IllegalStateException();
};
it.setAfterValidate(_function_1);
final Procedure2<URI, URI> _function_2 = (URI $0, URI $1) -> {
throw new IllegalStateException();
};
it.setAfterGenerateFile(_function_2);
};
final BuildRequest buildRequest = this.newBuildRequest(_function);
final IndexState result = this.build(buildRequest);
Assert.assertEquals(1, IterableExtensions.size(result.getResourceDescriptions().getAllResourceDescriptions()));
}
use of org.eclipse.xtext.xbase.lib.Procedures.Procedure2 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);
}
Aggregations