use of org.eclipse.xtext.xbase.lib.Procedures.Procedure1 in project xtext-eclipse by eclipse.
the class JavaBuilderState method getQualifiedTypeNames.
private TypeNames getQualifiedTypeNames(final String typeLocator, final String packageName, final String simpleName, final IJavaProject project) {
TypeNames _xblockexpression = null;
{
final TypeNames qualifiedTypeNames = new TypeNames(project);
final String primaryTypeFqn = this.getQualifedTypeName(packageName, simpleName);
char[][] _definedTypeNamesFor = null;
if (this.state != null) {
_definedTypeNamesFor = this.state.getDefinedTypeNamesFor(typeLocator);
}
final char[][] typeNames = _definedTypeNamesFor;
if ((typeNames == null)) {
TypeNames _typeNames = new TypeNames(project);
final Procedure1<TypeNames> _function = (TypeNames it) -> {
it.addTypeName(primaryTypeFqn, primaryTypeFqn);
};
return ObjectExtensions.<TypeNames>operator_doubleArrow(_typeNames, _function);
}
final Consumer<char[]> _function_1 = (char[] it) -> {
String _string = new String(it);
final String typeName = this.getQualifedTypeName(packageName, _string);
qualifiedTypeNames.addTypeName(typeName, primaryTypeFqn);
};
((List<char[]>) Conversions.doWrapArray(typeNames)).forEach(_function_1);
_xblockexpression = qualifiedTypeNames;
}
return _xblockexpression;
}
use of org.eclipse.xtext.xbase.lib.Procedures.Procedure1 in project xtext-eclipse by eclipse.
the class RuleEngineFormatter method _format.
@Override
protected void _format(final XSwitchExpression expr, @Extension final IFormattableDocument document) {
final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
it.indent();
};
document.set(this.textRegionExtensions.previousHiddenRegion(expr.getSwitch()), this.textRegionExtensions.nextHiddenRegion(expr), _function);
final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
it.oneSpace();
};
document.append(this.textRegionExtensions.regionFor(expr).keyword("switch"), _function_1);
final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
it.newLine();
};
document.<XExpression>format(document.<XExpression>append(expr.getSwitch(), _function_2));
EList<XCasePart> _cases = expr.getCases();
for (final XCasePart c : _cases) {
{
if (((c.getTypeGuard() != null) && (c.getCase() != null))) {
final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
it.oneSpace();
};
document.<JvmTypeReference>append(c.getTypeGuard(), _function_3);
final Procedure1<IHiddenRegionFormatter> _function_4 = (IHiddenRegionFormatter it) -> {
it.noSpace();
};
document.<XExpression>append(c.getCase(), _function_4);
} else {
JvmTypeReference _typeGuard = c.getTypeGuard();
boolean _tripleNotEquals = (_typeGuard != null);
if (_tripleNotEquals) {
final Procedure1<IHiddenRegionFormatter> _function_5 = (IHiddenRegionFormatter it) -> {
it.noSpace();
};
document.<JvmTypeReference>append(c.getTypeGuard(), _function_5);
} else {
XExpression _case = c.getCase();
boolean _tripleNotEquals_1 = (_case != null);
if (_tripleNotEquals_1) {
final Procedure1<IHiddenRegionFormatter> _function_6 = (IHiddenRegionFormatter it) -> {
it.oneSpace();
};
final Procedure1<IHiddenRegionFormatter> _function_7 = (IHiddenRegionFormatter it) -> {
it.noSpace();
};
document.<XExpression>append(document.<XExpression>prepend(c.getCase(), _function_6), _function_7);
}
}
}
final Procedure1<IHiddenRegionFormatter> _function_8 = (IHiddenRegionFormatter it) -> {
it.noSpace();
};
final Procedure1<IHiddenRegionFormatter> _function_9 = (IHiddenRegionFormatter it) -> {
it.newLine();
};
document.append(document.prepend(this.textRegionExtensions.regionFor(c).feature(XbasePackage.Literals.XCASE_PART__FALL_THROUGH), _function_8), _function_9);
document.<XExpression>format(c.getCase());
if ((Objects.equal(c, IterableExtensions.<XCasePart>last(expr.getCases())) && (expr.getDefault() == null))) {
this.formatBody(c.getThen(), true, document);
} else {
this.formatBodyParagraph(c.getThen(), document);
}
}
}
XExpression _default = expr.getDefault();
boolean _tripleNotEquals = (_default != null);
if (_tripleNotEquals) {
final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
it.noSpace();
};
document.append(this.textRegionExtensions.regionFor(expr).keyword("default"), _function_3);
this.formatBody(expr.getDefault(), true, document);
}
}
use of org.eclipse.xtext.xbase.lib.Procedures.Procedure1 in project xtext-eclipse by eclipse.
the class AdvancedNewProjectPage method createControl.
@Override
public void createControl(final Composite parent) {
Composite _composite = new Composite(parent, SWT.NONE);
final Procedure1<Composite> _function = (Composite it) -> {
GridData _gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
it.setLayoutData(_gridData);
GridLayout _gridLayout = new GridLayout(1, false);
it.setLayout(_gridLayout);
final Procedure1<Group> _function_1 = (Group it_1) -> {
it_1.setText(Messages.AdvancedNewProjectPage_LabelFacets);
final Procedure1<Button> _function_2 = (Button it_2) -> {
it_2.setText(Messages.AdvancedNewProjectPage_projEclipse);
};
this.createUiProject = this.CheckBox(it_1, _function_2);
final Procedure1<Group> _function_3 = (Group it_2) -> {
final Procedure1<Button> _function_4 = (Button it_3) -> {
it_3.setText(Messages.AdvancedNewProjectPage_projEclipseSDKFeature);
};
this.createSDKProject = this.CheckBox(it_2, _function_4);
final Procedure1<Button> _function_5 = (Button it_3) -> {
it_3.setText(Messages.AdvancedNewProjectPage_projEclipseP2);
};
this.createP2Project = this.CheckBox(it_2, _function_5);
};
this.createUiProjectSubGroup = this.Group(it_1, _function_3);
final Procedure1<Button> _function_4 = (Button it_2) -> {
it_2.setText(Messages.AdvancedNewProjectPage_projIdea);
it_2.setEnabled(true);
};
this.createIdeaProject = this.CheckBox(it_1, _function_4);
final Procedure1<Button> _function_5 = (Button it_2) -> {
it_2.setText(Messages.AdvancedNewProjectPage_projWeb);
it_2.setEnabled(true);
};
this.createWebProject = this.CheckBox(it_1, _function_5);
final Procedure1<Button> _function_6 = (Button it_2) -> {
it_2.setText(Messages.AdvancedNewProjectPage_projIde);
it_2.setEnabled(false);
this.InfoDecoration(it_2, Messages.AdvancedNewProjectPage_projIde_description);
GridData _gridData_1 = new GridData(SWT.LEFT, SWT.CENTER, true, false);
it_2.setLayoutData(_gridData_1);
};
this.createIdeProject = this.CheckBox(it_1, _function_6);
final Procedure1<Button> _function_7 = (Button it_2) -> {
it_2.setText(Messages.WizardNewXtextProjectCreationPage_TestingSupport);
};
this.createTestProject = this.CheckBox(it_1, _function_7);
};
this.Group(it, _function_1);
final Procedure1<Group> _function_2 = (Group it_1) -> {
it_1.setText(Messages.AdvancedNewProjectPage_prefBuildSys);
final Procedure1<Combo> _function_3 = (Combo it_2) -> {
it_2.setEnabled(true);
final Function1<BuildSystem, String> _function_4 = (BuildSystem it_3) -> {
return it_3.toString();
};
it_2.setItems(((String[]) Conversions.unwrapArray(ListExtensions.<BuildSystem, String>map(((List<BuildSystem>) Conversions.doWrapArray(BuildSystem.values())), _function_4), String.class)));
};
this.preferredBuildSystem = this.DropDown(it_1, _function_3);
};
this.Group(it, _function_2);
final Procedure1<Group> _function_3 = (Group it_1) -> {
it_1.setText(Messages.AdvancedNewProjectPage_languageServer);
final Procedure1<Combo> _function_4 = (Combo it_2) -> {
it_2.setEnabled(false);
final Function1<LanguageServer, String> _function_5 = (LanguageServer it_3) -> {
return it_3.toString();
};
it_2.setItems(((String[]) Conversions.unwrapArray(ListExtensions.<LanguageServer, String>map(((List<LanguageServer>) Conversions.doWrapArray(LanguageServer.values())), _function_5), String.class)));
this.InfoDecoration(it_2, Messages.AdvancedNewProjectPage_languageServer_description);
};
this.createLanguageServer = this.DropDown(it_1, _function_4);
};
this.Group(it, _function_3);
final Procedure1<Group> _function_4 = (Group it_1) -> {
it_1.setText(Messages.AdvancedNewProjectPage_srcLayout);
final Procedure1<Combo> _function_5 = (Combo it_2) -> {
it_2.setEnabled(true);
final Function1<SourceLayout, String> _function_6 = (SourceLayout it_3) -> {
return it_3.toString();
};
it_2.setItems(((String[]) Conversions.unwrapArray(ListExtensions.<SourceLayout, String>map(((List<SourceLayout>) Conversions.doWrapArray(SourceLayout.values())), _function_6), String.class)));
};
this.sourceLayout = this.DropDown(it_1, _function_5);
};
this.Group(it, _function_4);
StatusWidget _statusWidget = new StatusWidget(it, SWT.NONE);
final Procedure1<StatusWidget> _function_5 = (StatusWidget it_1) -> {
GridData _gridData_1 = new GridData(SWT.FILL, SWT.TOP, true, false);
it_1.setLayoutData(_gridData_1);
};
StatusWidget _doubleArrow = ObjectExtensions.<StatusWidget>operator_doubleArrow(_statusWidget, _function_5);
this.statusWidget = _doubleArrow;
};
Composite _doubleArrow = ObjectExtensions.<Composite>operator_doubleArrow(_composite, _function);
this.setControl(_doubleArrow);
final SelectionAdapter selectionControl = new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
AdvancedNewProjectPage.this.validate(e);
}
};
final List<Button> uiButtons = Collections.<Button>unmodifiableList(CollectionLiterals.<Button>newArrayList(this.createUiProject, this.createIdeaProject, this.createWebProject));
final SelectionAdapter selectionControlUi = new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
Object _source = e.getSource();
boolean _selection = ((Button) _source).getSelection();
if (_selection) {
boolean _selection_1 = AdvancedNewProjectPage.this.createIdeProject.getSelection();
boolean _not = (!_selection_1);
if (_not) {
AdvancedNewProjectPage.this.autoSelectIdeProject = true;
}
AdvancedNewProjectPage.this.createIdeProject.setSelection(true);
AdvancedNewProjectPage.this.createIdeProject.setEnabled(false);
} else {
final Function1<Button, Boolean> _function = (Button it) -> {
boolean _selection_2 = it.getSelection();
return Boolean.valueOf((!_selection_2));
};
boolean _forall = IterableExtensions.<Button>forall(uiButtons, _function);
if (_forall) {
AdvancedNewProjectPage.this.createIdeProject.setEnabled(true);
}
Object _source_1 = e.getSource();
boolean _equals = Objects.equal(_source_1, AdvancedNewProjectPage.this.createUiProject);
if (_equals) {
AdvancedNewProjectPage.this.createSDKProject.setSelection(false);
AdvancedNewProjectPage.this.createP2Project.setSelection(false);
}
}
AdvancedNewProjectPage.this.validate(e);
}
};
final SelectionAdapter selectionControlUpdateSite = new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
Object _source = e.getSource();
boolean _selection = ((Button) _source).getSelection();
if (_selection) {
boolean _selection_1 = AdvancedNewProjectPage.this.createSDKProject.getSelection();
boolean _not = (!_selection_1);
if (_not) {
AdvancedNewProjectPage.this.autoSelectSDKProject = true;
}
AdvancedNewProjectPage.this.createSDKProject.setSelection(true);
AdvancedNewProjectPage.this.createSDKProject.setEnabled(false);
} else {
AdvancedNewProjectPage.this.createSDKProject.setEnabled(true);
}
AdvancedNewProjectPage.this.validate(e);
}
};
this.createUiProject.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
final boolean uiProjectSelected = AdvancedNewProjectPage.this.createUiProject.getSelection();
AdvancedNewProjectPage.this.createUiProjectSubGroup.setEnabled(uiProjectSelected);
AdvancedNewProjectPage.this.createSDKProject.setEnabled(uiProjectSelected);
AdvancedNewProjectPage.this.createP2Project.setEnabled(uiProjectSelected);
AdvancedNewProjectPage.this.validate(e);
}
});
this.preferredBuildSystem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
BuildSystem _preferredBuildSystem = AdvancedNewProjectPage.this.getPreferredBuildSystem();
final boolean lsEnabled = (!Objects.equal(_preferredBuildSystem, BuildSystem.NONE));
AdvancedNewProjectPage.this.createLanguageServer.setEnabled(lsEnabled);
AdvancedNewProjectPage.this.validate(e);
}
});
this.createLanguageServer.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
boolean _isSelected = AdvancedNewProjectPage.this.isSelected(AdvancedNewProjectPage.this.createLanguageServer, LanguageServer.NONE);
if (_isSelected) {
final Function1<Button, Boolean> _function = (Button it) -> {
boolean _selection = it.getSelection();
return Boolean.valueOf((!_selection));
};
boolean _forall = IterableExtensions.<Button>forall(uiButtons, _function);
if (_forall) {
AdvancedNewProjectPage.this.createIdeProject.setEnabled(true);
}
} else {
boolean _selection = AdvancedNewProjectPage.this.createIdeProject.getSelection();
boolean _not = (!_selection);
if (_not) {
AdvancedNewProjectPage.this.createIdeProject.setSelection(true);
AdvancedNewProjectPage.this.autoSelectIdeProject = true;
}
}
AdvancedNewProjectPage.this.validate(e);
}
});
this.sourceLayout.addSelectionListener(selectionControl);
this.createTestProject.addSelectionListener(selectionControl);
this.createUiProject.addSelectionListener(selectionControlUi);
this.createIdeaProject.addSelectionListener(selectionControlUi);
this.createWebProject.addSelectionListener(selectionControlUi);
this.createIdeProject.addSelectionListener(selectionControl);
this.createSDKProject.addSelectionListener(selectionControl);
this.createP2Project.addSelectionListener(selectionControlUpdateSite);
this.createLanguageServer.addSelectionListener(selectionControl);
this.setDefaults();
PlatformUI.getWorkbench().getHelpSystem().setHelp(this.getShell(), "org.eclipse.xtext.xtext.ui.newProject_Advanced");
}
use of org.eclipse.xtext.xbase.lib.Procedures.Procedure1 in project xtext-eclipse by eclipse.
the class DomainmodelFormatter method _format.
protected void _format(final PackageDeclaration pkg, @Extension final IFormattableDocument document) {
final ISemanticRegion open = this.textRegionExtensions.regionFor(pkg).keyword("{");
final ISemanticRegion close = this.textRegionExtensions.regionFor(pkg).keyword("}");
final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
it.oneSpace();
};
document.surround(this.textRegionExtensions.regionFor(pkg).feature(DomainmodelPackage.Literals.ABSTRACT_ELEMENT__NAME), _function);
final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
it.newLine();
};
document.append(open, _function_1);
final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
it.indent();
};
document.<ISemanticRegion, ISemanticRegion>interior(open, close, _function_2);
EList<AbstractElement> _elements = pkg.getElements();
for (final AbstractElement element : _elements) {
{
document.<AbstractElement>format(element);
final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
it.setNewLines(1, 1, 2);
};
document.<AbstractElement>append(element, _function_3);
}
}
}
use of org.eclipse.xtext.xbase.lib.Procedures.Procedure1 in project xtext-eclipse by eclipse.
the class DomainmodelJvmModelInferrer method _infer.
protected void _infer(final Entity entity, @Extension final IJvmDeclaredTypeAcceptor acceptor, final boolean prelinkingPhase) {
final Procedure1<JvmGenericType> _function = (JvmGenericType it) -> {
this._jvmTypesBuilder.setDocumentation(it, this._jvmTypesBuilder.getDocumentation(entity));
JvmParameterizedTypeReference _superType = entity.getSuperType();
boolean _tripleNotEquals = (_superType != null);
if (_tripleNotEquals) {
EList<JvmTypeReference> _superTypes = it.getSuperTypes();
JvmTypeReference _cloneWithProxies = this._jvmTypesBuilder.cloneWithProxies(entity.getSuperType());
this._jvmTypesBuilder.<JvmTypeReference>operator_add(_superTypes, _cloneWithProxies);
}
EList<JvmMember> _members = it.getMembers();
final Procedure1<JvmConstructor> _function_1 = (JvmConstructor it_1) -> {
};
JvmConstructor _constructor = this._jvmTypesBuilder.toConstructor(entity, _function_1);
this._jvmTypesBuilder.<JvmConstructor>operator_add(_members, _constructor);
final JvmTypeReference procedureType = this._typeReferenceBuilder.typeRef(Procedure1.class, this._typeReferenceBuilder.typeRef(it));
EList<JvmMember> _members_1 = it.getMembers();
final Procedure1<JvmConstructor> _function_2 = (JvmConstructor it_1) -> {
EList<JvmFormalParameter> _parameters = it_1.getParameters();
JvmFormalParameter _parameter = this._jvmTypesBuilder.toParameter(entity, "initializer", procedureType);
this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter);
StringConcatenationClient _client = new StringConcatenationClient() {
@Override
protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
_builder.append("initializer.apply(this);");
_builder.newLine();
}
};
this._jvmTypesBuilder.setBody(it_1, _client);
};
JvmConstructor _constructor_1 = this._jvmTypesBuilder.toConstructor(entity, _function_2);
this._jvmTypesBuilder.<JvmConstructor>operator_add(_members_1, _constructor_1);
EList<Feature> _features = entity.getFeatures();
for (final Feature f : _features) {
boolean _matched = false;
if (f instanceof Property) {
_matched = true;
final JvmField field = this._jvmTypesBuilder.toField(f, ((Property) f).getName(), ((Property) f).getType());
EList<JvmMember> _members_2 = it.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_2, field);
EList<JvmMember> _members_3 = it.getMembers();
JvmOperation _getter = this._jvmTypesBuilder.toGetter(f, ((Property) f).getName(), ((Property) f).getType());
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_3, _getter);
EList<JvmMember> _members_4 = it.getMembers();
JvmOperation _setter = this._jvmTypesBuilder.toSetter(f, ((Property) f).getName(), ((Property) f).getType());
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_4, _setter);
}
if (!_matched) {
if (f instanceof Operation) {
_matched = true;
EList<JvmMember> _members_2 = it.getMembers();
String _name = ((Operation) f).getName();
JvmTypeReference _elvis = null;
JvmTypeReference _type = ((Operation) f).getType();
if (_type != null) {
_elvis = _type;
} else {
JvmTypeReference _inferredType = this._jvmTypesBuilder.inferredType();
_elvis = _inferredType;
}
final Procedure1<JvmOperation> _function_3 = (JvmOperation it_1) -> {
this._jvmTypesBuilder.setDocumentation(it_1, this._jvmTypesBuilder.getDocumentation(f));
EList<JvmFormalParameter> _params = ((Operation) f).getParams();
for (final JvmFormalParameter p : _params) {
EList<JvmFormalParameter> _parameters = it_1.getParameters();
JvmFormalParameter _parameter = this._jvmTypesBuilder.toParameter(p, p.getName(), p.getParameterType());
this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter);
}
this._jvmTypesBuilder.setBody(it_1, ((Operation) f).getBody());
};
JvmOperation _method = this._jvmTypesBuilder.toMethod(f, _name, _elvis, _function_3);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_2, _method);
}
}
}
EList<JvmMember> _members_2 = it.getMembers();
JvmOperation _toStringMethod = this._jvmTypesBuilder.toToStringMethod(entity, it);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_2, _toStringMethod);
};
acceptor.<JvmGenericType>accept(this._jvmTypesBuilder.toClass(entity, this._iQualifiedNameProvider.getFullyQualifiedName(entity)), _function);
}
Aggregations