use of org.eclipse.xtext.xbase.lib.Procedures.Procedure1 in project xtext-xtend by eclipse.
the class CompilationUnitImpl method toMemberDeclaration.
public MemberDeclaration toMemberDeclaration(final JvmMember delegate) {
final Function1<JvmMember, MemberDeclaration> _function = (JvmMember it) -> {
MemberDeclaration _switchResult = null;
boolean _matched = false;
if (delegate instanceof JvmDeclaredType) {
_matched = true;
_switchResult = this.toTypeDeclaration(((JvmDeclaredType) delegate));
}
if (!_matched) {
if (delegate instanceof JvmOperation) {
_matched = true;
MemberDeclaration _xifexpression = null;
JvmDeclaredType _declaringType = ((JvmOperation) delegate).getDeclaringType();
if ((_declaringType instanceof JvmAnnotationType)) {
JvmAnnotationTypeElementDeclarationImpl _xifexpression_1 = null;
boolean _isBelongedToCompilationUnit = this.isBelongedToCompilationUnit(delegate);
if (_isBelongedToCompilationUnit) {
MutableJvmAnnotationTypeElementDeclarationImpl _mutableJvmAnnotationTypeElementDeclarationImpl = new MutableJvmAnnotationTypeElementDeclarationImpl();
final Procedure1<MutableJvmAnnotationTypeElementDeclarationImpl> _function_1 = (MutableJvmAnnotationTypeElementDeclarationImpl it_1) -> {
it_1.setDelegate(((JvmOperation) delegate));
it_1.setCompilationUnit(this);
};
_xifexpression_1 = ObjectExtensions.<MutableJvmAnnotationTypeElementDeclarationImpl>operator_doubleArrow(_mutableJvmAnnotationTypeElementDeclarationImpl, _function_1);
} else {
JvmAnnotationTypeElementDeclarationImpl _jvmAnnotationTypeElementDeclarationImpl = new JvmAnnotationTypeElementDeclarationImpl();
final Procedure1<JvmAnnotationTypeElementDeclarationImpl> _function_2 = (JvmAnnotationTypeElementDeclarationImpl it_1) -> {
it_1.setDelegate(((JvmOperation) delegate));
it_1.setCompilationUnit(this);
};
_xifexpression_1 = ObjectExtensions.<JvmAnnotationTypeElementDeclarationImpl>operator_doubleArrow(_jvmAnnotationTypeElementDeclarationImpl, _function_2);
}
_xifexpression = _xifexpression_1;
} else {
JvmMethodDeclarationImpl _xifexpression_2 = null;
boolean _isBelongedToCompilationUnit_1 = this.isBelongedToCompilationUnit(delegate);
if (_isBelongedToCompilationUnit_1) {
MutableJvmMethodDeclarationImpl _mutableJvmMethodDeclarationImpl = new MutableJvmMethodDeclarationImpl();
final Procedure1<MutableJvmMethodDeclarationImpl> _function_3 = (MutableJvmMethodDeclarationImpl it_1) -> {
it_1.setDelegate(((JvmOperation) delegate));
it_1.setCompilationUnit(this);
};
_xifexpression_2 = ObjectExtensions.<MutableJvmMethodDeclarationImpl>operator_doubleArrow(_mutableJvmMethodDeclarationImpl, _function_3);
} else {
JvmMethodDeclarationImpl _jvmMethodDeclarationImpl = new JvmMethodDeclarationImpl();
final Procedure1<JvmMethodDeclarationImpl> _function_4 = (JvmMethodDeclarationImpl it_1) -> {
it_1.setDelegate(((JvmOperation) delegate));
it_1.setCompilationUnit(this);
};
_xifexpression_2 = ObjectExtensions.<JvmMethodDeclarationImpl>operator_doubleArrow(_jvmMethodDeclarationImpl, _function_4);
}
_xifexpression = ((MemberDeclaration) _xifexpression_2);
}
_switchResult = _xifexpression;
}
}
if (!_matched) {
if (delegate instanceof JvmConstructor) {
_matched = true;
JvmConstructorDeclarationImpl _xifexpression = null;
boolean _isBelongedToCompilationUnit = this.isBelongedToCompilationUnit(delegate);
if (_isBelongedToCompilationUnit) {
MutableJvmConstructorDeclarationImpl _mutableJvmConstructorDeclarationImpl = new MutableJvmConstructorDeclarationImpl();
final Procedure1<MutableJvmConstructorDeclarationImpl> _function_1 = (MutableJvmConstructorDeclarationImpl it_1) -> {
it_1.setDelegate(((JvmConstructor) delegate));
it_1.setCompilationUnit(this);
};
_xifexpression = ObjectExtensions.<MutableJvmConstructorDeclarationImpl>operator_doubleArrow(_mutableJvmConstructorDeclarationImpl, _function_1);
} else {
JvmConstructorDeclarationImpl _jvmConstructorDeclarationImpl = new JvmConstructorDeclarationImpl();
final Procedure1<JvmConstructorDeclarationImpl> _function_2 = (JvmConstructorDeclarationImpl it_1) -> {
it_1.setDelegate(((JvmConstructor) delegate));
it_1.setCompilationUnit(this);
};
_xifexpression = ObjectExtensions.<JvmConstructorDeclarationImpl>operator_doubleArrow(_jvmConstructorDeclarationImpl, _function_2);
}
_switchResult = _xifexpression;
}
}
if (!_matched) {
if (delegate instanceof JvmEnumerationLiteral) {
_matched = true;
JvmEnumerationValueDeclarationImpl _xifexpression = null;
boolean _isBelongedToCompilationUnit = this.isBelongedToCompilationUnit(delegate);
if (_isBelongedToCompilationUnit) {
MutableJvmEnumerationValueDeclarationImpl _mutableJvmEnumerationValueDeclarationImpl = new MutableJvmEnumerationValueDeclarationImpl();
final Procedure1<MutableJvmEnumerationValueDeclarationImpl> _function_1 = (MutableJvmEnumerationValueDeclarationImpl it_1) -> {
it_1.setDelegate(((JvmEnumerationLiteral) delegate));
it_1.setCompilationUnit(this);
};
_xifexpression = ObjectExtensions.<MutableJvmEnumerationValueDeclarationImpl>operator_doubleArrow(_mutableJvmEnumerationValueDeclarationImpl, _function_1);
} else {
JvmEnumerationValueDeclarationImpl _jvmEnumerationValueDeclarationImpl = new JvmEnumerationValueDeclarationImpl();
final Procedure1<JvmEnumerationValueDeclarationImpl> _function_2 = (JvmEnumerationValueDeclarationImpl it_1) -> {
it_1.setDelegate(((JvmEnumerationLiteral) delegate));
it_1.setCompilationUnit(this);
};
_xifexpression = ObjectExtensions.<JvmEnumerationValueDeclarationImpl>operator_doubleArrow(_jvmEnumerationValueDeclarationImpl, _function_2);
}
_switchResult = _xifexpression;
}
}
if (!_matched) {
if (delegate instanceof JvmField) {
_matched = true;
JvmFieldDeclarationImpl _xifexpression = null;
boolean _isBelongedToCompilationUnit = this.isBelongedToCompilationUnit(delegate);
if (_isBelongedToCompilationUnit) {
MutableJvmFieldDeclarationImpl _mutableJvmFieldDeclarationImpl = new MutableJvmFieldDeclarationImpl();
final Procedure1<MutableJvmFieldDeclarationImpl> _function_1 = (MutableJvmFieldDeclarationImpl it_1) -> {
it_1.setDelegate(((JvmField) delegate));
it_1.setCompilationUnit(this);
};
_xifexpression = ObjectExtensions.<MutableJvmFieldDeclarationImpl>operator_doubleArrow(_mutableJvmFieldDeclarationImpl, _function_1);
} else {
JvmFieldDeclarationImpl _jvmFieldDeclarationImpl = new JvmFieldDeclarationImpl();
final Procedure1<JvmFieldDeclarationImpl> _function_2 = (JvmFieldDeclarationImpl it_1) -> {
it_1.setDelegate(((JvmField) delegate));
it_1.setCompilationUnit(this);
};
_xifexpression = ObjectExtensions.<JvmFieldDeclarationImpl>operator_doubleArrow(_jvmFieldDeclarationImpl, _function_2);
}
_switchResult = _xifexpression;
}
}
return _switchResult;
};
return this.<JvmMember, MemberDeclaration>getOrCreate(delegate, _function);
}
use of org.eclipse.xtext.xbase.lib.Procedures.Procedure1 in project xtext-xtend by eclipse.
the class CompilationUnitImpl method toXtendMemberDeclaration.
public MemberDeclaration toXtendMemberDeclaration(final XtendMember delegate) {
final Function1<XtendMember, XtendMemberDeclarationImpl<? extends XtendMember>> _function = (XtendMember it) -> {
XtendMemberDeclarationImpl<? extends XtendMember> _switchResult = null;
boolean _matched = false;
if (delegate instanceof XtendTypeDeclaration) {
_matched = true;
_switchResult = this.toXtendTypeDeclaration(((XtendTypeDeclaration) delegate));
}
if (!_matched) {
if (delegate instanceof XtendFunction) {
_matched = true;
XtendMethodDeclarationImpl _xtendMethodDeclarationImpl = new XtendMethodDeclarationImpl();
final Procedure1<XtendMethodDeclarationImpl> _function_1 = (XtendMethodDeclarationImpl it_1) -> {
it_1.setDelegate(((XtendFunction) delegate));
it_1.setCompilationUnit(this);
};
_switchResult = ObjectExtensions.<XtendMethodDeclarationImpl>operator_doubleArrow(_xtendMethodDeclarationImpl, _function_1);
}
}
if (!_matched) {
if (delegate instanceof XtendConstructor) {
_matched = true;
XtendConstructorDeclarationImpl _xtendConstructorDeclarationImpl = new XtendConstructorDeclarationImpl();
final Procedure1<XtendConstructorDeclarationImpl> _function_1 = (XtendConstructorDeclarationImpl it_1) -> {
it_1.setDelegate(((XtendConstructor) delegate));
it_1.setCompilationUnit(this);
};
_switchResult = ObjectExtensions.<XtendConstructorDeclarationImpl>operator_doubleArrow(_xtendConstructorDeclarationImpl, _function_1);
}
}
if (!_matched) {
if (delegate instanceof XtendField) {
_matched = true;
XtendMemberDeclarationImpl<XtendField> _xifexpression = null;
EObject _eContainer = ((XtendField) delegate).eContainer();
if ((_eContainer instanceof XtendAnnotationType)) {
XtendAnnotationTypeElementDeclarationImpl _xtendAnnotationTypeElementDeclarationImpl = new XtendAnnotationTypeElementDeclarationImpl();
final Procedure1<XtendAnnotationTypeElementDeclarationImpl> _function_1 = (XtendAnnotationTypeElementDeclarationImpl it_1) -> {
it_1.setDelegate(((XtendField) delegate));
it_1.setCompilationUnit(this);
};
_xifexpression = ObjectExtensions.<XtendAnnotationTypeElementDeclarationImpl>operator_doubleArrow(_xtendAnnotationTypeElementDeclarationImpl, _function_1);
} else {
XtendFieldDeclarationImpl _xtendFieldDeclarationImpl = new XtendFieldDeclarationImpl();
final Procedure1<XtendFieldDeclarationImpl> _function_2 = (XtendFieldDeclarationImpl it_1) -> {
it_1.setDelegate(((XtendField) delegate));
it_1.setCompilationUnit(this);
};
_xifexpression = ObjectExtensions.<XtendFieldDeclarationImpl>operator_doubleArrow(_xtendFieldDeclarationImpl, _function_2);
}
_switchResult = _xifexpression;
}
}
if (!_matched) {
if (delegate instanceof XtendEnumLiteral) {
_matched = true;
XtendEnumerationValueDeclarationImpl _xtendEnumerationValueDeclarationImpl = new XtendEnumerationValueDeclarationImpl();
final Procedure1<XtendEnumerationValueDeclarationImpl> _function_1 = (XtendEnumerationValueDeclarationImpl it_1) -> {
it_1.setDelegate(((XtendEnumLiteral) delegate));
it_1.setCompilationUnit(this);
};
_switchResult = ObjectExtensions.<XtendEnumerationValueDeclarationImpl>operator_doubleArrow(_xtendEnumerationValueDeclarationImpl, _function_1);
}
}
return _switchResult;
};
return this.<XtendMember, XtendMemberDeclarationImpl<? extends XtendMember>>getOrCreate(delegate, _function);
}
use of org.eclipse.xtext.xbase.lib.Procedures.Procedure1 in project xtext-xtend by eclipse.
the class XtendTaskTagProvider method getTaskTags.
@Override
public TaskTags getTaskTags(final Resource resource) {
TaskTags _xblockexpression = null;
{
final IPreferenceValues prefs = this.preferenceValuesProvider.getPreferenceValues(resource);
PreferenceKey _preferenceKey = new PreferenceKey(JavaCore.COMPILER_TASK_TAGS, "TODO,FIXME,XXX");
final String namePref = prefs.getPreference(_preferenceKey);
PreferenceKey _preferenceKey_1 = new PreferenceKey(JavaCore.COMPILER_TASK_PRIORITIES, "NORMAL,HIGH,NORMAL");
final String prioritiesPref = prefs.getPreference(_preferenceKey_1);
PreferenceKey _preferenceKey_2 = new PreferenceKey(JavaCore.COMPILER_TASK_CASE_SENSITIVE, JavaCore.ENABLED);
final String caseSensitivePref = prefs.getPreference(_preferenceKey_2);
final List<TaskTag> tags = PreferenceTaskTagProvider.parseTags(namePref, prioritiesPref);
TaskTags _taskTags = new TaskTags();
final Procedure1<TaskTags> _function = (TaskTags it) -> {
List<TaskTag> _taskTags_1 = it.getTaskTags();
Iterables.<TaskTag>addAll(_taskTags_1, tags);
it.setCaseSensitive(caseSensitivePref.equals(JavaCore.ENABLED));
};
_xblockexpression = ObjectExtensions.<TaskTags>operator_doubleArrow(_taskTags, _function);
}
return _xblockexpression;
}
use of org.eclipse.xtext.xbase.lib.Procedures.Procedure1 in project xtext-xtend by eclipse.
the class DeclarationsTest method testMutableInterfaceDeclaration.
@Test
public void testMutableInterfaceDeclaration() {
StringConcatenation _builder = new StringConcatenation();
_builder.append("package foo");
_builder.newLine();
_builder.newLine();
_builder.append("interface MyInterface {");
_builder.newLine();
_builder.append("\t");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final Procedure1<CompilationUnitImpl> _function = (CompilationUnitImpl it) -> {
final MutableInterfaceDeclaration genInterface = it.getTypeLookup().findInterface("foo.MyInterface");
final Procedure1<MutableMethodDeclaration> _function_1 = (MutableMethodDeclaration it_1) -> {
};
final MutableMethodDeclaration m = genInterface.addMethod("newMethod", _function_1);
Assert.assertTrue(m.isAbstract());
};
this.asCompilationUnit(this.validFile(_builder), _function);
}
use of org.eclipse.xtext.xbase.lib.Procedures.Procedure1 in project xtext-xtend by eclipse.
the class XtendJvmModelInferrer method infer.
@Override
public void infer(/* @Nullable */
EObject object, final /* @NonNull */
IJvmDeclaredTypeAcceptor acceptor, boolean preIndexingPhase) {
if (!(object instanceof XtendFile))
return;
final Set<JvmDeclaredType> types = new LinkedHashSet<JvmDeclaredType>();
final IJvmDeclaredTypeAcceptor wrapper = new IJvmDeclaredTypeAcceptor() {
@SuppressWarnings("deprecation")
@Override
public <T extends JvmDeclaredType> IPostIndexingInitializing<T> accept(T type) {
types.add(type);
return acceptor.accept(type);
}
@Override
public <T extends JvmDeclaredType> void accept(T type, Procedure1<? super T> lateInitialization) {
types.add(type);
acceptor.accept(type, lateInitialization);
}
};
final XtendFile xtendFile = (XtendFile) object;
generatorConfig = generatorConfigProvider.get(xtendFile);
final List<Runnable> doLater = newArrayList();
for (final XtendTypeDeclaration declaration : xtendFile.getXtendTypes()) {
inferTypeSceleton(declaration, wrapper, preIndexingPhase, xtendFile, doLater, null);
}
ActiveAnnotationContexts contexts = null;
BatchLinkableResource resource = (BatchLinkableResource) xtendFile.eResource();
try {
compilerPhases.setIndexing(xtendFile, true);
try {
contexts = contextProvider.computeContext(xtendFile);
} catch (Throwable t) {
operationCanceledManager.propagateAsErrorIfCancelException(t);
logger.error("Couldn't create annotation contexts", t);
return;
}
try {
contexts.before(ActiveAnnotationContexts.AnnotationCallback.INDEXING);
for (ActiveAnnotationContext ctx : contexts.getContexts().values()) {
try {
annotationProcessor.indexingPhase(ctx, wrapper, CancelIndicator.NullImpl);
} catch (Throwable t) {
operationCanceledManager.propagateAsErrorIfCancelException(t);
ctx.handleProcessingError(xtendFile.eResource(), t);
}
}
} finally {
contexts.after(ActiveAnnotationContexts.AnnotationCallback.INDEXING);
}
} finally {
compilerPhases.setIndexing(xtendFile, false);
resource.getCache().clear(resource);
}
if (!preIndexingPhase) {
final ActiveAnnotationContexts finalContexts = contexts;
Runnable lateInit = new Runnable() {
@Override
public void run() {
for (Runnable runnable : doLater) {
runnable.run();
}
try {
finalContexts.before(ActiveAnnotationContexts.AnnotationCallback.INFERENCE);
for (ActiveAnnotationContext ctx : finalContexts.getContexts().values()) {
try {
annotationProcessor.inferencePhase(ctx, CancelIndicator.NullImpl);
} catch (Throwable t) {
operationCanceledManager.propagateAsErrorIfCancelException(t);
ctx.handleProcessingError(xtendFile.eResource(), t);
}
}
} finally {
finalContexts.after(ActiveAnnotationContexts.AnnotationCallback.INFERENCE);
}
}
};
resource.addJvmMemberInitializer(lateInit);
}
}
Aggregations