use of org.eclipse.xtext.xbase.lib.Procedures.Procedure1 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.Procedure1 in project applause by applause.
the class ScreenCompiler method doGenerate.
public void doGenerate(final Resource resource, final IFileSystemAccess fsa) {
TreeIterator<EObject> _allContents = resource.getAllContents();
Iterable<EObject> _iterable = IteratorExtensions.<EObject>toIterable(_allContents);
Iterable<Screen> _filter = Iterables.<Screen>filter(_iterable, Screen.class);
final Procedure1<Screen> _function = new Procedure1<Screen>() {
public void apply(final Screen it) {
ScreenKind _kind = it.getKind();
final ScreenKind getKind = _kind;
boolean _matched = false;
if (!_matched) {
if (Objects.equal(getKind, ScreenKind.DEFAULT_LIST)) {
_matched = true;
ScreenCompiler.this.defaultListScreenCompiler.doGenerate(it, fsa);
}
}
if (!_matched) {
if (Objects.equal(getKind, ScreenKind.DEFAULT_DETAILS)) {
_matched = true;
ScreenCompiler.this.defaultDetailsScreenCompiler.doGenerate(it, fsa);
}
}
}
};
IterableExtensions.<Screen>forEach(_filter, _function);
}
use of org.eclipse.xtext.xbase.lib.Procedures.Procedure1 in project xtext-xtend by eclipse.
the class XtendGenerator method generateMembersInBody.
@Override
public ITreeAppendable generateMembersInBody(final JvmDeclaredType it, final ITreeAppendable appendable, final GeneratorConfig config) {
ITreeAppendable _xifexpression = null;
boolean _isLocal = it.isLocal();
if (_isLocal) {
ITreeAppendable _xblockexpression = null;
{
appendable.append("{").increaseIndentation();
EObject _head = IterableExtensions.<EObject>head(this.getSourceElements(it));
final AnonymousClass anonymousClass = ((AnonymousClass) _head);
if (((!appendable.hasName(Pair.<String, JvmDeclaredType>of("this", it))) && this.needSyntheticThisVariable(anonymousClass, it))) {
final IResolvedTypes resolvedTypes = this.typeResolver.resolveTypes(anonymousClass);
final LightweightTypeReference actualType = resolvedTypes.getActualType(anonymousClass);
Pair<String, JvmDeclaredType> _mappedTo = Pair.<String, JvmDeclaredType>of("this", it);
final String thisName = appendable.declareSyntheticVariable(_mappedTo, "_this");
appendable.newLine().append("final ").append(actualType).append(" ").append(thisName).append(" = this;");
}
final Function1<JvmField, Boolean> _function = (JvmField it_1) -> {
boolean _xblockexpression_1 = false;
{
Procedure1<? super ITreeAppendable> _compilationStrategy = this._jvmTypeExtensions.getCompilationStrategy(it_1);
boolean _tripleNotEquals = (_compilationStrategy != null);
if (_tripleNotEquals) {
return Boolean.valueOf(true);
} else {
StringConcatenationClient _compilationTemplate = this._jvmTypeExtensions.getCompilationTemplate(it_1);
boolean _tripleNotEquals_1 = (_compilationTemplate != null);
if (_tripleNotEquals_1) {
return Boolean.valueOf(true);
} else {
boolean _not = (!(it_1.isFinal() && it_1.isStatic()));
if (_not) {
final XExpression expression = this._iLogicalContainerProvider.getAssociatedExpression(it_1);
if (((expression != null) && config.isGenerateExpressions())) {
return Boolean.valueOf(true);
}
}
}
}
_xblockexpression_1 = false;
}
return Boolean.valueOf(_xblockexpression_1);
};
final Iterable<JvmField> fieldsWithInitializer = IterableExtensions.<JvmField>filter(it.getDeclaredFields(), _function);
boolean _isEmpty = IterableExtensions.isEmpty(fieldsWithInitializer);
boolean _not = (!_isEmpty);
if (_not) {
appendable.newLine().append("{").increaseIndentation();
final Procedure1<LoopParams> _function_1 = (LoopParams it_1) -> {
final Function1<ITreeAppendable, ITreeAppendable> _function_2 = (ITreeAppendable it_2) -> {
return it_2.newLine();
};
it_1.setSeparator(_function_2);
};
final Procedure1<JvmField> _function_2 = (JvmField it_1) -> {
final ITreeAppendable memberAppendable = this._treeAppendableUtil.traceWithComments(appendable, it_1);
memberAppendable.openScope();
appendable.newLine();
final ITreeAppendable tracedAppendable = appendable.trace(it_1);
this._treeAppendableUtil.traceSignificant(tracedAppendable, it_1).append(it_1.getSimpleName());
this.generateInitialization(it_1, tracedAppendable, config);
tracedAppendable.append(";");
memberAppendable.closeScope();
};
this._loopExtensions.<JvmField>forEach(appendable, fieldsWithInitializer, _function_1, _function_2);
appendable.decreaseIndentation().newLine().append("}");
}
final Procedure1<LoopParams> _function_3 = (LoopParams it_1) -> {
final Function1<ITreeAppendable, ITreeAppendable> _function_4 = (ITreeAppendable it_2) -> {
return it_2.newLine();
};
it_1.setSeparator(_function_4);
};
final Procedure1<JvmMember> _function_4 = (JvmMember it_1) -> {
final ITreeAppendable memberAppendable = this._treeAppendableUtil.traceWithComments(appendable, it_1);
memberAppendable.openScope();
this.generateMember(it_1, memberAppendable, config);
memberAppendable.closeScope();
};
this._loopExtensions.<JvmMember>forEach(appendable, this.getMembersToBeCompiled(it), _function_3, _function_4);
_xblockexpression = appendable.decreaseIndentation().newLine().append("}");
}
_xifexpression = _xblockexpression;
} else {
_xifexpression = super.generateMembersInBody(it, appendable, config);
}
return _xifexpression;
}
use of org.eclipse.xtext.xbase.lib.Procedures.Procedure1 in project xtext-xtend by eclipse.
the class XtendFormatter method _format.
protected void _format(final XtendEnum enumeration, @Extension final IFormattableDocument format) {
this.formatAnnotations(enumeration, format, XbaseFormatterPreferenceKeys.newLineAfterClassAnnotations);
this.formatModifiers(enumeration, format);
final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
it.oneSpace();
};
format.append(this.textRegionExtensions.regionFor(enumeration).keyword("enum"), _function);
final ISemanticRegion open = this.textRegionExtensions.regionFor(enumeration).keyword("{");
final ISemanticRegion close = this.textRegionExtensions.regionFor(enumeration).keyword("}");
final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
it.indent();
};
format.<ISemanticRegion, ISemanticRegion>interior(open, close, _function_1);
format.prepend(open, XbaseFormatterPreferenceKeys.bracesInNewLine);
boolean _isEmpty = enumeration.getMembers().isEmpty();
boolean _not = (!_isEmpty);
if (_not) {
format.append(open, XtendFormatterPreferenceKeys.blankLinesBeforeFirstMember);
int _size = enumeration.getMembers().size();
int _minus = (_size - 1);
IntegerRange _upTo = new IntegerRange(0, _minus);
for (final Integer i : _upTo) {
{
final XtendMember current = enumeration.getMembers().get((i).intValue());
format.<XtendMember>format(current);
int _size_1 = enumeration.getMembers().size();
int _minus_1 = (_size_1 - 1);
boolean _lessThan = ((i).intValue() < _minus_1);
if (_lessThan) {
final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
it.noSpace();
};
format.append(format.prepend(this.textRegionExtensions.immediatelyFollowing(current).keyword(","), _function_2), XtendFormatterPreferenceKeys.blankLinesBetweenEnumLiterals);
} else {
format.<XtendMember>append(current, XtendFormatterPreferenceKeys.blankLinesAfterLastMember);
}
}
}
} else {
final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
it.newLine();
};
format.append(open, _function_2);
}
}
use of org.eclipse.xtext.xbase.lib.Procedures.Procedure1 in project xtext-xtend by eclipse.
the class XtendFormatter method _format.
protected void _format(final XtendInterface interfaze, @Extension final IFormattableDocument format) {
this.formatAnnotations(interfaze, format, XbaseFormatterPreferenceKeys.newLineAfterClassAnnotations);
this.formatModifiers(interfaze, format);
this.formatTypeParameters(interfaze, interfaze.getTypeParameters(), format);
final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
it.oneSpace();
};
format.append(this.textRegionExtensions.regionFor(interfaze).keyword("interface"), _function);
final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
it.oneSpace();
};
format.surround(this.textRegionExtensions.regionFor(interfaze).keyword("extends"), _function_1);
EList<JvmTypeReference> _extends = interfaze.getExtends();
for (final JvmTypeReference imp : _extends) {
{
final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
it.noSpace();
};
final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
it.oneSpace();
};
format.append(format.prepend(this.textRegionExtensions.immediatelyFollowing(imp).keyword(","), _function_2), _function_3);
format.<JvmTypeReference>format(imp);
}
}
this.formatBody(interfaze, format);
}
Aggregations